Class: DepGraph::FileSystemNodeFinder
- Inherits:
-
Object
- Object
- DepGraph::FileSystemNodeFinder
- Defined in:
- lib/file_system_node_finder.rb
Instance Attribute Summary collapse
-
#dependable_filter ⇒ Object
Returns the value of attribute dependable_filter.
-
#dependable_filter_capture_group_index ⇒ Object
Returns the value of attribute dependable_filter_capture_group_index.
-
#file_name_pattern ⇒ Object
Returns the value of attribute file_name_pattern.
-
#location ⇒ Object
writeonly
Sets the attribute location.
Instance Method Summary collapse
- #get_nodes ⇒ Object
-
#initialize(node_type) ⇒ FileSystemNodeFinder
constructor
A new instance of FileSystemNodeFinder.
- #load_dependencies_from_string(node, dependencies_string) ⇒ Object
Constructor Details
#initialize(node_type) ⇒ FileSystemNodeFinder
Returns a new instance of FileSystemNodeFinder.
9 10 11 12 13 14 15 16 |
# File 'lib/file_system_node_finder.rb', line 9 def initialize(node_type) dependable_filter_manager = DependencyTypesManager.new node_type @file_name_pattern = dependable_filter_manager.file_name_pattern @dependable_filter = dependable_filter_manager.dependable_regexp @dependable_filter_capture_group_index = dependable_filter_manager.dependable_regexp_capture_group_index @location = ['.'] end |
Instance Attribute Details
#dependable_filter ⇒ Object
Returns the value of attribute dependable_filter.
6 7 8 |
# File 'lib/file_system_node_finder.rb', line 6 def dependable_filter @dependable_filter end |
#dependable_filter_capture_group_index ⇒ Object
Returns the value of attribute dependable_filter_capture_group_index.
6 7 8 |
# File 'lib/file_system_node_finder.rb', line 6 def dependable_filter_capture_group_index @dependable_filter_capture_group_index end |
#file_name_pattern ⇒ Object
Returns the value of attribute file_name_pattern.
6 7 8 |
# File 'lib/file_system_node_finder.rb', line 6 def file_name_pattern @file_name_pattern end |
#location=(locs) ⇒ Object (writeonly)
Sets the attribute location
7 8 9 |
# File 'lib/file_system_node_finder.rb', line 7 def location=(value) @location = value end |
Instance Method Details
#get_nodes ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/file_system_node_finder.rb', line 26 def get_nodes files = [] @location.each do |dir| files += Dir.glob(dir.strip + '/**/' + @file_name_pattern) end nodes = [] files.each { |file| nodes << create_node_from_file(file) } return nodes end |
#load_dependencies_from_string(node, dependencies_string) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/file_system_node_finder.rb', line 37 def load_dependencies_from_string(node, dependencies_string) fail 'The dependable finder Regexp was not set' unless @dependable_filter dependencies_string.scan(@dependable_filter).each do |matches| dependable = (matches.respond_to? :to_ary) ? matches[@dependable_filter_capture_group_index] : matches node.depends_on(dependable) unless node.depends_on? dependable end end |