Class: CucumberAnalytics::FeatureFile
- Inherits:
-
Object
- Object
- CucumberAnalytics::FeatureFile
- Includes:
- Containing, Nested
- Defined in:
- lib/cucumber_analytics/feature_file.rb
Overview
A class modeling a Cucumber .feature file.
Instance Attribute Summary collapse
-
#features ⇒ Object
The Feature objects contained by the FeatureFile.
Attributes included from Nested
Instance Method Summary collapse
-
#contains ⇒ Object
Returns the immediate child elements of the file(i.e. its Feature object).
-
#feature ⇒ Object
Returns the Feature object contained by the FeatureFile.
-
#feature_count ⇒ Object
Returns the number of features contained in the file.
-
#initialize(file = nil) ⇒ FeatureFile
constructor
Creates a new FeatureFile object and, if file_parsed is provided, populates the object.
-
#name ⇒ Object
Returns the name of the file.
-
#path ⇒ Object
Returns the path of the file.
-
#to_s ⇒ Object
Returns the path of the feature file.
Methods included from Nested
Constructor Details
#initialize(file = nil) ⇒ FeatureFile
Creates a new FeatureFile object and, if file_parsed is provided, populates the object.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cucumber_analytics/feature_file.rb', line 17 def initialize(file = nil) @file = file @features = [] if file raise(ArgumentError, "Unknown file: #{file.inspect}") unless File.exists?(file) parsed_file = parse_file(file) build_file(parsed_file) end end |
Instance Attribute Details
#features ⇒ Object
The Feature objects contained by the FeatureFile
12 13 14 |
# File 'lib/cucumber_analytics/feature_file.rb', line 12 def features @features end |
Instance Method Details
#contains ⇒ Object
Returns the immediate child elements of the file(i.e. its Feature object).
41 42 43 |
# File 'lib/cucumber_analytics/feature_file.rb', line 41 def contains @features end |
#feature ⇒ Object
Returns the Feature object contained by the FeatureFile.
51 52 53 |
# File 'lib/cucumber_analytics/feature_file.rb', line 51 def feature @features.first end |
#feature_count ⇒ Object
Returns the number of features contained in the file.
46 47 48 |
# File 'lib/cucumber_analytics/feature_file.rb', line 46 def feature_count @features.count end |
#name ⇒ Object
Returns the name of the file.
31 32 33 |
# File 'lib/cucumber_analytics/feature_file.rb', line 31 def name File.basename(@file.gsub('\\', '/')) end |
#path ⇒ Object
Returns the path of the file.
36 37 38 |
# File 'lib/cucumber_analytics/feature_file.rb', line 36 def path @file end |
#to_s ⇒ Object
Returns the path of the feature file.
56 57 58 |
# File 'lib/cucumber_analytics/feature_file.rb', line 56 def to_s path.to_s end |