drg 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/lib/drg/tasks/active_pinner.rb +12 -2
- data/lib/drg/tasks/gemfile_line.rb +34 -13
- data/lib/drg/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: 5d977148d147d5723ae15052033d4dcb47c8b61f
|
4
|
+
data.tar.gz: e2cab2591d53736ebd56955b776f1d93ed473c36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b4aabe2fb664f1c7a7c32c15685c5337da7384a3f1b26cf9c77e487378f47733dee129e03c3ee2840a2f07c668a150583afa88cfeb15c1a505c1bf194fb6f2f
|
7
|
+
data.tar.gz: a16ef93951806031a4ddebb84c34741657e5f38cf05c907ac5457d159c1cbf392128f381c0580b1ff25834d87ff50b75a2517f0f57bd5db49da7b9bf325e3df9
|
data/.travis.yml
CHANGED
@@ -107,8 +107,18 @@ module DRG
|
|
107
107
|
# @param [Array] list of a gem version's segments
|
108
108
|
# @param [Array] other_list of another gem version's segments
|
109
109
|
def higher?(list, other_list)
|
110
|
-
|
111
|
-
|
110
|
+
higher = false
|
111
|
+
equal = false
|
112
|
+
sem_ver_size = [list.size, other_list.size].max
|
113
|
+
sem_ver_size.times do |i|
|
114
|
+
if list[i].to_i >= other_list[i].to_i
|
115
|
+
higher = true
|
116
|
+
equal = list[i].to_i == other_list[i].to_i
|
117
|
+
else
|
118
|
+
break
|
119
|
+
end
|
120
|
+
end
|
121
|
+
higher && !equal
|
112
122
|
end
|
113
123
|
end
|
114
124
|
end
|
@@ -11,7 +11,7 @@ module DRG
|
|
11
11
|
# @param [String] version is the new value for the gem (add/replace)
|
12
12
|
# @return [String] line
|
13
13
|
def update(new_version)
|
14
|
-
swap_version("
|
14
|
+
swap_version("'#{new_version.to_s}'")
|
15
15
|
end
|
16
16
|
|
17
17
|
# @return [String] line
|
@@ -19,27 +19,48 @@ module DRG
|
|
19
19
|
swap_version('')
|
20
20
|
end
|
21
21
|
|
22
|
+
# @description Replaces the gem version with the given one
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# line = "gem 'duck_puncher', '> 1', '< 2', require: false # dude"
|
26
|
+
# swap_version('1.5.5')
|
27
|
+
# line # => "gem 'duck_puncher', '1.5.5', require: false # dude"
|
28
|
+
#
|
29
|
+
# @destructive Modifies @line in place
|
30
|
+
# @param [String] full_version is the quoted version to update or remove from the gem line
|
22
31
|
# @return [String] line
|
23
32
|
def swap_version(full_version)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
code, *comments = line.split(/#/)
|
34
|
+
parts = code.split(',')
|
35
|
+
if parts.size == 1
|
36
|
+
parts[0].chomp!
|
37
|
+
parts << " #{full_version}" unless full_version.empty?
|
38
|
+
else
|
39
|
+
# ignore the first part, which is the gem name
|
40
|
+
parts_without_gem = parts.drop(1)
|
41
|
+
# reject options hash
|
42
|
+
version_parts = parts_without_gem.reject { |x| x.include?(':') }
|
43
|
+
# remove all but the first version part from the original parts array
|
44
|
+
version_parts.drop(1).each { |version_part| parts.delete(version_part) }
|
45
|
+
# find the index of it
|
46
|
+
if index = parts.index(version_parts.first)
|
47
|
+
# replace the current gem version (inside quotes)
|
48
|
+
parts[index].sub! /['"].+['"]/, full_version
|
49
|
+
# remove white spaces from this item if we're removing the version
|
50
|
+
parts[index].strip! if full_version.empty?
|
30
51
|
else
|
31
|
-
|
32
|
-
line[/\n/] = "#{comment}\n"
|
52
|
+
parts.insert 1, " #{full_version}"
|
33
53
|
end
|
34
|
-
|
35
|
-
line.sub!("\n", "#{full_version}#{comment}\n")
|
36
|
-
else
|
37
|
-
line << full_version << comment << "\n"
|
54
|
+
parts.reject!(&:empty?)
|
38
55
|
end
|
56
|
+
line.replace parts.join(',')
|
57
|
+
line << "#" << comments.join if comments.any?
|
58
|
+
line << "\n" unless line.end_with?("\n")
|
39
59
|
line
|
40
60
|
end
|
41
61
|
|
42
62
|
# @note not used
|
63
|
+
# @deprecated
|
43
64
|
def version
|
44
65
|
line[/, (.+)\n?/, 1]
|
45
66
|
end
|
data/lib/drg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|