root / trunk / Rakefile

Revision 241, 4.8 kB (checked in by archengule, 8 months ago)

Fix ticket:150 Rakefile will now get correct svn revision

Line 
1require 'rake'
2require 'rake/clean'
3require 'rake/gempackagetask'
4require 'rake/rdoctask'
5require 'rake/testtask'
6require 'fileutils'
7include FileUtils
8
9NAME = "camping"
10REV = File.read(".svn/entries").split("\n")[3] rescue nil
11VERS = ENV['VERSION'] || ("1.5" + (REV ? ".#{REV}" : ""))
12CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt']
13RDOC_OPTS = ['--quiet', '--title', "Camping, the Documentation",
14    "--opname", "index.html",
15    "--line-numbers",
16    "--main", "README",
17    "--inline-source"]
18
19desc "Packages up Camping."
20task :default => [:check]
21task :package => [:clean]
22
23task :doc => [:before_doc, :rdoc, :after_doc]
24
25task :before_doc do
26    mv "lib/camping.rb", "lib/camping-mural.rb"
27    mv "lib/camping-unabridged.rb", "lib/camping.rb"
28end
29
30Rake::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']
37end
38
39task :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/}
45end
46
47spec =
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
78omni =
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
95Rake::GemPackageTask.new(spec) do |p|
96    p.need_tar = true
97    p.gem_spec = spec
98end
99
100Rake::GemPackageTask.new(omni) do |p|
101    p.gem_spec = omni
102end
103
104task :install do
105  sh %{rake package}
106  sh %{sudo gem install pkg/#{NAME}-#{VERS}}
107end
108
109task :uninstall => [:clean] do
110  sh %{sudo gem uninstall #{NAME}}
111end
112
113Rake::TestTask.new(:test) do |t|
114  t.test_files = FileList['test/test_*.rb']
115#  t.warning = true
116#  t.verbose = true
117end
118
119desc "Compare camping and camping-unabridged parse trees"
120task :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"
129end
130
131task :check => ["check:valid", "check:size", "check:lines"]
132namespace :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
163end
Note: See TracBrowser for help on using the browser.