bundler-gem_version_tasks 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/Gemfile +12 -0
- data/Guardfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +3 -0
- data/bundler-gem_version_tasks.gemspec +25 -0
- data/lib/bundler/gem_version_tasks/version.rb +5 -0
- data/lib/bundler/gem_version_tasks.rb +94 -0
- data/spec/bundler/version_tasks_spec.rb +68 -0
- data/spec/fixture/version.rb +5 -0
- data/spec/spec_helper.rb +9 -0
- metadata +100 -0
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in bundler-gem_version_tasks.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem "minitest", "~> 5.0", ">= 5.0.0"
|
8
|
+
gem 'minitest-rg', "~> 5.0", ">= 5.0.0"
|
9
|
+
gem 'guard-minitest', "~> 2.2", '>= 2.2.0'
|
10
|
+
gem 'gimme'
|
11
|
+
gem 'pry-debugger'
|
12
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :minitest, all_after_pass: true do
|
5
|
+
|
6
|
+
# with Minitest::Spec
|
7
|
+
watch(%r{^spec/(.*)_spec\.rb$})
|
8
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
9
|
+
watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
10
|
+
|
11
|
+
end
|
12
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 yann ARMAND
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Bundler::GemVersionTasks
|
2
|
+
|
3
|
+
I have always use [jeweler](https://github.com/technicalpickles/jeweler) to develop my gems.
|
4
|
+
I decided recently to simply rely on bundler but I missed so much the
|
5
|
+
helper rake tasks to manage version that I reimplemented for bundler.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this gem (bundler-gem_version_tasks) as a development dependency in
|
10
|
+
your gemspec:
|
11
|
+
|
12
|
+
```
|
13
|
+
gem.add_development_dependency 'bundler-gem_version_tasks'
|
14
|
+
```
|
15
|
+
|
16
|
+
Add this to your Rakefile, instead of require 'bundler/gem_tasks':
|
17
|
+
|
18
|
+
```
|
19
|
+
require "bundler/gem_version_tasks"
|
20
|
+
```
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
rake version # print current version
|
25
|
+
rake version:bump:major # Bump the major version by 1
|
26
|
+
rake version:bump:minor # Bump the minor version by 1
|
27
|
+
rake version:bump:patch # Bump the patch version by 1
|
28
|
+
rake version:write # write a specific version - example: rake version:write VERSION=1.2.3
|
29
|
+
```
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/[my-github-username]/bundler-gem_version_tasks/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bundler/gem_version_tasks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bundler-gem_version_tasks"
|
8
|
+
spec.version = Bundler::GemVersionTasks::VERSION
|
9
|
+
spec.authors = ["yann ARMAND"]
|
10
|
+
spec.email = ["yann@harakys.com"]
|
11
|
+
spec.summary = %q{Helper rake tasks to update gem version.}
|
12
|
+
spec.description = %q{To complete standards bundler rake tasks,
|
13
|
+
this gem add a series of tasks to display, bump and write the gem version.
|
14
|
+
}
|
15
|
+
spec.homepage = "https://github.com/yarmand/bundler-gem_version_tasks"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "bundler/gem_version_tasks/version"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class GemVersionTasks
|
5
|
+
attr_reader :gemspec
|
6
|
+
|
7
|
+
def initialize( opts={} )
|
8
|
+
@gemspec = opts.fetch(:gemspec) { Bundler::GemHelper.gemspec }
|
9
|
+
@git_command = opts.fetch(:git_command, 'git')
|
10
|
+
end
|
11
|
+
|
12
|
+
def bump(what)
|
13
|
+
major,minor,patch = version.segments
|
14
|
+
case what
|
15
|
+
when :major
|
16
|
+
major += 1
|
17
|
+
minor = 0
|
18
|
+
patch = 0
|
19
|
+
when :minor
|
20
|
+
minor = minor.next
|
21
|
+
patch = 0
|
22
|
+
when :patch
|
23
|
+
patch = patch.next
|
24
|
+
else
|
25
|
+
raise 'need to specify what to bump in :major, :minor, :patch'
|
26
|
+
end
|
27
|
+
"#{major}.#{minor}.#{patch}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def replace_version(version_file, version)
|
31
|
+
lines = File.readlines(version_file).map { |l| l.gsub(/\s*VERSION\s*=.*/,"VERSION='#{version}'") }
|
32
|
+
File.open(version_file,'w') {|f| f.write(lines.join('')) }
|
33
|
+
commit_version(version_file, "Bumping to version #{version}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def commit_version(version_file, message)
|
37
|
+
`#{@git_command} commit -m "#{message}" #{version_file}`
|
38
|
+
end
|
39
|
+
|
40
|
+
def version_file
|
41
|
+
gemspec.files.grep(/version.rb$/).first
|
42
|
+
end
|
43
|
+
|
44
|
+
def version
|
45
|
+
gemspec.version
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.install!
|
49
|
+
new.install
|
50
|
+
end
|
51
|
+
|
52
|
+
include Rake::DSL if defined? Rake::DSL
|
53
|
+
def install
|
54
|
+
desc "print current version"
|
55
|
+
task 'version' do
|
56
|
+
puts version
|
57
|
+
end
|
58
|
+
|
59
|
+
namespace 'version' do
|
60
|
+
desc "write a specific version - example: rake version:write VERSION=1.2.3"
|
61
|
+
task 'write' do
|
62
|
+
new_version = ENV['VERSION']
|
63
|
+
replace_version(version_file, new_version)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
namespace 'version:bump' do
|
68
|
+
desc "Bump the major version by 1"
|
69
|
+
task 'major' do
|
70
|
+
new_version = bump(:major)
|
71
|
+
replace_version(version_file, new_version)
|
72
|
+
puts new_version
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Bump the minor version by 1"
|
76
|
+
task 'minor' do
|
77
|
+
new_version = bump(:minor)
|
78
|
+
replace_version(version_file, new_version)
|
79
|
+
puts new_version
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Bump the patch version by 1"
|
83
|
+
task 'patch' do
|
84
|
+
new_version = bump(:patch)
|
85
|
+
replace_version(version_file, new_version)
|
86
|
+
puts new_version
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
# Your code goes here...
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
Bundler::GemVersionTasks.install! unless defined? Minitest
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'bundler/gem_version_tasks'
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
describe GemVersionTasks do
|
7
|
+
|
8
|
+
subject { GemVersionTasks.new( { gemspec: gimme_gemspec, git_command: 'echo' } ) }
|
9
|
+
|
10
|
+
describe '#bump' do
|
11
|
+
it 'should raise an exception if what is not specifyed properly' do
|
12
|
+
lambda { subject.bump(:not_a_good_what) }.must_raise(RuntimeError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should bump major version' do
|
16
|
+
subject.bump(:major).must_equal '2.0.0'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should bump minor version' do
|
20
|
+
subject.bump(:minor).must_equal '1.3.0'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should bump patch version' do
|
24
|
+
subject.bump(:patch).must_equal '1.2.4'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#version_file' do
|
29
|
+
it 'retrieve the version.rb file' do
|
30
|
+
subject.version_file.must_equal 'lib/bundler/yammer_gem_tasks/version.rb'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#replace_version' do
|
35
|
+
before do
|
36
|
+
@file_name = 'tmp_version.rb'
|
37
|
+
system("cp spec/fixture/version.rb #{@file_name}")
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should write version in the version file' do
|
41
|
+
subject.replace_version(@file_name,'50.49.48')
|
42
|
+
vline = File.readlines(@file_name).grep(/VERSION/).first
|
43
|
+
vline.must_match(/VERSION\s*=\s*'50.49.48'/)
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
FileUtils.rm @file_name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def gimme_gemspec
|
53
|
+
gemspec = gimme
|
54
|
+
give(gemspec).files {
|
55
|
+
["Gemfile",
|
56
|
+
"LICENSE.txt",
|
57
|
+
"README.md",
|
58
|
+
"lib/bundler/yammer_gem_tasks/version.rb",
|
59
|
+
"bundler-yammer_gem_tasks.gemspec",
|
60
|
+
"lib/bundler/yammer_gem_tasks.rb",
|
61
|
+
]
|
62
|
+
}
|
63
|
+
give(gemspec).version { Gem::Version.new('1.2.3a') }
|
64
|
+
gemspec
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-gem_version_tasks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- yann ARMAND
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-05-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: ! "To complete standards bundler rake tasks, \n this gem add a series
|
47
|
+
of tasks to display, bump and write the gem version.\n "
|
48
|
+
email:
|
49
|
+
- yann@harakys.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Guardfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bundler-gem_version_tasks.gemspec
|
61
|
+
- lib/bundler/gem_version_tasks.rb
|
62
|
+
- lib/bundler/gem_version_tasks/version.rb
|
63
|
+
- spec/bundler/version_tasks_spec.rb
|
64
|
+
- spec/fixture/version.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
homepage: https://github.com/yarmand/bundler-gem_version_tasks
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: -1387550572555754235
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
hash: -1387550572555754235
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.8.23
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Helper rake tasks to update gem version.
|
97
|
+
test_files:
|
98
|
+
- spec/bundler/version_tasks_spec.rb
|
99
|
+
- spec/fixture/version.rb
|
100
|
+
- spec/spec_helper.rb
|