Class: CucumberJunitToJson::Parsers::JunitParser
- Inherits:
-
Object
- Object
- CucumberJunitToJson::Parsers::JunitParser
- Defined in:
- lib/cucumber_junit_to_json/parsers/junit_parser.rb
Overview
Abstract representation of a junit xml file parser
Constant Summary collapse
- Error =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#path_to_junit ⇒ Object
Returns the value of attribute path_to_junit.
Instance Method Summary collapse
- #feature_name(str) ⇒ Object
-
#initialize(path_to_junit) ⇒ JunitParser
constructor
A new instance of JunitParser.
- #path_to_file(str) ⇒ Object
- #read(file) ⇒ Object
Constructor Details
#initialize(path_to_junit) ⇒ JunitParser
Returns a new instance of JunitParser.
11 12 13 14 15 |
# File 'lib/cucumber_junit_to_json/parsers/junit_parser.rb', line 11 def initialize(path_to_junit) STDERR.puts 'warning: no junit directory given' if path_to_junit.empty? raise Error, "no such dir(s): #{path_to_junit}" unless Dir.exist?(path_to_junit) @path_to_junit = path_to_junit end |
Instance Attribute Details
#path_to_junit ⇒ Object
Returns the value of attribute path_to_junit.
10 11 12 |
# File 'lib/cucumber_junit_to_json/parsers/junit_parser.rb', line 10 def path_to_junit @path_to_junit end |
Instance Method Details
#feature_name(str) ⇒ Object
26 27 28 |
# File 'lib/cucumber_junit_to_json/parsers/junit_parser.rb', line 26 def feature_name(str) str.split('.').last.strip end |
#path_to_file(str) ⇒ Object
21 22 23 24 |
# File 'lib/cucumber_junit_to_json/parsers/junit_parser.rb', line 21 def path_to_file(str) arr = str.split('.') "#{arr.first(arr.size - 1).join('/')}.feature" end |
#read(file) ⇒ Object
17 18 19 |
# File 'lib/cucumber_junit_to_json/parsers/junit_parser.rb', line 17 def read(file) File.read(file).encode!('UTF-8', invalid: :replace) end |