rake-extensions 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rake-extensions.rb +26 -63
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a1f693eef67e1e885c2ed765e2d27c4e56ae8f0
|
4
|
+
data.tar.gz: f91a5824513b7175561eeb57ac0433a8c5d34ce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fef45ab9426e94b4f3af675c94029ee9efa37be8f7dc4af6badf2e62dafea76b94a349ef62f94ce842727342d04ff5994962ea7d4eec9d11568fbf7991e6dd54
|
7
|
+
data.tar.gz: d4027c9ceff62b3db0e5b943cb530d536d0377977a426e6785f6f88b3895d97a2febea9fe1380ac90a7673c6f7089156a92477ae72a90ecd0d0c2c6b417b538a
|
data/lib/rake-extensions.rb
CHANGED
@@ -67,7 +67,19 @@ class Versioner
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
def current_version_with_regex(filelist, r)
|
71
|
+
current_version = nil
|
72
|
+
FileUtils.cd @version_dir, :verbose => false do
|
73
|
+
filelist.each do |file|
|
74
|
+
text = File.read(file)
|
75
|
+
if match = text.match(r)
|
76
|
+
current_version = match.captures[1]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
current_version
|
81
|
+
end
|
82
|
+
class Versioner
|
71
83
|
def initialize(version_dir)
|
72
84
|
@version_dir = version_dir
|
73
85
|
end
|
@@ -76,60 +88,32 @@ class TomlVersioner
|
|
76
88
|
v = Version.new(current_version)
|
77
89
|
v.send(jump)
|
78
90
|
end
|
79
|
-
def get_current_version()
|
80
|
-
current_version = nil
|
81
|
-
FileUtils.cd @version_dir, :verbose => false do
|
82
|
-
['Cargo.toml'].each do |file|
|
83
|
-
text = File.read(file)
|
84
|
-
if match = text.match(/^version\s=\s\"(.*)\"/i)
|
85
|
-
current_version = match.captures[0]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
current_version
|
90
|
-
end
|
91
91
|
def increment_version(jump)
|
92
92
|
next_version = get_next_version(jump)
|
93
93
|
puts "increment version from #{get_current_version} ==> #{next_version}"
|
94
94
|
update_version(next_version)
|
95
95
|
end
|
96
|
+
end
|
97
|
+
class TomlVersioner < Versioner
|
98
|
+
VERSION_REGEX = /^(version\s=\s['\"])(\d+\.\d+\.\d+)(['\"])/i
|
99
|
+
def get_current_version()
|
100
|
+
current_version_with_regex(['Cargo.toml'], VERSION_REGEX)
|
101
|
+
end
|
96
102
|
def update_version(new_version)
|
97
103
|
FileUtils.cd @version_dir, :verbose => false do
|
98
104
|
['Cargo.toml'].each do |file|
|
99
105
|
text = File.read(file)
|
100
|
-
new_contents = text.gsub(
|
106
|
+
new_contents = text.gsub(VERSION_REGEX, "\\1#{new_version}\\3")
|
101
107
|
File.open(file, "w") { |f| f.puts new_contents }
|
102
108
|
end
|
103
109
|
end
|
104
110
|
end
|
105
111
|
end
|
106
|
-
class GemspecVersioner
|
112
|
+
class GemspecVersioner < Versioner
|
107
113
|
VERSION_REGEX = /^(\s*.*?\.version\s*?=\s*['\"])(.*)(['\"])/i
|
108
114
|
DATE_REGEX = /^(\s*.*?\.date\s*?=\s*['\"])(.*)(['\"])/
|
109
|
-
def initialize(version_dir)
|
110
|
-
@version_dir = version_dir
|
111
|
-
end
|
112
|
-
def get_next_version(jump)
|
113
|
-
current_version = get_current_version()
|
114
|
-
v = Version.new(current_version)
|
115
|
-
v.send(jump)
|
116
|
-
end
|
117
115
|
def get_current_version()
|
118
|
-
|
119
|
-
FileUtils.cd @version_dir, :verbose => false do
|
120
|
-
FileList['*.gemspec'].each do |file|
|
121
|
-
text = File.read(file)
|
122
|
-
if match = text.match(VERSION_REGEX)
|
123
|
-
current_version = match.captures[1]
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
current_version
|
128
|
-
end
|
129
|
-
def increment_version(jump)
|
130
|
-
next_version = get_next_version(jump)
|
131
|
-
puts "increment version from #{get_current_version} ==> #{next_version}"
|
132
|
-
update_version(next_version)
|
116
|
+
current_version_with_regex(FileList['*.gemspec'], VERSION_REGEX)
|
133
117
|
end
|
134
118
|
def update_version(new_version)
|
135
119
|
FileUtils.cd @version_dir, :verbose => false do
|
@@ -143,37 +127,16 @@ class GemspecVersioner
|
|
143
127
|
end
|
144
128
|
end
|
145
129
|
end
|
146
|
-
class JsonVersioner
|
147
|
-
|
148
|
-
@version_dir = version_dir
|
149
|
-
end
|
150
|
-
def get_next_version(jump)
|
151
|
-
current_version = get_current_version()
|
152
|
-
v = Version.new(current_version)
|
153
|
-
v.send(jump)
|
154
|
-
end
|
130
|
+
class JsonVersioner < Versioner
|
131
|
+
VERSION_REGEX = /^(\s\s['\"]version['\"]:\s['\"])(.*)(['\"])/i
|
155
132
|
def get_current_version()
|
156
|
-
|
157
|
-
FileUtils.cd @version_dir, :verbose => false do
|
158
|
-
['package.json'].each do |file|
|
159
|
-
text = File.read(file)
|
160
|
-
if match = text.match(/^\s\s\"version\":\s\"(.*)\"/i)
|
161
|
-
current_version = match.captures[0]
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
current_version
|
166
|
-
end
|
167
|
-
def increment_version(jump)
|
168
|
-
next_version = get_next_version(jump)
|
169
|
-
puts "increment version from #{get_current_version} ==> #{next_version}"
|
170
|
-
update_version(next_version)
|
133
|
+
current_version_with_regex(['package.json'], VERSION_REGEX)
|
171
134
|
end
|
172
135
|
def update_version(new_version)
|
173
136
|
FileUtils.cd @version_dir, :verbose => false do
|
174
137
|
['package.json'].each do |file|
|
175
138
|
text = File.read(file)
|
176
|
-
new_contents = text.gsub(
|
139
|
+
new_contents = text.gsub(VERSION_REGEX, "\\1#{new_version}\\3")
|
177
140
|
File.open(file, "w") { |f| f.puts new_contents }
|
178
141
|
end
|
179
142
|
end
|