gregwebs / module-import

selectively import methods from modules

module-import / Rakefile
5b003fbd » Greg Weber 2008-03-24 rake partiioning 1 $rubyforge_project = "'module import'"
2 $project = 'module-import'
3 $rcov_index_html = 'coverage/lib-module-import_rb.html'
f3a4e47f » Greg Weber 2008-03-10 rakefile 4
5b003fbd » Greg Weber 2008-03-24 rake partiioning 5 require 'tasks/helpers'
f3a4e47f » Greg Weber 2008-03-10 rakefile 6
7 def __DIR__; "#{File.dirname(__FILE__)}" end
df326359 » Greg Weber 2008-03-11 updated 8
f3a4e47f » Greg Weber 2008-03-10 rakefile 9 desc "test run all tests"
df326359 » Greg Weber 2008-03-11 updated 10 task :test => [:spec, 'test:readme', :rcov]
11
12 namespace :test do
13 # run README through xmp
14 desc "run README code through xmp filter"
15 task :readme do
16 cd_tmp do
17 example_file = "#{__DIR__}/example.rb"
18
19 File.write(example_file, (
b91cefe0 » Greg Weber 2008-03-12 import.rb => module-import.rb 20 File.read("#{__DIR__}/lib/module-import.rb") <<
df326359 » Greg Weber 2008-03-11 updated 21 File.readlines('../README').grep(/^ / ).
22 reject {|l| l =~ /^\s*require/ or l.include?('Error')}.
23 join ))
24
25 command = "ruby ../bin/xmpfilter -c #{example_file}"
26 Dir.chdir '/home/greg/src/head/lib' do
27 run "#{command}"
28 end
29 puts "README code successfully evaluated"
30 end
31 end
32 end
f3a4e47f » Greg Weber 2008-03-10 rakefile 33
72a07950 » Greg Weber 2008-11-01 update project tasks 34 namespace :readme do
35 desc "create html for website using coderay, use --silent option"
36 task :html do
37 rm_rf 'doc'
38 fail unless system 'rdoc --force-update --quiet README'
39
40 require 'hpricot'
41 require 'htmlentities'
42 doc = open( 'doc/files/README.html' ) { |f| Hpricot(f) }
43 # find example code
44 doc.at('#description').search('pre').
45 select {|elem| elem.inner_html =~ /class |module /}.each do |ex|
46 # add coderay and undo what rdoc has done in the example code
47 ex.swap("<coderay lang='ruby'>#{HTMLEntities.new.decode ex.inner_html}</coderay>")
48 end
49 puts doc.at('#description').to_html
50 end
51 end
52
53
f3a4e47f » Greg Weber 2008-03-10 rakefile 54 require 'rubygems'
55 require 'spec/rake/spectask'
56
816468f0 » Greg Weber 2008-03-08 initial commit 57 require 'rubygems'
58 require 'rake/gempackagetask'
59
60 spec = Gem::Specification.new do |s|
5b003fbd » Greg Weber 2008-03-24 rake partiioning 61 s.name = $project
62 s.rubyforge_project = $project
77b599eb » Greg Weber 2008-03-14 auto import of private modu... 63 s.version = "0.4.0"
816468f0 » Greg Weber 2008-03-08 initial commit 64 s.author = "Greg Weber"
65 s.email = "greg@gregweber.info"
5b003fbd » Greg Weber 2008-03-24 rake partiioning 66 s.homepage = "http://projects.gregweber.info/#{$project}"
816468f0 » Greg Weber 2008-03-08 initial commit 67 s.platform = Gem::Platform::RUBY
f5e34b73 » Greg Weber 2008-03-08 revised 68 s.summary = "selectively import methods from modules"
b91cefe0 » Greg Weber 2008-03-12 import.rb => module-import.rb 69 s.files = FileList.new('./**', '*/**') do |fl|
70 fl.exclude('pkg','pkg/*','tmp','tmp/*')
71 end
816468f0 » Greg Weber 2008-03-08 initial commit 72 s.require_path = "lib"
73 s.has_rdoc = true
74 s.extra_rdoc_files = ["README"]
75 end
76
77 Rake::GemPackageTask.new(spec) do |pkg|
78 pkg.need_tar = false
79 end
df326359 » Greg Weber 2008-03-11 updated 80
81 desc "run this once to set up the project"
82 task :setup do
83 cd_tmp do
84 unless File.exist? 'index.html'
85 File.write('index.html', <<-EOF
86 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
87 <html><head>
5b003fbd » Greg Weber 2008-03-24 rake partiioning 88 <meta http-equiv="REFRESH" content="0;url=http://projects.gregweber.info/#{$project}"></head>
df326359 » Greg Weber 2008-03-11 updated 89 </html>
90 EOF
91 )
92 end
5b003fbd » Greg Weber 2008-03-24 rake partiioning 93 run "scp index.html gregwebs@rubyforge.org:/var/www/gforge-projects/#{$project}"
df326359 » Greg Weber 2008-03-11 updated 94 end
95 end