Sha256: 0bcc3c643f397eb8916e0db37bdfd90333bbc360dc49c7f3ea428d20857dd518

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'yaml'

module Technologist
  class FrameworkDetector
    def initialize(repository)
      @repository = repository
    end

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

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

    private

    attr_reader :repository

    def rules
      @rules ||= YAML.load_file('lib/technologist/frameworks.yml')
    end

    def matched_frameworks
      @frameworks ||=
        begin
          rules.map do |technology, definition|
            definition['rules'].map do |rule|
              if rule.matches?(technology, repository)
                technology
              end
            end
          end.flatten.compact
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
technologist-0.2.1 lib/technologist/framework_detector.rb
technologist-0.2.0 lib/technologist/framework_detector.rb