Rakefile 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. # Rakefile for rake -*- ruby -*-
  2. # Copyright 2004, 2005, 2006 by Jim Weirich (jim@weirichhouse.org).
  3. # All rights reserved.
  4. # Permission is granted for use, copying, modification, distribution,
  5. # and distribution of modified versions of this work as long as the
  6. # above copyright notice is included.
  7. require 'rake/clean'
  8. require 'rake/testtask'
  9. require 'rake/rdoctask'
  10. begin
  11. require 'rubygems'
  12. require 'rake/gempackagetask'
  13. rescue Exception
  14. nil
  15. end
  16. # Determine the current version of the software
  17. CLOBBER.include('pkg')
  18. CURRENT_VERSION = '3.0.0'
  19. PKG_VERSION = ENV['REL'] ? ENV['REL'] : CURRENT_VERSION
  20. SRC_RB = FileList['lib/**/*.rb']
  21. # The default task is run if rake is given no explicit arguments.
  22. desc "Default Task"
  23. task :default => :test_all
  24. # Test Tasks ---------------------------------------------------------
  25. desc "Run all tests"
  26. task :test_all => [:test_units]
  27. task :ta => [:test_all]
  28. task :tu => [:test_units]
  29. Rake::TestTask.new("test_units") do |t|
  30. t.test_files = FileList['test/test*.rb']
  31. t.libs << "."
  32. t.verbose = false
  33. end
  34. # Create a task to build the RDOC documentation tree.
  35. rd = Rake::RDocTask.new("rdoc") { |rdoc|
  36. rdoc.rdoc_dir = 'html'
  37. rdoc.title = "Builder for Markup"
  38. rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
  39. rdoc.rdoc_files.include('lib/**/*.rb', '[A-Z]*', 'doc/**/*.rdoc')
  40. rdoc.template = 'doc/jamis.rb'
  41. }
  42. # ====================================================================
  43. # Create a task that will package the Rake software into distributable
  44. # gem files.
  45. PKG_FILES = FileList[
  46. 'lib/**/*.rb',
  47. 'test/**/*.rb',
  48. 'scripts/**/*.rb'
  49. ]
  50. PKG_FILES.exclude('test/testcssbuilder.rb')
  51. PKG_FILES.exclude('lib/builder/css.rb')
  52. BLANKSLATE_FILES = FileList[
  53. 'lib/blankslate.rb',
  54. 'test/test_blankslate.rb'
  55. ]
  56. if ! defined?(Gem)
  57. puts "Package Target requires RubyGEMs"
  58. else
  59. spec = Gem::Specification.new do |s|
  60. #### Basic information.
  61. s.name = 'builder'
  62. s.version = PKG_VERSION
  63. s.summary = "Builders for MarkUp."
  64. s.description = %{\
  65. Builder provides a number of builder objects that make creating structured data
  66. simple to do. Currently the following builder objects are supported:
  67. * XML Markup
  68. * XML Events
  69. }
  70. s.files = PKG_FILES.to_a
  71. s.require_path = 'lib'
  72. s.autorequire = 'builder'
  73. s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
  74. s.has_rdoc = true
  75. s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
  76. s.rdoc_options <<
  77. '--title' << 'Builder -- Easy XML Building' <<
  78. '--main' << 'README.rdoc' <<
  79. '--line-numbers'
  80. s.author = "Jim Weirich"
  81. s.email = "jim@weirichhouse.org"
  82. s.homepage = "http://onestepback.org"
  83. end
  84. blankslate_spec = Gem::Specification.new do |s|
  85. #### Basic information.
  86. s.name = 'blankslate'
  87. s.version = PKG_VERSION
  88. s.summary = "Blank Slate base class."
  89. s.description = %{\
  90. BlankSlate provides a base class where almost all of the methods from Object and
  91. Kernel have been removed. This is useful when providing proxy object and other
  92. classes that make heavy use of method_missing.
  93. }
  94. s.files = BLANKSLATE_FILES.to_a
  95. s.require_path = 'lib'
  96. s.autorequire = 'builder'
  97. s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
  98. s.has_rdoc = true
  99. s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
  100. s.rdoc_options <<
  101. '--title' << 'BlankSlate -- Base Class for building proxies.' <<
  102. '--main' << 'README.rdoc' <<
  103. '--line-numbers'
  104. s.author = "Jim Weirich"
  105. s.email = "jim@weirichhouse.org"
  106. s.homepage = "http://onestepback.org"
  107. end
  108. namespace 'builder' do
  109. Rake::GemPackageTask.new(spec) do |t|
  110. t.need_tar = true
  111. end
  112. end
  113. namespace 'blankslate' do
  114. Rake::GemPackageTask.new(blankslate_spec) do |t|
  115. t.need_tar = true
  116. end
  117. end
  118. task :package => ['builder:package', 'blankslate:package']
  119. end
  120. desc "Look for Debugging print lines"
  121. task :dbg do
  122. FileList['**/*.rb'].egrep /\bDBG|\bbreakpoint\b/
  123. end
  124. # RCov ---------------------------------------------------------------
  125. begin
  126. require 'rcov/rcovtask'
  127. Rcov::RcovTask.new do |t|
  128. t.libs << "test"
  129. t.rcov_opts = [
  130. '-xRakefile', '--text-report'
  131. ]
  132. t.test_files = FileList[
  133. 'test/test*.rb'
  134. ]
  135. t.output_dir = 'coverage'
  136. t.verbose = true
  137. end
  138. rescue LoadError
  139. # No rcov available
  140. end
  141. # Tags file ----------------------------------------------------------
  142. namespace "tags" do
  143. desc "Create a TAGS file"
  144. task :emacs => "TAGS"
  145. TAGS = 'xctags -e'
  146. file "TAGS" => SRC_RB do
  147. puts "Makings TAGS"
  148. sh "#{TAGS} #{SRC_RB}", :verbose => false
  149. end
  150. end
  151. # --------------------------------------------------------------------
  152. # Creating a release
  153. def announce(msg='')
  154. STDERR.puts msg
  155. end
  156. desc "Make a new release"
  157. task :release => [
  158. :prerelease,
  159. :clobber,
  160. :test_all,
  161. :update_version,
  162. :package,
  163. :tag] do
  164. announce
  165. announce "**************************************************************"
  166. announce "* Release #{PKG_VERSION} Complete."
  167. announce "* Packages ready to upload."
  168. announce "**************************************************************"
  169. announce
  170. end
  171. # Validate that everything is ready to go for a release.
  172. task :prerelease do
  173. announce
  174. announce "**************************************************************"
  175. announce "* Making RubyGem Release #{PKG_VERSION}"
  176. announce "* (current version #{CURRENT_VERSION})"
  177. announce "**************************************************************"
  178. announce
  179. # Is a release number supplied?
  180. unless ENV['REL']
  181. fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
  182. end
  183. # Is the release different than the current release.
  184. # (or is REUSE set?)
  185. if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
  186. fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
  187. end
  188. # Are all source files checked in?
  189. if ENV['RELTEST']
  190. announce "Release Task Testing, skipping checked-in file test"
  191. else
  192. announce "Checking for unchecked-in files..."
  193. data = `cvs -q update`
  194. unless data =~ /^$/
  195. fail "CVS update is not clean ... do you have unchecked-in files?"
  196. end
  197. announce "No outstanding checkins found ... OK"
  198. end
  199. end
  200. task :update_version => [:prerelease] do
  201. if PKG_VERSION == CURRENT_VERSION
  202. announce "No version change ... skipping version update"
  203. else
  204. announce "Updating Builder version to #{PKG_VERSION}"
  205. open("Rakefile") do |rakein|
  206. open("Rakefile.new", "w") do |rakeout|
  207. rakein.each do |line|
  208. if line =~ /^CURRENT_VERSION\s*=\s*/
  209. rakeout.puts "CURRENT_VERSION = '#{PKG_VERSION}'"
  210. else
  211. rakeout.puts line
  212. end
  213. end
  214. end
  215. end
  216. mv "Rakefile.new", "Rakefile"
  217. if ENV['RELTEST']
  218. announce "Release Task Testing, skipping commiting of new version"
  219. else
  220. sh "cvs commit -m \"Updated to version #{PKG_VERSION}\" Rakefile"
  221. end
  222. end
  223. end
  224. desc "Tag all the CVS files with the latest release number (REL=x.y.z)"
  225. task :tag => [:prerelease] do
  226. reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
  227. reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
  228. announce "Tagging CVS with [#{reltag}]"
  229. if ENV['RELTEST']
  230. announce "Release Task Testing, skipping CVS tagging"
  231. else
  232. sh %{cvs tag #{reltag}}
  233. end
  234. end
  235. desc "Install the jamis RDoc template"
  236. task :install_jamis_template do
  237. require 'rbconfig'
  238. dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
  239. fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
  240. install "doc/jamis.rb", dest_dir, :verbose => true
  241. end