Sha256: ea0103283c9ecb1d1966a7bbc2033dbc3d77945a9dcc41391f90bbe863b03bd3
Contents?: true
Size: 1.68 KB
Versions: 7
Compression:
Stored size: 1.68 KB
Contents
module Bibliothecary module Analyser def self.included(base) base.extend(ClassMethods) end module ClassMethods def parse_file(filename, contents) mapping.each do |regex, details| if filename.match(regex) return send(details[:parser], contents) end end return [] end def match?(filename) mapping.keys.any?{|regex| filename.match(regex) } end def platform_name self.name.to_s.split('::').last.downcase end def analyse(folder_path, file_list) file_list.map do |path| filename = path.gsub(folder_path, '').gsub(/^\//, '') contents = File.open(path).read analyse_contents(filename, contents) end.compact end def analyse_contents(filename, contents) begin dependencies = parse_file(filename, contents) if dependencies && dependencies.any? { platform: platform_name, path: filename, dependencies: dependencies, kind: determine_kind(filename) } else nil end rescue nil end end def determine_kind(filename) mapping.each do |regex, details| if filename.match(regex) return details[:kind] end end return [] end def parse_ruby_manifest(manifest) manifest.dependencies.inject([]) do |deps, dep| deps.push({ name: dep.name, requirement: dep.requirement.to_s, type: dep.type }) end.uniq end end end end
Version data entries
7 entries across 7 versions & 1 rubygems