class OpenPull::Runner
Attributes
argv[R]
options[RW]
Public Class Methods
new(argv = [])
click to toggle source
# File lib/openpull/runner.rb, line 16 def initialize(argv = []) @argv = argv @options = {} end
run(argv = [])
click to toggle source
# File lib/openpull/runner.rb, line 8 def run(argv = []) new(argv).run end
Public Instance Methods
run()
click to toggle source
# File lib/openpull/runner.rb, line 21 def run op = option_parser op.parse! check_options(op) puts OpenPull::Client.new(@options[:access_token], @options[:organisation], @options[:username]).show_table end
Private Instance Methods
check_access_token()
click to toggle source
# File lib/openpull/runner.rb, line 94 def check_access_token @options[:access_token] = ENV['GITHUB_ACCESS_TOKEN'] return unless @options[:access_token].nil? puts 'You need to set the GitHub access token in your environment. ' \ '(GITHUB_ACCESS_TOKEN)' exit end
check_options(option)
click to toggle source
# File lib/openpull/runner.rb, line 89 def check_options(option) check_access_token check_organisation(option) end
check_organisation(option)
click to toggle source
# File lib/openpull/runner.rb, line 103 def check_organisation(option) return unless @options[:organisation].nil? puts 'You need to either pass GitHub organisation or set it in your ' \ 'environment. (GITHUB_ORGANISATION)' puts "\n#{option}" exit end
option_parser()
click to toggle source
# File lib/openpull/runner.rb, line 33 def option_parser OptionParser.new do |opts| parse_banner(opts) parse_options(opts) parse_values(opts) end end
parse_options(opts)
click to toggle source
# File lib/openpull/runner.rb, line 50 def parse_options(opts) opts.separator 'Options:' opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end opts.on_tail('--version', 'Show version') do puts OpenPull::VERSION exit end end
parse_organisation(opts)
click to toggle source
# File lib/openpull/runner.rb, line 69 def parse_organisation(opts) @options[:organisation] = ENV['GITHUB_ORGANISATION'] opts.on('-o', '--organisation [ORG]', String, 'The Github organisation') do |o| @options[:organisation] = o end end
parse_username(opts)
click to toggle source
# File lib/openpull/runner.rb, line 79 def parse_username(opts) @options[:username] = ENV['GITHUB_USERNAME'] opts.on('-u', '--username [USER]', String, 'Your Github username') do |u| @options[:username] = u end end
parse_values(opts)
click to toggle source
# File lib/openpull/runner.rb, line 64 def parse_values(opts) parse_organisation(opts) parse_username(opts) end