Module: Cucumber::Core::Ast::Location
- Defined in:
- lib/cucumber/core/ast/location.rb
Defined Under Namespace
Classes: Lines, Precise, Wildcard
Class Method Summary
collapse
Class Method Details
.from_file_colon_line(file_colon_line) ⇒ Object
14
15
16
17
|
# File 'lib/cucumber/core/ast/location.rb', line 14
def self.from_file_colon_line(file_colon_line)
file, raw_line = file_colon_line.match(/(.*):(\d+)/)[1..2]
from_source_location(file, raw_line.to_i)
end
|
.from_source_location(file, line) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/cucumber/core/ast/location.rb', line 19
def self.from_source_location(file, line)
file = File.expand_path(file)
pwd = File.expand_path(Dir.pwd)
pwd.force_encoding(file.encoding)
if file.index(pwd)
file = file[pwd.length+1..-1]
elsif file =~ /.*\/gems\/(.*\.rb)$/
file = $1
end
new(file, line)
end
|
.merge(*locations) ⇒ Object
40
41
42
43
44
|
# File 'lib/cucumber/core/ast/location.rb', line 40
def self.merge(*locations)
locations.reduce do |a, b|
a + b
end
end
|
.new(file, raw_lines = nil) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/cucumber/core/ast/location.rb', line 31
def self.new(file, raw_lines=nil)
file || raise(ArgumentError, "file is mandatory")
if raw_lines
Precise.new(file, Lines.new(raw_lines))
else
Wildcard.new(file)
end
end
|
.of_caller(additional_depth = 0) ⇒ Object
10
11
12
|
# File 'lib/cucumber/core/ast/location.rb', line 10
def self.of_caller(additional_depth = 0)
from_file_colon_line(*caller[1 + additional_depth])
end
|