naturalsorter 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/lib/versioncmp.rb CHANGED
@@ -58,6 +58,14 @@ class Versioncmp
58
58
  return result if (result != 0)
59
59
  next
60
60
  else
61
+ # --- START ---- special case for awesome jquery shitty verison numbers
62
+ if ( part1.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part2.match(/^[0-9]+$/) != nil )
63
+ return -1
64
+ end
65
+ if ( part2.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part1.match(/^[0-9]+$/) != nil )
66
+ return 1
67
+ end
68
+ # --- END ---- special case for awesome jquery shitty verison numbers
61
69
  return 1 if (part1.match(/^[0-9]+$/) != nil && part2.match(/^[0-9]+$/) == nil)
62
70
  return -1;
63
71
  end
@@ -145,8 +153,8 @@ class Versioncmp
145
153
  for z in 0..100
146
154
  offsetz = offset + z
147
155
  break if offsetz > cake.length()
148
- p = cake[offset..offset + z]
149
- if ( p.match(/^[0-9]+$/) == nil )
156
+ p = cake[ offset..offset + z ]
157
+ if ( p.match(/^\w+\.$/) != nil )
150
158
  break
151
159
  end
152
160
  end
@@ -90,4 +90,8 @@ describe Versioncmp do
90
90
  Versioncmp.compare("1.1", "20040121.140929").should eql(1)
91
91
  end
92
92
 
93
+ it "1.7b2 is smaller than 1.7" do
94
+ Versioncmp.compare("1.7b2", "1.7").should eql(-1)
95
+ end
96
+
93
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naturalsorter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-06 00:00:00.000000000Z
12
+ date: 2012-04-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70217385346580 !ruby/object:Gem::Requirement
16
+ requirement: &70294219997440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '2.6'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70217385346580
24
+ version_requirements: *70294219997440
25
25
  description: This GEM is sorting Arrays in a natural order. a2 < a10
26
26
  email:
27
27
  - robert.reiz@gmx.com