Skip to content

Commit 6264e4c

Browse files
committed
get this on RakeGem. better release management.
1 parent 5431713 commit 6264e4c

File tree

5 files changed

+232
-28
lines changed

5 files changed

+232
-28
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
*.pyc
2+
bin
3+
.bundle
4+
Gemfile.lock

Rakefile

Lines changed: 125 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,133 @@
1+
require 'rubygems'
2+
require 'rake'
3+
require 'date'
4+
5+
#############################################################################
6+
#
7+
# Helper functions
8+
#
9+
#############################################################################
10+
11+
def name
12+
@name ||= Dir['*.gemspec'].first.split('.').first
13+
end
14+
15+
def version
16+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18+
end
19+
20+
def date
21+
Date.today.to_s
22+
end
23+
24+
def rubyforge_project
25+
name
26+
end
27+
28+
def gemspec_file
29+
"#{name}.gemspec"
30+
end
31+
32+
def gem_file
33+
"#{name}-#{version}.gem"
34+
end
35+
36+
def replace_header(head, header_name)
37+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38+
end
39+
40+
#############################################################################
41+
#
42+
# Standard tasks
43+
#
44+
#############################################################################
45+
146
task :default => :test
247

3-
desc "Run tests"
4-
task :test do
5-
Dir['test/**/*_test.rb'].each { |file| require file }
48+
require 'rake/testtask'
49+
Rake::TestTask.new(:test) do |test|
50+
test.libs << 'lib' << 'test'
51+
test.pattern = 'test/**/*_test.rb'
52+
test.verbose = true
653
end
754

55+
desc "Open an irb session preloaded with this library"
56+
task :console do
57+
sh "irb -rubygems -r ./lib/#{name}.rb"
58+
end
59+
60+
#############################################################################
61+
#
62+
# Custom tasks (add your own tasks here)
63+
#
64+
#############################################################################
65+
866
desc "Kick it"
967
task :kick do
1068
exec "kicker -e rake test lib"
1169
end
70+
71+
#############################################################################
72+
#
73+
# Packaging tasks
74+
#
75+
#############################################################################
76+
77+
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
78+
task :release => :build do
79+
unless `git branch` =~ /^\* master$/
80+
puts "You must be on the master branch to release!"
81+
exit!
82+
end
83+
sh "git commit --allow-empty -a -m 'Release #{version}'"
84+
sh "git tag v#{version}"
85+
sh "git push origin master"
86+
sh "git push origin v#{version}"
87+
sh "gem push pkg/#{name}-#{version}.gem"
88+
end
89+
90+
desc "Build #{gem_file} into the pkg directory"
91+
task :build => :gemspec do
92+
sh "mkdir -p pkg"
93+
sh "gem build #{gemspec_file}"
94+
sh "mv #{gem_file} pkg"
95+
end
96+
97+
desc "Generate #{gemspec_file}"
98+
task :gemspec => :validate do
99+
# read spec file and split out manifest section
100+
spec = File.read(gemspec_file)
101+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
102+
103+
# replace name version and date
104+
replace_header(head, :name)
105+
replace_header(head, :version)
106+
replace_header(head, :date)
107+
#comment this out if your rubyforge_project has a different name
108+
replace_header(head, :rubyforge_project)
109+
110+
# determine file list from git ls-files
111+
files = `git ls-files`.
112+
split("\n").
113+
sort.
114+
reject { |file| file =~ /^\./ }.
115+
reject { |file| file =~ /^(rdoc|pkg)/ }.
116+
map { |file| " #{file}" }.
117+
join("\n")
118+
119+
# piece file back together and write
120+
manifest = " s.files = %w[\n#{files}\n ]\n"
121+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
122+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
123+
puts "Updated #{gemspec_file}"
124+
end
125+
126+
desc "Validate #{gemspec_file}"
127+
task :validate do
128+
unless Dir['VERSION*'].empty?
129+
puts "A `VERSION` file at root level violates Gem best practices."
130+
exit!
131+
end
132+
end
133+

github-markup.gemspec

