Class: Tagregate::File

Inherits:
Object
  • Object
show all
Defined in:
lib/tagregate/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ File

Returns a new instance of File.



3
4
5
6
# File 'lib/tagregate/file.rb', line 3

def initialize(step_mother, io, options)
  @io = io
  @summary = {}
end

Instance Method Details

#after_features(whatever) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tagregate/file.rb', line 28

def after_features(whatever)
  keys = @summary.keys.sort

  keys.each do |k|
    @io.puts k

    @summary[k].each do |file_name|
      @io.puts "\t-#{file_name}"
    end

    @io.puts "\n"
  end
end

#after_tags(tags) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tagregate/file.rb', line 12

def after_tags(tags)
  if defined?(tags.tag_names)
    tag_names = tags.tag_names
  else
    tag_names = tags.tags.map(&:name)
  end

  tag_names.each do |name|
    @summary[name] ||= []

    unless @summary[name].include? @current_file
      @summary[name] << @current_file
    end
  end
end

#before_feature(feature) ⇒ Object



8
9
10
# File 'lib/tagregate/file.rb', line 8

def before_feature(feature)
  @current_file = feature.file
end