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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confetti (0.9.3)
4
+ confetti (0.9.4)
5
5
  mustache (~> 0.11.2)
6
6
 
7
7
  GEM
@@ -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
- fix_version(str)
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 fix_version(str)
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
@@ -1,3 +1,3 @@
1
1
  module Confetti
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 3
9
- version: 0.9.3
8
+ - 4
9
+ version: 0.9.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Lunny