Class: Technologist::FrameworkDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/technologist/framework_detector.rb

Constant Summary collapse

FRAMEWORK_RULES =
File.expand_path('../frameworks.yml',  __FILE__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ FrameworkDetector

Returns a new instance of FrameworkDetector.



9
10
11
12
# File 'lib/technologist/framework_detector.rb', line 9

def initialize(repository)
  @repository = repository
  @yaml_parser = YamlParser.new(FRAMEWORK_RULES)
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



7
8
9
# File 'lib/technologist/framework_detector.rb', line 7

def repository
  @repository
end

#yaml_parserObject (readonly)

Returns the value of attribute yaml_parser.



7
8
9
# File 'lib/technologist/framework_detector.rb', line 7

def yaml_parser
  @yaml_parser
end

Instance Method Details

#frameworksObject



14
15
16
17
18
# File 'lib/technologist/framework_detector.rb', line 14

def frameworks
  matched_frameworks.flat_map do |technology, definition|
    [definition['primary'], technology]
  end.compact.uniq
end

#primary_frameworksObject



20
21
22
23
24
25
26
# File 'lib/technologist/framework_detector.rb', line 20

def primary_frameworks
  matched_frameworks.map do |technology, definition|
    # it's either the primary value defined in the yaml
    # or the technology itself
    definition['primary'] || technology
  end.uniq
end

#secondary_frameworksObject



28
29
30
31
32
33
# File 'lib/technologist/framework_detector.rb', line 28

def secondary_frameworks
  matched_frameworks.map do |technology, definition|
    # it's a secondary if a primary is defined in the yaml
    definition['primary'] && technology
  end.compact
end