Module: Bibliothecary

Defined in:
lib/bibliothecary.rb,
lib/bibliothecary/version.rb,
lib/bibliothecary/analyser.rb,
lib/bibliothecary/parsers/go.rb,
lib/bibliothecary/parsers/dub.rb,
lib/bibliothecary/parsers/elm.rb,
lib/bibliothecary/parsers/hex.rb,
lib/bibliothecary/parsers/npm.rb,
lib/bibliothecary/parsers/pub.rb,
lib/bibliothecary/parsers/cpan.rb,
lib/bibliothecary/parsers/cran.rb,
lib/bibliothecary/parsers/pypi.rb,
lib/bibliothecary/parsers/bower.rb,
lib/bibliothecary/parsers/cargo.rb,
lib/bibliothecary/parsers/julia.rb,
lib/bibliothecary/parsers/maven.rb,
lib/bibliothecary/parsers/nuget.rb,
lib/bibliothecary/parsers/shard.rb,
lib/bibliothecary/parsers/meteor.rb,
lib/bibliothecary/parsers/clojars.rb,
lib/bibliothecary/parsers/carthage.rb,
lib/bibliothecary/parsers/rubygems.rb,
lib/bibliothecary/parsers/swift_pm.rb,
lib/bibliothecary/parsers/cocoapods.rb,
lib/bibliothecary/parsers/packagist.rb

Defined Under Namespace

Modules: Analyser, Parsers

Constant Summary collapse

VERSION =
"5.3.0"

Class Method Summary collapse

Class Method Details

.analyse(path) ⇒ Object



9
10
11
12
13
# File 'lib/bibliothecary.rb', line 9

def self.analyse(path)
  cmd = `find #{path} -type f | grep -vE "#{ignored_files}"`
  file_list = cmd.split("\n").sort
  package_managers.map{|pm| pm.analyse(path, file_list) }.flatten.compact
end

.analyse_file(file_path, contents) ⇒ Object



15
16
17
18
19
# File 'lib/bibliothecary.rb', line 15

def self.analyse_file(file_path, contents)
  package_managers.map do |pm|
    pm.analyse_contents(file_path, contents)
  end.flatten.uniq.compact
end

.identify_manifests(file_list) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/bibliothecary.rb', line 21

def self.identify_manifests(file_list)
  package_managers.map do |pm|
    file_list.select do |file_path|
      pm.match?(file_path)
    end
  end.flatten.uniq.compact
end

.ignored_filesObject



33
34
35
# File 'lib/bibliothecary.rb', line 33

def self.ignored_files
  ['.git', 'node_modules', 'bower_components', 'spec/fixtures', 'vendor/bundle'].join('|')
end

.package_managersObject



29
30
31
# File 'lib/bibliothecary.rb', line 29

def self.package_managers
  Bibliothecary::Parsers.constants.map{|c| Bibliothecary::Parsers.const_get(c) }.sort_by{|c| c.to_s.downcase }
end