Class: Jasmine::Headless::SpecFileAnalyzer
Instance Attribute Summary
#file
Class Method Summary
collapse
Instance Method Summary
collapse
cache_dir, cache_dir=, #cache_file, cache_type=, #cached?, enabled=, enabled?, for, #fresh?, #handle, #initialize
Class Method Details
.cache_type ⇒ Object
6
7
8
|
# File 'lib/jasmine/headless/spec_file_analyzer.rb', line 6
def cache_type
"spec_file_analysis"
end
|
Instance Method Details
#action ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/jasmine/headless/spec_file_analyzer.rb', line 11
def action
line_numbers = {}
data = File.read(file)
if data.respond_to?(:encode)
data.encode!('US-ASCII', 'UTF-8', :invalid => :replace, :undef => :replace)
else
require 'iconv'
ic = Iconv.new('UTF-8//IGNORE', 'US-ASCII')
data = ic.iconv(File.read(file) + ' ')[0..-2]
end
data.force_encoding('US-ASCII') if data.respond_to?(:force_encoding)
data.lines.each_with_index.each { |line, index|
if description = line[%r{(describe|context|it)[( ]*(["'])(.*)\2}, 3]
(line_numbers[description] ||= []) << (index + 1)
end
}
line_numbers
end
|
#serialize(data) ⇒ Object
35
36
37
|
# File 'lib/jasmine/headless/spec_file_analyzer.rb', line 35
def serialize(data)
MultiJson.encode(data)
end
|
#unserialize(data) ⇒ Object
39
40
41
|
# File 'lib/jasmine/headless/spec_file_analyzer.rb', line 39
def unserialize(data)
MultiJson.decode(data)
end
|