pivotal / erector

A builder-like widget html generation framework.

This URL has Read+Write access

erector / Rakefile
100644 133 lines (113 sloc) 4.16 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require './tasks/hoex.rb' # Alex's patched version of Hoe
 
def rails_root
  "#{File.dirname(__FILE__)}/spec/rails_root"
end
 
dir = File.dirname(__FILE__)
$: << "#{dir}/lib"
require "erector/version"
 
gem_definition = lambda do |s|
  s.name = "erector"
  s.summary = "Html Builder library."
  s.email = "erector@googlegroups.com"
  s.description = "Html Builder library."
  specs = Dir.glob("spec/**/*").reject{|file| file =~ %r{^spec/rails_root}}
  s.files = ["lib/**/*", "README.txt", "VERSION.yml", "bin/erector", specs]
  s.test_files = specs
end
 
begin
  require 'jeweler'
  Jeweler::Tasks.new do |s|
    gem_definition.call(s)
    s.homepage = "http://erector.rubyforge.org/"
    s.authors = [
      "Alex Chaffee",
      "Brian Takita",
      "Jeff Dean",
      "Jim Kingdon",
    ]
    s.add_dependency 'treetop', ">= 1.2.3"
    s.rubyforge_project = "erector"
  end
rescue LoadError
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end
 
 
RAILS_PATH = "spec/rails_root/vendor/rails"
Hoe.new("erector", Erector::VERSION) do |hoe|
  gem_definition.call(hoe)
  hoe.developer("Pivotal Labs", "pivotallabsopensource@googlegroups.com")
  hoe.rdoc_dir = "rdoc"
  hoe.remote_rdoc_dir = "rdoc"
 
  # Many of these options are based on what will work with rubyforge and
  # groups and permissions
  hoe.rsync_args = "-rlv --delete --inplace --exclude .svn"
end
Hoe::remove_tasks("audit", "check_manifest", "post_blog", "multi", "test", "test_deps", "docs")
 
EDGE_PATH = "spec/rails_root/vendor/rails_versions/edge"
 
desc "Default: run tests"
task :default => :spec
 
task :test => :spec
 
task :cruise => [:geminstaller, :install_dependencies, :switch_to_rails_version_tag, :test]
 
task :geminstaller do
  require 'geminstaller'
  GemInstaller.run('--sudo --exceptions') || raise("GemInstaller failed")
end
 
desc "Run the specs for the erector plugin"
task :spec do
  unless File.exists?("#{rails_root}/vendor/rails/railties/lib/initializer.rb")
    warn "Rails not cloned into #{rails_root}. Installing dependencies."
    Rake.application[:install_dependencies].invoke
  end
  require "spec/spec_suite"
  SpecSuite.all
end
 
desc "Build the web site from the .rb files in web/"
task :web do
  dir = File.dirname(__FILE__)
  files = Dir["web/*.rb"] - ["web/page.rb", "web/sidebar.rb", "web/clickable_li.rb"]
  require 'erector'
  require 'erector/erect'
  Erector::Widget.prettyprint_default = true
  Erector::Erect.new(["--to-html", *files]).run
end
 
desc "Generate rdoc"
task :docs do
  FileUtils.rm_rf("rdoc")
  options = %w(-o rdoc --inline-source --main README.txt)
  options << "-t \"Erector #{Erector::VERSION}\""
  options << '-d' if RUBY_PLATFORM !~ /win32/ and `which dot` =~ /\/dot/ and not ENV['NODOT']
  system "rdoc #{options.join(" ")} lib bin README.txt"
end
 
desc "Install dependencies to run the build. This task uses Git."
task(:install_dependencies) do
  require "lib/erector/rails/rails_version"
  FileUtils.rm_rf(RAILS_PATH)
  system("git clone git://github.com/rails/rails.git #{RAILS_PATH}") || raise("Git clone of Rails failed")
  Rake.application[:switch_to_rails_version_tag].invoke
end
 
desc "Refreshes the Rails versions from edge git repo"
task(:switch_to_rails_version_tag) do
  require "lib/erector/rails/rails_version"
  Dir.chdir(RAILS_PATH) do
    system("git fetch origin")
    system("git checkout #{Erector::Rails::RAILS_VERSION_TAG}")
  end
end
 
desc "Updates the dependencies to run the build. This task uses Git."
task(:update_dependencies) do
  system "cd #{RAILS_PATH}; git fetch origin"
end
 
desc "Regenerate unicode.rb from UnicodeData.txt from unicode.org. Only needs to be run when there is a new version of the Unicode specification"
task(:build_unicode) do
  require 'lib/erector/unicode_builder'
  builder = Erector::UnicodeBuilder.new(
    File.open("/usr/lib/perl5/5.8.8/unicore/UnicodeData.txt"),
    File.open("lib/erector/unicode.rb", "w")
  )
  builder.generate
end