| 1 |
require 'rubygems' |
|---|
| 2 |
require 'rake' |
|---|
| 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') |
|---|
| 9 |
|
|---|
| 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}" |
|---|
| 14 |
|
|---|
| 15 |
RELEASE_NAME = "REL #{PKG_VERSION}" |
|---|
| 16 |
|
|---|
| 17 |
RUBY_FORGE_PROJECT = "activerecord" |
|---|
| 18 |
RUBY_FORGE_USER = "webster132" |
|---|
| 19 |
|
|---|
| 20 |
PKG_FILES = FileList[ |
|---|
| 21 |
"lib/**/*", "test/**/*", "[A-Z]*", "Rakefile" |
|---|
| 22 |
].exclude(/\bCVS\b|~$/) |
|---|
| 23 |
|
|---|
| 24 |
desc "Default Task" |
|---|
| 25 |
task :default => [ :test ] |
|---|
| 26 |
|
|---|
| 27 |
# Run the unit tests |
|---|
| 28 |
|
|---|
| 29 |
Rake::TestTask.new { |t| |
|---|
| 30 |
t.libs << "test" |
|---|
| 31 |
t.pattern = 'test/**/*_test.rb' |
|---|
| 32 |
t.verbose = true |
|---|
| 33 |
t.warning = true |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
# Generate the RDoc documentation |
|---|
| 38 |
|
|---|
| 39 |
Rake::RDocTask.new { |rdoc| |
|---|
| 40 |
rdoc.rdoc_dir = 'doc' |
|---|
| 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') |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
# Create compressed packages |
|---|
| 51 |
|
|---|
| 52 |
dist_dirs = [ "lib", "test", "examples", "dev-utils" ] |
|---|
| 53 |
|
|---|
| 54 |
spec = Gem::Specification.new do |s| |
|---|
| 55 |
s.platform = Gem::Platform::RUBY |
|---|
| 56 |
s.name = PKG_NAME |
|---|
| 57 |
s.version = PKG_VERSION |
|---|
| 58 |
s.summary = "Think Active Record for web resources." |
|---|
| 59 |
s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.} |
|---|
| 60 |
|
|---|
| 61 |
s.files = [ "Rakefile", "README", "CHANGELOG" ] |
|---|
| 62 |
dist_dirs.each do |dir| |
|---|
| 63 |
s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } |
|---|
| 64 |
end |
|---|
| 65 |
|
|---|
| 66 |
s.add_dependency('activesupport', '= 2.0.2' + PKG_BUILD) |
|---|
| 67 |
|
|---|
| 68 |
s.require_path = 'lib' |
|---|
| 69 |
s.autorequire = 'active_resource' |
|---|
| 70 |
|
|---|
| 71 |
s.has_rdoc = true |
|---|
| 72 |
s.extra_rdoc_files = %w( README ) |
|---|
| 73 |
s.rdoc_options.concat ['--main', 'README'] |
|---|
| 74 |
|
|---|
| 75 |
s.author = "David Heinemeier Hansson" |
|---|
| 76 |
s.email = "david@loudthinking.com" |
|---|
| 77 |
s.homepage = "http://www.rubyonrails.org" |
|---|
| 78 |
s.rubyforge_project = "activeresource" |
|---|
| 79 |
end |
|---|
| 80 |
|
|---|
| 81 |
Rake::GemPackageTask.new(spec) do |p| |
|---|
| 82 |
p.gem_spec = spec |
|---|
| 83 |
p.need_tar = true |
|---|
| 84 |
p.need_zip = true |
|---|
| 85 |
end |
|---|
| 86 |
|
|---|
| 87 |
task :lines do |
|---|
| 88 |
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 |
|---|
| 89 |
|
|---|
| 90 |
for file_name in FileList["lib/active_resource/**/*.rb"] |
|---|
| 91 |
next if file_name =~ /vendor/ |
|---|
| 92 |
f = File.open(file_name) |
|---|
| 93 |
|
|---|
| 94 |
while line = f.gets |
|---|
| 95 |
lines += 1 |
|---|
| 96 |
next if line =~ /^\s*$/ |
|---|
| 97 |
next if line =~ /^\s*#/ |
|---|
| 98 |
codelines += 1 |
|---|
| 99 |
end |
|---|
| 100 |
puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}" |
|---|
| 101 |
|
|---|
| 102 |
total_lines += lines |
|---|
| 103 |
total_codelines += codelines |
|---|
| 104 |
|
|---|
| 105 |
lines, codelines = 0, 0 |
|---|
| 106 |
end |
|---|
| 107 |
|
|---|
| 108 |
puts "Total: Lines #{total_lines}, LOC #{total_codelines}" |
|---|
| 109 |
end |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
# Publishing ------------------------------------------------------ |
|---|
| 113 |
|
|---|
| 114 |
desc "Publish the beta gem" |
|---|
| 115 |
task :pgem => [:package] do |
|---|
| 116 |
Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload |
|---|
| 117 |
`ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'` |
|---|
| 118 |
end |
|---|
| 119 |
|
|---|
| 120 |
desc "Publish the API documentation" |
|---|
| 121 |
task :pdoc => [:rdoc] do |
|---|
| 122 |
Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/ar", "doc").upload |
|---|
| 123 |
end |
|---|
| 124 |
|
|---|
| 125 |
desc "Publish the release files to RubyForge." |
|---|
| 126 |
task :release => [ :package ] do |
|---|
| 127 |
`rubyforge login` |
|---|
| 128 |
|
|---|
| 129 |
for ext in %w( gem tgz zip ) |
|---|
| 130 |
release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" |
|---|
| 131 |
puts release_command |
|---|
| 132 |
system(release_command) |
|---|
| 133 |
end |
|---|
| 134 |
end |
|---|