gem-release 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,23 @@
1
1
  module GemRelease
2
2
  module CommandOptions
3
+ def initialize(*args)
4
+ @arguments = ''
5
+ super
6
+ end
7
+
3
8
  def option(key, short, description)
4
- long = "--[no-]#{key}"
5
- default = self.class::OPTIONS[key]
6
- add_option(short, long, description, "Defaults to #{default}") do |value, options|
7
- options[key] = value
9
+ options = self.class::OPTIONS
10
+ default = options[key]
11
+
12
+ if String === default
13
+ long = "--#{key} #{key.to_s.upcase}"
14
+ args = [short, long, String, "#{description} (defaults to #{default})"]
15
+ else
16
+ long = "--[no-]#{key}"
17
+ args = [short, long, "#{description} (defaults to #{default})"]
8
18
  end
19
+
20
+ add_option(*args) { |value, options| options[key] = value }
9
21
  end
10
22
  end
11
23
  end
@@ -1,5 +1,5 @@
1
1
  module GemRelease
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
 
4
4
  class Version < Template
5
5
  attr_reader :version
@@ -1,26 +1,21 @@
1
1
  require 'gem_release/helpers'
2
+ require 'rubygems/commands/gemspec_command'
2
3
 
3
- class Gem::Commands::InitCommand < Gem::Command
4
- include GemRelease
4
+ class Gem::Commands::BootstrapCommand < Gem::Command
5
+ include GemRelease, Gem::Commands
5
6
  include Helpers, CommandOptions
6
7
 
7
- OPTIONS = {
8
- :gemspec => true,
9
- :scaffold => false,
10
- :github => false
11
- }
8
+ OPTIONS = { :gemspec => true, :strategy => 'git', :scaffold => false, :github => false }
12
9
 
13
10
  attr_reader :arguments, :usage
14
11
 
15
12
  def initialize
16
- super 'init', 'Initialize a new gem source repository', OPTIONS
13
+ super 'bootstrap', 'Bootstrap a new gem source repository', OPTIONS
17
14
 
18
15
  option :gemspec, '-g', 'Generate a .gemspec'
16
+ option :strategy, '-f', 'Strategy for collecting files [glob|git] in .gemspec'
19
17
  option :scaffold, '-s', 'Scaffold lib/[gem_name]/version.rb README test/'
20
- option :github, '-h', 'Init a git repo, create on github and push'
21
-
22
- @arguments = ''
23
- @usage = "#{program_name}"
18
+ option :github, '-h', 'Bootstrap a git repo, create on github and push'
24
19
  end
25
20
 
26
21
  def execute
@@ -29,21 +24,28 @@ class Gem::Commands::InitCommand < Gem::Command
29
24
  create_repo if options[:github]
30
25
  end
31
26
 
27
+ def write_gemspec
28
+ GemspecCommand.new.invoke
29
+ end
30
+
32
31
  def write_scaffold
32
+ say 'scaffolding lib/ README test/'
33
33
  `mkdir lib test`
34
34
  `touch README`
35
- Version.new(options).write
35
+ write_version
36
36
  end
37
-
38
- def write_gemspec
39
- Gemspec.new(options).write
37
+
38
+ def write_version
39
+ version = Version.new(options)
40
+ say "Creating #{version.filename}"
41
+ version.write
40
42
  end
41
43
 
42
44
  def create_repo
43
45
  options = { :login => github_user, :token => github_token, :name => gem_name }
44
46
  options = options.map { |name, value| "-F '#{name}=#{value}'" }.join(' ')
45
47
 
46
- say 'Initializing git repository'
48
+ say 'Bootstrapializing git repository'
47
49
  `git init`
48
50
 
49
51
  say 'Staging files'
