Sha256: 160cee1e6a3f1e52d784bcd78edc958b52f902c79b38c54a3d0d7bd3ea3ab66a

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

#!/usr/bin/env ruby

require 'travis_check_rubies/travis_yml'
require 'optparse'
require 'yaml'

CONFIG_FILE = '.travis_check_rubies.yml'

update = false

options = if File.exist?(CONFIG_FILE)
  yaml = YAML.load_file(CONFIG_FILE) || {}
  fail "#{CONFIG_FILE} doesn't contain options hash" unless yaml.is_a?(Hash)
  yaml.map{ |key, value| [key.to_sym, value] }.to_h
else
  {}
end

op = OptionParser.new
op.banner += "\nOptions can be also specified in .travis_check_rubies.yml"
op.on('--parts N|M..N', 'Match updates by how many parts (0..2 by default)') do |parts|
  options[:parts] = case parts
  when /\A\d+\z/
    parts.to_i
  when /\A(\d+)..(\d+)\z/
    $1.to_i..$2.to_i
  else
    fail "Expected number N or range M..N, got #{parts}"
  end
end
op.on('--[no-]allow-pre', 'Allow matching pre releases (false by default)') do |allow_pre|
  options[:allow_pre] = allow_pre
end
op.on('--[no-]intermediary', 'Include all latest version distinct by maximum matchable '\
    'parts, like 2.3.X when current is 2.2.X and latest is 2.4.X (true by default)') do |intermediary|
  options[:intermediary] = intermediary
end
op.on('--exclude V,V,V', Array, 'Exclude matching versions') do |exclude|
  options[:exclude] = exclude
end
op.on('-u', '--update', 'Update versions') do
  update = true
end
begin
  op.parse!
rescue => e
  abort "#{e}\n\n#{op.help}"
end

travis_yml = TravisCheckRubies::TravisYml.new(options: options)
if update
  abort unless travis_yml.update
else
  abort unless travis_yml.suggest
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis_check_rubies-0.3.0 bin/travis_check_rubies