Blob of Rakefile (raw blob data)

1 require 'rubygems'
2 require 'rake'
3 require 'rake/clean'
4 require 'rake/testtask'
5 require 'rake/packagetask'
6 require 'rake/gempackagetask'
7 require 'rake/rdoctask'
8 require 'rake/contrib/rubyforgepublisher'
9 require 'fileutils'
10 require 'hoe'
11 begin
12 require 'spec/rake/spectask'
13 rescue LoadError
14 puts 'To use rspec for testing you must install rspec gem:'
15 puts '$ sudo gem install rspec'
16 exit
17 end
18
19 include FileUtils
20 require File.join(File.dirname(__FILE__), 'lib', 'piston', 'version')
21
22 AUTHOR = 'Francois Beausoleil' # can also be an array of Authors
23 EMAIL = "francois@teksol.info"
24 DESCRIPTION = "description of gem"
25 GEM_NAME = 'piston' # what ppl will type to install your gem
26
27 @config_file = "~/.rubyforge/user-config.yml"
28 @config = nil
29 def rubyforge_username
30 unless @config
31 begin
32 @config = YAML.load(File.read(File.expand_path(@config_file)))
33 rescue
34 puts <<-EOS
35 ERROR: No rubyforge config file found: #{@config_file}"
36 Run 'rubyforge setup' to prepare your env for access to Rubyforge
37 - See http://newgem.rubyforge.org/rubyforge.html for more details
38 EOS
39 exit
40 end
41 end
42 @rubyforge_username ||= @config["username"]
43 end
44
45 RUBYFORGE_PROJECT = 'piston' # The unix name for your project
46 HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
47 DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
48
49 NAME = "piston"
50 REV = nil
51 # UNCOMMENT IF REQUIRED:
52 # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
53 VERS = Piston::VERSION::STRING + (REV ? ".#{REV}" : "")
54 CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
55 RDOC_OPTS = ['--quiet', '--title', 'piston documentation',
56 "--opname", "index.html",
57 "--line-numbers",
58 "--main", "README",
59 "--inline-source"]
60
61 class Hoe
62 def extra_deps
63 @extra_deps.reject { |x| Array(x).first == 'hoe' }
64 end
65 end
66
67 # Generate all the Rake tasks
68 # Run 'rake -T' to see list of generated tasks (from gem root directory)
69 hoe = Hoe.new(GEM_NAME, VERS) do |p|
70 p.author = AUTHOR
71 p.description = DESCRIPTION
72 p.email = EMAIL
73 p.summary = DESCRIPTION
74 p.url = HOMEPATH
75 p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
76 p.test_globs = ["test/**/test_*.rb"]
77 p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
78
79 # == Optional
80 p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
81 p.extra_deps = [["open4", ">= 0.9.3"]]
82 #p.spec_extras = {} # A hash of extra values to set in the gemspec.
83 end
84
85 CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
86 PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
87 hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
88
89 desc 'Generate website files'
90 task :website_generate do
91 Dir['website/**/*.txt'].each do |txt|
92 sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
93 end
94 end
95
96 desc 'Upload website files to rubyforge'
97 task :website_upload do
98 host = "#{rubyforge_username}@rubyforge.org"
99 remote_dir = "/var/www/gforge-projects/#{PATH}/"
100 local_dir = 'website'
101 sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
102 end
103
104 desc 'Generate and upload website files'
105 task :website => [:website_generate, :website_upload, :publish_docs]
106
107 desc 'Release the website and new gem version'
108 task :deploy => [:check_version, :website, :release] do
109 puts "Remember to create SVN tag:"
110 puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
111 "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
112 puts "Suggested comment:"
113 puts "Tagging release #{CHANGES}"
114 end
115
116 desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
117 task :local_deploy => [:website_generate, :install_gem]
118
119 task :check_version do
120 unless ENV['VERSION']
121 puts 'Must pass a VERSION=x.y.z release version'
122 exit
123 end
124 unless ENV['VERSION'] == VERS
125 puts "Please update your version.rb to match the release version, currently #{VERS}"
126 exit
127 end
128 end
129
130 desc "Run the specs under spec/"
131 Spec::Rake::SpecTask.new do |t|
132 t.libs << File.dirname(__FILE__) + "/lib"
133 t.spec_opts = ['--options', "spec/spec.opts"]
134 t.spec_files = FileList['spec/*_spec.rb']
135 end
136
137 desc "Default task is to run specs"
138 task :default => :spec