librarianp 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/librarian/action/resolve.rb +4 -4
- data/lib/librarian/dependency.rb +26 -0
- data/lib/librarian/environment.rb +1 -1
- data/lib/librarian/manifest.rb +3 -24
- data/lib/librarian/mock/environment.rb +4 -2
- data/lib/librarian/source/git/repository.rb +1 -1
- data/lib/librarian/spec.rb +0 -1
- data/lib/librarian/specfile.rb +1 -1
- data/librarian.gemspec +3 -3
- data/spec/unit/action/resolve_spec.rb +25 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a318f3a8c81d302b411ab7c49a30516b919052d0
|
4
|
+
data.tar.gz: a6f81353d1114c4be9c0e800855c4111f45c5ad1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8d8828d8a3691916a68ce07b538630d5aa84e87fda4bd49e9c177ea2dc882594acb240387720ae1c9a9ee92baf5b829c5e468eb815cfc32783f25803e531f07
|
7
|
+
data.tar.gz: c4ae9428382e90ae828e839a731848bc3b0277f9f590f321aee0c717412c7f2938aba9001e3b851a346f495dad88cbf38f6b29cac2801bd328b945bd60b47323
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -23,14 +23,14 @@ module Librarian
|
|
23
23
|
manifests = changes.analyze
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise Error, "Duplicated dependencies: #{dupes.values.flatten.map {|d| {d.name => d.source.to_s} }}"
|
26
|
+
spec.dependencies, duplicated = Dependency.remove_duplicate_dependencies(spec.dependencies)
|
27
|
+
duplicated.each do |name, dependencies_same_name|
|
28
|
+
environment.logger.info { "Dependency '#{name}' duplicated for module #{name}, merging: #{dependencies_same_name.map{|d| d.to_s}}" }
|
30
29
|
end
|
31
30
|
|
32
31
|
resolution = resolver.resolve(spec, manifests)
|
33
32
|
persist_resolution(resolution)
|
33
|
+
resolution
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
data/lib/librarian/dependency.rb
CHANGED
@@ -185,6 +185,32 @@ module Librarian
|
|
185
185
|
!consistent_with?(other)
|
186
186
|
end
|
187
187
|
|
188
|
+
class << self
|
189
|
+
# merge dependencies with the same name into one
|
190
|
+
# with the source of the first one and merged requirements
|
191
|
+
def merge_dependencies(dependencies)
|
192
|
+
requirement = Dependency::Requirement.new(*dependencies.map{|d| d.requirement})
|
193
|
+
dependencies.last.class.new(dependencies.last.name, requirement, dependencies.last.source)
|
194
|
+
end
|
195
|
+
|
196
|
+
# Avoid duplicated dependencies with different sources or requirements
|
197
|
+
# Return [merged dependnecies, duplicates as a map by name]
|
198
|
+
def remove_duplicate_dependencies(dependencies)
|
199
|
+
uniq = []
|
200
|
+
duplicated = {}
|
201
|
+
dependencies_by_name = dependencies.group_by{|d| d.name}
|
202
|
+
dependencies_by_name.map do |name, dependencies_same_name|
|
203
|
+
if dependencies_same_name.size > 1
|
204
|
+
duplicated[name] = dependencies_same_name
|
205
|
+
uniq << merge_dependencies(dependencies_same_name)
|
206
|
+
else
|
207
|
+
uniq << dependencies_same_name.first
|
208
|
+
end
|
209
|
+
end
|
210
|
+
[uniq, duplicated]
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
188
214
|
private
|
189
215
|
|
190
216
|
def assert_name_valid!(name)
|
data/lib/librarian/manifest.rb
CHANGED
@@ -94,31 +94,10 @@ module Librarian
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def fetch_dependencies!
|
97
|
-
remove_duplicate_dependencies(
|
98
|
-
|
99
|
-
|
100
|
-
# merge dependencies with the same name into one
|
101
|
-
# with the source of the first one and merged requirements
|
102
|
-
def merge_dependencies(dependencies)
|
103
|
-
requirement = Dependency::Requirement.new(*dependencies.map{|d| d.requirement})
|
104
|
-
dependencies.first.class.new(dependencies.first.name, requirement, dependencies.first.source)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Avoid duplicated dependencies with different sources or requirements
|
108
|
-
def remove_duplicate_dependencies(module_name, dependencies)
|
109
|
-
uniq = []
|
110
|
-
dependencies_by_name = dependencies.group_by{|d| d.name}
|
111
|
-
dependencies_by_name.map do |name, dependencies_same_name|
|
112
|
-
if dependencies_same_name.size > 1
|
113
|
-
environment.logger.warn { "Dependency '#{name}' duplicated for module #{module_name}, trying to merge: #{dependencies_same_name.map{|d| d.to_s}}" }
|
114
|
-
merged = merge_dependencies(dependencies_same_name)
|
115
|
-
environment.logger.warn { "Dependency '#{name}' merged as #{merged}" }
|
116
|
-
uniq << merged
|
117
|
-
else
|
118
|
-
uniq << dependencies_same_name.first
|
119
|
-
end
|
97
|
+
dependencies, duplicated = Dependency.remove_duplicate_dependencies(source.fetch_dependencies(name, version, extra))
|
98
|
+
duplicated.each do |name, dependencies_same_name|
|
99
|
+
environment.logger.info { "Dependency '#{name}' duplicated for module #{module_name}, merging: #{dependencies_same_name.map{|d| d.to_s}}" }
|
120
100
|
end
|
121
|
-
uniq
|
122
101
|
end
|
123
102
|
|
124
103
|
def _normalize_version(version)
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require "librarian/environment"
|
2
|
+
require "librarian/ui"
|
2
3
|
require "librarian/mock/dsl"
|
3
4
|
require "librarian/mock/version"
|
5
|
+
require 'thor'
|
4
6
|
|
5
7
|
module Librarian
|
6
8
|
module Mock
|
7
9
|
class Environment < Environment
|
8
10
|
|
9
|
-
def
|
10
|
-
|
11
|
+
def ui
|
12
|
+
Librarian::UI::Shell.new(Thor::Shell::Basic.new)
|
11
13
|
end
|
12
14
|
|
13
15
|
def registry(options = nil, &block)
|
data/lib/librarian/spec.rb
CHANGED
data/lib/librarian/specfile.rb
CHANGED
data/librarian.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: librarianp 0.
|
2
|
+
# stub: librarianp 0.6.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "librarianp"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.6.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Jay Feldblum", "Carlos Sanchez"]
|
11
|
-
s.date = "2015-03-
|
11
|
+
s.date = "2015-03-06"
|
12
12
|
s.description = "A Framework for Bundlers, used by librarian-puppet."
|
13
13
|
s.email = ["y_feldblum@yahoo.com", "carlos@apache.org"]
|
14
14
|
s.files = [".gitignore", ".rspec", ".travis.yml", "CHANGELOG.md", "Gemfile", "Gemfile.lock", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/librarian.rb", "lib/librarian/action.rb", "lib/librarian/action/base.rb", "lib/librarian/action/clean.rb", "lib/librarian/action/ensure.rb", "lib/librarian/action/install.rb", "lib/librarian/action/persist_resolution_mixin.rb", "lib/librarian/action/resolve.rb", "lib/librarian/action/update.rb", "lib/librarian/algorithms.rb", "lib/librarian/cli.rb", "lib/librarian/cli/manifest_presenter.rb", "lib/librarian/config.rb", "lib/librarian/config/database.rb", "lib/librarian/config/file_source.rb", "lib/librarian/config/hash_source.rb", "lib/librarian/config/source.rb", "lib/librarian/dependency.rb", "lib/librarian/dsl.rb", "lib/librarian/dsl/receiver.rb", "lib/librarian/dsl/target.rb", "lib/librarian/environment.rb", "lib/librarian/environment/runtime_cache.rb", "lib/librarian/error.rb", "lib/librarian/helpers.rb", "lib/librarian/linter/source_linter.rb", "lib/librarian/lockfile.rb", "lib/librarian/lockfile/compiler.rb", "lib/librarian/lockfile/parser.rb", "lib/librarian/logger.rb", "lib/librarian/manifest.rb", "lib/librarian/manifest/pre_release_version.rb", "lib/librarian/manifest/version.rb", "lib/librarian/manifest_set.rb", "lib/librarian/mock.rb", "lib/librarian/mock/cli.rb", "lib/librarian/mock/dsl.rb", "lib/librarian/mock/environment.rb", "lib/librarian/mock/extension.rb", "lib/librarian/mock/source.rb", "lib/librarian/mock/source/mock.rb", "lib/librarian/mock/source/mock/registry.rb", "lib/librarian/mock/version.rb", "lib/librarian/posix.rb", "lib/librarian/resolution.rb", "lib/librarian/resolver.rb", "lib/librarian/resolver/implementation.rb", "lib/librarian/rspec/support/cli_macro.rb", "lib/librarian/source.rb", "lib/librarian/source/basic_api.rb", "lib/librarian/source/git.rb", "lib/librarian/source/git/repository.rb", "lib/librarian/source/local.rb", "lib/librarian/source/path.rb", "lib/librarian/spec.rb", "lib/librarian/spec_change_set.rb", "lib/librarian/specfile.rb", "lib/librarian/support/abstract_method.rb", "lib/librarian/ui.rb", "lib/librarian/version.rb", "librarian.gemspec", "spec/functional/cli_spec.rb", "spec/functional/posix_spec.rb", "spec/functional/source/git/repository_spec.rb", "spec/functional/source/git_spec.rb", "spec/support/fakefs.rb", "spec/support/method_patch_macro.rb", "spec/support/project_path_macro.rb", "spec/support/with_env_macro.rb", "spec/unit/action/base_spec.rb", "spec/unit/action/clean_spec.rb", "spec/unit/action/ensure_spec.rb", "spec/unit/action/install_spec.rb", "spec/unit/action/resolve_spec.rb", "spec/unit/algorithms_spec.rb", "spec/unit/config/database_spec.rb", "spec/unit/dependency/requirement_spec.rb", "spec/unit/dependency_spec.rb", "spec/unit/dsl_spec.rb", "spec/unit/environment/runtime_cache_spec.rb", "spec/unit/environment_spec.rb", "spec/unit/lockfile/parser_spec.rb", "spec/unit/lockfile_spec.rb", "spec/unit/manifest/version_spec.rb", "spec/unit/manifest_set_spec.rb", "spec/unit/manifest_spec.rb", "spec/unit/mock/environment_spec.rb", "spec/unit/mock/source/mock_spec.rb", "spec/unit/resolver_spec.rb", "spec/unit/source/git_spec.rb", "spec/unit/spec_change_set_spec.rb"]
|
@@ -1,27 +1,44 @@
|
|
1
1
|
require "librarian/error"
|
2
|
+
require "librarian/logger"
|
2
3
|
require "librarian/action/resolve"
|
4
|
+
require "librarian/mock/environment"
|
3
5
|
require "librarian/mock/source"
|
4
6
|
|
5
7
|
module Librarian
|
6
8
|
describe Action::Resolve do
|
7
9
|
|
8
10
|
let(:options) { {} }
|
9
|
-
let(:spec) {
|
10
|
-
let(:env) {
|
11
|
+
let(:spec) { Spec.new([], dependencies, []) }
|
12
|
+
let(:env) { Librarian::Mock::Environment.new }
|
11
13
|
let(:action) { described_class.new(env, options) }
|
14
|
+
let(:source1) { Librarian::Mock::Source::Mock.new(env, "source1", {}) }
|
15
|
+
let(:source2) { Librarian::Mock::Source::Mock.new(env, "source2", {}) }
|
16
|
+
|
17
|
+
before do
|
18
|
+
env.stub(:specfile => double(:read => spec))
|
19
|
+
end
|
12
20
|
|
13
21
|
describe "#run" do
|
14
22
|
|
15
23
|
describe "behavior" do
|
16
24
|
|
17
|
-
describe "
|
25
|
+
describe "merge duplicated dependencies" do
|
18
26
|
let(:options) { {:force => true} }
|
19
|
-
let(:
|
20
|
-
let(:
|
21
|
-
let(:
|
27
|
+
let(:dependency1) { Dependency.new('dependency_name', '1.0.0', source1) }
|
28
|
+
let(:dependency2) { Dependency.new('dependency_name', '1.0.0', source2) }
|
29
|
+
let(:dependencies) { [ dependency1, dependency2 ] }
|
30
|
+
let(:manifest) do
|
31
|
+
m = Manifest.new(source1, dependency1.name)
|
32
|
+
m.version = '1.0.0'
|
33
|
+
m.dependencies = []
|
34
|
+
m
|
35
|
+
end
|
22
36
|
|
23
|
-
it "should
|
24
|
-
|
37
|
+
it "should merge duplicated dependencies" do
|
38
|
+
Dependency.any_instance.stub(:manifests => [manifest])
|
39
|
+
action.stub(:persist_resolution)
|
40
|
+
resolution = action.run
|
41
|
+
expect(resolution.dependencies).to eq([dependency2])
|
25
42
|
end
|
26
43
|
|
27
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librarianp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Feldblum
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|