Module: Bibliothecary

Defined in:
lib/bibliothecary.rb,
lib/bibliothecary/cli.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/configuration.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/hackage.rb,
lib/bibliothecary/parsers/haxelib.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 Classes: CLI, Configuration

Constant Summary collapse

VERSION =
"6.2.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



47
48
49
# File 'lib/bibliothecary.rb', line 47

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.analyse(path) ⇒ Object



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

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

.analyse_file(file_path, contents) ⇒ Object



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

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

.configure {|configuration| ... } ⇒ Object

Yields:



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

def self.configure
  yield(configuration)
end

.identify_manifests(file_list) ⇒ Object



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

def self.identify_manifests(file_list)
  allowed_file_list = file_list.reject{|f| f.start_with?(*ignored_files) }
  package_managers.map do |pm|
    allowed_file_list.select do |file_path|
      pm.match?(file_path)
    end
  end.flatten.uniq.compact
end

.ignored_filesObject



35
36
37
# File 'lib/bibliothecary.rb', line 35

def self.ignored_files
  configuration.ignored_files
end

.ignored_files_regexObject



39
40
41
# File 'lib/bibliothecary.rb', line 39

def self.ignored_files_regex
  ignored_files.join('|')
end

.package_managersObject



31
32
33
# File 'lib/bibliothecary.rb', line 31

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

.resetObject



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

def self.reset
  @configuration = Configuration.new
end