rake-version 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -6
- data/LICENSE.txt +1 -1
- data/README.md +83 -9
- data/VERSION +1 -1
- data/lib/rake-version.rb +1 -4
- data/lib/rake-version/config.rb +1 -2
- data/lib/rake-version/context.rb +3 -14
- data/lib/rake-version/copier.rb +4 -18
- data/lib/rake-version/manager.rb +3 -3
- data/lib/rake-version/tasks.rb +36 -7
- data/lib/rake-version/version.rb +8 -9
- metadata +11 -39
- data/.document +0 -5
- data/.rspec +0 -2
- data/.rvmrc +0 -41
- data/.screenrc +0 -5
- data/.travis.yml +0 -5
- data/Gemfile.lock +0 -51
- data/Rakefile +0 -58
- data/rake-version.gemspec +0 -89
- data/spec/config_spec.rb +0 -68
- data/spec/context_spec.rb +0 -48
- data/spec/copier_spec.rb +0 -185
- data/spec/helper.rb +0 -21
- data/spec/manager_spec.rb +0 -117
- data/spec/tasks_spec.rb +0 -57
- data/spec/version_spec.rb +0 -73
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,92 @@
|
|
1
1
|
# rake-version
|
2
2
|
|
3
|
-
**
|
3
|
+
**Simple rake tasks for version management.**
|
4
4
|
|
5
|
-
|
5
|
+
[](http://badge.fury.io/rb/rake-version)
|
6
|
+
[](https://gemnasium.com/AlphaHydrae/rake-version)
|
7
|
+
[](http://travis-ci.org/AlphaHydrae/rake-version)
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
**rake-version** helps you manage your `VERSION` file according to the rules of [semantic versioning](http://semver.org).
|
10
|
+
It does nothing more.
|
11
|
+
It does not create tags; it does not commit; it does not push; it does not release.
|
9
12
|
|
10
|
-
##
|
13
|
+
## Installation
|
11
14
|
|
12
|
-
|
15
|
+
Add to your Gemfile and `bundle install`:
|
13
16
|
|
14
|
-
|
17
|
+
```rb
|
18
|
+
gem "rake-version", "~> 0.0"
|
19
|
+
```
|
15
20
|
|
16
|
-
|
21
|
+
Add the tasks to your Rakefile:
|
17
22
|
|
18
|
-
|
23
|
+
```rb
|
24
|
+
require 'rake-version'
|
25
|
+
RakeVersion::Tasks.new
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
```bash
|
31
|
+
# show current version
|
32
|
+
rake version #=> 1.0.0
|
33
|
+
|
34
|
+
# bump version
|
35
|
+
rake version:bump:patch #=> 1.0.1
|
36
|
+
rake version:bump:minor #=> 1.1.0
|
37
|
+
rake version:bump:major #=> 2.0.0
|
38
|
+
|
39
|
+
# set version
|
40
|
+
rake "version:set[1.2.3]" #=> 1.2.3
|
41
|
+
```
|
42
|
+
|
43
|
+
### Auto-update other files
|
44
|
+
|
45
|
+
When you add the rake version tasks in your Rakefile, you may specify additional files to update with the new version.
|
46
|
+
|
47
|
+
```rb
|
48
|
+
require 'rake-version'
|
49
|
+
RakeVersion::Tasks.new do |v|
|
50
|
+
v.copy 'lib/my-gem.rb' # update single file
|
51
|
+
v.copy 'lib/a.rb', 'lib/b.rb' # update multiple files
|
52
|
+
v.copy 'lib/*.rb' # update all files matching a glob pattern
|
53
|
+
v.copy /lib/ # update all files whose path matches a regexp
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
By default, **rake-version** will replace the first occurrence of a semantic version pattern (`number.number.number(-prerelease)(+build)`) with the new version.
|
58
|
+
It will not modify the prerelease version or build metadata.
|
59
|
+
For example, when bumping the minor version from 1.0.0, it will change the contents of this file:
|
60
|
+
|
61
|
+
```rb
|
62
|
+
class Thing
|
63
|
+
VERSION = '1.0.0'
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
To this:
|
68
|
+
|
69
|
+
```rb
|
70
|
+
class Thing
|
71
|
+
VERSION = '1.1.0'
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
You can customize this behavior as follows:
|
76
|
+
|
77
|
+
```rb
|
78
|
+
RakeVersion::Tasks.new do |v|
|
79
|
+
v.copy 'lib/my-gem.rb', all: true # replace all occurrences
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
### Semantic versioning
|
84
|
+
|
85
|
+
**rake-version** partially supports [semantic versioning v2.0.0](http://semver.org/spec/v2.0.0.html).
|
86
|
+
You can add prerelease (e.g. `-beta`) and build (e.g. `+20131313`) information to your versions,
|
87
|
+
but there are currently no tasks to update them other than `version:set`.
|
88
|
+
|
89
|
+
## Meta
|
90
|
+
|
91
|
+
* **Author:** Simon Oulevay (Alpha Hydrae)
|
92
|
+
* **License:** MIT (see [LICENSE.txt](https://raw.github.com/AlphaHydrae/rake-version/master/LICENSE.txt))
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/rake-version.rb
CHANGED
@@ -7,6 +7,7 @@ module RakeVersion
|
|
7
7
|
class Error < StandardError; end
|
8
8
|
class BadVersionString < Error; end
|
9
9
|
class MissingContext < Error; end
|
10
|
+
class MissingVersionFile < Error; end
|
10
11
|
class BadArgument < Error; end
|
11
12
|
class BadContext < BadArgument; end
|
12
13
|
class BadVersion < BadArgument; end
|
@@ -14,10 +15,6 @@ module RakeVersion
|
|
14
15
|
class BadFilePattern < BadArgument; end
|
15
16
|
class BadVersionPattern < BadArgument; end
|
16
17
|
|
17
|
-
def self.check_context o
|
18
|
-
self.check_type o, RakeVersion::Context, BadContext
|
19
|
-
end
|
20
|
-
|
21
18
|
def self.check_version o
|
22
19
|
self.check_type o, RakeVersion::Version, BadVersion
|
23
20
|
end
|
data/lib/rake-version/config.rb
CHANGED
data/lib/rake-version/context.rb
CHANGED
@@ -2,21 +2,10 @@
|
|
2
2
|
module RakeVersion
|
3
3
|
|
4
4
|
class Context
|
5
|
+
attr_reader :root
|
5
6
|
|
6
|
-
def initialize
|
7
|
-
@
|
8
|
-
end
|
9
|
-
|
10
|
-
def root
|
11
|
-
File.expand_path @task.application.original_dir
|
12
|
-
end
|
13
|
-
|
14
|
-
def read file
|
15
|
-
File.open(file, 'r').read
|
16
|
-
end
|
17
|
-
|
18
|
-
def write file, contents
|
19
|
-
File.open(file, 'w'){ |f| f.write contents }
|
7
|
+
def initialize root
|
8
|
+
@root = root
|
20
9
|
end
|
21
10
|
end
|
22
11
|
end
|
data/lib/rake-version/copier.rb
CHANGED
@@ -5,11 +5,11 @@ module RakeVersion
|
|
5
5
|
class Copier
|
6
6
|
|
7
7
|
def initialize *args
|
8
|
-
|
8
|
+
options = args.last.kind_of?(Hash) ? args.pop : {}
|
9
9
|
|
10
10
|
@file_patterns = args.collect{ |arg| check_file_pattern arg }
|
11
|
-
@version_pattern =
|
12
|
-
@replace_all = !!
|
11
|
+
@version_pattern = Version::REGEXP
|
12
|
+
@replace_all = !!options[:all]
|
13
13
|
end
|
14
14
|
|
15
15
|
def copy version, context
|
@@ -18,14 +18,6 @@ module RakeVersion
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
def option sym
|
22
|
-
if @options.key? sym
|
23
|
-
@options[sym]
|
24
|
-
elsif @options.key? sym.to_s
|
25
|
-
@options[sym.to_s]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
21
|
def check_file_pattern pattern
|
30
22
|
unless [ String, Regexp ].any?{ |klass| pattern.kind_of? klass }
|
31
23
|
raise BadFilePattern, "Expected file pattern to be a glob string or regexp, got #{pattern.class.name}."
|
@@ -33,18 +25,12 @@ module RakeVersion
|
|
33
25
|
pattern
|
34
26
|
end
|
35
27
|
|
36
|
-
def check_version_pattern pattern
|
37
|
-
unless pattern.nil? or pattern.kind_of? Regexp
|
38
|
-
raise BadVersionPattern, "Expected version option to be a regexp, got #{pattern.class.name}."
|
39
|
-
end
|
40
|
-
pattern
|
41
|
-
end
|
42
|
-
|
43
28
|
def copy_version file, version
|
44
29
|
File.open(file, 'r+') do |f|
|
45
30
|
contents = f.read
|
46
31
|
return unless match? contents
|
47
32
|
f.rewind
|
33
|
+
f.truncate 0
|
48
34
|
f.write process(contents, version)
|
49
35
|
end
|
50
36
|
end
|
data/lib/rake-version/manager.rb
CHANGED
@@ -28,7 +28,6 @@ module RakeVersion
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def with_context context, &block
|
31
|
-
RakeVersion.check_context context
|
32
31
|
@context = context
|
33
32
|
yield self if block_given?
|
34
33
|
@context = nil
|
@@ -53,11 +52,12 @@ module RakeVersion
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def read_version
|
56
|
-
|
55
|
+
raise MissingVersionFile, "Version file doesn't exist: #{version_file}" unless File.exists? version_file
|
56
|
+
File.read version_file
|
57
57
|
end
|
58
58
|
|
59
59
|
def write_version version
|
60
|
-
version.tap{ |v|
|
60
|
+
version.tap{ |v| File.open(version_file, 'w'){ |f| f.write version.to_s } }
|
61
61
|
end
|
62
62
|
|
63
63
|
def version_file
|
data/lib/rake-version/tasks.rb
CHANGED
@@ -2,24 +2,29 @@
|
|
2
2
|
module RakeVersion
|
3
3
|
|
4
4
|
class Tasks < ::Rake::TaskLib
|
5
|
+
NAMES = [ 'version', 'version:bump:major', 'version:bump:minor', 'version:bump:patch', 'version:set' ]
|
6
|
+
OTHER_NAMES = [ 'version:write' ]
|
5
7
|
|
6
|
-
def initialize &block
|
8
|
+
def initialize options = {}, &block
|
7
9
|
@manager = RakeVersion::Manager.new
|
8
10
|
@config = RakeVersion::Config.new
|
9
11
|
yield @config if block_given?
|
10
12
|
@manager.config = @config
|
11
|
-
define
|
13
|
+
define options
|
12
14
|
end
|
13
15
|
|
14
|
-
def define
|
16
|
+
def define options = {}
|
17
|
+
|
18
|
+
clear_tasks options unless options[:clear] == false
|
19
|
+
|
15
20
|
desc 'Show the current version'
|
16
21
|
task :version do |t|
|
17
|
-
puts @manager.version.to_s
|
22
|
+
handle_missing_version{ puts @manager.version.to_s }
|
18
23
|
end
|
19
24
|
|
20
25
|
namespace :version do
|
21
26
|
|
22
|
-
desc 'Set the version (
|
27
|
+
desc 'Set the version (rake "version:set[1.2.3]")'
|
23
28
|
task :set, :value do |t, args|
|
24
29
|
puts @manager.set(args.value.to_s)
|
25
30
|
end
|
@@ -29,7 +34,7 @@ module RakeVersion
|
|
29
34
|
[ :major, :minor, :patch ].each do |type|
|
30
35
|
desc "Bump the #{type} version"
|
31
36
|
task type do |t|
|
32
|
-
puts @manager.bump(type).to_s
|
37
|
+
handle_missing_version{ puts @manager.bump(type).to_s }
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -44,10 +49,34 @@ module RakeVersion
|
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
52
|
+
def clear_tasks options = {}
|
53
|
+
task_names = NAMES
|
54
|
+
task_names += OTHER_NAMES unless options[:clear_strict]
|
55
|
+
task_names.each{ |task| clear task }
|
56
|
+
end
|
57
|
+
|
47
58
|
private
|
48
59
|
|
60
|
+
def handle_missing_version
|
61
|
+
return yield if Rake.application.options.trace
|
62
|
+
begin
|
63
|
+
yield
|
64
|
+
rescue MissingVersionFile => e
|
65
|
+
warn %|#{e.message}\nCreate it with:\n rake "version:set[1.0.0]"|
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def clear task
|
71
|
+
begin
|
72
|
+
Rake::Task[task].clear if Rake::Task[task]
|
73
|
+
rescue
|
74
|
+
false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
49
78
|
def context task
|
50
|
-
RakeVersion::Context.new task
|
79
|
+
RakeVersion::Context.new task.application.original_dir
|
51
80
|
end
|
52
81
|
end
|
53
82
|
end
|
data/lib/rake-version/version.rb
CHANGED
@@ -2,21 +2,20 @@
|
|
2
2
|
module RakeVersion
|
3
3
|
|
4
4
|
class Version
|
5
|
-
REGEXP =
|
5
|
+
REGEXP = /(\d+)\.(\d+)\.(\d+)(?:\-([a-z0-9\-]+(?:\.[a-z0-9\-]+)*))?(?:\+([a-z0-9\-]+(?:\.[a-z0-9\-]+)*))?/i
|
6
6
|
|
7
7
|
attr_reader :major
|
8
8
|
attr_reader :minor
|
9
9
|
attr_reader :patch
|
10
|
+
attr_reader :prerelease
|
10
11
|
attr_reader :build
|
11
|
-
attr_reader :tags
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
@major = 0
|
15
15
|
@minor = 0
|
16
16
|
@patch = 0
|
17
|
+
@prerelease = nil
|
17
18
|
@build = nil
|
18
|
-
@tags = []
|
19
|
-
# TODO: create methods to list, add and remove tags
|
20
19
|
end
|
21
20
|
|
22
21
|
def bump type
|
@@ -38,12 +37,12 @@ module RakeVersion
|
|
38
37
|
|
39
38
|
def from_s s
|
40
39
|
s.to_s.match(REGEXP).tap do |m|
|
41
|
-
raise BadVersionString, "Version '#{s}' expected to have format MAJOR.MINOR.PATCH(
|
40
|
+
raise BadVersionString, "Version '#{s}' expected to have format MAJOR.MINOR.PATCH(-PRERELEASE)(+BUILD)." if m.nil?
|
42
41
|
@major = m[1].to_i
|
43
42
|
@minor = m[2].to_i
|
44
43
|
@patch = m[3].to_i
|
45
|
-
@
|
46
|
-
@
|
44
|
+
@prerelease = m[4]
|
45
|
+
@build = m[5]
|
47
46
|
end
|
48
47
|
self
|
49
48
|
end
|
@@ -51,8 +50,8 @@ module RakeVersion
|
|
51
50
|
def to_s
|
52
51
|
String.new.tap do |s|
|
53
52
|
s << "#{@major}.#{@minor}.#{@patch}"
|
54
|
-
s << "
|
55
|
-
s <<
|
53
|
+
s << "-#{@prerelease}" if @prerelease
|
54
|
+
s << "+#{@build}" if @build
|
56
55
|
end
|
57
56
|
end
|
58
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-version
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -108,23 +108,7 @@ dependencies:
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: rdiscount
|
111
|
+
name: travis-lint
|
128
112
|
requirement: !ruby/object:Gem::Requirement
|
129
113
|
none: false
|
130
114
|
requirements:
|
@@ -140,7 +124,7 @@ dependencies:
|
|
140
124
|
- !ruby/object:Gem::Version
|
141
125
|
version: '0'
|
142
126
|
- !ruby/object:Gem::Dependency
|
143
|
-
name:
|
127
|
+
name: fakefs
|
144
128
|
requirement: !ruby/object:Gem::Requirement
|
145
129
|
none: false
|
146
130
|
requirements:
|
@@ -155,7 +139,8 @@ dependencies:
|
|
155
139
|
- - ! '>='
|
156
140
|
- !ruby/object:Gem::Version
|
157
141
|
version: '0'
|
158
|
-
description: Rake tasks
|
142
|
+
description: Rake tasks to manage your VERSION file. No repository management (tags,
|
143
|
+
committing, pushing), no release management.
|
159
144
|
email: hydrae.alpha@gmail.com
|
160
145
|
executables: []
|
161
146
|
extensions: []
|
@@ -163,16 +148,9 @@ extra_rdoc_files:
|
|
163
148
|
- LICENSE.txt
|
164
149
|
- README.md
|
165
150
|
files:
|
166
|
-
- .document
|
167
|
-
- .rspec
|
168
|
-
- .rvmrc
|
169
|
-
- .screenrc
|
170
|
-
- .travis.yml
|
171
151
|
- Gemfile
|
172
|
-
- Gemfile.lock
|
173
152
|
- LICENSE.txt
|
174
153
|
- README.md
|
175
|
-
- Rakefile
|
176
154
|
- VERSION
|
177
155
|
- lib/rake-version.rb
|
178
156
|
- lib/rake-version/config.rb
|
@@ -181,15 +159,7 @@ files:
|
|
181
159
|
- lib/rake-version/manager.rb
|
182
160
|
- lib/rake-version/tasks.rb
|
183
161
|
- lib/rake-version/version.rb
|
184
|
-
|
185
|
-
- spec/config_spec.rb
|
186
|
-
- spec/context_spec.rb
|
187
|
-
- spec/copier_spec.rb
|
188
|
-
- spec/helper.rb
|
189
|
-
- spec/manager_spec.rb
|
190
|
-
- spec/tasks_spec.rb
|
191
|
-
- spec/version_spec.rb
|
192
|
-
homepage: http://github.com/AlphaHydrae/rake-version
|
162
|
+
homepage: https://github.com/AlphaHydrae/rake-version
|
193
163
|
licenses:
|
194
164
|
- MIT
|
195
165
|
post_install_message:
|
@@ -202,6 +172,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
172
|
- - ! '>='
|
203
173
|
- !ruby/object:Gem::Version
|
204
174
|
version: '0'
|
175
|
+
segments:
|
176
|
+
- 0
|
177
|
+
hash: -419221732059248615
|
205
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
179
|
none: false
|
207
180
|
requirements:
|
@@ -213,6 +186,5 @@ rubyforge_project:
|
|
213
186
|
rubygems_version: 1.8.25
|
214
187
|
signing_key:
|
215
188
|
specification_version: 3
|
216
|
-
summary:
|
189
|
+
summary: Simple rake tasks for version management.
|
217
190
|
test_files: []
|
218
|
-
has_rdoc:
|