Skip to content

Using with .gemspec #11

@gmcinnes

Description

@gmcinnes

Hi. I have a traditional gem project, set up like:

mygem/mycode/version.rb:

module MyGem
  module MyCode
    VERSION = '0.0.1'
  end
end

Then, in my mygem.gemspec file I have:

# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mygem/mycode/version'

Gem::Specification.new do |gem|
  gem.version = MyGem::MyCode::VERSION
end

and in Gemfile I have

source 'https://rubygems.org'

# Specify your gem's dependencies in capistrano-postgresql.gemspec
gemspec

I can't figure out how to use SemVer to set the Version here. If I try and use SemVer inside the module code, it's not available yet. I can't specify it as a dependency in the .gemspec, because the .gemspec needs it to set the version, and I can't specify it in the Gemfile, because the Gemfile depends on the .gemspec.

It seems to be a circular dependency, but it must be solvable - I can't be the first person trying to do this, can I? Am I just missing something obvious?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions