Sha256: e41607587c19beed7f30c799a517d697db330931aa021a0a1333a218e0ef63a3

Contents?: true

Size: 1.7 KB

Versions: 13

Compression:

Stored size: 1.7 KB

Contents

class Jeweler
  module Commands
    class ReleaseToGithub
      attr_accessor :gemspec, :version, :repo, :output, :gemspec_helper, :base_dir

      def initialize(attributes = {})
        self.output = $stdout

        attributes.each_pair do |key, value|
          send("#{key}=", value)
        end
      end

      def run
        raise "Hey buddy, try committing them files first" unless clean_staging_area?

        repo.checkout('master')

        regenerate_gemspec!
        commit_gemspec! if gemspec_changed?

        output.puts "Pushing master to origin"
        repo.push
      end

      def clean_staging_area?
        status = repo.status
        status.added.empty? && status.deleted.empty? && status.changed.empty?
      end

      def commit_gemspec!
        repo.add(gemspec_helper.path)
        output.puts "Committing #{gemspec_helper.path}"
        repo.commit "Regenerated gemspec for version #{version}"
      end

      def regenerate_gemspec!
        gemspec_helper.update_version(version)
        gemspec_helper.write
      end

      def gemspec_changed?
        `git status` # OMGHAX. status always ends up being 'M' unless this runs
        status = repo.status[gemspec_helper.path]
        ! status.type.nil?
      end

      def gemspec_helper
        @gemspec_helper ||= Jeweler::GemSpecHelper.new(self.gemspec, self.base_dir)
      end

      def self.build_for(jeweler)
        command = self.new

        command.base_dir = jeweler.base_dir
        command.gemspec = jeweler.gemspec
        command.version = jeweler.version
        command.repo = jeweler.repo
        command.output = jeweler.output
        command.gemspec_helper = jeweler.gemspec_helper

        command
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
gemrage-1.0.0 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.3.0 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.2.0 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.1.2 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.1.1 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.1.0 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
gemrage-0.0.0 vendor/ruby/1.8/gems/jeweler-1.4.0/lib/jeweler/commands/release_to_github.rb
jeweler-1.4.0 lib/jeweler/commands/release_to_github.rb
jeweler-1.3.0 lib/jeweler/commands/release_to_github.rb