ruby_version_sorter 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60241d50bce547b299cf5b13eb0ed7a90259f0f0
4
- data.tar.gz: 3cd6e621bbf1f73371506471f99d0fb9d0d39779
3
+ metadata.gz: 616893b86065239d620e68cfa00a0a14028c23db
4
+ data.tar.gz: 175366fc521df0b3c7ffe6c6cda2b59015dbfb4d
5
5
  SHA512:
6
- metadata.gz: df5fda3ae8ff03a6b29185aa94e6eb4267b110905b773c969dd8d0436cb6e5591eeb1c4b8d1527bce22d139734f312c87df4b3a0e1e323ec10e22dd31b569565
7
- data.tar.gz: ad9978d24bc417735ba31b090e6b7933343c352e9e1258056584f53d117a07c9c50a00a6e79175d8712a8143a1fe6ba6fdaa2e15e8fca1debfab52d95ac0ad52
6
+ metadata.gz: b3e4839aed9dc19f2c3be1418dbfa63512ec4d6551f4423901461071d6c48a993e3521c3f9384dbc8bf02fbe9aa4473c016cab830e174a8650aff1ff1c2f3896
7
+ data.tar.gz: 1eb48176bd3fbe470707032c34a5a3f3fc6cd0fb44cf60a3cc09f43912204aee13d81800074df616a90803b0f7e6877290b22e0766981500515e6cffa7375d2e
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.1
6
+
7
+ 2016.08.12
8
+
9
+ Simplify the implementation.
10
+
5
11
  ## 1.0.0
6
12
 
7
13
  2016.08.10.
@@ -2,66 +2,6 @@ require "ruby_version_sorter/version"
2
2
 
3
3
  class RubyVersionSorter
4
4
  def self.sort(versions)
5
- new(versions).send :move_prereleases
5
+ versions.sort
6
6
  end
7
-
8
- def initialize(versions)
9
- pre_releases, @non_pre_releases = versions.sort.partition { |v| v =~ PRERELEASE_REGEXP }
10
- @pre_release_groups = pre_releases.group_by { |v| node_identifier(v) }
11
- end
12
-
13
- private
14
-
15
- PRERELEASE_REGEXP = /((preview|rc|RC|pre|b)\d{1})/
16
- IDENTIFIER_REGEXP = /([\d+\.])*/
17
-
18
- private_constant :PRERELEASE_REGEXP, :IDENTIFIER_REGEXP
19
-
20
- attr_reader :versions, :non_pre_releases, :pre_release_groups
21
-
22
- def move_prereleases
23
- pre_release_groups.each_with_index do |(version_lead, versions), index|
24
- node_index = version_nodes.index { |node| node[0] == version_lead }
25
-
26
- insert_index = get_insert_index(node_index)
27
-
28
- non_pre_releases.insert(insert_index, *versions)
29
-
30
- version_nodes(true) if !(index == pre_release_group_length - 1)
31
- end
32
-
33
- non_pre_releases
34
- end
35
-
36
- def pre_release_group_length
37
- @_pre_release_group_length ||= pre_release_groups.size
38
- end
39
-
40
- def get_insert_index(node_index)
41
- if node_index == 0
42
- 0
43
- elsif node_index == nil
44
- -1
45
- else
46
- version_nodes[node_index].last
47
- end
48
- end
49
-
50
- def node_identifier(version)
51
- version[IDENTIFIER_REGEXP]
52
- end
53
-
54
- def version_nodes(recompute = false)
55
- if recompute
56
- @_evolve_graph = compute_version_nodes
57
- else
58
- @_evolve_graph ||= compute_version_nodes
59
- end
60
- end
61
-
62
- def compute_version_nodes
63
- non_pre_releases.
64
- uniq { |version| node_identifier(version) }.
65
- map.with_index { |version, index| [node_identifier(version), index] }
66
- end
67
7
  end
@@ -1,3 +1,3 @@
1
1
  class RubyVersionSorter
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_version_sorter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JuanitoFatas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: