Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 6428f03322e8cacb82ecb4a7b890fabec30a08cd Sven Fuchs committed Apr 3, 2010
Showing with 68 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +19 −0 gem-release.gemspec
  3. +3 −0 lib/gem_release/version.rb
  4. +45 −0 lib/rubygems_plugin.rb
1 .gitignore
@@ -0,0 +1 @@
+*.gem
19 gem-release.gemspec
@@ -0,0 +1,19 @@
+# encoding: utf-8
+
+require File.expand_path('../lib/gem_release/version', __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = 'gem-release'
+ s.version = GemRelease::VERSION
+ s.authors = ['Sven Fuchs']
+ s.email = 'svenfuchs@artweb-design.de'
+ s.homepage = 'http://github.com/svenfuchs/gem-release'
+ s.summary = 'Release your ruby gems with ease'
+ s.description = 'Release your ruby gems with ease. (What a bold statement for such a tiny plugin ...)'
+ s.files = Dir['{lib/**/*,[A-Z]*}']
+
+ s.platform = Gem::Platform::RUBY
+ s.require_path = 'lib'
+ s.rubyforge_project = '[none]'
+ s.required_rubygems_version = '>= 1.3.6'
+end
3 lib/gem_release/version.rb
@@ -0,0 +1,3 @@
+module GemRelease
+ VERSION = '0.0.1'
+end
45 lib/rubygems_plugin.rb
@@ -0,0 +1,45 @@
+require 'rubygems/command_manager'
+require 'rubygems/commands/build_command'
+require 'rubygems/commands/push_command'
+
+class Gem::Commands::ReleaseCommand < Gem::Command
+ def initialize
+ super 'release', 'Build a gem from a gemspec and push to rubygems.org'
+ end
+
+ def arguments # :nodoc:
+ "GEMSPEC_FILE optional (will use the first *.gemspec if not specified)"
+ end
+
+ def usage # :nodoc:
+ "#{program_name} [GEMSPEC_FILE]"
+ end
+
+ def execute
+ file_name = build
+ push(file_name)
+ end
+
+ def build
+ command = Gem::Commands::BuildCommand.new
+ command.handle_options([gemspec])
+ command.execute
+ command.load_gemspecs(gemspec).first.file_name
+ end
+
+ def push(filename)
+ command = Gem::Commands::PushCommand.new
+ command.handle_options([filename])
+ command.execute
+ end
+
+ def gemspec
+ @gemspec ||= begin
+ gemspec = Array(options[:args]).first
+ gemspec ||= Dir['*.gemspec'].first
+ gemspec || raise("No gemspec found or given.")
+ end
+ end
+end
+
+Gem::CommandManager.instance.register_command :release

0 comments on commit 6428f03

Please sign in to comment.