Skip to content
This repository was archived by the owner on May 1, 2018. It is now read-only.

Commit d8bf0eb

Browse files
committed
Massive cleanup in gem-related rake tasks.
1 parent c8ceb3e commit d8bf0eb

File tree

2 files changed

+37
-66
lines changed

2 files changed

+37
-66
lines changed

git_remote_branch.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- encoding: utf-8 -*-
22
$:.push File.expand_path("../lib", __FILE__)
3+
require 'version'
34

45
Gem::Specification.new do |s|
5-
s.name = "git_remote_branch"
6-
s.version = '0.3.0'
6+
s.name = GitRemoteBranch::NAME
7+
s.version = GitRemoteBranch::VERSION::STRING
78
s.platform = Gem::Platform::RUBY
89
s.authors = ["Mathieu Martin", "Carl Mercier"]
910
s.email = "webmat@gmail.com"
@@ -15,12 +16,11 @@ Gem::Specification.new do |s|
1516
s.test_files = `git ls-files -- test/*`.split("\n")
1617
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
1718
s.require_paths = ["lib"]
18-
19+
1920
s.add_development_dependency "rake"
2021
s.add_development_dependency "rdoc"
2122
s.add_development_dependency 'test-unit'
2223
s.add_development_dependency 'shoulda'
2324
s.add_development_dependency 'mocha'
2425
s.add_dependency 'rainbow'
25-
s.add_dependency 'colored'
2626
end

tasks/gem.rake

Lines changed: 33 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,58 @@
11
require 'yaml'
22

3-
require 'rubygems/package_task'
3+
gem_name = GitRemoteBranch::NAME
4+
version = GitRemoteBranch::VERSION::STRING
5+
gem_file = "#{gem_name}-#{version}.gem"
46

5-
spec = Gem::Specification.new do |s|
6-
s.name = GitRemoteBranch::NAME.dup
7-
s.version = GitRemoteBranch::VERSION::STRING.dup
8-
s.summary = "git_remote_branch eases the interaction with remote branches"
9-
s.description = "git_remote_branch is a learning tool to ease the interaction with " +
10-
"remote branches in simple situations."
11-
12-
s.authors = ['Mathieu Martin', 'Carl Mercier']
13-
s.email = "webmat@gmail.com"
14-
s.homepage = "http://github.com/webmat/git_remote_branch"
15-
s.rubyforge_project = 'grb'
16-
17-
s.has_rdoc = true
18-
s.extra_rdoc_files << 'README.rdoc'
19-
s.rdoc_options << '--main' << 'README.rdoc' << '--exclude' << 'lib'
7+
tag_command = "git tag -m 'Tagging version #{version}' -a v#{version}"
8+
push_tags_command = 'git push --tags'
209

21-
s.test_files = Dir['test/**/*'].reject{|f| f =~ /test_runs/}
22-
s.files = Dir['**/*'].reject{|f| f =~ /\Apkg|\Acoverage|\Ardoc|test_runs|\.gemspec\Z/}
10+
task :tag_warn do
11+
puts <<-TAG
12+
#{"*" * 40}
13+
Don't forget to tag the release:
2314
24-
s.executable = 'grb'
25-
s.bindir = "bin"
26-
s.require_path = "lib"
15+
#{tag_command}
16+
#{push_tags_command}
17+
or
18+
run rake tag tag:push
2719
28-
s.add_dependency( 'rainbow', '>= 1.0.1' )
20+
#{"*" * 40}
21+
TAG
2922
end
3023

31-
#Creates clobber_package, gem, package and repackage tasks
32-
#Note on clobber_package: fortunately, this will clobber the CODE package
33-
Gem::PackageTask.new(spec) do |p|
34-
p.gem_spec = spec
24+
task :tag do
25+
sh tag_command
26+
puts "Upload tags to repo with '#{push_tags_command}'"
3527
end
3628

37-
TAG_COMMAND = "git tag -m 'Tagging version #{GitRemoteBranch::VERSION::STRING}' -a v#{GitRemoteBranch::VERSION::STRING}"
38-
push_tags_command = 'git push --tags'
39-
task :tag_warn do
40-
puts "*" * 40,
41-
"Don't forget to tag the release:",
42-
'',
43-
" " + TAG_COMMAND,
44-
'',
45-
"or run rake tag",
46-
"*" * 40
29+
namespace :tag do
30+
task :push do
31+
sh push_tags_command
32+
end
4733
end
48-
task :tag do
49-
sh TAG_COMMAND
50-
puts "Upload tags to repo with '#{push_tags_command}'"
34+
35+
desc "Build gem and put it in pkg/"
36+
task :gem => [:test, :tag_warn] do
37+
sh "gem build #{gem_name}.gemspec && mv #{gem_file} pkg/"
5138
end
52-
task :gem => :tag_warn
5339

5440
namespace :gem do
5541
desc 'Upload gem to rubygems.org'
5642
task :publish => :gem do
57-
sh "gem push pkg/#{spec.full_name}.gem"
43+
sh "gem push pkg/#{gem_file}"
5844
end
5945

60-
desc 'Install the gem built locally'
61-
task :install => [:clean, :gem] do
62-
sh "gem install pkg/#{spec.full_name}.gem"
46+
desc 'Install the last gem built locally'
47+
task :install do
48+
sh "gem install pkg/#{gem_file}"
6349
end
6450

65-
desc "Uninstall version #{GitRemoteBranch::VERSION::STRING} of the gem"
51+
desc "Uninstall version #{version} of the gem"
6652
task :uninstall do
67-
sh "gem uninstall -v #{GitRemoteBranch::VERSION::STRING} -x #{GitRemoteBranch::NAME}"
53+
sh "gem uninstall -v #{version} -x #{gem_name}"
6854
end
6955

7056
desc "Build and publish the gem, tag the commit and push the tags in one command"
71-
task :feeling_lucky => [:gem, :publish, :tag] do
72-
sh push_tags_command
73-
end
74-
75-
if WINDOWS
76-
win_spec = spec.dup
77-
win_spec.platform = Gem::Platform::CURRENT
78-
win_spec.add_dependency( 'win32console', '~> 1.1' ) # Missing dependency in the 'colored' gem
79-
80-
desc "Generate the Windows version of the gem"
81-
namespace :windows do
82-
Rake::GemPackageTask.new(win_spec) do |p|
83-
p.gem_spec = win_spec
84-
end
85-
end
86-
end
57+
task :feeling_lucky => [:gem, :publish, :tag, 'tag:push']
8758
end

0 commit comments

Comments
 (0)