3 require 'rake/testtask'
4 require 'rake/rdoctask'
5 require 'rake/packagetask'
6 require 'rake/gempackagetask'
7 require 'rake/contrib/rubyforgepublisher'
8 require File.join(File.dirname(__FILE__), 'lib', 'active_resource', 'version')
10 PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11 PKG_NAME = 'activeresource'
12 PKG_VERSION = ActiveResource::VERSION::STRING + PKG_BUILD
13 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
15 RELEASE_NAME = "REL #{PKG_VERSION}"
17 RUBY_FORGE_PROJECT = "activerecord"
18 RUBY_FORGE_USER = "webster132"
21 "lib/**/*", "test/**/*", "[A-Z]*", "Rakefile"
22 ].exclude(/\bCVS\b|~$/)
25 task :default => [ :test ]
29 Rake::TestTask.new { |t|
31 t.pattern = 'test/**/*_test.rb'
37 # Generate the RDoc documentation
39 Rake::RDocTask.new { |rdoc|
41 rdoc.title = "Active Resource -- Object-oriented REST services"
42 rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
43 rdoc.options << '--charset' << 'utf-8'
44 rdoc.template = "#{ENV['template']}.rb" if ENV['template']
45 rdoc.rdoc_files.include('README', 'CHANGELOG')
46 rdoc.rdoc_files.include('lib/**/*.rb')
50 # Create compressed packages
52 dist_dirs = [ "lib", "test", "examples", "dev-utils" ]
54 spec = Gem::Specification.new do |s|
56 s.version = PKG_VERSION
57 s.summary = "Think Active Record for web resources."
58 s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.}
60 s.files = [ "Rakefile", "README", "CHANGELOG" ]
61 dist_dirs.each do |dir|
62 s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
65 s.add_dependency('activesupport', '= 1.99.0' + PKG_BUILD)
67 s.require_path = 'lib'
68 s.autorequire = 'active_resource'
71 s.extra_rdoc_files = %w( README )
72 s.rdoc_options.concat ['--main', 'README']
74 s.author = "David Heinemeier Hansson"
75 s.email = "david@loudthinking.com"
76 s.homepage = "http://www.rubyonrails.org"
77 s.rubyforge_project = "activeresource"
80 Rake::GemPackageTask.new(spec) do |p|
87 lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
89 for file_name in FileList["lib/active_resource/**/*.rb"]
90 next if file_name =~ /vendor/
91 f = File.open(file_name)
95 next if line =~ /^\s*$/
96 next if line =~ /^\s*#/
99 puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
102 total_codelines += codelines
104 lines, codelines = 0, 0
107 puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
111 # Publishing ------------------------------------------------------
113 desc "Publish the beta gem"
114 task :pgem => [:package] do
115 Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
116 `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
119 desc "Publish the API documentation"
120 task :pdoc => [:rdoc] do
121 Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/ar", "doc").upload
124 desc "Publish the release files to RubyForge."
125 task :release => [ :package ] do
128 for ext in %w( gem tgz zip )
129 release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}"
131 system(release_command)