bumpz 0.5.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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +19 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +26 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/bin/bump +37 -0
- data/bump.gemspec +17 -0
- data/lib/bump.rb +193 -0
- data/lib/bump/tasks.rb +26 -0
- data/spec/bump/tasks_spec.rb +35 -0
- data/spec/bump_spec.rb +441 -0
- data/spec/spec_helper.rb +41 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 01d032eb0a781ca4e91101bf2422ea84316fe3ba
|
4
|
+
data.tar.gz: 83f30c4ee6a0d82dba7027e89b5c229483fd6f11
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a4e11b7795fc8b50d69396b9824452b4cbd3d97c743f4e1cb230b11c8a7115db1ac04db6924add057d3bd297b81b35f4fcc1365602d6b7725bf730a4d7c0b9e
|
7
|
+
data.tar.gz: d43cd09785f97222f3de9c6447bc2aa7e650170c6fd73f8c208bffe4be565292c02e5536613b1311f8544acc2e16a5adfb26d8b049c29f0743f3a9fb2a8a7186
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
rvm:
|
2
|
+
- ree
|
3
|
+
- 1.8.7
|
4
|
+
- 1.9.2
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0.0
|
7
|
+
- 2.1.0
|
8
|
+
- jruby-18mode
|
9
|
+
- jruby-19mode
|
10
|
+
- rbx-2.1.1
|
11
|
+
matrix:
|
12
|
+
allow_failures:
|
13
|
+
- rvm: 2.1.0
|
14
|
+
before_script:
|
15
|
+
- git config --global user.email "you@example.com"
|
16
|
+
- git config --global user.name "Your Name"
|
17
|
+
before_install:
|
18
|
+
- gem update --system 2.1.11
|
19
|
+
- gem --version
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bump (0.5.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rake (10.0.2)
|
11
|
+
rspec (2.11.0)
|
12
|
+
rspec-core (~> 2.11.0)
|
13
|
+
rspec-expectations (~> 2.11.0)
|
14
|
+
rspec-mocks (~> 2.11.0)
|
15
|
+
rspec-core (2.11.1)
|
16
|
+
rspec-expectations (2.11.3)
|
17
|
+
diff-lcs (~> 1.1.3)
|
18
|
+
rspec-mocks (2.11.3)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bump!
|
25
|
+
rake (~> 10.0.0)
|
26
|
+
rspec (~> 2.0)
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
[](https://travis-ci.org/gregorym/bump)
|
2
|
+
[](http://badge.fury.io/rb/bump)
|
3
|
+
|
4
|
+
# Introduction
|
5
|
+
Bump is a gem that will simplify the way you build gems and chef-cookbooks.
|
6
|
+
|
7
|
+
|
8
|
+
# Installation
|
9
|
+
|
10
|
+
gem install bump
|
11
|
+
|
12
|
+
# Usage
|
13
|
+
|
14
|
+
Current version:
|
15
|
+
|
16
|
+
bump current
|
17
|
+
|
18
|
+
Current version: 0.1.2
|
19
|
+
|
20
|
+
Bump (major, minor, patch, pre):
|
21
|
+
|
22
|
+
bump patch
|
23
|
+
|
24
|
+
Bump version 0.1.2 to 0.1.3
|
25
|
+
|
26
|
+
### Options
|
27
|
+
|
28
|
+
### --no-commit
|
29
|
+
If you don't want to make a commit after bumping, add the `--no-commit` option.
|
30
|
+
|
31
|
+
bump patch --no-commit
|
32
|
+
|
33
|
+
### --tag
|
34
|
+
Will add a git tag (if the current project is a git repository and `--no-commit` has not been given).
|
35
|
+
|
36
|
+
bump patch --tag
|
37
|
+
|
38
|
+
### --no-bundle
|
39
|
+
If you don't want to run the `bundle` command after bumping, add the `--no-bundle` option.
|
40
|
+
|
41
|
+
bump patch --no-bundle
|
42
|
+
|
43
|
+
### Rake
|
44
|
+
|
45
|
+
```Ruby
|
46
|
+
# Rakefile
|
47
|
+
require "bump/tasks"
|
48
|
+
```
|
49
|
+
|
50
|
+
rake bump:patch
|
51
|
+
rake bump:current
|
52
|
+
|
53
|
+
### Ruby
|
54
|
+
```Ruby
|
55
|
+
require "bump"
|
56
|
+
Bump::Bump.current # -> "1.2.3"
|
57
|
+
Bump::Bump.run("patch") # -> version changed
|
58
|
+
Bump::Bump.run("patch", commit: false, bundle:false, tag:false) # -> version changed with options
|
59
|
+
```
|
60
|
+
|
61
|
+
# Supported locations
|
62
|
+
- VERSION file with "1.2.3"
|
63
|
+
- gemspec with `gem.version = "1.2.3"` or `Gem:Specification.new "gem-name", "1.2.3" do`
|
64
|
+
- lib/**/version.rb file with `VERSION = "1.2.3"`
|
65
|
+
- metadata.rb with `version "1.2.3"`
|
66
|
+
|
67
|
+
# Todo
|
68
|
+
|
69
|
+
- `VERSION = "1.2.3"` in lib/*.rb
|
70
|
+
|
71
|
+
# Author
|
72
|
+
Gregory<br/>
|
73
|
+
License: MIT<br/>
|
data/Rakefile
ADDED
data/bin/bump
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
options = {}
|
5
|
+
OptionParser.new do |opts|
|
6
|
+
opts.banner = <<BANNER
|
7
|
+
Bump your gem version.
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
bump current # show current version
|
11
|
+
bump pre # increase prerelease version of your gem (1.0.0-X) [alpha, beta, rc, ]
|
12
|
+
bump patch # increase patch version of your gem (1.0.X)
|
13
|
+
bump minor # increase minor version of your gem (1.X.0)
|
14
|
+
bump major # increase major version of your gem (X.0.0)
|
15
|
+
bump set 1.2.3 # set the version number to the given value
|
16
|
+
|
17
|
+
Options:
|
18
|
+
BANNER
|
19
|
+
opts.on("--no-commit", "Do not make a commit.") { options[:commit] = false }
|
20
|
+
opts.on("--no-bundle", "Do not bundle.") { options[:bundle] = false }
|
21
|
+
opts.on("--tag", "Create git tag from version (only if commit is true).") { options[:tag] = true }
|
22
|
+
opts.on("-h", "--help","Show this.") { puts opts; exit }
|
23
|
+
end.parse!
|
24
|
+
|
25
|
+
unless (ARGV.size == 1 && ARGV.first != "set") || (ARGV.size == 2 && ARGV.first == "set")
|
26
|
+
puts "Usage instructions: bump --help"
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
|
30
|
+
if ARGV.first == "set"
|
31
|
+
options[:version] = ARGV[1]
|
32
|
+
end
|
33
|
+
|
34
|
+
require File.dirname(__FILE__) + '/../lib/bump'
|
35
|
+
output, status = Bump::Bump.run(ARGV.first, options)
|
36
|
+
puts output
|
37
|
+
exit status
|
data/bump.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new "bumpz" do |s|
|
2
|
+
s.version = "0.5.0"
|
3
|
+
s.author = "Gregory Marcilhacy"
|
4
|
+
s.email = "g.marcilhacy@gmail.com"
|
5
|
+
s.homepage = "https://github.com/treeder/bump"
|
6
|
+
s.summary = "Bump your gem version file"
|
7
|
+
|
8
|
+
s.files = `git ls-files`.split("\n")
|
9
|
+
s.license = "MIT"
|
10
|
+
s.require_path = "lib"
|
11
|
+
s.executables = ["bump"]
|
12
|
+
|
13
|
+
s.add_development_dependency 'rake', '~> 10.0.0'
|
14
|
+
s.add_development_dependency 'rspec', '~> 2.0'
|
15
|
+
end
|
16
|
+
|
17
|
+
|
data/lib/bump.rb
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Bump
|
4
|
+
class InvalidOptionError < StandardError; end
|
5
|
+
class InvalidVersionError < StandardError; end
|
6
|
+
class UnfoundVersionError < StandardError; end
|
7
|
+
class TooManyVersionFilesError < StandardError; end
|
8
|
+
class UnfoundVersionFileError < StandardError; end
|
9
|
+
|
10
|
+
class Bump
|
11
|
+
BUMPS = %w(major minor patch pre)
|
12
|
+
PRERELEASE = ["alpha","beta","rc",nil]
|
13
|
+
OPTIONS = BUMPS | ["set", "current"]
|
14
|
+
VERSION_REGEX = /(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/
|
15
|
+
|
16
|
+
def self.defaults
|
17
|
+
{
|
18
|
+
:commit => true,
|
19
|
+
:bundle => File.exist?("Gemfile"),
|
20
|
+
:tag => false
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run(bump, options={})
|
25
|
+
options = defaults.merge(options)
|
26
|
+
|
27
|
+
case bump
|
28
|
+
when *BUMPS
|
29
|
+
bump_part(bump, options)
|
30
|
+
when "set"
|
31
|
+
raise InvalidVersionError unless options[:version]
|
32
|
+
bump_set(options[:version], options)
|
33
|
+
when "current"
|
34
|
+
["Current version: #{current}", 0]
|
35
|
+
else
|
36
|
+
raise InvalidOptionError
|
37
|
+
end
|
38
|
+
rescue InvalidOptionError
|
39
|
+
["Invalid option. Choose between #{OPTIONS.join(',')}.", 1]
|
40
|
+
rescue InvalidVersionError
|
41
|
+
["Invalid version number given.", 1]
|
42
|
+
rescue UnfoundVersionError
|
43
|
+
["Unable to find your gem version", 1]
|
44
|
+
rescue UnfoundVersionFileError
|
45
|
+
["Unable to find a file with the gem version", 1]
|
46
|
+
rescue TooManyVersionFilesError
|
47
|
+
["More than one gemspec file", 1]
|
48
|
+
rescue Exception => e
|
49
|
+
["Something wrong happened: #{e.message}\n#{e.backtrace.join("\n")}", 1]
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.current
|
53
|
+
current_info.first
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def self.bump(file, current, next_version, options)
|
59
|
+
replace(file, current, next_version)
|
60
|
+
if options[:bundle] and under_version_control?("Gemfile.lock")
|
61
|
+
bundler_with_clean_env do
|
62
|
+
system("bundle")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
commit(next_version, file, options) if options[:commit]
|
66
|
+
["Bump version #{current} to #{next_version}", 0]
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.bundler_with_clean_env(&block)
|
70
|
+
if defined?(Bundler)
|
71
|
+
Bundler.with_clean_env(&block)
|
72
|
+
else
|
73
|
+
yield
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.bump_part(part, options)
|
78
|
+
current, file = current_info
|
79
|
+
next_version = next_version(current, part)
|
80
|
+
bump(file, current, next_version, options)
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.bump_set(next_version, options)
|
84
|
+
current, file = current_info
|
85
|
+
bump(file, current, next_version, options)
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.commit(version, file, options)
|
89
|
+
return unless File.directory?(".git")
|
90
|
+
system("git add --update Gemfile.lock") if options[:bundle]
|
91
|
+
system("git add --update #{file} && git commit -m 'v#{version}'")
|
92
|
+
system("git tag -a -m 'Bump to v#{version}' v#{version}") if options[:tag]
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.replace(file, old, new)
|
96
|
+
content = File.read(file)
|
97
|
+
File.open(file, "w"){|f| f.write(content.sub(old, new)) }
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.current_info
|
101
|
+
version, file = (
|
102
|
+
version_from_version ||
|
103
|
+
version_from_version_rb ||
|
104
|
+
version_from_gemspec ||
|
105
|
+
version_from_lib_rb ||
|
106
|
+
version_from_chef ||
|
107
|
+
version_from_json ||
|
108
|
+
raise(UnfoundVersionFileError)
|
109
|
+
)
|
110
|
+
raise UnfoundVersionError unless version
|
111
|
+
[version, file]
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.version_from_gemspec
|
115
|
+
return unless file = find_version_file("*.gemspec")
|
116
|
+
version = File.read(file)[/\.version\s*=\s*["']#{VERSION_REGEX}["']/, 1]
|
117
|
+
return unless version = File.read(file)[/Gem::Specification.new.+ ["']#{VERSION_REGEX}["']/, 1] if version.nil?
|
118
|
+
[version, file]
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.version_from_version_rb
|
122
|
+
return unless file = find_version_file("lib/**/version.rb")
|
123
|
+
extract_version_from_file(file)
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.version_from_version
|
127
|
+
return unless file = find_version_file("VERSION")
|
128
|
+
extract_version_from_file(file)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.version_from_lib_rb
|
132
|
+
files = Dir.glob("lib/**/*.rb")
|
133
|
+
file = files.detect do |file|
|
134
|
+
File.read(file) =~ /^\s+VERSION = ['"](#{VERSION_REGEX})['"]/i
|
135
|
+
end
|
136
|
+
[$1, file] if file
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.version_from_chef
|
140
|
+
file = find_version_file("metadata.rb")
|
141
|
+
return unless file && File.read(file) =~ /^version\s+(['"])(#{VERSION_REGEX})['"]/
|
142
|
+
[$2, file]
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.version_from_json
|
146
|
+
file = find_version_file("meta.json")
|
147
|
+
d = JSON.parse(File.read(file))
|
148
|
+
return unless d["version"]
|
149
|
+
return [d["version"], file]
|
150
|
+
[$2, file]
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.extract_version_from_file(file)
|
154
|
+
return unless version = File.read(file)[VERSION_REGEX]
|
155
|
+
[version, file]
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.find_version_file(pattern)
|
159
|
+
files = Dir.glob(pattern)
|
160
|
+
case files.size
|
161
|
+
when 0 then nil
|
162
|
+
when 1 then files.first
|
163
|
+
else
|
164
|
+
raise TooManyVersionFilesError
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.next_version(current, part)
|
169
|
+
current, prerelease = current.split('-')
|
170
|
+
major, minor, patch, *other = current.split('.')
|
171
|
+
case part
|
172
|
+
when "major"
|
173
|
+
major, minor, patch, prerelease = major.succ, 0, 0, nil
|
174
|
+
when "minor"
|
175
|
+
minor, patch, prerelease = minor.succ, 0, nil
|
176
|
+
when "patch"
|
177
|
+
patch = patch.succ
|
178
|
+
when "pre"
|
179
|
+
prerelease.strip! if prerelease.respond_to? :strip
|
180
|
+
prerelease = PRERELEASE[PRERELEASE.index(prerelease).succ % PRERELEASE.length]
|
181
|
+
else
|
182
|
+
raise "unknown part #{part.inspect}"
|
183
|
+
end
|
184
|
+
version = [major, minor, patch, *other].compact.join('.')
|
185
|
+
[version, prerelease].compact.join('-')
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.under_version_control?(file)
|
189
|
+
@all_files ||= `git ls-files`.split(/\r?\n/)
|
190
|
+
@all_files.include?(file)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
data/lib/bump/tasks.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "bump"
|
2
|
+
|
3
|
+
namespace :bump do
|
4
|
+
run_bump = lambda do |bump, options|
|
5
|
+
output, status = Bump::Bump.run(bump, options)
|
6
|
+
puts output
|
7
|
+
abort unless status == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
(Bump::Bump::BUMPS + ["current"]).each do |bump|
|
11
|
+
if bump == "current"
|
12
|
+
desc "Show current gem version"
|
13
|
+
else
|
14
|
+
desc "Bump #{bump} part of gem version"
|
15
|
+
end
|
16
|
+
|
17
|
+
task bump do
|
18
|
+
run_bump.call(bump, {})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Sets the version number using the VERSION environment variable"
|
23
|
+
task :set do
|
24
|
+
run_bump.call("set", :version => ENV['VERSION'])
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "rake bump" do
|
4
|
+
inside_of_folder("spec/fixture")
|
5
|
+
|
6
|
+
before do
|
7
|
+
write "VERSION", "1.2.3\n"
|
8
|
+
write "Rakefile", "require File.expand_path('../../../lib/bump/tasks', __FILE__)"
|
9
|
+
raise unless system("git add VERSION")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "bumps a version" do
|
13
|
+
output = run "rake bump:minor"
|
14
|
+
output.should include("1.3.0")
|
15
|
+
read("VERSION").should == "1.3.0\n"
|
16
|
+
`git log -1 --pretty=format:'%s'`.should == "v1.3.0"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "sets a version" do
|
20
|
+
output = run "VERSION=1.3.0 rake bump:set"
|
21
|
+
output.should include("1.3.0")
|
22
|
+
read("VERSION").should == "1.3.0\n"
|
23
|
+
`git log -1 --pretty=format:'%s'`.should == "v1.3.0"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "fails when it cannot bump" do
|
27
|
+
write "VERSION", "AAA"
|
28
|
+
run "rake bump:minor", :fail => true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "shows the version" do
|
32
|
+
result = run "rake bump:current"
|
33
|
+
result.should include("1.2.3")
|
34
|
+
end
|
35
|
+
end
|
data/spec/bump_spec.rb
ADDED
@@ -0,0 +1,441 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Bump do
|
4
|
+
let(:gemspec) { "fixture.gemspec" }
|
5
|
+
|
6
|
+
inside_of_folder("spec/fixture")
|
7
|
+
|
8
|
+
it "should fail if it cannot find anything to bump" do
|
9
|
+
bump("current", :fail => true).should include "Unable to find"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should fail without command" do
|
13
|
+
write_gemspec
|
14
|
+
bump("", :fail => true).should include "Usage instructions: bump --help"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should fail with invalid options" do
|
18
|
+
write_gemspec
|
19
|
+
bump("xxx", :fail => true).should include "Invalid option"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should fail with multiple gemspecs" do
|
23
|
+
write_gemspec
|
24
|
+
write("xxxx.gemspec", "Gem::Specification.new{}")
|
25
|
+
bump("current", :fail => true).should include "More than one gemspec file"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should fail if version is weird" do
|
29
|
+
write_gemspec('"1."+"3.4"')
|
30
|
+
bump("current", :fail => true).should include "Unable to find a file with the gem version"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should show help" do
|
34
|
+
bump("--help").should include("bump current")
|
35
|
+
end
|
36
|
+
|
37
|
+
context "git" do
|
38
|
+
it "should commit the new version" do
|
39
|
+
write_gemspec
|
40
|
+
`git add #{gemspec}`
|
41
|
+
|
42
|
+
bump("patch")
|
43
|
+
|
44
|
+
`git log -1 --pretty=format:'%s'`.should == "v4.2.4"
|
45
|
+
`git status`.should include "nothing to commit"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not commit if --no-commit flag was given" do
|
49
|
+
write_gemspec
|
50
|
+
`git add #{gemspec}`
|
51
|
+
|
52
|
+
bump("patch --no-commit")
|
53
|
+
|
54
|
+
`git log -1 --pretty=format:'%s'`.should == "initial"
|
55
|
+
`git status`.should_not include "nothing to commit"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should not add untracked gemspec" do
|
59
|
+
write_gemspec
|
60
|
+
|
61
|
+
bump("patch")
|
62
|
+
|
63
|
+
`git log -1 --pretty=format:'%s'`.should == "initial"
|
64
|
+
`git status`.should include "Untracked files:"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should tag the version if --tag flag given" do
|
68
|
+
write_gemspec
|
69
|
+
|
70
|
+
bump("patch --tag")
|
71
|
+
`git tag -l`.should include 'v4.2.4'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not tag the version if --no-commit and --tag flag given" do
|
75
|
+
write_gemspec
|
76
|
+
|
77
|
+
bump("patch --no-commit --tag")
|
78
|
+
`git tag -l`.should == ''
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context ".version in gemspec" do
|
83
|
+
before do
|
84
|
+
write_gemspec
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should find current version" do
|
88
|
+
bump("current").should include("4.2.3")
|
89
|
+
read(gemspec).should include('s.version = "4.2.3"')
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should bump patch" do
|
93
|
+
bump("patch").should include("4.2.4")
|
94
|
+
read(gemspec).should include('s.version = "4.2.4"')
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should bump minor" do
|
98
|
+
bump("minor").should include("4.3.0")
|
99
|
+
read(gemspec).should include('s.version = "4.3.0"')
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should bump major" do
|
103
|
+
bump("major").should include("5.0.0")
|
104
|
+
read(gemspec).should include('s.version = "5.0.0"')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should set the version" do
|
108
|
+
bump("set 1.2.3").should include("1.2.3")
|
109
|
+
read(gemspec).should include('s.version = "1.2.3"')
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should bump more then 10" do
|
113
|
+
bump("patch").should include("4.2.4")
|
114
|
+
bump("patch").should include("4.2.5")
|
115
|
+
bump("patch").should include("4.2.6")
|
116
|
+
bump("patch").should include("4.2.7")
|
117
|
+
bump("patch").should include("4.2.8")
|
118
|
+
bump("patch").should include("4.2.9")
|
119
|
+
bump("patch").should include("4.2.10")
|
120
|
+
bump("patch").should include("4.2.11")
|
121
|
+
read(gemspec).should include('s.version = "4.2.11"')
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should not bump multiple versions" do
|
125
|
+
version = '"4.2.3"'
|
126
|
+
write gemspec, <<-RUBY
|
127
|
+
Gem::Specification.new do |s|
|
128
|
+
s.name = 'fixture'
|
129
|
+
s.version = #{version}
|
130
|
+
s.summary = 'Fixture gem'
|
131
|
+
s.runtime_dependency 'rake', #{version}
|
132
|
+
end
|
133
|
+
RUBY
|
134
|
+
bump("patch").should include("4.2.4")
|
135
|
+
read(gemspec).should include('s.version = "4.2.4"')
|
136
|
+
read(gemspec).should include("'rake', #{version}")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context ".version in gemspec within the initializer" do
|
141
|
+
before do
|
142
|
+
write gemspec, <<-RUBY.sub(" "*6, "")
|
143
|
+
Gem::Specification.new "bump", "4.2.3" do
|
144
|
+
end
|
145
|
+
RUBY
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should bump patch" do
|
149
|
+
bump("patch").should include("4.2.4")
|
150
|
+
read(gemspec).should include('"4.2.4"')
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should set the version" do
|
154
|
+
bump("set 1.2.3").should include("1.2.3")
|
155
|
+
read(gemspec).should include('"1.2.3"')
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "VERSION in version.rb" do
|
160
|
+
let(:version_file) { "lib/foo/version.rb" }
|
161
|
+
|
162
|
+
before do
|
163
|
+
write_version_file
|
164
|
+
end
|
165
|
+
|
166
|
+
it "show current" do
|
167
|
+
bump("current").should include("1.2.3")
|
168
|
+
read(version_file).should include(' VERSION = "1.2.3"')
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should bump VERSION" do
|
172
|
+
bump("minor").should include("1.3.0")
|
173
|
+
read(version_file).should include(' VERSION = "1.3.0"')
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should set the version" do
|
177
|
+
bump("set 1.2.3").should include("1.2.3")
|
178
|
+
read(version_file).should include('"1.2.3"')
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should bump Version" do
|
182
|
+
write version_file, <<-RUBY.sub(" "*8, "")
|
183
|
+
module Foo
|
184
|
+
Version = "1.2.3"
|
185
|
+
end
|
186
|
+
RUBY
|
187
|
+
bump("minor").should include("1.3.0")
|
188
|
+
read(version_file).should include(' Version = "1.3.0"')
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should set Version" do
|
192
|
+
write version_file, <<-RUBY.sub(" "*8, "")
|
193
|
+
module Foo
|
194
|
+
Version = "1.2.3"
|
195
|
+
end
|
196
|
+
RUBY
|
197
|
+
bump("set 1.3.0").should include("1.3.0")
|
198
|
+
read(version_file).should include(' Version = "1.3.0"')
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should bump if a gemspec exists and leave it alone" do
|
202
|
+
write_gemspec "'1.'+'2.3'"
|
203
|
+
bump("minor").should include("1.3.0")
|
204
|
+
read(gemspec).should include("version = '1.'+'2.3'")
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
context "version in VERSION" do
|
209
|
+
let(:version) { "1.2.3" }
|
210
|
+
let(:version_file) { "lib/foo/version.rb" }
|
211
|
+
|
212
|
+
before do
|
213
|
+
write "VERSION", "#{version}\n"
|
214
|
+
end
|
215
|
+
|
216
|
+
it "show current" do
|
217
|
+
bump("current").should include("#{version}")
|
218
|
+
read("VERSION").should include("#{version}")
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should bump version" do
|
222
|
+
bump("minor").should include("1.3.0")
|
223
|
+
read("VERSION").should include("1.3.0")
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should set the version" do
|
227
|
+
bump("set 1.3.0").should include("1.3.0")
|
228
|
+
read("VERSION").should include("1.3.0")
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should bump if a gemspec & version.rb exists and leave it alone" do
|
232
|
+
write_gemspec "'1.2.0'"
|
233
|
+
write_version_file "File.read('VERSION')"
|
234
|
+
bump("minor").should include("1.3.0")
|
235
|
+
read("VERSION").should include("1.3.0")
|
236
|
+
read(version_file).should include("VERSION = File.read('VERSION')")
|
237
|
+
read(gemspec).should include("version = '1.2.0'")
|
238
|
+
end
|
239
|
+
|
240
|
+
context "with pre-release identifier" do
|
241
|
+
let(:version) { "1.2.3-alpha" }
|
242
|
+
before do
|
243
|
+
write "VERSION", "#{version}\n"
|
244
|
+
end
|
245
|
+
|
246
|
+
it "show current" do
|
247
|
+
bump("current").should include(version)
|
248
|
+
read("VERSION").should include(version)
|
249
|
+
end
|
250
|
+
|
251
|
+
it "minor should drop prerelease" do
|
252
|
+
bump("minor").should include("1.3.0")
|
253
|
+
read("VERSION").should include("1.3.0")
|
254
|
+
bump("minor").should_not include("alpha")
|
255
|
+
read("VERSION").should_not include("alpha")
|
256
|
+
end
|
257
|
+
|
258
|
+
it "major should drop prerelease" do
|
259
|
+
bump("major").should include("2.0.0")
|
260
|
+
read("VERSION").should include("2.0.0")
|
261
|
+
bump("major").should_not include("alpha")
|
262
|
+
read("VERSION").should_not include("alpha")
|
263
|
+
end
|
264
|
+
|
265
|
+
context "alpha" do
|
266
|
+
it "should bump to beta" do
|
267
|
+
bump("pre").should include("1.2.3-beta")
|
268
|
+
read("VERSION").should include("1.2.3-beta")
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
context "beta" do
|
273
|
+
let(:version) { "1.2.3-beta" }
|
274
|
+
it "should bump to rc" do
|
275
|
+
bump("pre").should include("1.2.3-rc")
|
276
|
+
read("VERSION").should include("1.2.3-rc")
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
context "rc" do
|
281
|
+
let(:version) { "1.2.3-rc" }
|
282
|
+
it "should bump to final" do
|
283
|
+
bump("pre").should include("1.2.3")
|
284
|
+
read("VERSION").should include("1.2.3")
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
context "final" do
|
289
|
+
let(:version) { "1.2.3" }
|
290
|
+
it "should bump to alpha" do
|
291
|
+
bump("pre").should include("1.2.3-alpha")
|
292
|
+
read("VERSION").should include("1.2.3-alpha")
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
context "with a Gemfile" do
|
299
|
+
before do
|
300
|
+
write_gemspec('"1.0.0"')
|
301
|
+
write "Gemfile", <<-RUBY
|
302
|
+
source 'https://rubygems.org'
|
303
|
+
gem "parallel" # a gem not in the Gemfile used to run this test
|
304
|
+
gemspec
|
305
|
+
RUBY
|
306
|
+
`git add Gemfile #{gemspec}`
|
307
|
+
Bundler.with_clean_env { run("bundle") }
|
308
|
+
end
|
309
|
+
|
310
|
+
it "bundle to keep version up to date and commit changed Gemfile.lock" do
|
311
|
+
`git add Gemfile.lock`
|
312
|
+
bump("patch")
|
313
|
+
read("Gemfile.lock").should include "1.0.1"
|
314
|
+
`git status`.should include "nothing to commit"
|
315
|
+
end
|
316
|
+
|
317
|
+
it "does not bundle with --no-bundle" do
|
318
|
+
bump("patch --no-bundle")
|
319
|
+
read(gemspec).should include "1.0.1"
|
320
|
+
read("Gemfile.lock").should include "1.0.0"
|
321
|
+
`git status --porcelain`.should include "?? Gemfile.lock"
|
322
|
+
end
|
323
|
+
|
324
|
+
it "does not bundle or commit an untracked Gemfile.lock" do
|
325
|
+
bump("patch")
|
326
|
+
read("Gemfile.lock").should include "1.0.0"
|
327
|
+
`git status --porcelain`.should include "?? Gemfile.lock"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context ".current" do
|
332
|
+
it "returns the version as a string" do
|
333
|
+
write_gemspec
|
334
|
+
Bump::Bump.current.should == "4.2.3"
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
context "VERSION in lib file" do
|
339
|
+
let(:version_file) { "lib/foo.rb" }
|
340
|
+
|
341
|
+
before do
|
342
|
+
write_version_file
|
343
|
+
write("lib/random_other_file.rb", "foo")
|
344
|
+
write("lib/random/other/file.rb", "foo")
|
345
|
+
end
|
346
|
+
|
347
|
+
it "show current" do
|
348
|
+
bump("current").should include("1.2.3")
|
349
|
+
read(version_file).should include(' VERSION = "1.2.3"')
|
350
|
+
end
|
351
|
+
|
352
|
+
it "should bump VERSION" do
|
353
|
+
bump("minor").should include("1.3.0")
|
354
|
+
read(version_file).should include(' VERSION = "1.3.0"')
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should set VERSION" do
|
358
|
+
bump("set 1.3.0").should include("1.3.0")
|
359
|
+
read(version_file).should include(' VERSION = "1.3.0"')
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should bump Version" do
|
363
|
+
write version_file, <<-RUBY.sub(" "*8, "")
|
364
|
+
module Foo
|
365
|
+
Version = "1.2.3"
|
366
|
+
end
|
367
|
+
RUBY
|
368
|
+
bump("minor").should include("1.3.0")
|
369
|
+
read(version_file).should include(' Version = "1.3.0"')
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should set Version" do
|
373
|
+
write version_file, <<-RUBY.sub(" "*8, "")
|
374
|
+
module Foo
|
375
|
+
Version = "1.2.3"
|
376
|
+
end
|
377
|
+
RUBY
|
378
|
+
bump("set 1.3.0").should include("1.3.0")
|
379
|
+
read(version_file).should include(' Version = "1.3.0"')
|
380
|
+
end
|
381
|
+
|
382
|
+
it "should bump if a gemspec exists and leave it alone" do
|
383
|
+
write_gemspec "'1.'+'2.3'"
|
384
|
+
bump("minor").should include("1.3.0")
|
385
|
+
read(gemspec).should include("version = '1.'+'2.3'")
|
386
|
+
end
|
387
|
+
|
388
|
+
context "that is nested" do
|
389
|
+
let(:version_file) { "lib/bar/baz/foo.rb" }
|
390
|
+
|
391
|
+
it "show current" do
|
392
|
+
bump("current").should include("1.2.3")
|
393
|
+
read(version_file).should include(' VERSION = "1.2.3"')
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
context "version in metadata.rb" do
|
399
|
+
let(:version) { "1.2.3" }
|
400
|
+
let(:version_file) { "metadata.rb" }
|
401
|
+
|
402
|
+
before do
|
403
|
+
write version_file, "foo :bar\nversion '#{version}'\nbar :baz\n"
|
404
|
+
end
|
405
|
+
|
406
|
+
it "should bump version" do
|
407
|
+
bump("minor").should include("1.3.0")
|
408
|
+
read(version_file).should include("1.3.0")
|
409
|
+
end
|
410
|
+
|
411
|
+
it "should set the version" do
|
412
|
+
bump("set 1.3.0").should include("1.3.0")
|
413
|
+
read(version_file).should include("1.3.0")
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
private
|
418
|
+
|
419
|
+
def bump(command="", options={})
|
420
|
+
cmdline = "#{File.expand_path("../../bin/bump", __FILE__)} #{command}"
|
421
|
+
run cmdline, options
|
422
|
+
end
|
423
|
+
|
424
|
+
def write_gemspec(version = '"4.2.3"')
|
425
|
+
write gemspec, <<-RUBY.sub(" "*6, "")
|
426
|
+
Gem::Specification.new do |s|
|
427
|
+
s.name = 'fixture'
|
428
|
+
s.version = #{version}
|
429
|
+
s.summary = 'Fixture gem'
|
430
|
+
end
|
431
|
+
RUBY
|
432
|
+
end
|
433
|
+
|
434
|
+
def write_version_file(version = '"1.2.3"')
|
435
|
+
write version_file, <<-RUBY.sub(" "*6, "")
|
436
|
+
module Foo
|
437
|
+
VERSION = #{version}
|
438
|
+
end
|
439
|
+
RUBY
|
440
|
+
end
|
441
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "bump"
|
3
|
+
|
4
|
+
module SpecHelpers
|
5
|
+
module InstanceMethods
|
6
|
+
def write(file, content)
|
7
|
+
folder = File.dirname(file)
|
8
|
+
run "mkdir -p #{folder}" unless File.exist?(folder)
|
9
|
+
File.open(file, 'w'){|f| f.write content }
|
10
|
+
end
|
11
|
+
|
12
|
+
def read(file)
|
13
|
+
File.read(file)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(cmd, options={})
|
17
|
+
result = `#{cmd} 2>&1`
|
18
|
+
raise "FAILED #{cmd} --> #{result}" if $?.success? != !options[:fail]
|
19
|
+
result
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module ClassMethods
|
24
|
+
def inside_of_folder(folder)
|
25
|
+
folder = File.expand_path(folder, File.dirname(File.dirname(__FILE__)))
|
26
|
+
around do |example|
|
27
|
+
run "rm -rf #{folder} && mkdir #{folder}"
|
28
|
+
Dir.chdir folder do
|
29
|
+
`git init && git commit --allow-empty -am 'initial'` # so we never accidentally do commit to the current repo
|
30
|
+
example.call
|
31
|
+
end
|
32
|
+
run "rm -rf #{folder}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec.configure do |c|
|
39
|
+
c.include SpecHelpers::InstanceMethods
|
40
|
+
c.extend SpecHelpers::ClassMethods
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bumpz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gregory Marcilhacy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 10.0.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 10.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
description:
|
42
|
+
email: g.marcilhacy@gmail.com
|
43
|
+
executables:
|
44
|
+
- bump
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .travis.yml
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/bump
|
55
|
+
- bump.gemspec
|
56
|
+
- lib/bump.rb
|
57
|
+
- lib/bump/tasks.rb
|
58
|
+
- spec/bump/tasks_spec.rb
|
59
|
+
- spec/bump_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
homepage: https://github.com/treeder/bump
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.2.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Bump your gem version file
|
85
|
+
test_files: []
|