Module: Bibliothecary::Analyser::ClassMethods
- Defined in:
- lib/bibliothecary/analyser.rb
Instance Method Summary collapse
-
#add_multi_parser(klass) ⇒ Object
Add a MultiParser module to a Parser class.
- #generic? ⇒ Boolean
- #map_dependencies(hash, key, type, source = nil) ⇒ Object
- #platform_name ⇒ Object
Instance Method Details
#add_multi_parser(klass) ⇒ Object
Add a MultiParser module to a Parser class. This extends the self.mapping method on the parser to include the multi parser’s files to watch for, and it extends the Parser class with the multi parser for you.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/bibliothecary/analyser.rb', line 78 def add_multi_parser(klass) raise "No mapping found! You should place the add_multi_parser call below def self.mapping." unless respond_to?(:mapping) original_mapping = mapping define_singleton_method(:mapping) do original_mapping.merge(klass.mapping) end send(:extend, klass) end |
#generic? ⇒ Boolean
53 54 55 |
# File 'lib/bibliothecary/analyser.rb', line 53 def generic? platform_name == "generic" end |
#map_dependencies(hash, key, type, source = nil) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bibliothecary/analyser.rb', line 61 def map_dependencies(hash, key, type, source = nil) hash.fetch(key, []).map do |name, requirement| Dependency.new( name: name, requirement: requirement, type: type, source: source ) end end |
#platform_name ⇒ Object
57 58 59 |
# File 'lib/bibliothecary/analyser.rb', line 57 def platform_name name.to_s.split("::").last.downcase end |