class Released::Goals::GemBuilt

Public Class Methods

new(config = {}) click to toggle source
# File lib/released/goals/gem_built.rb, line 6
def initialize(config = {})
  @name = config.fetch('name')
  @version = config.fetch('version')
end

Public Instance Methods

achieved?() click to toggle source
# File lib/released/goals/gem_built.rb, line 28
def achieved?
  File.file?(expected_name)
end
failure_reason() click to toggle source
# File lib/released/goals/gem_built.rb, line 32
def failure_reason
  "file #{expected_name} does not exist"
end
to_s() click to toggle source
# File lib/released/goals/gem_built.rb, line 11
def to_s
  "gem built (#{@name})"
end
try_achieve() click to toggle source
# File lib/released/goals/gem_built.rb, line 15
def try_achieve
  stdout = ''
  stderr = ''
  piper = Released::Piper.new(stdout: stdout, stderr: stderr)

  begin
    gemspec_file_path = "#{@name}.gemspec"
    piper.run(['gem', 'build', gemspec_file_path], [])
  rescue
    raise "Failed to build gem: #{stderr}"
  end
end

Private Instance Methods

expected_name() click to toggle source
# File lib/released/goals/gem_built.rb, line 38
def expected_name
  @_expected_name ||= @name + '-' + @version + '.gem'
end