Class: CucumberAnalytics::FeatureFile

Inherits:
Object
  • Object
show all
Includes:
Containing, Nested
Defined in:
lib/cucumber_analytics/feature_file.rb

Overview

A class modeling a Cucumber .feature file.

Instance Attribute Summary collapse

Attributes included from Nested

#parent_element

Instance Method Summary collapse

Methods included from Nested

#get_ancestor

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

#featuresObject

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

#containsObject

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

#featureObject

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_countObject

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

#nameObject

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

#pathObject

Returns the path of the file.



36
37
38
# File 'lib/cucumber_analytics/feature_file.rb', line 36

def path
  @file
end

#to_sObject

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