gem-release 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gem_release.rb +1 -0
- data/lib/gem_release/helpers.rb +9 -1
- data/lib/gem_release/version.rb +2 -2
- data/lib/gem_release/version_file.rb +54 -0
- data/lib/rubygems/commands/bootstrap_command.rb +0 -1
- data/lib/rubygems/commands/bump_command.rb +45 -0
- data/lib/rubygems/commands/gemspec_command.rb +0 -2
- data/lib/rubygems/commands/release_command.rb +0 -1
- data/lib/rubygems/commands/tag_command.rb +0 -2
- data/lib/rubygems_plugin.rb +2 -1
- metadata +10 -24
data/lib/gem_release.rb
CHANGED
data/lib/gem_release/helpers.rb
CHANGED
@@ -18,6 +18,14 @@ module GemRelease
|
|
18
18
|
File.basename(Dir.pwd)
|
19
19
|
end
|
20
20
|
|
21
|
+
def gem_module_path
|
22
|
+
@gem_module_path ||= gem_name.gsub('-', '_')
|
23
|
+
end
|
24
|
+
|
25
|
+
def gem_module_name
|
26
|
+
@gem_module_name ||= gem_module_path.camelize
|
27
|
+
end
|
28
|
+
|
21
29
|
def gem_filename
|
22
30
|
gemspec.file_name
|
23
31
|
end
|
@@ -34,7 +42,7 @@ module GemRelease
|
|
34
42
|
|
35
43
|
def gemspec_filename
|
36
44
|
@gemspec_filename ||= begin
|
37
|
-
name = Array(options[:args]).first
|
45
|
+
name = Array(options[:args]).first rescue nil
|
38
46
|
name ||= Dir['*.gemspec'].first
|
39
47
|
name || raise("No gemspec found or given.")
|
40
48
|
end
|
data/lib/gem_release/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
module GemRelease
|
2
|
+
class VersionFile
|
3
|
+
include GemRelease::Helpers
|
4
|
+
|
5
|
+
VERSION_PATTERN = /(VERSION\s*=\s*(?:"|'))(\d+\.\d+\.\d+)("|')/
|
6
|
+
NUMBER_PATTERN = /(\d+)\.(\d+)\.(\d+)/
|
7
|
+
|
8
|
+
attr_reader :target
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@target = options[:target] || :patch
|
12
|
+
end
|
13
|
+
|
14
|
+
def bump!
|
15
|
+
File.open(filename, 'w+') { |f| f.write(bumped_content) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def new_number
|
19
|
+
@new_number ||= old_number.sub(NUMBER_PATTERN) do
|
20
|
+
respond_to?(target) ? send(target, $1, $2, $3) : target
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def old_number
|
25
|
+
@old_number ||= content =~ VERSION_PATTERN && $2
|
26
|
+
end
|
27
|
+
|
28
|
+
def filename
|
29
|
+
File.expand_path("lib/#{gem_module_path}/version.rb")
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def major(major, minor, patch)
|
35
|
+
"#{major.to_i + 1}.0.0"
|
36
|
+
end
|
37
|
+
|
38
|
+
def minor(major, minor, patch)
|
39
|
+
"#{major}.#{minor.to_i + 1}.0"
|
40
|
+
end
|
41
|
+
|
42
|
+
def patch(major, minor, patch)
|
43
|
+
"#{major}.#{minor}.#{patch.to_i + 1}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def content
|
47
|
+
@content ||= File.read(filename)
|
48
|
+
end
|
49
|
+
|
50
|
+
def bumped_content
|
51
|
+
content.sub(VERSION_PATTERN) { "#{$1}#{new_number}#{$3}"}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'core_ext/string/camelize'
|
2
|
+
|
3
|
+
class Gem::Commands::BumpCommand < Gem::Command
|
4
|
+
include GemRelease
|
5
|
+
include Helpers, CommandOptions
|
6
|
+
|
7
|
+
attr_reader :arguments, :usage
|
8
|
+
|
9
|
+
OPTIONS = { :to => :patch, :push => false }
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super 'bump', 'Bump the gem version', OPTIONS
|
13
|
+
|
14
|
+
option :to, '-t', 'Target version: next [major|minor|patch] or a given version number [x.x.x]'
|
15
|
+
option :push, '-p', 'Push to origin (defaults to false)'
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
bump
|
20
|
+
commit
|
21
|
+
push if options[:push]
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def bump
|
27
|
+
say "Bumping from #{version.old_number} to version #{version.new_number}"
|
28
|
+
version.bump!
|
29
|
+
end
|
30
|
+
|
31
|
+
def commit
|
32
|
+
say "Creating commit"
|
33
|
+
`git add #{version.filename}`
|
34
|
+
`git commit -m "Bump to #{version.new_number}"`
|
35
|
+
end
|
36
|
+
|
37
|
+
def push
|
38
|
+
say "Pushing to origin"
|
39
|
+
`git push`
|
40
|
+
end
|
41
|
+
|
42
|
+
def version
|
43
|
+
@version ||= VersionFile.new(:target => options[:to])
|
44
|
+
end
|
45
|
+
end
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -3,5 +3,6 @@ require 'gem_release'
|
|
3
3
|
|
4
4
|
Gem::CommandManager.instance.register_command :gemspec
|
5
5
|
Gem::CommandManager.instance.register_command :bootstrap
|
6
|
+
Gem::CommandManager.instance.register_command :bump
|
6
7
|
Gem::CommandManager.instance.register_command :release
|
7
|
-
Gem::CommandManager.instance.register_command :tag
|
8
|
+
Gem::CommandManager.instance.register_command :tag
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-release
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sven Fuchs
|
@@ -15,29 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-29 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
name: minitest
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 15
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 6
|
33
|
-
- 0
|
34
|
-
version: 1.6.0
|
35
|
-
type: :development
|
36
|
-
version_requirements: *id001
|
37
21
|
- !ruby/object:Gem::Dependency
|
38
22
|
name: test_declarative
|
39
23
|
prerelease: false
|
40
|
-
requirement: &
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
41
25
|
none: false
|
42
26
|
requirements:
|
43
27
|
- - ">="
|
@@ -49,11 +33,11 @@ dependencies:
|
|
49
33
|
- 2
|
50
34
|
version: 0.0.2
|
51
35
|
type: :development
|
52
|
-
version_requirements: *
|
36
|
+
version_requirements: *id001
|
53
37
|
- !ruby/object:Gem::Dependency
|
54
38
|
name: mocha
|
55
39
|
prerelease: false
|
56
|
-
requirement: &
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
57
41
|
none: false
|
58
42
|
requirements:
|
59
43
|
- - ">="
|
@@ -65,7 +49,7 @@ dependencies:
|
|
65
49
|
- 8
|
66
50
|
version: 0.9.8
|
67
51
|
type: :development
|
68
|
-
version_requirements: *
|
52
|
+
version_requirements: *id002
|
69
53
|
description: Release your ruby gems with ease. (What a bold statement for such a tiny plugin ...)
|
70
54
|
email: svenfuchs@artweb-design.de
|
71
55
|
executables: []
|
@@ -85,7 +69,9 @@ files:
|
|
85
69
|
- lib/gem_release/templates/gemspec.erb
|
86
70
|
- lib/gem_release/templates/version.erb
|
87
71
|
- lib/gem_release/version.rb
|
72
|
+
- lib/gem_release/version_file.rb
|
88
73
|
- lib/rubygems/commands/bootstrap_command.rb
|
74
|
+
- lib/rubygems/commands/bump_command.rb
|
89
75
|
- lib/rubygems/commands/gemspec_command.rb
|
90
76
|
- lib/rubygems/commands/release_command.rb
|
91
77
|
- lib/rubygems/commands/tag_command.rb
|