Sha256: 437b2763f0ae0346411ef590b0122c7146e9fa21fd6d8ac2ffda1032e7f1d372
Contents?: true
Size: 950 Bytes
Versions: 2
Compression:
Stored size: 950 Bytes
Contents
require 'multi_json' module Jasmine::Headless class SpecFileAnalyzer < CacheableAction class << self def cache_type "spec_file_analysis" end end def action line_numbers = {} data = File.read(file) if data.respond_to?(:encode) data.encode!('US-ASCII', 'UTF-8', :invalid => :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 def serialize(data) MultiJson.encode(data) end def unserialize(data) MultiJson.decode(data) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jasmine-headless-webkit-0.7.3.1 | lib/jasmine/headless/spec_file_analyzer.rb |
jasmine-headless-webkit-0.7.2 | lib/jasmine/headless/spec_file_analyzer.rb |