Module: Bibliothecary

Defined in:
lib/bibliothecary/parsers/conan.rb,
lib/bibliothecary.rb,
lib/bibliothecary/cli.rb,
lib/bibliothecary/runner.rb,
lib/bibliothecary/version.rb,
lib/bibliothecary/analyser.rb,
lib/bibliothecary/file_info.rb,
lib/bibliothecary/purl_util.rb,
lib/bibliothecary/dependency.rb,
lib/bibliothecary/exceptions.rb,
lib/bibliothecary/parsers/go.rb,
lib/bibliothecary/parsers/dub.rb,
lib/bibliothecary/parsers/elm.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/parser_result.rb,
lib/bibliothecary/parsers/bower.rb,
lib/bibliothecary/parsers/cargo.rb,
lib/bibliothecary/parsers/conda.rb,
lib/bibliothecary/parsers/julia.rb,
lib/bibliothecary/parsers/maven.rb,
lib/bibliothecary/parsers/nuget.rb,
lib/bibliothecary/parsers/shard.rb,
lib/bibliothecary/parsers/vcpkg.rb,
lib/bibliothecary/parsers/meteor.rb,
lib/bibliothecary/parsers/haxelib.rb,
lib/bibliothecary/parsers/rubygems.rb,
lib/bibliothecary/analyser/analysis.rb,
lib/bibliothecary/analyser/matchers.rb,
lib/bibliothecary/parsers/cocoapods.rb,
lib/bibliothecary/parsers/packagist.rb,
lib/bibliothecary/multi_parsers/spdx.rb,
lib/bibliothecary/related_files_info.rb,
lib/bibliothecary/analyser/determinations.rb,
lib/bibliothecary/multi_parsers/cyclonedx.rb,
lib/bibliothecary/parser_mixins/json_runtime.rb,
lib/bibliothecary/runner/multi_manifest_filter.rb,
lib/bibliothecary/multi_parsers/dependencies_csv.rb,
lib/bibliothecary/parser_mixins/bundler_like_manifest.rb

Overview

Known shortcomings and unimplemented Maven features:

pom.xml
  <exclusions> cannot be taken into  (because it requires knowledge of transitive deps)
  <properties> are the only thing inherited from parent poms currenly

Defined Under Namespace

Modules: Analyser, MultiParsers, ParserMixins, Parsers Classes: CLI, Configuration, Dependency, FileInfo, FileParsingError, ParserResult, PurlUtil, RelatedFilesInfo, RemoteParsingError, Runner

Constant Summary collapse

VERSION_OPERATORS =
/[~^<>*"]/
INVALID_UTF8_ERROR_REGEXP =
/invalid byte sequence/
VERSION =
"15.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



120
121
122
123
124
# File 'lib/bibliothecary.rb', line 120

def self.configuration
  @configuration ||= Configuration.new
  @runner = Runner.new(@configuration)
  @configuration
end

Class Method Details

.analyse(path, ignore_unparseable_files: true) ⇒ Object Also known as: analyze



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

def self.analyse(path, ignore_unparseable_files: true)
  runner.analyse(path, ignore_unparseable_files: ignore_unparseable_files)
end

.analyse_file(file_path, contents) ⇒ Object Also known as: analyze_file



61
62
63
# File 'lib/bibliothecary.rb', line 61

def self.analyse_file(file_path, contents)
  runner.analyse_file(file_path, contents)
end

.applicable_package_managers(_info) ⇒ Object



41
42
43
# File 'lib/bibliothecary.rb', line 41

def self.applicable_package_managers(_info)
  raise "Bibliothecary.applicable_package_managers() has been removed in bibliothecary 15.0.0. Use parsers() instead, which now includes MultiParsers."
end

.applicable_parsers(info) ⇒ Object



45
46
47
# File 'lib/bibliothecary.rb', line 45

def self.applicable_parsers(info)
  runner.applicable_parsers(info)
end

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

Yields:



131
132
133
# File 'lib/bibliothecary.rb', line 131

def self.configure
  yield(configuration)
end

.find_manifests(path) ⇒ Object



77
78
79
# File 'lib/bibliothecary.rb', line 77

def self.find_manifests(path)
  runner.find_manifests(path)
end

.find_manifests_from_contents(file_path_contents_hash) ⇒ Object



85
86
87
# File 'lib/bibliothecary.rb', line 85

def self.find_manifests_from_contents(file_path_contents_hash)
  runner.find_manifests_from_contents(file_path_contents_hash)
end

.find_manifests_from_paths(paths) ⇒ Object



81
82
83
# File 'lib/bibliothecary.rb', line 81

def self.find_manifests_from_paths(paths)
  runner.find_manifests_from_paths(paths)
end

.identify_manifests(file_list) ⇒ Object



65
66
67
# File 'lib/bibliothecary.rb', line 65

def self.identify_manifests(file_list)
  runner.identify_manifests(file_list)
end

.ignored_dirsObject



89
90
91
# File 'lib/bibliothecary.rb', line 89

def self.ignored_dirs
  configuration.ignored_dirs
end

.ignored_filesObject



93
94
95
# File 'lib/bibliothecary.rb', line 93

def self.ignored_files
  configuration.ignored_files
end

.load_file_info_list(path) ⇒ Object



49
50
51
# File 'lib/bibliothecary.rb', line 49

def self.load_file_info_list(path)
  runner.load_file_info_list(path)
end

.load_file_info_list_from_contents(file_path_contents_hash) ⇒ Object



57
58
59
# File 'lib/bibliothecary.rb', line 57

def self.load_file_info_list_from_contents(file_path_contents_hash)
  runner.load_file_info_list_from_contents(file_path_contents_hash)
end

.load_file_info_list_from_paths(paths) ⇒ Object



53
54
55
# File 'lib/bibliothecary.rb', line 53

def self.load_file_info_list_from_paths(paths)
  runner.load_file_info_list_from_paths(paths)
end

.load_file_list(path) ⇒ Object

deprecated; use load_file_info_list.



37
38
39
# File 'lib/bibliothecary.rb', line 37

def self.load_file_list(path)
  runner.load_file_list(path)
end

.package_managersObject



69
70
71
# File 'lib/bibliothecary.rb', line 69

def self.package_managers
  raise "Bibliothecary.package_managers() has been removed in bibliothecary 15.0.0. Use parsers() instead, which now includes MultiParsers."
end

.parsersObject



73
74
75
# File 'lib/bibliothecary.rb', line 73

def self.parsers
  runner.parsers
end

.resetObject



126
127
128
129
# File 'lib/bibliothecary.rb', line 126

def self.reset
  @configuration = Configuration.new
  @runner = Runner.new(@configuration)
end

.runnerObject



115
116
117
118
# File 'lib/bibliothecary.rb', line 115

def self.runner
  configuration
  @runner
end

.utf8_string(string) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/bibliothecary.rb', line 97

def self.utf8_string(string)
  string
    .dup # ensure we don't have a frozen string
    .force_encoding("UTF-8") # treat all strings as utf8
    .sub(/^\xEF\xBB\xBF/, "") # remove any Byte Order Marks so JSON, etc don't fail while parsing them.
rescue ArgumentError => e
  # Bibliothecary doesn't need to analyze non-UTF8 files like binary files, so just return blank.
  return "" if e.message.match?(INVALID_UTF8_ERROR_REGEXP)

  raise e
end