Sha256: 0afdd1b25940f35d8d7123a6e45579efef7676dac82303cbaff672ac8cb9d3f4

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require "milestoner"

module Gemsmith
  module Rake
    # Provides gem release functionality. Meant to be wrapped in Rake tasks.
    class Release
      def initialize gem_spec_path = Dir.glob("#{Dir.pwd}/*.gemspec").first,
                     bundler: Bundler,
                     tagger: Milestoner::Tagger.new,
                     shell: Bundler::UI::Shell.new

        @gem_spec_path = gem_spec_path
        @tagger = tagger
        @shell = shell
        @gem_spec = bundler.load_gemspec gem_spec_path.to_s
      rescue Errno::ENOENT
        @shell.error "Invalid gemspec file path: #{@gem_spec_path}."
      end

      def version_number
        gem_spec.version.version
      end

      def version_label
        "v#{version_number}"
      end

      def gem_file_name
        "#{gem_spec.name}-#{version_number}.gem"
      end

      def publish
        tagger.create version_number, sign: true
      rescue Milestoner::Errors::Base => error
        shell.error error.message
      end

      private

      attr_reader :gem_spec_path, :gem_spec, :tagger, :shell
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gemsmith-6.0.0 lib/gemsmith/rake/release.rb
gemsmith-5.6.0 lib/gemsmith/rake/release.rb