Skip to content
Browse files

Massive cleanup in gem-related rake tasks.

  • Loading branch information...
1 parent c8ceb3e commit d8bf0eb3dc3fca81f63d603eb9cfb16efbe26a4f @webmat committed Dec 14, 2011
Showing with 37 additions and 66 deletions.
  1. +4 −4 git_remote_branch.gemspec
  2. +33 −62 tasks/gem.rake
View
8 git_remote_branch.gemspec
@@ -1,9 +1,10 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
+require 'version'
Gem::Specification.new do |s|
- s.name = "git_remote_branch"
- s.version = '0.3.0'
+ s.name = GitRemoteBranch::NAME
+ s.version = GitRemoteBranch::VERSION::STRING
s.platform = Gem::Platform::RUBY
s.authors = ["Mathieu Martin", "Carl Mercier"]
s.email = "webmat@gmail.com"
@@ -15,12 +16,11 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- test/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
-
+
s.add_development_dependency "rake"
s.add_development_dependency "rdoc"
s.add_development_dependency 'test-unit'
s.add_development_dependency 'shoulda'
s.add_development_dependency 'mocha'
s.add_dependency 'rainbow'
- s.add_dependency 'colored'
end
View
95 tasks/gem.rake
@@ -1,87 +1,58 @@
require 'yaml'
-require 'rubygems/package_task'
+gem_name = GitRemoteBranch::NAME
+version = GitRemoteBranch::VERSION::STRING
+gem_file = "#{gem_name}-#{version}.gem"
-spec = Gem::Specification.new do |s|
- s.name = GitRemoteBranch::NAME.dup
- s.version = GitRemoteBranch::VERSION::STRING.dup
- s.summary = "git_remote_branch eases the interaction with remote branches"
- s.description = "git_remote_branch is a learning tool to ease the interaction with " +
- "remote branches in simple situations."
-
- s.authors = ['Mathieu Martin', 'Carl Mercier']
- s.email = "webmat@gmail.com"
- s.homepage = "http://github.com/webmat/git_remote_branch"
- s.rubyforge_project = 'grb'
-
- s.has_rdoc = true
- s.extra_rdoc_files << 'README.rdoc'
- s.rdoc_options << '--main' << 'README.rdoc' << '--exclude' << 'lib'
+tag_command = "git tag -m 'Tagging version #{version}' -a v#{version}"
+push_tags_command = 'git push --tags'
- s.test_files = Dir['test/**/*'].reject{|f| f =~ /test_runs/}
- s.files = Dir['**/*'].reject{|f| f =~ /\Apkg|\Acoverage|\Ardoc|test_runs|\.gemspec\Z/}
+task :tag_warn do
+ puts <<-TAG
+#{"*" * 40}
+Don't forget to tag the release:
- s.executable = 'grb'
- s.bindir = "bin"
- s.require_path = "lib"
+ #{tag_command}
+ #{push_tags_command}
+or
+ run rake tag tag:push
- s.add_dependency( 'rainbow', '>= 1.0.1' )
+#{"*" * 40}
+TAG
end
-#Creates clobber_package, gem, package and repackage tasks
-#Note on clobber_package: fortunately, this will clobber the CODE package
-Gem::PackageTask.new(spec) do |p|
- p.gem_spec = spec
+task :tag do
+ sh tag_command
+ puts "Upload tags to repo with '#{push_tags_command}'"
end
-TAG_COMMAND = "git tag -m 'Tagging version #{GitRemoteBranch::VERSION::STRING}' -a v#{GitRemoteBranch::VERSION::STRING}"
-push_tags_command = 'git push --tags'
-task :tag_warn do
- puts "*" * 40,
- "Don't forget to tag the release:",
- '',
- " " + TAG_COMMAND,
- '',
- "or run rake tag",
- "*" * 40
+namespace :tag do
+ task :push do
+ sh push_tags_command
+ end
end
-task :tag do
- sh TAG_COMMAND
- puts "Upload tags to repo with '#{push_tags_command}'"
+
+desc "Build gem and put it in pkg/"
+task :gem => [:test, :tag_warn] do
+ sh "gem build #{gem_name}.gemspec && mv #{gem_file} pkg/"
end
-task :gem => :tag_warn
namespace :gem do
desc 'Upload gem to rubygems.org'
task :publish => :gem do
- sh "gem push pkg/#{spec.full_name}.gem"
+ sh "gem push pkg/#{gem_file}"
end
- desc 'Install the gem built locally'
- task :install => [:clean, :gem] do
- sh "gem install pkg/#{spec.full_name}.gem"
+ desc 'Install the last gem built locally'
+ task :install do
+ sh "gem install pkg/#{gem_file}"
end
- desc "Uninstall version #{GitRemoteBranch::VERSION::STRING} of the gem"
+ desc "Uninstall version #{version} of the gem"
task :uninstall do
- sh "gem uninstall -v #{GitRemoteBranch::VERSION::STRING} -x #{GitRemoteBranch::NAME}"
+ sh "gem uninstall -v #{version} -x #{gem_name}"
end
desc "Build and publish the gem, tag the commit and push the tags in one command"
- task :feeling_lucky => [:gem, :publish, :tag] do
- sh push_tags_command
- end
-
- if WINDOWS
- win_spec = spec.dup
- win_spec.platform = Gem::Platform::CURRENT
- win_spec.add_dependency( 'win32console', '~> 1.1' ) # Missing dependency in the 'colored' gem
-
- desc "Generate the Windows version of the gem"
- namespace :windows do
- Rake::GemPackageTask.new(win_spec) do |p|
- p.gem_spec = win_spec
- end
- end
- end
+ task :feeling_lucky => [:gem, :publish, :tag, 'tag:push']
end

0 comments on commit d8bf0eb

Please sign in to comment.
Something went wrong with that request. Please try again.