Class: Wally::CountsTags

Inherits:
Object
  • Object
show all
Defined in:
lib/wally/counts_tags.rb

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ CountsTags

Returns a new instance of CountsTags.



3
4
5
# File 'lib/wally/counts_tags.rb', line 3

def initialize project
  @project = project
end

Instance Method Details

#count_tagsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wally/counts_tags.rb', line 7

def count_tags
  @project.features.inject(Hash.new(0)) do |tag_count, feature|
    if feature.gherkin["tags"]
      feature.gherkin["tags"].each do |tag|
        tag_count[tag["name"].downcase] += 1
      end
    end
    if feature.gherkin["elements"]
      feature.gherkin["elements"].each do |element|
        if element["tags"]
          element["tags"].each do |tag|
            tag_count[tag["name"].downcase] += 1
          end
        end
      end
    end
    tag_count
  end
end