Class: CucumberStatistics::FeatureStatistics

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_statistics/feature_statistics.rb

Instance Method Summary collapse

Constructor Details

#initializeFeatureStatistics

Returns a new instance of FeatureStatistics.



3
4
5
# File 'lib/cucumber_statistics/feature_statistics.rb', line 3

def initialize
  @all = Hash.new
end

Instance Method Details

#allObject



18
19
20
# File 'lib/cucumber_statistics/feature_statistics.rb', line 18

def all
  @all
end

#record(feature_name, duration, file) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/cucumber_statistics/feature_statistics.rb', line 7

def record feature_name, duration, file
  short_file = file[file.index('features').to_i..-1]

  feature_result = @all[short_file]
  feature_result ||= Hash.new
  feature_result[:duration] = duration
  feature_result[:feature_name] = feature_name

  @all[short_file] ||= feature_result
end

#sort_by_property(property) ⇒ Object



22
23
24
25
# File 'lib/cucumber_statistics/feature_statistics.rb', line 22

def sort_by_property property
  result = @all.sort {|a,b| a.last[property.to_sym] <=> b.last[property.to_sym]}
  result
end