Module: Bibliothecary::Analyser::ClassMethods

Defined in:
lib/bibliothecary/analyser.rb

Instance Method Summary collapse

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.

Parameters:

  • klass (Class)

    A Bibliothecary::MultiParsers class



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/bibliothecary/analyser.rb', line 75

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

Returns:

  • (Boolean)


51
52
53
# File 'lib/bibliothecary/analyser.rb', line 51

def generic?
  platform_name == "generic"
end

#map_dependencies(hash, key, type) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/bibliothecary/analyser.rb', line 59

def map_dependencies(hash, key, type)
  hash.fetch(key,[]).map do |name, requirement|
    {
      name: name,
      requirement: requirement,
      type: type,
    }
  end
end

#platform_nameObject



55
56
57
# File 'lib/bibliothecary/analyser.rb', line 55

def platform_name
  self.name.to_s.split("::").last.downcase
end