Class: BambooRat::ComponentTree

Inherits:
Object
  • Object
show all
Defined in:
lib/bamboo_rat/component_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ComponentTree

Returns a new instance of ComponentTree.



5
6
7
8
9
10
11
# File 'lib/bamboo_rat/component_tree.rb', line 5

def initialize(path)
  @path = path
  @ruby_components = Set.new
  @js_components = Set.new
  @components = map_components
  self
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



3
4
5
# File 'lib/bamboo_rat/component_tree.rb', line 3

def components
  @components
end

#js_componentsObject (readonly)

Returns the value of attribute js_components.



3
4
5
# File 'lib/bamboo_rat/component_tree.rb', line 3

def js_components
  @js_components
end

#ruby_componentsObject (readonly)

Returns the value of attribute ruby_components.



3
4
5
# File 'lib/bamboo_rat/component_tree.rb', line 3

def ruby_components
  @ruby_components
end

Instance Method Details

#map_componentsObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/bamboo_rat/component_tree.rb', line 13

def map_components
  folders = Dir[File.join(@path, '/*/*')].select do |entry|
    File.directory? entry
  end
  folders.each do |path|
    @ruby_components << RubyComponent.new(path) if RubyComponent.ruby?(path)
    @js_components << JSComponent.new(path) if JSComponent.js?(path)
  end
  @ruby_components + @js_components
end