Rakefile in contextr-0.0.3 vs Rakefile in contextr-0.1.0
- old
+ new
@@ -6,23 +6,52 @@
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'fileutils'
require 'hoe'
+begin
+ require 'spec/rake/spectask'
+rescue LoadError
+ puts 'To use rspec for testing you must install rspec gem:'
+ puts '$ sudo gem install rspec'
+ exit
+end
+
include FileUtils
require File.join(File.dirname(__FILE__), 'lib', 'contextr', 'version')
-AUTHOR = 'schmidt' # can also be an array of Authors
+AUTHOR = 'Gregor Schmidt' # can also be an array of Authors
EMAIL = "ruby@schmidtwisser.de"
DESCRIPTION = "The goal is to equip Ruby with an API to allow context-oriented programming."
GEM_NAME = 'contextr' # what ppl will type to install your gem
+
+@config_file = "~/.rubyforge/user-config.yml"
+@config = nil
+def rubyforge_username
+ unless @config
+ begin
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
+ rescue
+ puts <<-EOS
+ERROR: No rubyforge config file found: #{@config_file}"
+Run 'rubyforge setup' to prepare your env for access to Rubyforge
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
+ EOS
+ exit
+ end
+ end
+ @rubyforge_username ||= @config["username"]
+end
+
RUBYFORGE_PROJECT = 'contextr' # The unix name for your project
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
NAME = "contextr"
-REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
+REV = nil
+# UNCOMMENT IF REQUIRED:
+# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
VERS = ContextR::VERSION::STRING + (REV ? ".#{REV}" : "")
CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
RDOC_OPTS = ['--quiet', '--title', 'contextr documentation',
"--opname", "index.html",
"--line-numbers",
@@ -43,42 +72,52 @@
p.email = EMAIL
p.summary = DESCRIPTION
p.url = HOMEPATH
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
p.test_globs = ["test/**/test_*.rb"]
- p.clean_globs = CLEAN #An array of file patterns to delete on clean.
+ p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
# == Optional
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
end
+CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
+PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
+hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
desc 'Generate website files'
task :website_generate do
Dir['website/**/*.txt'].each do |txt|
sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
end
end
desc 'Upload website files to rubyforge'
task :website_upload do
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
- host = "#{config["username"]}@rubyforge.org"
- remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
- # remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
+ host = "#{rubyforge_username}@rubyforge.org"
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
local_dir = 'website'
- sh %{rsync -av --exclude=".*/" #{local_dir}/ #{host}:#{remote_dir}}
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
end
desc 'Generate and upload website files'
-task :website => [:website_generate, :website_upload]
+task :website => [:website_generate, :website_upload, :publish_docs]
desc 'Release the website and new gem version'
-task :deploy => [:check_version, :website, :release]
+task :deploy => [:check_version, :website, :release] do
+ puts "Remember to create SVN tag:"
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
+ puts "Suggested comment:"
+ puts "Tagging release #{CHANGES}"
+end
+desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
+task :local_deploy => [:website_generate, :install_gem]
+
task :check_version do
unless ENV['VERSION']
puts 'Must pass a VERSION=x.y.z release version'
exit
end
@@ -86,85 +125,13 @@
puts "Please update your version.rb to match the release version, currently #{VERS}"
exit
end
end
-#desc 'Submit the docs HTML files to RubyForge'
-#task :docs_publish => [ :docs ] do
-# config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
-# host = "#{config["username"]}@rubyforge.org"
-# remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/api"
-# local_dir = 'doc'
-# sh %{rsync -av --delete-excluded --exclude=".*/" #{local_dir}/ #{host}:#{remote_dir}}
-#end
-
-# Most of this code was taken from the Rubinius Rakefile.
-# Thanks for the help.
-
-ROOT = File.expand_path(File.dirname(__FILE__))
-
-def load_files(files)
- files.each do |path|
- begin
- require(path)
- rescue Object => e
- STDERR.puts "Unable to load #{path}. #{e.message} (#{e.class})"
- end
- end
+desc "Run the specs under spec/models"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_opts = ['--options', "spec/spec.opts"]
+ t.spec_files = FileList['spec/*_spec.rb']
end
-def require_files(files)
- files.each do |path|
- begin
- require(path)
- rescue Object => e
- STDERR.puts "Unable to load #{path}. #{e.message} (#{e.class})"
- end
- end
-end
-begin
- require 'spec/rake/spectask'
-rescue LoadError
- raise <<-EOM
-Unable to load spec/rake/spectask. RSpec is a requirement to build Rubinius.
-Please install RSpec before building (http://rspec.rubyforge.org).
- EOM
-end
-
-# Task class extensions
-paths = Dir[ File.join(File.dirname(__FILE__), 'rake/*') ]
-require_files(paths)
-#
-# Other tasks
-paths = Dir[ File.join(File.dirname(__FILE__), 'tasks/*') ]
-load_files(paths)
-
-desc "Run all specs and tests"
-task :default => [ :spec, :test ]
-
-task :spec => 'spec:all'
-
-# Generate all the spec tasks
-namespace :spec do
-
- spec_targets = %w(contextr core_ext)
-
- spec_targets.each do | group |
- spec_files = Dir[ File.join( File.dirname(__FILE__),
- "spec/#{group}/*_spec.rb") ]
-
- GroupSpecTask.new( group )
-
- namespace group do
- spec_files.each do | file |
- SpecificGroupSpecTask.new( File.basename( file, '_spec.rb'), group )
- end
- end
- end
-
- desc "Run all specs."
- task :all => spec_targets.collect! { | group | 'spec:' << group }
-end
-
-desc "Run all benchmarks - currently none"
-task :benchmark
-
+desc "Run specs and tests by default"
+task :default => [:spec, :test]