Class: InfinityTest::Options

Inherits:
Hash
  • Object
show all
Defined in:
lib/infinity_test/options.rb

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ Options

Returns a new instance of Options.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/infinity_test/options.rb', line 6

def initialize(arguments)
  super()
  @options = OptionParser.new do |options|
    [:test_unit, :rspec, :bacon, :rubygems, :rails, :rubies, :verbose, :patterns, :bundler, :version].each do |name|
      send("parse_#{name}", options)
    end
    options.banner = [ "Usage: infinity_test [options]", "Starts a continuous test server."].join("\n")
    options.on_tail("--help", "You're looking at it.") do
      print options.help
      exit
    end
  end
  @options.parse!(arguments.clone)
end

Instance Method Details

#parse_bacon(options) ⇒ Object



33
34
35
36
37
# File 'lib/infinity_test/options.rb', line 33

def parse_bacon(options)
  options.on('--bacon', 'Test Framework: Bacon') do
    self[:test_framework] = :bacon
  end
end

#parse_bundler(options) ⇒ Object



83
84
85
86
87
# File 'lib/infinity_test/options.rb', line 83

def parse_bundler(options)
  options.on('--skip-bundler', "Bypass Infinity Test's Bundler support, even if a Gemfile is present") do
    self[:skip_bundler?] = true
  end
end

#parse_patterns(options) ⇒ Object

def parse_cucumber(options)

options.on('--cucumber', 'Run with the Cucumber too') do
  self[:cucumber] = true
end

end



77
78
79
80
81
# File 'lib/infinity_test/options.rb', line 77

def parse_patterns(options)
  options.on('--heuristics', 'Show all defined heuristics and exit') do
    self[:show_heuristics?] = true
  end
end

#parse_rails(options) ⇒ Object



59
60
61
62
63
# File 'lib/infinity_test/options.rb', line 59

def parse_rails(options)
  options.on('--rails', 'Application Framework: Rails') do
    self[:app_framework] = :rails
  end
end

#parse_rspec(options) ⇒ Object



21
22
23
24
25
# File 'lib/infinity_test/options.rb', line 21

def parse_rspec(options)
  options.on('--rspec', 'Test Framework: RSpec') do
    self[:test_framework] = :rspec
  end
end

#parse_rubies(options) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/infinity_test/options.rb', line 39

def parse_rubies(options)
  options.on('--rubies=rubies', 'Specify Ruby version(s) to test against') do |versions|
    rubies = []
    self[:specific_options] = {}
    versions.split(",").each do |r|
      rubie = r.split('+')[0]
      params = r.split('+')[1]
      self[:specific_options][rubie] = params 
      rubies << rubie
    end
    self[:rubies] = rubies.join(',')
  end
end

#parse_rubygems(options) ⇒ Object



65
66
67
68
69
# File 'lib/infinity_test/options.rb', line 65

def parse_rubygems(options)
  options.on('--rubygems', 'Application Framework: Rubygems (Default)') do
    self[:app_framework] = :rubygems
  end
end

#parse_test_unit(options) ⇒ Object



27
28
29
30
31
# File 'lib/infinity_test/options.rb', line 27

def parse_test_unit(options)
  options.on('--test-unit', 'Test Framework: Test Unit (Default)') do
    self[:test_framework] = :test_unit
  end
end

#parse_verbose(options) ⇒ Object



53
54
55
56
57
# File 'lib/infinity_test/options.rb', line 53

def parse_verbose(options)
  options.on('--verbose', 'Print commands before executing them') do
    self[:verbose] = true
  end
end

#parse_version(options) ⇒ Object



89
90
91
92
93
94
# File 'lib/infinity_test/options.rb', line 89

def parse_version(options)
  options.on("--version", "Show version and exit") do
    puts InfinityTest.version
    exit
  end
end