class Relsr::Initializer

Constants

YAML_FILE

Public Instance Methods

init() click to toggle source
# File lib/relsr/initializer.rb, line 21
def init
  create_default_yaml
end
release() click to toggle source
# File lib/relsr/initializer.rb, line 13
def release
  puts options
  manager = release_manager
  manager.create_release_branch
  manager.create_pull_request unless options['no-pr']
end

Private Instance Methods

create_default_yaml() click to toggle source
# File lib/relsr/initializer.rb, line 59
def create_default_yaml
  content = {
   'repo' => 'username/repo_name',
   'label' => 'acceptance-done'
  }
  File.open(YAML_FILE, 'w') {|f| f.write content.to_yaml }
end
parse_yaml() click to toggle source
# File lib/relsr/initializer.rb, line 27
def parse_yaml
  unless File.exist?(YAML_FILE)
    puts "Could not file #{YAML_FILE} file."
    exit 1
  end
  begin
    config = YAML.load_file(YAML_FILE)
    raise 'repo: has not been set' if config['repo'].nil?
    raise 'label: has not been set' if config['label'].nil?
    @repo = config['repo']
    @label = config['label']
    @extra_branches += config['add_branches'] if config.key? 'add_branches'

  rescue StandardError => error
    puts "invalid #{YAML_FILE} file"
    puts error.message
    exit 1
  end
end
release_manager() click to toggle source
# File lib/relsr/initializer.rb, line 47
def release_manager
  @extra_branches = options['add'].to_a
  parse_yaml

  Relsr::ReleaseManager.new(
    repo_name: @repo, 
    label: @label, 
    dry_run: options['dry-run'], 
    extra_branches: @extra_branches.uniq
  )
end