librarianp 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba0b480a24c69d616894564789dedde87e711120
4
- data.tar.gz: c59aea592433b7cae32f3f4a4b8cfbe5e40aa463
3
+ metadata.gz: 04a1e4db0787f3a2fd35ed107c2b56d4d4ad6a6b
4
+ data.tar.gz: 2818792e819ffa97695db3845a5cf49d5a523530
5
5
  SHA512:
6
- metadata.gz: 6f1ee150fb236d72793ba05c4d2dba4cfe29364e862e9a8189c2641477a5935610103fcd2f88fd17fe07e00446c34fec9704f486a10490b8e76ea3dd9a1db84e
7
- data.tar.gz: c15fc1536c848418fe5aade277508341345abf5dbf36bb752d9af6f3ff9227c25eded6ff4b7c7e1a4cb45acb404eff08fcd5aef4a74baa47e2bb25730b596ec6
6
+ metadata.gz: 1c5819c7a0a6313718d33d812bf635244135e835599822014e6d93c167cc449a43609484c275257e6f150d24fff45a84ec6bd34fdb17c34e3e6b5c450caae7be
7
+ data.tar.gz: 2ca7a08199372c51f33be95176edfe1adf391858066671f78a31da1db987b15b43ca17f00660b2c55439d6429221aaace6ce9384042365dd956556e52a3e7c33
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.4.0
4
+
5
+ * Resolve iteratively instead of recursively
6
+ * Fail if there are duplicated dependencies in spec file
7
+ * Merge duplicated dependencies and warn the user
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  * Allow customizing default specfile and receiver downstream
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- librarianp (0.3.0)
4
+ librarianp (0.4.0)
5
5
  thor (~> 0.15)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Librarian [![Build Status](https://secure.travis-ci.org/carlossg/librarian.png)](http://travis-ci.org/carlossg/librarian) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/carlossg/librarian)
2
2
  =========
3
3
 
4
+ This is a forked version published as `librarianp` with improvements in order to support `librarian-puppet`.
5
+
4
6
  Librarian is a framework for writing bundlers, which are tools that resolve,
5
7
  fetch, install, and isolate a project's dependencies, in Ruby.
6
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -23,6 +23,11 @@ module Librarian
23
23
  manifests = changes.analyze
24
24
  end
25
25
 
26
+ dupes = spec.dependencies.group_by{ |e| e.name }.select { |k, v| v.size > 1 }
27
+ unless dupes.empty?
28
+ raise Error, "Duplicated dependencies: #{dupes.values.flatten.map {|d| {d.name => d.source.to_s} }}"
29
+ end
30
+
26
31
  resolution = resolver.resolve(spec, manifests)
27
32
  persist_resolution(resolution)
28
33
  end
@@ -171,6 +171,12 @@ module Librarian
171
171
  self.source == other.source
172
172
  end
173
173
 
174
+ alias :eql? :==
175
+
176
+ def hash
177
+ self.to_s.hash
178
+ end
179
+
174
180
  def consistent_with?(other)
175
181
  name != other.name || requirement.consistent_with?(other.requirement)
176
182
  end
@@ -219,7 +219,31 @@ module Librarian
219
219
  end
220
220
 
221
221
  def fetch_dependencies!
222
- source.fetch_dependencies(name, version, extra)
222
+ remove_duplicate_dependencies(name, source.fetch_dependencies(name, version, extra))
223
+ end
224
+
225
+ # merge dependencies with the same name into one
226
+ # with the source of the first one and merged requirements
227
+ def merge_dependencies(dependencies)
228
+ requirement = Dependency::Requirement.new(*dependencies.map{|d| d.requirement})
229
+ Dependency.new(dependencies.first.name, requirement, dependencies.first.source)
230
+ end
231
+
232
+ # Avoid duplicated dependencies with different sources or requirements
233
+ def remove_duplicate_dependencies(module_name, dependencies)
234
+ uniq = []
235
+ dependencies_by_name = dependencies.group_by{|d| d.name}
236
+ dependencies_by_name.map do |name, dependencies_same_name|
237
+ if dependencies_same_name.size > 1
238
+ environment.logger.warn { "Dependency '#{name}' duplicated for module #{module_name}, trying to merge: #{dependencies_same_name.map{|d| d.to_s}}" }
239
+ merged = merge_dependencies(dependencies_same_name)
240
+ environment.logger.warn { "Dependency '#{name}' merged as #{merged}" }
241
+ uniq << merged
242
+ else
243
+ uniq << dependencies_same_name.first
244
+ end
245
+ end
246
+ uniq
223
247
  end
224
248
 
225
249
  def _normalize_version(version)
@@ -47,27 +47,31 @@ module Librarian
47
47
  manifests = index_by(manifests, &:name) if manifests.kind_of?(Array)
48
48
  queue = spec.dependencies + sourced_dependencies_for_manifests(manifests)
49
49
  state = State.new(manifests.dup, [], queue)
50
- recursive_resolve(state)
50
+ do_resolve(state)
51
51
  end
52
52
 
53
53
  private
54
54
 
55
- def recursive_resolve(state)
56
- shift_resolved_enqueued_dependencies(state) or return
57
- state.queue.empty? and return state.manifests
55
+ def do_resolve(state)
56
+ stack = [state]
57
+ while !stack.empty? do
58
+ state = stack.pop
59
+ shift_resolved_enqueued_dependencies(state) or return
60
+ state.queue.empty? and return state.manifests
58
61
 
59
- state.dependencies << state.queue.shift
60
- dependency = state.dependencies.last
62
+ state.dependencies << state.queue.shift
63
+ dependency = state.dependencies.last
61
64
 
62
- resolving_dependency_map_find_manifests(dependency) do |manifest|
63
- check_manifest(state, manifest) or next
64
- check_manifest_for_cycles(state, manifest) or next unless cyclic
65
+ resolving_dependency_map_find_manifests(dependency) do |manifest|
66
+ check_manifest(state, manifest) or next
67
+ check_manifest_for_cycles(state, manifest) or next unless cyclic
65
68
 
66
- m = state.manifests.merge(dependency.name => manifest)
67
- a = sourced_dependencies_for_manifest(manifest)
68
- s = State.new(m, state.dependencies.dup, state.queue + a)
69
+ m = state.manifests.merge(dependency.name => manifest)
70
+ a = sourced_dependencies_for_manifest(manifest)
71
+ s = State.new(m, state.dependencies.dup, state.queue + a)
69
72
 
70
- recursive_resolve(s)
73
+ stack.push(s)
74
+ end
71
75
  end
72
76
  end
73
77
 
data/librarian.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: librarianp 0.3.0 ruby lib
2
+ # stub: librarianp 0.4.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "librarianp"
6
- s.version = "0.3.0"
6
+ s.version = "0.4.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-02-25"
11
+ s.date = "2015-02-26"
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_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/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"]
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.3.0
4
+ version: 0.4.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-02-25 00:00:00.000000000 Z
12
+ date: 2015-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -241,4 +241,3 @@ test_files:
241
241
  - spec/unit/resolver_spec.rb
242
242
  - spec/unit/source/git_spec.rb
243
243
  - spec/unit/spec_change_set_spec.rb
244
- has_rdoc: