-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_3356.diff
62 lines (55 loc) · 2.69 KB
/
fix_3356.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 67f84002e6346b0b8b9c9b84b14ab883b9e2c336 Mon Sep 17 00:00:00 2001
From: = <=>
Date: Fri, 9 Oct 2009 16:19:07 +0200
Subject: [PATCH] Fix
---
railties/lib/rails/gem_dependency.rb | 5 +++--
railties/lib/rails/vendor_gem_source_index.rb | 4 ++--
railties/test/gem_dependency_test.rb | 6 ++++++
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb
index 06d830b..38dcaa6 100644
--- a/railties/lib/rails/gem_dependency.rb
+++ b/railties/lib/rails/gem_dependency.rb
@@ -31,8 +31,9 @@ module Rails
def self.from_directory_name(directory_name, load_spec=true)
directory_name_parts = File.basename(directory_name).split('-')
- name = directory_name_parts[0..-2].join('-')
- version = directory_name_parts.last
+ version = directory_name_parts.find {|part| part =~ /\d+.+/}
+ name_boundary = directory_name_parts.find_index(version).to_i - 1
+ name = directory_name_parts[0..name_boundary].join('-')
result = self.new(name, :version => version)
spec_filename = File.join(directory_name, '.specification')
if load_spec
diff --git a/railties/lib/rails/vendor_gem_source_index.rb b/railties/lib/rails/vendor_gem_source_index.rb
index 5b7721f..3a4f29e 100644
--- a/railties/lib/rails/vendor_gem_source_index.rb
+++ b/railties/lib/rails/vendor_gem_source_index.rb
@@ -101,8 +101,8 @@ module Rails
end
def version_for_dir(d)
- matches = /-([^-]+)$/.match(d)
- Gem::Version.new(matches[1]) if matches
+ version = d.split('-').find {|part| part =~ /\d+.+/}
+ Gem::Version.new(version) if version
end
def load_specification(gem_dir)
diff --git a/railties/test/gem_dependency_test.rb b/railties/test/gem_dependency_test.rb
index 92132be..42ae270 100644
--- a/railties/test/gem_dependency_test.rb
+++ b/railties/test/gem_dependency_test.rb
@@ -176,6 +176,12 @@ class GemDependencyTest < Test::Unit::TestCase
dummy_gem = Rails::GemDependency.from_directory_name('dummy-gem-1.1', false)
assert_equal 'dummy-gem', dummy_gem.name
assert_equal '= 1.1', dummy_gem.version_requirements.to_s
+ dummy_java_gem = Rails::GemDependency.from_directory_name('dummy-gem-2.2-java', false)
+ assert_equal 'dummy-gem', dummy_java_gem.name
+ assert_equal '= 2.2', dummy_java_gem.version_requirements.to_s
+ dummy_complex_gem = Rails::GemDependency.from_directory_name('dummy-gem-3.3.3-universal-java', false)
+ assert_equal 'dummy-gem', dummy_complex_gem.name
+ assert_equal '= 3.3.3', dummy_complex_gem.version_requirements.to_s
end
def test_gem_from_directory_name_loads_specification_successfully
--
1.6.0.4