зеркало из https://github.com/github/licensed.git
get rid of search root usage
not sure why this was added in the first place. from what I've seen, bundler doesn't really do dependency nesting. additionally, what was returned from spec_root looks an awful lot like the specifications gem_dir
This commit is contained in:
Родитель
644457a537
Коммит
8c244d1d69
|
@ -12,9 +12,9 @@ module Licensed
|
|||
class Dependency < Licensed::Dependency
|
||||
attr_reader :loaded_from
|
||||
|
||||
def initialize(name:, version:, path:, loaded_from:, search_root:, errors: [], metadata: {})
|
||||
def initialize(name:, version:, path:, loaded_from:, errors: [], metadata: {})
|
||||
@loaded_from = loaded_from
|
||||
super name: name, version: version, path: path, errors: errors, metadata: metadata, search_root: search_root
|
||||
super name: name, version: version, path: path, errors: errors, metadata: metadata
|
||||
end
|
||||
|
||||
# Load a package manager file from the base Licensee::Projects::FsProject
|
||||
|
@ -62,7 +62,6 @@ module Licensed
|
|||
version: spec.version.to_s,
|
||||
path: spec.gem_dir,
|
||||
loaded_from: spec.loaded_from,
|
||||
search_root: spec_root(spec),
|
||||
errors: Array(error),
|
||||
metadata: {
|
||||
"type" => Bundler.type,
|
||||
|
@ -91,20 +90,6 @@ module Licensed
|
|||
end
|
||||
end
|
||||
|
||||
# Returns a search root for a specification, one of:
|
||||
# - the local bundler gem location
|
||||
# - the system rubygems install gem location
|
||||
# - nil
|
||||
def spec_root(spec)
|
||||
return if spec.gem_dir.nil?
|
||||
root = [Gem.default_dir, Gem.dir].find { |dir| spec.gem_dir.start_with?(dir) }
|
||||
return unless root
|
||||
|
||||
path = "#{root}/gems/#{spec.full_name}"
|
||||
return unless File.exist?(path)
|
||||
path
|
||||
end
|
||||
|
||||
# Build the bundler definition
|
||||
def definition
|
||||
@definition ||= ::Bundler::Definition.build(gemfile_path, lockfile_path, nil)
|
||||
|
|
|
@ -248,21 +248,6 @@ if Licensed::Shell.tool_available?("bundle")
|
|||
assert_equal "apache-2.0", dep.license_key
|
||||
end
|
||||
end
|
||||
|
||||
it "sets a search root relative to the bundler gem dir for bundled gems" do
|
||||
Dir.chdir(fixtures) do
|
||||
dep = source.dependencies.find { |d| d.name == "semantic" }
|
||||
assert_equal "#{Gem.dir}/gems/#{dep.name}-#{dep.version}", dep.instance_variable_get("@root")
|
||||
end
|
||||
end
|
||||
|
||||
it "sets a search root relative to the system gem dir for system gems" do
|
||||
Dir.chdir(fixtures) do
|
||||
dep = source.dependencies.find { |d| d.name == "bundler" }
|
||||
assert dep
|
||||
assert_equal "#{Gem.default_dir}/gems/#{dep.name}-#{dep.version}", dep.instance_variable_get("@root")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "when run in ruby packer runtime" do
|
||||
|
|
Загрузка…
Ссылка в новой задаче