Class: BocaGolf::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/boca_golf/command_line.rb

Instance Method Summary collapse

Instance Method Details

#run(args, stdout, stderr) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/boca_golf/command_line.rb', line 3

def run(args, stdout, stderr)
  ::Rspec::Core::Runner.disable_autorun!

  if args.size > 1
    run_with_checked_args args, stdout, stderr
  else
    show_usage stdout, stderr
  end
end

#run_with_checked_args(args, stdout, stderr) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/boca_golf/command_line.rb', line 13

def run_with_checked_args(args, stdout, stderr)
  gist_location, *specs = *args
  stdout.puts "Testing #{gist_location} against specs:"
  specs.each do |spec|
    stdout.puts "  - #{spec}"
  end
  stdout.puts

  result = BocaGolf.new.run args, stdout, stderr

  stdout.puts "\nCode:"
  stdout.puts result.gist.code
  stdout.puts "\nScore:"
  stdout.puts result.score
rescue => e
  stderr.puts e.message
end

#show_usage(stdout, stderr) ⇒ Object



31
32
33
# File 'lib/boca_golf/command_line.rb', line 31

def show_usage(stdout, stderr)
  stderr.puts "Usage: boca-golf file_or_gist_url spec_file ..."
end