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) ⇒ 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.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/bibliothecary/analyser.rb', line 74 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 = self.mapping define_singleton_method(:mapping) do original_mapping.merge(klass.mapping) end send(:extend, klass) end |
#generic? ⇒ Boolean
50 51 52 |
# File 'lib/bibliothecary/analyser.rb', line 50 def generic? platform_name == "generic" end |
#map_dependencies(hash, key, type) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/bibliothecary/analyser.rb', line 58 def map_dependencies(hash, key, type) hash.fetch(key,[]).map do |name, requirement| { name: name, requirement: requirement, type: type } end end |
#platform_name ⇒ Object
54 55 56 |
# File 'lib/bibliothecary/analyser.rb', line 54 def platform_name self.name.to_s.split('::').last.downcase end |