Skip to content

Commit

Permalink
Rationalised Rakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Feb 23, 2009
1 parent 8ef6ccb commit dbcb688
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 75 deletions.
6 changes: 6 additions & 0 deletions History.txt
@@ -1,3 +1,9 @@
== Edge

* 1 minor enhancement
* rationalised Rakefile


== 0.1.11 - 22 Feb 2009

* 2 minor enhancements
Expand Down
143 changes: 68 additions & 75 deletions Rakefile
Expand Up @@ -4,40 +4,21 @@ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base) and !$LOAD_PATH.includ

require 'spec/rake/spectask'
require 'spec/rake/verify_rcov'
require 'hanna/rdoctask'
require 'rake/gempackagetask'

$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
require 'pickle/version'

plugin_name = 'pickle'
PluginName = 'pickle'

task :default => [:spec]

plugins_base = File.expand_path(File.join(File.dirname(__FILE__), '..'))
cucumber_base = File.join(plugins_base, 'cucumber/lib')
if File.exists?(cucumber_base) && plugins_base =~ /\/vendor\/plugins$/ # if we're in rails app
$:.unshift(cucumber_base)
require 'cucumber/rake/task'

Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format progress -r features/step_definitions features"
end

namespace :features do
Cucumber::Rake::Task.new(:full) do |t|
t.cucumber_opts = '-r features/step_definitions features'
end
end
end

desc "Run the specs for #{plugin_name}"
desc "Run the specs for #{PluginName}"
Spec::Rake::SpecTask.new(:spec) do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ["--colour"]
end

desc "Generate RCov report for #{plugin_name}"
desc "Generate RCov report for #{PluginName}"
Spec::Rake::SpecTask.new(:rcov) do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.rcov = true
Expand All @@ -46,71 +27,83 @@ Spec::Rake::SpecTask.new(:rcov) do |t|
end

namespace :rcov do
desc "Verify RCov threshold for #{plugin_name}"
desc "Verify RCov threshold for #{PluginName}"
RCov::VerifyTask.new(:verify => :rcov) do |t|
t.threshold = 100.0
t.index_html = File.join(File.dirname(__FILE__), 'doc/coverage/index.html')
end
end

task :rdoc => :doc

desc "Generate rdoc for #{plugin_name}"
Rake::RDocTask.new(:doc) do |d|
d.rdoc_dir = 'doc'
d.main = 'README.rdoc'
d.title = "#{plugin_name} API Docs (#{`git log HEAD -1 --pretty=format:"%H"`[0..6]})"
d.rdoc_files.include('README.rdoc', 'History.txt', 'License.txt', 'Todo.txt').
include('lib/**/*.rb')
end
# cucumber features require an enclosing rails app
plugins_base = File.expand_path(File.join(File.dirname(__FILE__), '..'))
cucumber_base = File.join(plugins_base, 'cucumber/lib')
if File.exists?(cucumber_base) && plugins_base.ends_with?('/vendor/plugins') # if we're in rails app
$:.unshift(cucumber_base)
require 'cucumber/rake/task'

namespace :doc do
task :gh_pages => :doc do
`git branch -m gh-pages orig-gh-pages > /dev/null 2>&1`
`mv doc doctmp`
`git checkout -b gh-pages origin/gh-pages`
if `cat doc/index.html | grep "<title>"` != `cat doctmp/index.html | grep "<title>"`
`rm -rf doc`
`mv doctmp doc`
`git add doc`
`git commit -a -m "Update API docs"`
`git push`
else
`rm -rf doctmp`
desc "Run features for #{PluginName} (progress)"
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format progress -r features/step_definitions features"
end

desc "Run features for #{PluginName} (full output)"
namespace :features do
Cucumber::Rake::Task.new(:full) do |t|
t.cucumber_opts = '-r features/step_definitions features'
end
`git checkout master`
`git branch -D gh-pages`
`git branch -m orig-gh-pages gh-pages > /dev/null 2>&1`
end
end

task :cruise do
sh "garlic clean && garlic all"
Rake::Task['doc:gh_pages'].invoke
puts "The build is GOOD"
end
# the following optional tasks are for CI, gems and doc building
begin
require 'hanna/rdoctask'
require 'garlic/tasks'
require 'grancher/task'
require 'rake/gempackagetask'

task :cruise => ['garlic:all', 'doc:publish']

Rake::RDocTask.new(:doc) do |d|
d.options << '--all'
d.rdoc_dir = 'doc'
d.main = 'README.rdoc'
d.title = "#{PluginName} API docs"
d.rdoc_files.include('README.rdoc', 'History.txt', 'License.txt', 'Todo.txt', 'lib/**/*.rb')
end

spec = Gem::Specification.new do |s|
s.name = plugin_name
s.version = Pickle::Version::String
s.summary = "Easy model creation and reference in your cucumber features"
s.description = "Easy model creation and reference in your cucumber features"
s.author = "Ian White"
s.email = "ian.w.white@gmail.com"
s.homepage = "http://github.com/ianwhite/pickle/tree"
s.has_rdoc = true
s.rdoc_options << "--title" << "Pickle" << "--line-numbers"
s.test_files = FileList["spec/**/*_spec.rb"]
s.files = FileList["lib/**/*.rb", "rails_generators/**/*.rb", "License.txt", "README.rdoc", "Todo.txt", "History.txt"]
end
namespace :doc do
Grancher::Task.new(:publish => :doc) do |g|
g.keep 'index.html', '.gitignore'
g.directory 'doc', 'doc'
g.branch = 'gh-pages'
g.push_to = 'origin'
end
end

Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = true
p.need_zip = true
end
spec = Gem::Specification.new do |s|
s.name = "pickle"
s.version = Pickle::Version::String
s.summary = "Easy model creation and reference in your cucumber features"
s.description = "Easy model creation and reference in your cucumber features"
s.author = "Ian White"
s.email = "ian.w.white@gmail.com"
s.homepage = "http://github.com/ianwhite/pickle/tree"
s.has_rdoc = true
s.rdoc_options << "--title" << "Pickle" << "--line-numbers"
s.test_files = FileList["spec/**/*_spec.rb"]
s.files = FileList["lib/**/*.rb", "rails_generators/**/*.rb", "License.txt", "README.rdoc", "Todo.txt", "History.txt"]
end

Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = true
p.need_zip = true
end

desc "Generate pickle.gemspec file"
task :build do
File.open('pickle.gemspec', 'w') {|f| f.write spec.to_ruby }
desc "Generate pickle.gemspec file"
task :build do
File.open('pickle.gemspec', 'w') {|f| f.write spec.to_ruby }
end

rescue LoadError
end

0 comments on commit dbcb688

Please sign in to comment.