@@ -0,0 +1,22 @@
1
+ require 'gem_release/helpers'
2
+
3
+ class Gem::Commands::GemspecCommand < Gem::Command
4
+ include GemRelease
5
+ include Helpers, CommandOptions
6
+
7
+ OPTIONS = { :strategy => 'git' }
8
+
9
+ attr_reader :arguments, :usage
10
+
11
+ def initialize
12
+ super 'bootstrap', 'Bootstrap a new gem source repository', OPTIONS
13
+
14
+ option :strategy, '-f', 'Strategy for collecting files [glob|git] in .gemspec'
15
+ end
16
+
17
+ def execute
18
+ gemspec = Gemspec.new(options)
19
+ say "Creating #{gemspec.filename}"
20
+ gemspec.write
21
+ end
22
+ end
@@ -4,16 +4,17 @@ require 'rubygems/commands/tag_command'
4
4
  require 'gem_release/helpers'
5
5
 
6
6
  class Gem::Commands::ReleaseCommand < Gem::Command
7
- include GemRelease::Helpers, Gem::Commands
7
+ include GemRelease, Gem::Commands
8
+ include Helpers, CommandOptions
9
+
10
+ OPTIONS = { :tag => false }
8
11
 
9
12
  attr_reader :arguments, :usage
10
13
 
11
14
  def initialize
12
- super('release', 'Build a gem from a gemspec and push to rubygems.org', :tag => false)
13
- add_option('-t', '--tag', "Create a git tag and push --tags to origin. Defaults to #{options[:tag]}.") do |tag, options|
14
- options[:tag] = tag
15
- end
16
- @arguments = "gemspec - optional gemspec file, will use the first *.gemspec if not specified"
15
+ super 'release', 'Build a gem from a gemspec and push to rubygems.org'
16
+ option :tag, '-t', 'Create a git tag and push --tags to origin'
17
+ @arguments = "gemspec - optional gemspec file name, will use the first *.gemspec if not specified"
17
18
  @usage = "#{program_name} [gemspec]"
18
19
  end
19
20
 
@@ -22,7 +23,7 @@ class Gem::Commands::ReleaseCommand < Gem::Command
22
23
  push
23
24
  remove
24
25
  tag if options[:tag]
25
- say "All done, thanks buddy.\n"
26
+ say "All is good, thanks buddy.\n"
26
27
  end
27
28
 
28
29
  protected
@@ -39,7 +40,7 @@ class Gem::Commands::ReleaseCommand < Gem::Command
39
40
  `rm #{gem_filename}`
40
41
  say "Deleting left over gem file #{gem_filename}"
41
42
  end
42
-
43
+
43
44
  def tag
44
45
  TagCommand.new.invoke
45
46
  end
@@ -1,14 +1,13 @@
1
1
  require 'gem_release/helpers'
2
2
 
3
3
  class Gem::Commands::TagCommand < Gem::Command
4
- include GemRelease::Helpers
4
+ include GemRelease
5
+ include Helpers, CommandOptions
5
6
 
6
7
  attr_reader :arguments, :usage
7
8
 
8
9
  def initialize
9
10
  super 'tag', 'Create a git tag and push --tags to origin'
10
- @arguments = ''
11
- @usage = "#{program_name}"
12
11
  end
13
12
 
14
13
  def execute
@@ -1,6 +1,7 @@
1
1
  require 'rubygems/command_manager'
2
2
  require 'gem_release'
3
3
 
4
- Gem::CommandManager.instance.register_command :init
4
+ Gem::CommandManager.instance.register_command :gemspec
5
+ Gem::CommandManager.instance.register_command :bootstrap
5
6
  Gem::CommandManager.instance.register_command :release
6
7
  Gem::CommandManager.instance.register_command :tag
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sven Fuchs
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-04 00:00:00 +02:00
17
+ date: 2010-04-05 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -37,7 +37,8 @@ files:
37
37
  - lib/gem_release/templates/gemspec.erb
38
38
  - lib/gem_release/templates/version.erb
39
39
  - lib/gem_release/version.rb
40
- - lib/rubygems/commands/init_command.rb
40
+ - lib/rubygems/commands/bootstrap_command.rb
41
+ - lib/rubygems/commands/gemspec_command.rb
41
42
  - lib/rubygems/commands/release_command.rb
42
43
  - lib/rubygems/commands/tag_command.rb
43
44
  - lib/rubygems_plugin.rb