class Rpmchange::Cli

Public Class Methods

shared_options() click to toggle source
# File lib/rpmchange/cli.rb, line 4
def shared_options
  (@shared_options || {}).each do |name, options|
    method_option name, options
  end
end
spec_construct(options) click to toggle source
# File lib/rpmchange/cli.rb, line 10
def spec_construct(options)
  Spec.loadfile(options['specfile'])
end
spec_write!(spec, options) click to toggle source
# File lib/rpmchange/cli.rb, line 14
def spec_write!(spec, options)
  File.open(options['specfile'], 'w') {|f| f.write spec.dump}
end

Public Instance Methods

append() click to toggle source
# File lib/rpmchange/cli.rb, line 74
def append
  spec = self.class.spec_construct options
  after = options['after']
  after = Regexp.new(after) if after
  spec.append(section: options['section'], value: options['value'], after: after)
  self.class.spec_write! spec, options
end
changelog() click to toggle source
# File lib/rpmchange/cli.rb, line 30
def changelog
  spec = self.class.spec_construct options
  if options['append']
    spec.append_changelog(name: options['name'],
                          email: options['email'],
                          message: options['message'])
    self.class.spec_write! spec, options
  else
    puts spec.changelog_lines
  end
end
patch() click to toggle source
# File lib/rpmchange/cli.rb, line 63
def patch
  spec = self.class.spec_construct options
  spec.append_patch(options['name'])
  self.class.spec_write! spec, options
end
prepend() click to toggle source
# File lib/rpmchange/cli.rb, line 87
def prepend
  spec = self.class.spec_construct options
  before = options['before']
  before = Regexp.new(before) if before
  spec.prepend(section: options['section'], value: options['value'], before: before)
  self.class.spec_write! spec, options
end
replace() click to toggle source
# File lib/rpmchange/cli.rb, line 100
def replace
  spec = self.class.spec_construct options
  match = options['match']
  match = Regexp.new(match) if match
  spec.replace(section: options['section'], value: options['value'], match: match)
  self.class.spec_write! spec, options
end
tag() click to toggle source
# File lib/rpmchange/cli.rb, line 46
def tag
  spec = self.class.spec_construct options
  if options['value']
    spec.set_tag(options['name'], options['value'])
    self.class.spec_write! spec, options
  else
    if value = spec.tag(options['name'])
      puts value
    else
      exit(1)
    end
  end
end