Skip to content
Browse files

get this on RakeGem. better release management.

  • Loading branch information...
1 parent 5431713 commit 6264e4c021161e901007a465f9befc13bdff34e2 @technoweenie technoweenie committed Dec 7, 2011
Showing with 232 additions and 28 deletions.
  1. +3 −0 .gitignore
  2. +125 −3 Rakefile
  3. +98 −20 github-markup.gemspec
  4. +6 −0 lib/github-markup.rb
  5. +0 −5 lib/github/markup/version.rb
View
3 .gitignore
@@ -1 +1,4 @@
*.pyc
+bin
+.bundle
+Gemfile.lock
View
128 Rakefile
@@ -1,11 +1,133 @@
+require 'rubygems'
+require 'rake'
+require 'date'
+
+#############################################################################
+#
+# Helper functions
+#
+#############################################################################
+
+def name
+ @name ||= Dir['*.gemspec'].first.split('.').first
+end
+
+def version
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
+end
+
+def date
+ Date.today.to_s
+end
+
+def rubyforge_project
+ name
+end
+
+def gemspec_file
+ "#{name}.gemspec"
+end
+
+def gem_file
+ "#{name}-#{version}.gem"
+end
+
+def replace_header(head, header_name)
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
+end
+
+#############################################################################
+#
+# Standard tasks
+#
+#############################################################################
+
task :default => :test
-desc "Run tests"
-task :test do
- Dir['test/**/*_test.rb'].each { |file| require file }
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/**/*_test.rb'
+ test.verbose = true
end
+desc "Open an irb session preloaded with this library"
+task :console do
+ sh "irb -rubygems -r ./lib/#{name}.rb"
+end
+
+#############################################################################
+#
+# Custom tasks (add your own tasks here)
+#
+#############################################################################
+
desc "Kick it"
task :kick do
exec "kicker -e rake test lib"
end
+
+#############################################################################
+#
+# Packaging tasks
+#
+#############################################################################
+
+desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
+task :release => :build do
+ unless `git branch` =~ /^\* master$/
+ puts "You must be on the master branch to release!"
+ exit!
+ end
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
+ sh "git tag v#{version}"
+ sh "git push origin master"
+ sh "git push origin v#{version}"
+ sh "gem push pkg/#{name}-#{version}.gem"
+end
+
+desc "Build #{gem_file} into the pkg directory"
+task :build => :gemspec do
+ sh "mkdir -p pkg"
+ sh "gem build #{gemspec_file}"
+ sh "mv #{gem_file} pkg"
+end
+
+desc "Generate #{gemspec_file}"
+task :gemspec => :validate do
+ # read spec file and split out manifest section
+ spec = File.read(gemspec_file)
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
+
+ # replace name version and date
+ replace_header(head, :name)
+ replace_header(head, :version)
+ replace_header(head, :date)
+ #comment this out if your rubyforge_project has a different name
+ replace_header(head, :rubyforge_project)
+
+ # determine file list from git ls-files
+ files = `git ls-files`.
+ split("\n").
+ sort.
+ reject { |file| file =~ /^\./ }.
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
+ map { |file| " #{file}" }.
+ join("\n")
+
+ # piece file back together and write
+ manifest = " s.files = %w[\n#{files}\n ]\n"
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
+ puts "Updated #{gemspec_file}"
+end
+
+desc "Validate #{gemspec_file}"
+task :validate do
+ unless Dir['VERSION*'].empty?
+ puts "A `VERSION` file at root level violates Gem best practices."
+ exit!
+ end
+end
+
View
118 github-markup.gemspec
@@ -1,25 +1,103 @@
-$LOAD_PATH.unshift 'lib'
-require "github/markup/version"
-
+## This is the rakegem gemspec template. Make sure you read and understand
+## all of the comments. Some sections require modification, and others can
+## be deleted if you don't need them. Once you understand the contents of
+## this file, feel free to delete any comments that begin with two hash marks.
+## You can find comprehensive Gem::Specification documentation, at
+## http://docs.rubygems.org/read/chapter/20
Gem::Specification.new do |s|
- s.name = "github-markup"
- s.version = GitHub::Markup::Version
- s.date = Time.now.strftime('%Y-%m-%d')
- s.summary = "The code GitHub uses to render README.markup"
- s.homepage = "http://github.com/github/markup"
- s.email = "chris@ozmm.org"
- s.authors = [ "Chris Wanstrath" ]
- s.has_rdoc = false
-
- s.files = %w( README.md Rakefile LICENSE )
- s.files += Dir.glob("lib/**/*")
- s.files += Dir.glob("bin/**/*")
- s.files += Dir.glob("man/**/*")
- s.files += Dir.glob("test/**/*")
-
-# s.executables = %w( github-markup )
- s.description = <<desc
+ s.specification_version = 2 if s.respond_to? :specification_version=
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.rubygems_version = '1.3.5'
+
+ ## Leave these as is they will be modified for you by the rake gemspec task.
+ ## If your rubyforge_project name is different, then edit it and comment out
+ ## the sub! line in the Rakefile
+ s.name = 'github-markup'
+ s.version = '0.7.0'
+ s.date = '2011-12-07'
+ s.rubyforge_project = 'github-markup'
+
+ ## Make sure your summary is short. The description may be as long
+ ## as you like.
+ s.summary = "The code GitHub uses to render README.markup"
+ s.description = <<desc
This gem is used by GitHub to render any fancy markup such as
Markdown, Textile, Org-Mode, etc. Fork it and add your own!
desc
+
+ ## List the primary authors. If there are a bunch of authors, it's probably
+ ## better to set the email to an email list or something. If you don't have
+ ## a custom homepage, consider using your GitHub URL or the like.
+ s.authors = ["Chris Wanstrath"]
+ s.email = 'chris@ozmm.org'
+ s.homepage = 'https://github.com/github/markup'
+
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
+ s.require_paths = %w[lib]
+
+ ## Specify any RDoc options here. You'll want to add your README and
+ ## LICENSE files to the extra_rdoc_files list.
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.extra_rdoc_files = %w[README.md LICENSE]
+
+ ## List your runtime dependencies here. Runtime dependencies are those
+ ## that are needed for an end user to actually USE your code.
+ #s.add_dependency('simple_uuid', "~> 0.1.2")
+
+ ## List your development dependencies here. Development dependencies are
+ ## those that are only needed during development
+ #s.add_development_dependency("test-unit", "~> 2.3.0")
+
+ ## Leave this section as-is. It will be automatically generated from the
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
+ # = MANIFEST =
+ s.files = %w[
+ Gemfile
+ HISTORY.md
+ LICENSE
+ README.md
+ Rakefile
+ bin/github-markup
+ github-markup.gemspec
+ lib/github/commands/asciidoc2html
+ lib/github/commands/asciidocapi.py
+ lib/github/commands/rest2html
+ lib/github/markup.rb
+ lib/github/markup/rdoc.rb
+ lib/github/markup/version.rb
+ lib/github/markups.rb
+ test/markup_test.rb
+ test/markups/README.asciidoc
+ test/markups/README.asciidoc.html
+ test/markups/README.creole
+ test/markups/README.creole.html
+ test/markups/README.markdown
+ test/markups/README.markdown.html
+ test/markups/README.mediawiki
+ test/markups/README.mediawiki.html
+ test/markups/README.noformat
+ test/markups/README.noformat.html
+ test/markups/README.org
+ test/markups/README.org.html
+ test/markups/README.pod
+ test/markups/README.pod.html
+ test/markups/README.rdoc
+ test/markups/README.rdoc.html
+ test/markups/README.rst
+ test/markups/README.rst.html
+ test/markups/README.rst.txt
+ test/markups/README.rst.txt.html
+ test/markups/README.textile
+ test/markups/README.textile.html
+ test/markups/README.txt
+ test/markups/README.txt.html
+ ]
+ # = MANIFEST =
+
+ ## Test files will be grabbed from the file list. Make sure the path glob
+ ## matches what you actually use.
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
end
+
View
6 lib/github-markup.rb
@@ -0,0 +1,6 @@
+module GitHub
+ module Markup
+ VERSION = '0.7.0'
+ Version = VERSION
+ end
+end
View
5 lib/github/markup/version.rb
@@ -1,5 +0,0 @@
-module GitHub
- module Markup
- Version = VERSION = '0.7.0'
- end
-end

0 comments on commit 6264e4c

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