gem-release 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,4 +20,4 @@ module GemRelease
20
20
  add_option(*args) { |value, options| options[key] = value }
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -13,7 +13,7 @@ module GemRelease
13
13
  @description ||= '[description]'
14
14
  @strategy = options[:strategy]
15
15
  end
16
-
16
+
17
17
  def files
18
18
  case @strategy
19
19
  when 'git'
@@ -22,7 +22,7 @@ module GemRelease
22
22
  'Dir.glob("lib/**/**")'
23
23
  end
24
24
  end
25
-
25
+
26
26
  def filename
27
27
  "#{name}.gemspec"
28
28
  end
@@ -1,4 +1,4 @@
1
- require 'core_ext/kernel/silence'
1
+ require 'core_ext/string/camelize'
2
2
 
3
3
  module GemRelease
4
4
  module Helpers
@@ -35,7 +35,7 @@ module GemRelease
35
35
  end
36
36
 
37
37
  def gemspec
38
- @gemspec ||= Gem::Specification.load(gemspec_filename) # silence { }
38
+ @gemspec ||= Gem::Specification.load(gemspec_filename)
39
39
  rescue LoadError, RuntimeError
40
40
  nil
41
41
  end
@@ -48,4 +48,4 @@ module GemRelease
48
48
  end
49
49
  end
50
50
  end
51
- end
51
+ end
@@ -30,4 +30,4 @@ module GemRelease
30
30
  File.new(File.expand_path("../templates/#{template_name}", __FILE__)).read
31
31
  end
32
32
  end
33
- end
33
+ end
@@ -16,5 +16,4 @@ Gem::Specification.new do |s|
16
16
  s.platform = Gem::Platform::RUBY
17
17
  s.require_path = 'lib'
18
18
  s.rubyforge_project = '[none]'
19
- s.required_rubygems_version = '>= 1.3.6'
20
19
  end
@@ -1,3 +1,3 @@
1
1
  module <%= module_name %>
2
2
  VERSION = <%= version.inspect %>
3
- end
3
+ end
@@ -1,5 +1,5 @@
1
1
  module GemRelease
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14'
3
3
 
4
4
  class Version < Template
5
5
  attr_reader :version
@@ -12,9 +12,9 @@ module GemRelease
12
12
  def filename
13
13
  "lib/#{module_path}/version.rb"
14
14
  end
15
-
15
+
16
16
  def template_name
17
17
  'version.erb'
18
18
  end
19
19
  end if defined?(Template)
20
- end
20
+ end
@@ -1,54 +1,54 @@
1
1
  module GemRelease
2
2
  class VersionFile
3
3
  include GemRelease::Helpers
