molinillo 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/molinillo/resolution.rb +14 -2
- data/spec/resolver_integration_specs/index_from_rubygems.rb +76 -0
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aac1d186cbe00eb9659705c4c35c8cfc3b6f4e84
|
4
|
+
data.tar.gz: 3ea34b9aa3e68233ee0744442f136eeec3972e08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 250f701b7bf421d1e964fe6051f15652f4a2ab4611763b070732b51eef770739ef892c7df461845c859c85e4b4c2e10595caa0eabf3082c9d6c7f84541c856dc
|
7
|
+
data.tar.gz: 84858314e130d50eabf2fabe9da871003d8c75633e55cb35713968c8ac2fdfab8a8a21b1957e6ae89c53df80bb006e5a1039a685fa8f35ec9d80b8dd63b4aa75
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ $ gem install molinillo
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
|
31
|
+
See the [ARCHITECTURE](ARCHITECTURE.md) file for an overview and look at the test suite for example usage. Better documentation and examples are
|
32
32
|
forthcoming.
|
33
33
|
|
34
34
|
## Contributing
|
data/lib/molinillo/resolution.rb
CHANGED
@@ -229,7 +229,7 @@ module Molinillo
|
|
229
229
|
# `requirement`.
|
230
230
|
def find_state_for(requirement)
|
231
231
|
return nil unless requirement
|
232
|
-
states.find { |i| requirement == i.requirement }
|
232
|
+
states.reverse_each.find { |i| requirement == i.requirement && i.is_a?(DependencyState) }
|
233
233
|
end
|
234
234
|
|
235
235
|
# @return [Boolean] whether or not the given state has any possibilities
|
@@ -320,12 +320,24 @@ module Molinillo
|
|
320
320
|
new_requirements = requirements.dup
|
321
321
|
push_state_for_requirements(new_requirements)
|
322
322
|
else
|
323
|
+
return if attempt_to_swap_possibility
|
323
324
|
create_conflict
|
324
325
|
debug(depth) { "Unsatisfied by existing spec (#{existing_node.payload})" }
|
325
326
|
unwind_for_conflict
|
326
327
|
end
|
327
328
|
end
|
328
329
|
|
330
|
+
# Attempts to swp the current {#possibility} with the already-activated
|
331
|
+
# spec with the given name
|
332
|
+
# @return [Boolean] Whether the possibility was swapped into {#activated}
|
333
|
+
def attempt_to_swap_possibility
|
334
|
+
swapped = activated.dup
|
335
|
+
swapped.vertex_named(name).payload = possibility
|
336
|
+
return unless swapped.vertex_named(name).requirements.
|
337
|
+
all? { |r| requirement_satisfied_by?(r, swapped, possibility) }
|
338
|
+
attempt_to_activate_new_spec
|
339
|
+
end
|
340
|
+
|
329
341
|
# Attempts to activate the current {#possibility} (given that it hasn't
|
330
342
|
# already been activated)
|
331
343
|
# @return [void]
|
@@ -383,7 +395,7 @@ module Molinillo
|
|
383
395
|
# @param [Array] new_requirements
|
384
396
|
# @return [void]
|
385
397
|
def push_state_for_requirements(new_requirements)
|
386
|
-
new_requirements = sort_dependencies(new_requirements, activated, conflicts)
|
398
|
+
new_requirements = sort_dependencies(new_requirements.uniq, activated, conflicts)
|
387
399
|
new_requirement = new_requirements.shift
|
388
400
|
states.push DependencyState.new(
|
389
401
|
new_requirement ? name_for(new_requirement) : '',
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'set'
|
6
|
+
|
7
|
+
GEMS = %w(rails capybara bundler).freeze
|
8
|
+
|
9
|
+
VERSION_PATTERN = /\A
|
10
|
+
[0-9]+\.[0-9]+\.[0-9]+ (?# Number component)
|
11
|
+
([-][0-9a-z-]+(\.[0-9a-z-]+)*)? (?# Pre-release component)
|
12
|
+
([+][0-9a-z-]+(\.[0-9a-z-]+)*)? (?# Build component)
|
13
|
+
\Z/xi
|
14
|
+
|
15
|
+
def coerce_to_semver(version)
|
16
|
+
return version if version.sub(/^(\S+\s+)/, '') =~ VERSION_PATTERN
|
17
|
+
return "#{Regexp.last_match[1]}#{Regexp.last_match[2]}" if version =~ /^(\S+\s+)? (\d+\.\d+\.\d+) (?: \.\d+)*$/ix
|
18
|
+
|
19
|
+
parts = version.split(/[\.-]/, 4)
|
20
|
+
4.times do |i|
|
21
|
+
if parts[i] =~ /-?([a-zA-Z])/
|
22
|
+
parts << '0' until parts.size >= 3
|
23
|
+
parts[i].sub!(/-?([a-zA-Z]+)/, '')
|
24
|
+
parts[i] = '0' if parts[i].empty?
|
25
|
+
parts[3] = Regexp.last_match[1] + parts[i..-1].join('')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
semver = parts[0..2].join('.')
|
29
|
+
semver.sub!(/([a-zA-Z])/, '-\1')
|
30
|
+
semver += '-' + parts[-1] if parts.size > 3
|
31
|
+
semver
|
32
|
+
end
|
33
|
+
|
34
|
+
def coerce_dependencies_to_semver(deps)
|
35
|
+
dependencies = {}
|
36
|
+
deps.each do |name, req|
|
37
|
+
dependencies[name] = req.split(',').map { |r| coerce_to_semver(r) }.join(',')
|
38
|
+
end
|
39
|
+
dependencies
|
40
|
+
end
|
41
|
+
|
42
|
+
gems = Set.new(GEMS)
|
43
|
+
downloaded_gems = Set.new
|
44
|
+
specs = []
|
45
|
+
|
46
|
+
loop do
|
47
|
+
size = gems.size
|
48
|
+
(gems ^ downloaded_gems).each_slice(200) do |g|
|
49
|
+
specs += JSON.load open("http://bundler.rubygems.org/api/v1/dependencies.json?gems=#{g.join(',')}")
|
50
|
+
end
|
51
|
+
downloaded_gems.merge(gems)
|
52
|
+
|
53
|
+
gems.merge(specs.flat_map { |s| s['dependencies'].map(&:first) })
|
54
|
+
|
55
|
+
break if gems.size == size
|
56
|
+
end
|
57
|
+
|
58
|
+
specs.reject! { |s| s['platform'] != 'ruby' }
|
59
|
+
specs.uniq! { |s| [s['name'], s['number']] }
|
60
|
+
specs.sort_by! { |s| s['name'].downcase }
|
61
|
+
specs = specs.group_by { |s| s['name'] }.values.map do |spec|
|
62
|
+
[spec.first['name'], spec.flat_map do |s|
|
63
|
+
{
|
64
|
+
'name' => s['name'],
|
65
|
+
'version' => coerce_to_semver(s['number']),
|
66
|
+
'dependencies' => coerce_dependencies_to_semver(Hash[s['dependencies']])
|
67
|
+
}
|
68
|
+
end.uniq { |s| s['version'] }.sort_by { |s| Gem::Version.new(s['version']) }
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
specs = Hash[specs]
|
73
|
+
|
74
|
+
json = JSON.pretty_generate(specs)
|
75
|
+
|
76
|
+
File.open('index/rubygems.json', 'w') { |f| f.write json }
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: molinillo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel E. Giddins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description:
|
@@ -45,6 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- lib/molinillo.rb
|
48
51
|
- lib/molinillo/dependency_graph.rb
|
49
52
|
- lib/molinillo/errors.rb
|
50
53
|
- lib/molinillo/gem_metadata.rb
|
@@ -53,15 +56,13 @@ files:
|
|
53
56
|
- lib/molinillo/resolution.rb
|
54
57
|
- lib/molinillo/resolver.rb
|
55
58
|
- lib/molinillo/state.rb
|
56
|
-
- lib/molinillo.rb
|
57
|
-
- README.md
|
58
|
-
- LICENSE
|
59
59
|
- spec/dependency_graph_spec.rb
|
60
|
+
- spec/resolver_integration_specs/index_from_rubygems.rb
|
60
61
|
- spec/resolver_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
61
63
|
- spec/spec_helper/index.rb
|
62
64
|
- spec/spec_helper/specification.rb
|
63
65
|
- spec/spec_helper/ui.rb
|
64
|
-
- spec/spec_helper.rb
|
65
66
|
- spec/state_spec.rb
|
66
67
|
homepage: https://github.com/CocoaPods/Molinillo
|
67
68
|
licenses:
|
@@ -73,22 +74,23 @@ require_paths:
|
|
73
74
|
- lib
|
74
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
76
|
requirements:
|
76
|
-
- -
|
77
|
+
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
|
-
- -
|
82
|
+
- - ">="
|
82
83
|
- !ruby/object:Gem::Version
|
83
84
|
version: '0'
|
84
85
|
requirements: []
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.4.5
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: Provides support for dependency resolution
|
90
91
|
test_files:
|
91
92
|
- spec/dependency_graph_spec.rb
|
93
|
+
- spec/resolver_integration_specs/index_from_rubygems.rb
|
92
94
|
- spec/resolver_spec.rb
|
93
95
|
- spec/spec_helper/index.rb
|
94
96
|
- spec/spec_helper/specification.rb
|