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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/ruby_version_sorter.rb +1 -61
- data/lib/ruby_version_sorter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 616893b86065239d620e68cfa00a0a14028c23db
|
4
|
+
data.tar.gz: 175366fc521df0b3c7ffe6c6cda2b59015dbfb4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3e4839aed9dc19f2c3be1418dbfa63512ec4d6551f4423901461071d6c48a993e3521c3f9384dbc8bf02fbe9aa4473c016cab830e174a8650aff1ff1c2f3896
|
7
|
+
data.tar.gz: 1eb48176bd3fbe470707032c34a5a3f3fc6cd0fb44cf60a3cc09f43912204aee13d81800074df616a90803b0f7e6877290b22e0766981500515e6cffa7375d2e
|
data/CHANGELOG.md
CHANGED
data/lib/ruby_version_sorter.rb
CHANGED
@@ -2,66 +2,6 @@ require "ruby_version_sorter/version"
|
|
2
2
|
|
3
3
|
class RubyVersionSorter
|
4
4
|
def self.sort(versions)
|
5
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|