confetti 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -12,14 +12,16 @@ module Confetti
|
|
12
12
|
elsif str.match /^(\d)+[.](\d)+[.](\d)+$/
|
13
13
|
str
|
14
14
|
elsif str.match /^((\d)+[.])*(\d)+$/
|
15
|
-
|
15
|
+
extend_version(str)
|
16
|
+
elsif str.match /^([\d\w]+)[.]([\d\w]+)[.]([\d\w]+)$/
|
17
|
+
deletter_version(str)
|
16
18
|
else
|
17
19
|
raise VersionError, "need a valid version number of the form 0.0.0"
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
22
|
-
def
|
24
|
+
def extend_version(str)
|
23
25
|
segments = str.split('.')
|
24
26
|
|
25
27
|
segments << '0' if segments.length == 1
|
@@ -27,6 +29,22 @@ module Confetti
|
|
27
29
|
|
28
30
|
segments[0,3].join '.'
|
29
31
|
end
|
32
|
+
|
33
|
+
def deletter_version(str)
|
34
|
+
segments = str.split('.')
|
35
|
+
new_parts = []
|
36
|
+
|
37
|
+
segments.each do |seg|
|
38
|
+
unless /\d+/ =~ seg
|
39
|
+
seg.gsub!(/\w/, '')
|
40
|
+
seg = '0' if seg.length == 0
|
41
|
+
end
|
42
|
+
|
43
|
+
new_parts << seg
|
44
|
+
end
|
45
|
+
|
46
|
+
new_parts.join '.'
|
47
|
+
end
|
30
48
|
end
|
31
49
|
end
|
32
50
|
end
|
data/lib/confetti/version.rb
CHANGED
@@ -31,5 +31,9 @@ describe Confetti::Template::VersionHelper do
|
|
31
31
|
it "should truncate extra digits if string has too many segments" do
|
32
32
|
normalize_version('1.2.3.4.5').should == "1.2.3"
|
33
33
|
end
|
34
|
+
|
35
|
+
it "should switch letters out for numbers" do
|
36
|
+
normalize_version('1.3.a').should == "1.3.0"
|
37
|
+
end
|
34
38
|
end
|
35
39
|
end
|
@@ -158,6 +158,11 @@ describe Confetti::Template::WindowsPhone7Manifest do
|
|
158
158
|
@config.version_string = "2012.05.20"
|
159
159
|
@template.version.should == "2012.0.2.0"
|
160
160
|
end
|
161
|
+
|
162
|
+
it "should ensure letters are converted to numbers" do
|
163
|
+
@config.version_string = "1.3.a"
|
164
|
+
@template.version.should == "1.3.0.0"
|
165
|
+
end
|
161
166
|
end
|
162
167
|
|
163
168
|
describe "author" do
|