Sha256: 7a6ca507649635c4bcb6618b6a7dd60a90d90b6f57de508e45e81f4b6f79582a

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

require 'anvil/task'
require 'anvil/rubygems'

class Gem::ReleaseTask < Anvil::Task
  description 'Builds a new version and pushes it to rubygems'

  parser do
    arguments %w[bump_term]

    on('-i', '--[no-]install', 'Install gem') do |i|
      options[:install] = i
    end
  end

  attr_reader :bump_term, :options

  def initialize(bump_term, options = {})
    @bump_term = bump_term
    @options = options
  end

  def task
    version  = bump
    gem_file = build

    push gem_file, version.dup.to_s
  end

  protected

  def gemspec_file
    Dir['*.gemspec'].first
  end

  def bump
    Gem::BumpTask.new(bump_term, persist: true).task
  end

  def build
    Gem::BuildTask.new(gemspec_file, options).task
  end

  def push(gem_file, version)
    logger.info "Pushing version #{version} to rubygems"
    Anvil::Rubygems.push gem_file
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anvil-core-0.6.0 lib/tasks/gem/release_task.rb
anvil-core-0.5.0 lib/tasks/gem/release_task.rb