pompompom 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,5 +7,5 @@ require 'pompompom/resolver'
7
7
  require 'pompompom/config'
8
8
 
9
9
  module PomPomPom
10
- VERSION = '1.1.2'
10
+ VERSION = '1.1.3'
11
11
  end
@@ -27,7 +27,7 @@ module PomPomPom
27
27
  def filter_newest(pom_groups)
28
28
  pom_groups.map do |id, poms|
29
29
  if poms.size > 1
30
- newest = poms.sort { |a, b| a.version <=> b.version }.reverse.first
30
+ newest = find_newest_version(poms)
31
31
  @logger.warn(%(Warning: multiple versions of #{id} were required, using the newest required version (#{newest.version})))
32
32
  newest
33
33
  else
@@ -35,6 +35,32 @@ module PomPomPom
35
35
  end
36
36
  end.flatten
37
37
  end
38
+
39
+ def find_newest_version(poms)
40
+ sorted = poms.sort do |a, b|
41
+ a_version = a.version.sub(/-\w+$/, '').split('.').map(&:to_i)
42
+ b_version = b.version.sub(/-\w+$/, '').split('.').map(&:to_i)
43
+
44
+ while a_version.size < b_version.size
45
+ a_version << 0
46
+ end
47
+
48
+ while a_version.size > b_version.size
49
+ b_version << 0
50
+ end
51
+
52
+ cmp = 0
53
+
54
+ a_version.zip(b_version).each do |(an, bn)|
55
+ cmp = an <=> bn
56
+ break unless cmp == 0
57
+ end
58
+
59
+ cmp
60
+ end
61
+
62
+ sorted.reverse.first
63
+ end
38
64
 
39
65
  def group_by_artifact(poms)
40
66
  poms.inject({}) do |acc, pom|
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pompompom}
8
- s.version = "1.1.2"
8
+ s.version = "1.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Theo Hultberg"]
12
- s.date = %q{2010-08-06}
12
+ s.date = %q{2010-08-26}
13
13
  s.default_executable = %q{pompompom}
14
14
  s.description = %q{Ruby dependency manager for Maven repository artifacts}
15
15
  s.email = %q{theo@iconara.net}
@@ -63,6 +63,8 @@ Gem::Specification.new do |s|
63
63
  "spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.jar",
64
64
  "spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.pom",
65
65
  "spec/resources/repository/com/example/test-parent/1.0/test-parent-1.0.pom",
66
+ "spec/resources/repository/com/example/test/77.7/test-77.7.jar",
67
+ "spec/resources/repository/com/example/test/77.7/test-77.7.pom",
66
68
  "spec/resources/repository/com/example/test/8.8/test-8.8.jar",
67
69
  "spec/resources/repository/com/example/test/8.8/test-8.8.pom",
68
70
  "spec/resources/repository/com/example/test/9.9/test-9.9.jar",
@@ -145,7 +145,8 @@ module PomPomPom
145
145
 
146
146
  it 'selects the newest dependency if more than one of the same are found' do
147
147
  @all_dependencies = @resolver.find_transitive_dependencies(*@dependencies)
148
- @all_dependencies.map(&:to_s).should include('com.example:test:9.9')
148
+ @all_dependencies.map(&:to_s).should include('com.example:test:77.7')
149
+ @all_dependencies.map(&:to_s).should_not include('com.example:test:9.9')
149
150
  @all_dependencies.map(&:to_s).should_not include('com.example:test:8.8')
150
151
  end
151
152
 
@@ -155,7 +156,7 @@ module PomPomPom
155
156
  end
156
157
 
157
158
  it 'warns if dependencies on multiple versions of an artifact are found' do
158
- @logger.should_receive(:warn).with('Warning: multiple versions of com.example:test were required, using the newest required version (9.9)')
159
+ @logger.should_receive(:warn).with('Warning: multiple versions of com.example:test were required, using the newest required version (77.7)')
159
160
  @resolver.find_transitive_dependencies(*@dependencies)
160
161
  end
161
162
  end
@@ -13,7 +13,7 @@
13
13
  <dependency>
14
14
  <groupId>com.example</groupId>
15
15
  <artifactId>test</artifactId>
16
- <version>9.9</version>
16
+ <version>77.7</version>
17
17
  </dependency>
18
18
  </dependencies>
19
19
  </project>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0"?>
2
+ <project>
3
+ <modelVersion>4.0.0</modelVersion>
4
+ <groupId>com.example</groupId>
5
+ <artifactId>test</artifactId>
6
+ <version>77.7</version>
7
+ <packaging>jar</packaging>
8
+ <name>Test POM</name>
9
+ <description>Test POM</description>
10
+ <url>http://www.example.com</url>
11
+ </project>
@@ -6,6 +6,7 @@
6
6
  <versions>
7
7
  <version>8.8</version>
8
8
  <version>9.9</version>
9
+ <version>77.7</version>
9
10
  </versions>
10
11
  </versioning>
11
12
  </metadata>
@@ -4,6 +4,7 @@ require 'spec/rake/spectask'
4
4
 
5
5
  Spec::Rake::SpecTask.new(:spec) do |spec|
6
6
  spec.libs << 'lib' << 'spec'
7
+ spec.spec_opts << '--backtrace' << '--color'
7
8
  spec.spec_files = FileList['spec/**/*_spec.rb']
8
9
  end
9
10
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pompompom
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 2
10
- version: 1.1.2
9
+ - 3
10
+ version: 1.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Theo Hultberg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-06 00:00:00 +02:00
18
+ date: 2010-08-26 00:00:00 +02:00
19
19
  default_executable: pompompom
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -100,6 +100,8 @@ files:
100
100
  - spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.jar
101
101
  - spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.pom
102
102
  - spec/resources/repository/com/example/test-parent/1.0/test-parent-1.0.pom
103
+ - spec/resources/repository/com/example/test/77.7/test-77.7.jar
104
+ - spec/resources/repository/com/example/test/77.7/test-77.7.pom
103
105
  - spec/resources/repository/com/example/test/8.8/test-8.8.jar
104
106
  - spec/resources/repository/com/example/test/8.8/test-8.8.pom
105
107
  - spec/resources/repository/com/example/test/9.9/test-9.9.jar