Sha256: 57d459a2a1f3de6efb0f047bd3e317214f031e130d164ab392106afe9d3fa7b9

Contents?: true

Size: 1.31 KB

Versions: 117

Compression:

Stored size: 1.31 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

          self.version_helper.write
          self.gemspec.version = self.version_helper.to_s

          commit_version if self.repo && self.commit
        end

        def update_version
          raise "Subclasses should implement this"
        end

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

        def working_subdir
          return @working_subdir if @working_subdir
          cwd = base_dir_path
          @working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
          @working_subdir
        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

117 entries across 63 versions & 7 rubygems

Version Path
jeweler-1.8.7 lib/jeweler/commands/version/base.rb
jeweler-1.8.6 lib/jeweler/commands/version/base.rb
jeweler-1.8.5 lib/jeweler/commands/version/base.rb
devise_sociable-0.1.0 vendor/bundle/gems/jeweler-1.8.4/lib/jeweler/commands/version/base.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/jeweler-1.5.2/lib/jeweler/commands/version/base.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/jeweler-1.6.4/lib/jeweler/commands/version/base.rb