aeden / rddb

Ruby Document Database

This URL has Read+Write access

aeden (author)
Sat Dec 15 20:18:30 -0800 2007
commit  9f0baa6b82fdbad5233e09719ff587c140b6055e
tree    fcfe81ea9c48d10a2f4d197ead92e9749a4ee5aa
parent  eae34b2d7277ccd4ba0a8a1595569f770661e1a2
rddb / Rakefile
100644 183 lines (152 sloc) 4.797 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher'
 
require File.join(File.dirname(__FILE__), 'lib/rddb')
 
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_NAME = 'rddb'
PKG_VERSION = Rddb::VERSION::STRING + PKG_BUILD
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_DESTINATION = ENV["PKG_DESTINATION"] || "../#{PKG_NAME}"
 
RELEASE_NAME = "REL #{PKG_VERSION}"
 
desc 'Default: run unit tests.'
task :default => 'test:units'
 
desc 'Execute the library unit tests.'
task :test => ['test:units']
 
namespace :test do
  desc 'Unit tests'
  Rake::TestTask.new(:units) do |t|
    t.libs << 'lib'
    t.pattern = 'test/unit/**/*_test.rb'
    t.verbose = true
  end
  
  desc 'S3 unit tests'
  Rake::TestTask.new(:s3units) do |t|
    t.libs << 'lib'
    t.pattern = 'test/s3unit/**/*_test.rb'
    t.verbose = true
  end
  
  desc 'Integration tests'
  Rake::TestTask.new(:integration) do |t|
    t.libs << 'lib'
    t.pattern = 'test/integration/**/*_test.rb'
    t.verbose = true
  end
  
  desc 'REST tests'
  Rake::TestTask.new(:rest) do |t|
    t.libs << 'lib'
    t.pattern = 'test/rest/**/*_test.rb'
    t.verbose = true
  end
  
  desc 'Performance tests'
  Rake::TestTask.new(:perf) do |t|
    t.libs << 'lib'
    t.pattern = 'test/perf/**/*_test.rb'
    t.verbose = true
  end
  
  desc 'Run all tests'
  task :all => ['test:units','test:integration','test:s3units','test:rest']
end
 
desc 'Generate documentation for the library.'
Rake::RDocTask.new(:rdoc) do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title = 'Document-based Ruby Database'
  rdoc.options << '--line-numbers' << '--inline-source'
  rdoc.rdoc_files.include('README')
  rdoc.rdoc_files.include('LICENSE')
  rdoc.rdoc_files.include('lib/rddb.rb')
  rdoc.rdoc_files.include('lib/rddb/**/*.rb')
end
 
namespace :rcov do
  namespace :test do
    desc 'Measures unit test coverage'
    task :unit do
      rm_f 'coverage.data'
      mkdir 'coverage' unless File.exist?('coverage')
      rcov = "rcov --aggregate coverage.data --text-summary --text-report --no-html -Ilib"
      system("#{rcov} test/unit/*_test.rb")
      #system("open coverage/index.html") if PLATFORM['darwin']
    end
  end
end
 
PKG_FILES = FileList[
  #'CHANGELOG',
  'LICENSE',
  'README',
  #'TODO',
  'Rakefile',
  'bin/**/*',
  'doc/**/*',
  'lib/**/*',
  'example/**/*',
] - [ 'test' ]
 
spec = Gem::Specification.new do |s|
  s.name = 'rddb'
  s.version = PKG_VERSION
  s.summary = "Document-oriented Ruby Database."
  s.description = <<-EOF
A documented-oriented Ruby database using Ruby code for views.
EOF
 
  s.add_dependency('rake', '>= 0.7.1')
  s.add_dependency('mongrel', '>= 1.0.1')
  s.add_dependency('uuid', '>= 1.0.4')
  s.add_dependency('daemons', '>= 1.0.7')
  s.add_dependency('aws-s3', '>= 0.4.0')
  s.add_dependency('json', '>= 1.1.1')
 
  s.rdoc_options << '--exclude' << '.'
  s.has_rdoc = false
 
  s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')}
  s.require_path = 'lib'
  
  s.bindir = "bin" # Use these for applications.
  s.executables = ['rddb-server','rddb-worker']
  s.default_executable = "rddb-server"
 
  s.author = "Anthony Eden"
  s.email = "anthonyeden@gmail.com"
end
 
Rake::GemPackageTask.new(spec) do |pkg|
  pkg.gem_spec = spec
  pkg.need_tar = true
  pkg.need_zip = true
end
 
desc "Generate code statistics"
task :lines do
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
 
  for file_name in FileList["lib/**/*.rb"]
    next if file_name =~ /vendor/
    f = File.open(file_name)
 
    while line = f.gets
      lines += 1
      next if line =~ /^\s*$/
      next if line =~ /^\s*#/
      codelines += 1
    end
    puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
    
    total_lines += lines
    total_codelines += codelines
    
    lines, codelines = 0, 0
  end
 
  puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
end
 
desc "Publish the release files to RubyForge."
task :release => [ :package ] do
  `rubyforge login`
 
  for ext in %w( gem tgz zip )
    release_command = "rubyforge add_release rddb #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}"
    puts release_command
    system(release_command)
  end
end
 
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
  Rake::SshDirPublisher.new("aeden@rubyforge.org", "/var/www/gforge-projects/rddb/", "rdoc").upload
end
 
desc "Reinstall the gem from a local package copy"
task :reinstall => [:package] do
  windows = RUBY_PLATFORM =~ /mswin/
  sudo = windows ? '' : 'sudo'
  gem = windows ? 'gem.bat' : 'gem'
  `#{sudo} #{gem} uninstall -x -i #{PKG_NAME}`
  `#{sudo} #{gem} install pkg/#{PKG_NAME}-#{PKG_VERSION}`
end