| 1 | require 'rake' |
|---|
| 2 | require 'rake/clean' |
|---|
| 3 | require 'rake/gempackagetask' |
|---|
| 4 | require 'rake/rdoctask' |
|---|
| 5 | require 'rake/testtask' |
|---|
| 6 | require 'fileutils' |
|---|
| 7 | include FileUtils |
|---|
| 8 | |
|---|
| 9 | NAME = "camping" |
|---|
| 10 | REV = File.read(".svn/entries").split("\n")[3] rescue nil |
|---|
| 11 | VERS = ENV['VERSION'] || ("1.5" + (REV ? ".#{REV}" : "")) |
|---|
| 12 | CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt'] |
|---|
| 13 | RDOC_OPTS = ['--quiet', '--title', "Camping, the Documentation", |
|---|
| 14 | "--opname", "index.html", |
|---|
| 15 | "--line-numbers", |
|---|
| 16 | "--main", "README", |
|---|
| 17 | "--inline-source"] |
|---|
| 18 | |
|---|
| 19 | desc "Packages up Camping." |
|---|
| 20 | task :default => [:check] |
|---|
| 21 | task :package => [:clean] |
|---|
| 22 | |
|---|
| 23 | task :doc => [:before_doc, :rdoc, :after_doc] |
|---|
| 24 | |
|---|
| 25 | task :before_doc do |
|---|
| 26 | mv "lib/camping.rb", "lib/camping-mural.rb" |
|---|
| 27 | mv "lib/camping-unabridged.rb", "lib/camping.rb" |
|---|
| 28 | end |
|---|
| 29 | |
|---|
| 30 | Rake::RDocTask.new do |rdoc| |
|---|
| 31 | rdoc.rdoc_dir = 'doc/rdoc' |
|---|
| 32 | rdoc.options += RDOC_OPTS |
|---|
| 33 | rdoc.template = "extras/flipbook_rdoc.rb" |
|---|
| 34 | rdoc.main = "README" |
|---|
| 35 | rdoc.title = "Camping, the Documentation" |
|---|
| 36 | rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/camping.rb', 'lib/camping/*.rb'] |
|---|
| 37 | end |
|---|
| 38 | |
|---|
| 39 | task :after_doc do |
|---|
| 40 | mv "lib/camping.rb", "lib/camping-unabridged.rb" |
|---|
| 41 | mv "lib/camping-mural.rb", "lib/camping.rb" |
|---|
| 42 | cp "extras/Camping.gif", "doc/rdoc/" |
|---|
| 43 | cp "extras/permalink.gif", "doc/rdoc/" |
|---|
| 44 | sh %{scp -r doc/rdoc/* #{ENV['USER']}@rubyforge.org:/var/www/gforge-projects/camping/} |
|---|
| 45 | end |
|---|
| 46 | |
|---|
| 47 | spec = |
|---|
| 48 | Gem::Specification.new do |s| |
|---|
| 49 | s.name = NAME |
|---|
| 50 | s.version = VERS |
|---|
| 51 | s.platform = Gem::Platform::RUBY |
|---|
| 52 | s.has_rdoc = true |
|---|
| 53 | s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"] |
|---|
| 54 | s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)\/', '--exclude', 'lib/camping.rb'] |
|---|
| 55 | s.summary = "minature rails for stay-at-home moms" |
|---|
| 56 | s.description = s.summary |
|---|
| 57 | s.author = "why the lucky stiff" |
|---|
| 58 | s.email = 'why@ruby-lang.org' |
|---|
| 59 | s.homepage = 'http://code.whytheluckystiff.net/camping/' |
|---|
| 60 | s.executables = ['camping'] |
|---|
| 61 | |
|---|
| 62 | s.add_dependency('activesupport', '>=1.3.1') |
|---|
| 63 | s.add_dependency('markaby', '>=0.5') |
|---|
| 64 | s.add_dependency('metaid') |
|---|
| 65 | s.required_ruby_version = '>= 1.8.2' |
|---|
| 66 | |
|---|
| 67 | s.files = %w(COPYING README Rakefile) + |
|---|
| 68 | Dir.glob("{bin,doc,test,lib,extras}/**/*") + |
|---|
| 69 | Dir.glob("ext/**/*.{h,c,rb}") + |
|---|
| 70 | Dir.glob("examples/**/*.rb") + |
|---|
| 71 | Dir.glob("tools/*.rb") |
|---|
| 72 | |
|---|
| 73 | s.require_path = "lib" |
|---|
| 74 | # s.extensions = FileList["ext/**/extconf.rb"].to_a |
|---|
| 75 | s.bindir = "bin" |
|---|
| 76 | end |
|---|
| 77 | |
|---|
| 78 | omni = |
|---|
| 79 | Gem::Specification.new do |s| |
|---|
| 80 | s.name = "camping-omnibus" |
|---|
| 81 | s.version = VERS |
|---|
| 82 | s.platform = Gem::Platform::RUBY |
|---|
| 83 | s.summary = "the camping meta-package for updating ActiveRecord, Mongrel and SQLite3 bindings" |
|---|
| 84 | s.description = s.summary |
|---|
| 85 | %w[author email homepage].each { |x| s.__send__("#{x}=", spec.__send__(x)) } |
|---|
| 86 | |
|---|
| 87 | s.add_dependency('camping', "=#{VERS}") |
|---|
| 88 | s.add_dependency('activerecord') |
|---|
| 89 | s.add_dependency('sqlite3-ruby', '>=1.1.0.1') |
|---|
| 90 | s.add_dependency('mongrel') |
|---|
| 91 | s.add_dependency('acts_as_versioned') |
|---|
| 92 | s.add_dependency('RedCloth') |
|---|
| 93 | end |
|---|
| 94 | |
|---|
| 95 | Rake::GemPackageTask.new(spec) do |p| |
|---|
| 96 | p.need_tar = true |
|---|
| 97 | p.gem_spec = spec |
|---|
| 98 | end |
|---|
| 99 | |
|---|
| 100 | Rake::GemPackageTask.new(omni) do |p| |
|---|
| 101 | p.gem_spec = omni |
|---|
| 102 | end |
|---|
| 103 | |
|---|
| 104 | task :install do |
|---|
| 105 | sh %{rake package} |
|---|
| 106 | sh %{sudo gem install pkg/#{NAME}-#{VERS}} |
|---|
| 107 | end |
|---|
| 108 | |
|---|
| 109 | task :uninstall => [:clean] do |
|---|
| 110 | sh %{sudo gem uninstall #{NAME}} |
|---|
| 111 | end |
|---|
| 112 | |
|---|
| 113 | Rake::TestTask.new(:test) do |t| |
|---|
| 114 | t.test_files = FileList['test/test_*.rb'] |
|---|
| 115 | # t.warning = true |
|---|
| 116 | # t.verbose = true |
|---|
| 117 | end |
|---|
| 118 | |
|---|
| 119 | desc "Compare camping and camping-unabridged parse trees" |
|---|
| 120 | task :diff do |
|---|
| 121 | if `which parse_tree_show`.strip.empty? |
|---|
| 122 | STDERR.puts "ERROR: parse_tree_show missing : `gem install ParseTree`" |
|---|
| 123 | exit 1 |
|---|
| 124 | end |
|---|
| 125 | |
|---|
| 126 | sh "parse_tree_show lib/camping.rb > .camping.pt" |
|---|
| 127 | sh "parse_tree_show lib/camping-unabridged.rb > .camping-unabridged.pt" |
|---|
| 128 | sh "diff -u .camping-unabridged.pt .camping.pt | less" |
|---|
| 129 | end |
|---|
| 130 | |
|---|
| 131 | task :check => ["check:valid", "check:size", "check:lines"] |
|---|
| 132 | namespace :check do |
|---|
| 133 | |
|---|
| 134 | desc "Check source code validity" |
|---|
| 135 | task :valid do |
|---|
| 136 | ruby "-w", "lib/camping-unabridged.rb" |
|---|
| 137 | ruby "-w", "lib/camping.rb" |
|---|
| 138 | end |
|---|
| 139 | |
|---|
| 140 | SIZE_LIMIT = 4096 |
|---|
| 141 | desc "Compare camping sizes to unabridged" |
|---|
| 142 | task :size do |
|---|
| 143 | FileList["lib/camping*.rb"].each do |path| |
|---|
| 144 | s = File.size(path) |
|---|
| 145 | puts "%21s : % 6d % 4d%" % [File.basename(path), s, (100 * s / SIZE_LIMIT)] |
|---|
| 146 | end |
|---|
| 147 | if File.size("lib/camping.rb") > SIZE_LIMIT |
|---|
| 148 | STDERR.puts "lib/camping.rb: file is too big (> #{SIZE_LIMIT})" |
|---|
| 149 | end |
|---|
| 150 | end |
|---|
| 151 | |
|---|
| 152 | desc "Verify that line lenght doesn't exceed 80 chars for camping.rb" |
|---|
| 153 | task :lines do |
|---|
| 154 | i = 1 |
|---|
| 155 | File.open("lib/camping.rb").each_line do |line| |
|---|
| 156 | if line.size > 81 # 1 added for \n |
|---|
| 157 | STDERR.puts "lib/camping.rb:#{i}: line too long (#{line[-10..-1].inspect})" |
|---|
| 158 | end |
|---|
| 159 | i += 1 |
|---|
| 160 | end |
|---|
| 161 | end |
|---|
| 162 | |
|---|
| 163 | end |
|---|