Sha256: 2069a2e945cf1e00d08ebab6bef1a95c80f7334377ffc6614c05df84538cd22f

Contents?: true

Size: 1.17 KB

Versions: 10

Compression:

Stored size: 1.17 KB

Contents

require 'pathname'

class Jeweler
  module Commands
    module Version
      class Base
        attr_accessor :repo, :version_helper, :gemspec, :commit, :base_dir

        def run
          update_version

          version_helper.write
          gemspec.version = version_helper.to_s

          commit_version if repo && commit
        end

        def update_version
          raise 'Subclasses should implement this'
        end

        def commit_version
          if repo
            repo.add(working_subdir.join(version_helper.path).to_s)
            repo.commit("Version bump to #{version_helper}")
          end
        end

        def working_subdir
          @working_subdir ||= base_dir_path.relative_path_from(Pathname.new(repo.dir.path))
        end

        def base_dir_path
          Pathname.new(base_dir).realpath
        end

        def self.build_for(jeweler)
          command = new
          command.repo = jeweler.repo
          command.version_helper = jeweler.version_helper
          command.gemspec = jeweler.gemspec
          command.commit = jeweler.commit
          command.base_dir = jeweler.base_dir

          command
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jeweler-2.3.9 lib/jeweler/commands/version/base.rb
jeweler-2.3.7 lib/jeweler/commands/version/base.rb
jeweler-2.3.6 lib/jeweler/commands/version/base.rb
jeweler-2.3.5 lib/jeweler/commands/version/base.rb
jeweler-2.3.3 lib/jeweler/commands/version/base.rb
jeweler-2.3.2 lib/jeweler/commands/version/base.rb
jeweler-2.3.1 lib/jeweler/commands/version/base.rb
jeweler-2.3.0 lib/jeweler/commands/version/base.rb
jeweler-2.2.1 lib/jeweler/commands/version/base.rb
jeweler-2.1.2 lib/jeweler/commands/version/base.rb