4
-
4
+
5
5
  VERSION_PATTERN = /(VERSION\s*=\s*(?:"|'))(\d+\.\d+\.\d+)("|')/
6
6
  NUMBER_PATTERN = /(\d+)\.(\d+)\.(\d+)/
7
-
7
+
8
8
  attr_reader :target
9
-
9
+
10
10
  def initialize(options = {})
11
11
  @target = options[:target] || :patch
12
12
  end
13
-
13
+
14
14
  def bump!
15
15
  File.open(filename, 'w+') { |f| f.write(bumped_content) }
16
16
  end
17
-
17
+
18
18
  def new_number
19
19
  @new_number ||= old_number.sub(NUMBER_PATTERN) do
20
20
  respond_to?(target) ? send(target, $1, $2, $3) : target
21
21
  end
22
22
  end
23
-
23
+
24
24
  def old_number
25
25
  @old_number ||= content =~ VERSION_PATTERN && $2
26
26
  end
27
-
27
+
28
28
  def filename
29
29
  File.expand_path("lib/#{gem_module_path}/version.rb")
30
30
  end
31
-
31
+
32
32
  protected
33
-
33
+
34
34
  def major(major, minor, patch)
35
35
  "#{major.to_i + 1}.0.0"
36
36
  end
37
-
37
+
38
38
  def minor(major, minor, patch)
39
39
  "#{major}.#{minor.to_i + 1}.0"
40
40
  end
41
-
41
+
42
42
  def patch(major, minor, patch)
43
43
  "#{major}.#{minor}.#{patch.to_i + 1}"
44
44
  end
45
-
45
+
46
46
  def content
47
47
  @content ||= File.read(filename)
48
48
  end
49
-
49
+
50
50
  def bumped_content
51
- content.sub(VERSION_PATTERN) { "#{$1}#{new_number}#{$3}"}
51
+ content.sub(VERSION_PATTERN) { "#{$1}#{new_number}#{$3}" }
52
52
  end
53
53
  end
54
- end
54
+ end
@@ -1,4 +1,5 @@
1
1
  require 'rubygems/commands/gemspec_command'
2
+ require 'core_ext/kernel/silence'
2
3
 
3
4
  class Gem::Commands::BootstrapCommand < Gem::Command
4
5
  include GemRelease, Gem::Commands
@@ -7,7 +8,7 @@ class Gem::Commands::BootstrapCommand < Gem::Command
7
8
  OPTIONS = { :gemspec => true, :strategy => 'git', :scaffold => false, :github => false }
8
9
 
9
10
  attr_reader :arguments, :usage
10
-
11
+
11
12
  def initialize
12
13
  super 'bootstrap', 'Bootstrap a new gem source repository', OPTIONS
13
14
 
@@ -34,7 +35,7 @@ class Gem::Commands::BootstrapCommand < Gem::Command
34
35
  write_version
35
36
  write_rakefile
36
37
  end
37
-
38
+
38
39
  def write_version
39
40
  version = Version.new(options)
40
41
  say "Creating #{version.filename}"
@@ -60,22 +61,22 @@ RAKEFILE
60
61
  def create_repo
61
62
  options = { :login => github_user, :token => github_token, :name => gem_name }
62
63
  options = options.map { |name, value| "-F '#{name}=#{value}'" }.join(' ')
63
-
64
+
64
65
  say 'Bootstrapializing git repository'
65
66
  `git init`
66
-
67
+
67
68
  say 'Staging files'
68
69
  `git add .`
69
-
70
+
70
71
  say 'Creating initial commit'
71
72
  `git commit -m 'initial commit'`
72
-
73
+
73
74
  say "Adding remote origin git@github.com:#{github_user}/#{gem_name}.git"
74
75
  `git remote add origin git@github.com:#{github_user}/#{gem_name}.git`
75
76
 
76
77
  say 'Creating repository on Github'
77
78
  silence { `curl #{options} http://github.com/api/v2/yaml/repos/create` }
78
-
79
+
79
80
  say 'Pushing to Github'
80
81
  `git push origin master`
81
82
  end
@@ -1,26 +1,31 @@
1
- require 'core_ext/string/camelize'
1
+ require 'rubygems/commands/tag_command'
2
+ require 'rubygems/commands/release_command'
2
3
 
3
4
  class Gem::Commands::BumpCommand < Gem::Command
4
- include GemRelease
5
+ include GemRelease, Gem::Commands
5
6
  include Helpers, CommandOptions
6
7
 
7
8
  attr_reader :arguments, :usage
8
9
 
9
- OPTIONS = { :to => :patch, :push => false }
10
+ OPTIONS = { :version => 'patch', :push => false, :tag => false, :release => false }
10
11
 
11
12
  def initialize
12
13
  super 'bump', 'Bump the gem version', OPTIONS
13
14
 
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)'
15
+ option :version, '-v', 'Target version: next [major|minor|patch] or a given version number [x.x.x]'
16
+ option :push, '-p', 'Push to origin'
17
+ option :tag, '-t', 'Create a git tag and push --tags to origin'
18
+ option :release, '-r', 'Build gem from a gemspec and push to rubygems.org'
16
19
  end
17
20
 
18
21
  def execute
19
22
  bump
20
23
  commit
21
- push if options[:push]
24
+ push if options[:push] || options[:tag]
25
+ release if options[:release]
26
+ tag if options[:tag]
22
27
  end
23
-
28
+
24
29
  protected
25
30
 
26
31
  def bump
@@ -38,8 +43,16 @@ class Gem::Commands::BumpCommand < Gem::Command
38
43
  say "Pushing to origin"
39
44
  `git push`
40
45
  end
41
-
46
+
47
+ def release
48
+ ReleaseCommand.new.invoke
49
+ end
50
+
51
+ def tag
52
+ TagCommand.new.invoke
53
+ end
54
+
42
55
  def version
43
- @version ||= VersionFile.new(:target => options[:to])
56
+ @version ||= VersionFile.new(:target => options[:version])
44
57
  end
45
- end
58
+ end
@@ -17,4 +17,4 @@ class Gem::Commands::GemspecCommand < Gem::Command
17
17
  say "Creating #{gemspec.filename}"
18
18
  gemspec.write
19
19
  end
20
- end
20
+ end
@@ -11,7 +11,7 @@ class Gem::Commands::ReleaseCommand < Gem::Command
11
11
  attr_reader :arguments, :usage
12
12
 
13
13
  def initialize
14
- super 'release', 'Build a gem from a gemspec and push to rubygems.org'
14
+ super 'release', 'Build gem from a gemspec and push to rubygems.org'
15
15
  option :tag, '-t', 'Create a git tag and push --tags to origin'
16
16
  @arguments = "gemspec - optional gemspec file name, will use the first *.gemspec if not specified"
17
17
  @usage = "#{program_name} [gemspec]"
@@ -43,4 +43,4 @@ class Gem::Commands::ReleaseCommand < Gem::Command
43
43
  def tag
44
44
  TagCommand.new.invoke
45
45
  end
46
- end
46
+ end
@@ -12,7 +12,7 @@ class Gem::Commands::TagCommand < Gem::Command
12
12
  tag
13
13
  push
14
14
  end
15
-
15
+
16
16
  protected
17
17
 
18
18
  def tag
@@ -24,8 +24,8 @@ class Gem::Commands::TagCommand < Gem::Command
24
24
  say "Pushing --tags to origin git repository"
25
25
  `git push --tags origin`
26
26
  end
27
-
27
+
28
28
  def tag_name
29
29
  "v#{gem_version}"
30
30
  end
31
- end
31
+ end
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: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 14
10
+ version: 0.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-29 00:00:00 +02:00
18
+ date: 2010-10-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency