Class: Tdd::CommandLineParser

Inherits:
Object
  • Object
show all
Defined in:
lib/tdd/command_line_parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandLineParser



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tdd/command_line_parser.rb', line 9

def initialize
  pos = ARGV.index('--')
  if pos
    @paths = ARGV[0 ... pos]
    @test_args = ARGV[pos + 1 .. -1].join(' ')
  else
    @paths = []
    @test_args = ARGV[0..-1].join(' ')
  end
  @test_file = @test_args.scan(/^.+.rb/).first
  glob_for_test_file_matches
  parse_all_files_mode
  parse_controller_mode
  parse_test_framework
end

Instance Attribute Details

#pathsObject

Returns the value of attribute paths.



7
8
9
# File 'lib/tdd/command_line_parser.rb', line 7

def paths
  @paths
end

#test_frameworkObject

Returns the value of attribute test_framework.



7
8
9
# File 'lib/tdd/command_line_parser.rb', line 7

def test_framework
  @test_framework
end

Class Method Details

.parseObject



2
3
4
5
# File 'lib/tdd/command_line_parser.rb', line 2

def self.parse
  parser = self.new
  [parser.paths.flatten, parser.test_command]
end

Instance Method Details

#test_commandObject



25
26
27
# File 'lib/tdd/command_line_parser.rb', line 25

def test_command
  "#{@test_framework} #{@test_args}"
end