naturalsorter 0.5.9 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -76,7 +76,7 @@ because '~>1.1' doesn't fit anymore the newest version.
76
76
 
77
77
  You should add this line to your Gemfile
78
78
 
79
- `gem 'naturalsorter', '0.5.9'`
79
+ `gem 'naturalsorter', '0.5.10'`
80
80
 
81
81
  and run this command in your app root directory
82
82
 
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "0.5.9"
2
+ VERSION = "0.5.10"
3
3
  end
data/lib/versioncmp.rb CHANGED
@@ -26,20 +26,30 @@
26
26
  class Versioncmp
27
27
 
28
28
  # 'Natural version order' comparison of two version strings
29
- def self.compare(a, b)
29
+ def self.compare(a_val, b_val)
30
30
 
31
- if (!a.nil? || a.eql?("") ) && b.nil?
31
+ if (!a_val.nil? || a_val.eql?("") ) && b_val.nil?
32
32
  return 1
33
33
  end
34
34
 
35
- if (!b.nil? || b.eql?("")) && a.nil?
35
+ if (!b_val.nil? || b_val.eql?("")) && a_val.nil?
36
36
  return -1
37
37
  end
38
38
 
39
- if a.nil? && b.nil?
39
+ if a_val.nil? && b_val.nil?
40
40
  return -1
41
41
  end
42
42
 
43
+ a = String.new(a_val)
44
+ if a_val.match(/\.x-dev$/)
45
+ a = a_val.gsub("x-dev", "9999999")
46
+ end
47
+
48
+ b = String.new(b_val)
49
+ if b_val.match(/\.x-dev$/)
50
+ b = b_val.gsub("x-dev", "9999999")
51
+ end
52
+
43
53
  offset1 = 0;
44
54
  offset2 = 0;
45
55
 
@@ -5,6 +5,10 @@ describe Versioncmp do
5
5
  it "smaler" do
6
6
  Versioncmp.compare("1.1", "1.2").should eql(-1)
7
7
  end
8
+
9
+ it "smaler" do
10
+ Versioncmp.compare("1.1.5", "1.1.x-dev").should eql(-1)
11
+ end
8
12
 
9
13
  it "bigger" do
10
14
  Versioncmp.compare("1.1", "1.0").should eql(1)
metadata CHANGED
@@ -1,46 +1,40 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: naturalsorter
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 5
8
- - 9
9
- version: 0.5.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.10
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - reiz
13
9
  - versioneye
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2012-10-04 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2012-10-21 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
26
20
  - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 6
31
- version: "2.6"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.6'
32
23
  type: :development
33
- version_requirements: *id001
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '2.6'
34
31
  description: This GEM is sorting Arrays in a natural order. a2 < a10
35
- email:
32
+ email:
36
33
  - robert.reiz@gmx.com
37
34
  executables: []
38
-
39
35
  extensions: []
40
-
41
36
  extra_rdoc_files: []
42
-
43
- files:
37
+ files:
44
38
  - .gitignore
45
39
  - Gemfile
46
40
  - README.markdown
@@ -54,37 +48,31 @@ files:
54
48
  - spec/naturalsorter_spec.rb
55
49
  - spec/release_recognizer_spec.rb
56
50
  - spec/versioncmp_spec.rb
57
- has_rdoc: true
58
51
  homepage: https://github.com/versioneye/naturalsorter
59
52
  licenses: []
60
-
61
53
  post_install_message:
62
54
  rdoc_options: []
63
-
64
- require_paths:
55
+ require_paths:
65
56
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- segments:
71
- - 0
72
- version: "0"
73
- required_rubygems_version: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- segments:
78
- - 0
79
- version: "0"
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
80
69
  requirements: []
81
-
82
70
  rubyforge_project: naturalsorter
83
- rubygems_version: 1.3.6
71
+ rubygems_version: 1.8.24
84
72
  signing_key:
85
73
  specification_version: 3
86
74
  summary: Sorting arrays in natural order
87
- test_files:
75
+ test_files:
88
76
  - spec/naturalsorter_spec.rb
89
77
  - spec/release_recognizer_spec.rb
90
78
  - spec/versioncmp_spec.rb