Lines changed: 98 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,103 @@
1-
$LOAD_PATH.unshift 'lib'
2-
require "github/markup/version"
3-
1+
## This is the rakegem gemspec template. Make sure you read and understand
2+
## all of the comments. Some sections require modification, and others can
3+
## be deleted if you don't need them. Once you understand the contents of
4+
## this file, feel free to delete any comments that begin with two hash marks.
5+
## You can find comprehensive Gem::Specification documentation, at
6+
## http://docs.rubygems.org/read/chapter/20
47
Gem::Specification.new do |s|
5-
s.name = "github-markup"
6-
s.version = GitHub::Markup::Version
7-
s.date = Time.now.strftime('%Y-%m-%d')
8-
s.summary = "The code GitHub uses to render README.markup"
9-
s.homepage = "http://github.com/github/markup"
10-
s.email = "[email protected]"
11-
s.authors = [ "Chris Wanstrath" ]
12-
s.has_rdoc = false
13-
14-
s.files = %w( README.md Rakefile LICENSE )
15-
s.files += Dir.glob("lib/**/*")
16-
s.files += Dir.glob("bin/**/*")
17-
s.files += Dir.glob("man/**/*")
18-
s.files += Dir.glob("test/**/*")
19-
20-
# s.executables = %w( github-markup )
21-
s.description = <<desc
8+
s.specification_version = 2 if s.respond_to? :specification_version=
9+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10+
s.rubygems_version = '1.3.5'
11+
12+
## Leave these as is they will be modified for you by the rake gemspec task.
13+
## If your rubyforge_project name is different, then edit it and comment out
14+
## the sub! line in the Rakefile
15+
s.name = 'github-markup'
16+
s.version = '0.7.0'
17+
s.date = '2011-12-07'
18+
s.rubyforge_project = 'github-markup'
19+
20+
## Make sure your summary is short. The description may be as long
21+
## as you like.
22+
s.summary = "The code GitHub uses to render README.markup"
23+
s.description = <<desc
2224
This gem is used by GitHub to render any fancy markup such as
2325
Markdown, Textile, Org-Mode, etc. Fork it and add your own!
2426
desc
27+
28+
## List the primary authors. If there are a bunch of authors, it's probably
29+
## better to set the email to an email list or something. If you don't have
30+
## a custom homepage, consider using your GitHub URL or the like.
31+
s.authors = ["Chris Wanstrath"]
32+
s.email = '[email protected]'
33+
s.homepage = 'https://github.com/github/markup'
34+
35+
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
36+
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
37+
s.require_paths = %w[lib]
38+
39+
## Specify any RDoc options here. You'll want to add your README and
40+
## LICENSE files to the extra_rdoc_files list.
41+
s.rdoc_options = ["--charset=UTF-8"]
42+
s.extra_rdoc_files = %w[README.md LICENSE]
43+
44+
## List your runtime dependencies here. Runtime dependencies are those
45+
## that are needed for an end user to actually USE your code.
46+
#s.add_dependency('simple_uuid', "~> 0.1.2")
47+
48+
## List your development dependencies here. Development dependencies are
49+
## those that are only needed during development
50+
#s.add_development_dependency("test-unit", "~> 2.3.0")
51+
52+
## Leave this section as-is. It will be automatically generated from the
53+
## contents of your Git repository via the gemspec task. DO NOT REMOVE
54+
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
55+
# = MANIFEST =
56+
s.files = %w[
57+
Gemfile
58+
HISTORY.md
59+
LICENSE
60+
README.md
61+
Rakefile
62+
bin/github-markup
63+
github-markup.gemspec
64+
lib/github/commands/asciidoc2html
65+
lib/github/commands/asciidocapi.py
66+
lib/github/commands/rest2html
67+
lib/github/markup.rb
68+
lib/github/markup/rdoc.rb
69+
lib/github/markup/version.rb
70+
lib/github/markups.rb
71+
test/markup_test.rb
72+
test/markups/README.asciidoc
73+
test/markups/README.asciidoc.html
74+
test/markups/README.creole
75+
test/markups/README.creole.html
76+
test/markups/README.markdown
77+
test/markups/README.markdown.html
78+
test/markups/README.mediawiki
79+
test/markups/README.mediawiki.html
80+
test/markups/README.noformat
81+
test/markups/README.noformat.html
82+
test/markups/README.org
83+
test/markups/README.org.html
84+
test/markups/README.pod
85+
test/markups/README.pod.html
86+
test/markups/README.rdoc
87+
test/markups/README.rdoc.html
88+
test/markups/README.rst
89+
test/markups/README.rst.html
90+
test/markups/README.rst.txt
91+
test/markups/README.rst.txt.html
92+
test/markups/README.textile
93+
test/markups/README.textile.html
94+
test/markups/README.txt
95+
test/markups/README.txt.html
96+
]
97+
# = MANIFEST =
98+
99+
## Test files will be grabbed from the file list. Make sure the path glob
100+
## matches what you actually use.
101+
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
25102
end
103+

lib/github-markup.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module GitHub
2+
module Markup
3+
VERSION = '0.7.0'
4+
Version = VERSION
5+
end
6+
end

lib/github/markup/version.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)