mole 1.0.12 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metadata +24 -146
- data/History.txt +0 -17
- data/Manifest.txt +0 -132
- data/README.txt +0 -216
- data/Rakefile +0 -46
- data/config/database.yml +0 -21
- data/config/test_database.yml +0 -69
- data/lib/mole.rb +0 -260
- data/lib/mole/db/migrate.rb +0 -90
- data/lib/mole/e_mole.rb +0 -75
- data/lib/mole/logger.rb +0 -134
- data/lib/mole/models/mole_feature.rb +0 -58
- data/lib/mole/models/mole_log.rb +0 -31
- data/lib/mole/module.rb +0 -292
- data/lib/mole/moler.rb +0 -71
- data/lib/mole/utils/frameworks.rb +0 -53
- data/lib/mole/version.rb +0 -15
- data/samples/merbapp/README +0 -14
- data/samples/merbapp/Rakefile +0 -124
- data/samples/merbapp/app/controllers/application.rb +0 -3
- data/samples/merbapp/app/controllers/exceptions.rb +0 -13
- data/samples/merbapp/app/controllers/moled.rb +0 -25
- data/samples/merbapp/app/helpers/global_helper.rb +0 -5
- data/samples/merbapp/app/mailers/views/layout/application.html.erb +0 -1
- data/samples/merbapp/app/mailers/views/layout/application.text.erb +0 -1
- data/samples/merbapp/app/parts/views/layout/application.html.erb +0 -1
- data/samples/merbapp/app/views/exceptions/internal_server_error.html.erb +0 -216
- data/samples/merbapp/app/views/exceptions/not_acceptable.html.erb +0 -38
- data/samples/merbapp/app/views/exceptions/not_found.html.erb +0 -40
- data/samples/merbapp/app/views/layout/application.html.erb +0 -11
- data/samples/merbapp/app/views/moled/index.html.erb +0 -5
- data/samples/merbapp/app/views/moled/result.html.erb +0 -5
- data/samples/merbapp/config/boot.rb +0 -11
- data/samples/merbapp/config/dependencies.rb +0 -41
- data/samples/merbapp/config/environments/development.rb +0 -1
- data/samples/merbapp/config/environments/production.rb +0 -1
- data/samples/merbapp/config/environments/test.rb +0 -1
- data/samples/merbapp/config/merb.yml +0 -82
- data/samples/merbapp/config/merb_init.rb +0 -26
- data/samples/merbapp/config/mole_config.rb +0 -33
- data/samples/merbapp/config/router.rb +0 -38
- data/samples/merbapp/config/upload.conf +0 -0
- data/samples/merbapp/public/images/merb.jpg +0 -0
- data/samples/merbapp/public/merb.fcgi +0 -6
- data/samples/merbapp/public/stylesheets/master.css +0 -119
- data/samples/merbapp/script/destroy +0 -32
- data/samples/merbapp/script/generate +0 -32
- data/samples/merbapp/script/stop_merb +0 -13
- data/samples/merbapp/spec/spec_helper.rb +0 -15
- data/samples/merbapp/test/test_helper.rb +0 -14
- data/samples/railsapp/README +0 -14
- data/samples/railsapp/Rakefile +0 -10
- data/samples/railsapp/app/controllers/application.rb +0 -13
- data/samples/railsapp/app/controllers/moled_controller.rb +0 -23
- data/samples/railsapp/app/helpers/application_helper.rb +0 -3
- data/samples/railsapp/app/views/moled/index.html.erb +0 -5
- data/samples/railsapp/app/views/moled/result.html.erb +0 -5
- data/samples/railsapp/config/boot.rb +0 -109
- data/samples/railsapp/config/database.yml +0 -13
- data/samples/railsapp/config/environment.rb +0 -59
- data/samples/railsapp/config/environments/development.rb +0 -18
- data/samples/railsapp/config/environments/production.rb +0 -20
- data/samples/railsapp/config/environments/test.rb +0 -22
- data/samples/railsapp/config/initializers/inflections.rb +0 -10
- data/samples/railsapp/config/initializers/mime_types.rb +0 -5
- data/samples/railsapp/config/initializers/mole.rb +0 -10
- data/samples/railsapp/config/moles/mole_config.rb +0 -44
- data/samples/railsapp/config/routes.rb +0 -35
- data/samples/railsapp/doc/README_FOR_APP +0 -2
- data/samples/railsapp/public/.htaccess +0 -40
- data/samples/railsapp/public/404.html +0 -30
- data/samples/railsapp/public/422.html +0 -30
- data/samples/railsapp/public/500.html +0 -30
- data/samples/railsapp/public/dispatch.cgi +0 -10
- data/samples/railsapp/public/dispatch.fcgi +0 -24
- data/samples/railsapp/public/dispatch.rb +0 -10
- data/samples/railsapp/public/favicon.ico +0 -0
- data/samples/railsapp/public/images/rails.png +0 -0
- data/samples/railsapp/public/javascripts/application.js +0 -2
- data/samples/railsapp/public/javascripts/controls.js +0 -963
- data/samples/railsapp/public/javascripts/dragdrop.js +0 -972
- data/samples/railsapp/public/javascripts/effects.js +0 -1120
- data/samples/railsapp/public/javascripts/prototype.js +0 -4225
- data/samples/railsapp/public/robots.txt +0 -5
- data/samples/railsapp/script/about +0 -3
- data/samples/railsapp/script/console +0 -3
- data/samples/railsapp/script/destroy +0 -3
- data/samples/railsapp/script/generate +0 -3
- data/samples/railsapp/script/performance/benchmarker +0 -3
- data/samples/railsapp/script/performance/profiler +0 -3
- data/samples/railsapp/script/performance/request +0 -3
- data/samples/railsapp/script/plugin +0 -3
- data/samples/railsapp/script/process/inspector +0 -3
- data/samples/railsapp/script/process/reaper +0 -3
- data/samples/railsapp/script/process/spawner +0 -3
- data/samples/railsapp/script/runner +0 -3
- data/samples/railsapp/script/server +0 -3
- data/samples/railsapp/test/test_helper.rb +0 -38
- data/samples/rubyapp/README +0 -22
- data/samples/rubyapp/bin/ruby_app +0 -35
- data/samples/rubyapp/config/mole_conf.rb +0 -31
- data/samples/rubyapp/lib/fred.rb +0 -22
- data/spec/config/auto_mole_config.rb +0 -26
- data/spec/config/mole_config.rb +0 -0
- data/spec/config/moles/fred_config.rb +0 -0
- data/spec/data/blee.rb +0 -64
- data/spec/db/migrate_spec.rb +0 -19
- data/spec/emole_spec.rb +0 -43
- data/spec/logger_spec.rb +0 -56
- data/spec/models/mole_feature_spec.rb +0 -48
- data/spec/models/mole_log_spec.rb +0 -62
- data/spec/module_spec.rb +0 -229
- data/spec/mole_spec.rb +0 -135
- data/spec/moler_spec.rb +0 -77
- data/spec/spec_helper.rb +0 -76
- data/spec/utils/framework_spec.rb +0 -99
- data/tasks/ann.rake +0 -76
- data/tasks/annotations.rake +0 -22
- data/tasks/doc.rake +0 -48
- data/tasks/gem.rake +0 -110
- data/tasks/manifest.rake +0 -49
- data/tasks/mole.rake +0 -115
- data/tasks/post_load.rake +0 -26
- data/tasks/rubyforge.rake +0 -57
- data/tasks/setup.rb +0 -227
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -44
- data/tasks/test.rake +0 -38
- data/templates/mole/e_mole/exception_alerts.rhtml +0 -14
- data/templates/mole/e_mole/feature_alerts.rhtml +0 -11
- data/templates/mole/e_mole/perf_alerts.rhtml +0 -12
data/spec/moler_spec.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper" )
|
2
|
-
|
3
|
-
require 'action_mailer'
|
4
|
-
ActionMailer::Base.delivery_method = :sendmail
|
5
|
-
ActionMailer::Base.raise_delivery_errors = true
|
6
|
-
|
7
|
-
describe Mole::Moler do
|
8
|
-
TEST_LOG = "/tmp/test.log"
|
9
|
-
before( :each ) do
|
10
|
-
::Mole.reset_configuration!
|
11
|
-
@io = StringIO.new
|
12
|
-
::Mole.initialize( :mode => :transient,
|
13
|
-
:logger_name => "Test",
|
14
|
-
:log_file => @io,
|
15
|
-
:moleable => true,
|
16
|
-
:emole_from => "MOleBeatch@liquidrail.com",
|
17
|
-
:emole_recipients => ['fernand@liquidrail.com'] )
|
18
|
-
@args = { :blee => "Hello", :duh => "World" }
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should log unchecked to the db exceptions correctly" do
|
22
|
-
::Mole.switch_mode :persistent
|
23
|
-
begin
|
24
|
-
raise "Something bad happened !"
|
25
|
-
rescue => boom
|
26
|
-
@args[:boom] = boom
|
27
|
-
::Mole::Moler.check_it( self, 100, @args )
|
28
|
-
end
|
29
|
-
feature = MoleFeature.find_exception_feature( ::Mole.application )
|
30
|
-
feature.should_not be_nil
|
31
|
-
check_it( feature, 100, @args )
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should log perf exception to the db correctly" do
|
35
|
-
::Mole.switch_mode :persistent
|
36
|
-
::Mole::Moler.perf_it( self, 100, @args )
|
37
|
-
feature = MoleFeature.find_performance_feature( ::Mole.application )
|
38
|
-
feature.should_not be_nil
|
39
|
-
check_it( feature, 100, @args )
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should mole a feature to the db correctly" do
|
43
|
-
::Mole.switch_mode :persistent
|
44
|
-
::Mole::Moler.mole_it( "Test", "fred", 100, @args )
|
45
|
-
feature = MoleFeature.find_or_create_feature( "fred", ::Mole.application, "Test".class.name )
|
46
|
-
feature.should_not be_nil
|
47
|
-
check_it( feature, 100, @args )
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should log a feature to the db and send an email correctly" do
|
51
|
-
::Mole.switch_mode :persistent
|
52
|
-
@args[:email] = true
|
53
|
-
::Mole::Moler.mole_it( "Test", "fred", 100, @args )
|
54
|
-
feature = MoleFeature.find_or_create_feature( "fred", ::Mole.application, "Test".class.name )
|
55
|
-
feature.should_not be_nil
|
56
|
-
check_it( feature, 100, { :email => true, :blee => "Hello", :duh => "World" } )
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should log unchecked exceptions to the logger correctly" do
|
60
|
-
::Mole.switch_mode :transient
|
61
|
-
::Mole::Moler.check_it( self, 100, @args )
|
62
|
-
@io.string[@io.string.index( "---" )..@io.string.size].should == "--- 100 -> blee=>Hello, duh=>World\n"
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should log perf exception to the logger correctly" do
|
66
|
-
::Mole.switch_mode :transient
|
67
|
-
::Mole::Moler.perf_it( self, 100, @args )
|
68
|
-
@io.string[@io.string.index( "---" )..@io.string.size].should == "--- 100 -> blee=>Hello, duh=>World\n"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should mole a feature to the logger correctly" do
|
72
|
-
::Mole.switch_mode :transient
|
73
|
-
::Mole::Moler.mole_it( "Test", "Fred", 100, @args )
|
74
|
-
@io.string[@io.string.index( "---" )..@io.string.size].should == "--- 100 -> blee=>Hello, duh=>World\n"
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'active_record'
|
3
|
-
|
4
|
-
require File.join( File.dirname(__FILE__), %w[.. lib mole] )
|
5
|
-
|
6
|
-
# Init the mole with defaults
|
7
|
-
::Mole.initialize
|
8
|
-
|
9
|
-
# Connect to the database
|
10
|
-
unless ActiveRecord::Base.connected?
|
11
|
-
db_config = YAML.load_file( File.join( File.dirname(__FILE__), %w[.. config database.yml] ) )["test"]
|
12
|
-
# ::ActiveRecord::Base.logger = ::Mole.logger
|
13
|
-
# ::ActiveRecord::Base.logger.level = :debug
|
14
|
-
::ActiveRecord::Base.establish_connection(db_config)
|
15
|
-
end
|
16
|
-
|
17
|
-
class CallStackChecker
|
18
|
-
class << self
|
19
|
-
def called
|
20
|
-
@called = 1
|
21
|
-
end
|
22
|
-
|
23
|
-
def reset!
|
24
|
-
@called = 0
|
25
|
-
end
|
26
|
-
|
27
|
-
def called?
|
28
|
-
@called == 1
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
gem 'rspec'
|
34
|
-
require 'spec'
|
35
|
-
|
36
|
-
Spec::Runner.configure do |config|
|
37
|
-
config.before(:each) do
|
38
|
-
# from fixtures.rb in rails
|
39
|
-
begin
|
40
|
-
ActiveRecord::Base.send :increment_open_transactions
|
41
|
-
ActiveRecord::Base.connection.begin_db_transaction
|
42
|
-
rescue
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
config.after(:each) do
|
47
|
-
begin
|
48
|
-
# from fixtures.rb in rails
|
49
|
-
if Thread.current['open_transactions'] && Thread.current['open_transactions'] > 0
|
50
|
-
Thread.current['open_transactions'].downto(1) do
|
51
|
-
ActiveRecord::Base.connection.rollback_db_transaction if ActiveRecord::Base.connection
|
52
|
-
end
|
53
|
-
Thread.current['open_transactions'] = 0
|
54
|
-
end
|
55
|
-
ActiveRecord::Base.verify_active_connections!
|
56
|
-
rescue
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Convenience to check mole_logs
|
62
|
-
def check_it( feature, user_id, args={} )
|
63
|
-
log = MoleLog.find( :first, :conditions => ['mole_feature_id = ?', feature.id] )
|
64
|
-
log.should_not be_nil
|
65
|
-
log.user_id.should == user_id
|
66
|
-
log_args = YAML.load( log.params )
|
67
|
-
check_args( log_args, args )
|
68
|
-
log
|
69
|
-
end
|
70
|
-
def check_args( args, expected_args )
|
71
|
-
args.should have(expected_args.size).items
|
72
|
-
expected_args.keys.each do |k|
|
73
|
-
args[k].should_not be_nil
|
74
|
-
args[k].should == expected_args[k]
|
75
|
-
end
|
76
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), %w[.. spec_helper] )
|
2
|
-
|
3
|
-
describe Mole::Utils::Frameworks do
|
4
|
-
before( :all ) do
|
5
|
-
::Mole.reset_configuration!
|
6
|
-
::Mole.initialize( :moleable => true )
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".flatten_params" do
|
10
|
-
it "should flatten request parameters correctly" do
|
11
|
-
Mole::Utils::Frameworks.flatten_params( RailsController.new ).should == "action => fred, controller => rails, id => 10"
|
12
|
-
end
|
13
|
-
it "should detect if this is not a controller class" do
|
14
|
-
Mole::Utils::Frameworks.flatten_params( Poro.new ).should be_nil
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ".features_for" do
|
19
|
-
it "should find the correct features for a merb controller" do
|
20
|
-
features = Mole::Utils::Frameworks.features_for( MerbController )
|
21
|
-
features.sort.should == %w[blee fred]
|
22
|
-
end
|
23
|
-
it "should find the correct features for a rails controller" do
|
24
|
-
features = Mole::Utils::Frameworks.features_for( RailsController )
|
25
|
-
features.sort.should == %w[blee fred]
|
26
|
-
end
|
27
|
-
it "should find the correct features for a plain old ruby object" do
|
28
|
-
features = Mole::Utils::Frameworks.features_for( Poro )
|
29
|
-
features.sort.should == %w[blee duh]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe ".merb_actions" do
|
34
|
-
it "should retrieve Merb controller actions correctly" do
|
35
|
-
actions = Mole::Utils::Frameworks.merb_actions( MerbController )
|
36
|
-
actions.sort.should == %w[blee fred]
|
37
|
-
end
|
38
|
-
it "should raise an exception if it is not a merb controller" do
|
39
|
-
lambda { Mole::Utils::Frameworks.merb_actions( String ) }.should raise_error( "Invalid Merb Controller class `String" )
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe ".rails_actions" do
|
44
|
-
it "should retrieve Rails controller actions correctly" do
|
45
|
-
actions = Mole::Utils::Frameworks.rails_actions( RailsController )
|
46
|
-
actions.sort.should == %w[blee fred]
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should raise an exception if it is not a rails controller" do
|
50
|
-
lambda { Mole::Utils::Frameworks.rails_actions( String ) }.should raise_error( "Invalid Rails Controller class `String" )
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class Poro
|
55
|
-
def blee
|
56
|
-
end
|
57
|
-
|
58
|
-
def duh
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class MerbController
|
63
|
-
def self.callable_actions
|
64
|
-
{ 'fred' => nil, 'blee' => nil }
|
65
|
-
end
|
66
|
-
|
67
|
-
def fred
|
68
|
-
end
|
69
|
-
|
70
|
-
def blee
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def duh
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
class RailsController
|
80
|
-
def params
|
81
|
-
{ :id => 10, :action => "fred", :controller => "rails" }
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.action_methods
|
85
|
-
%w[fred blee]
|
86
|
-
end
|
87
|
-
|
88
|
-
def fred
|
89
|
-
end
|
90
|
-
|
91
|
-
def blee
|
92
|
-
end
|
93
|
-
|
94
|
-
private
|
95
|
-
|
96
|
-
def duh
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
data/tasks/ann.rake
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'bones/smtp_tls'
|
5
|
-
rescue LoadError
|
6
|
-
require 'net/smtp'
|
7
|
-
end
|
8
|
-
require 'time'
|
9
|
-
|
10
|
-
namespace :ann do
|
11
|
-
|
12
|
-
file PROJ.ann_file do
|
13
|
-
puts "Generating #{PROJ.ann_file}"
|
14
|
-
File.open(PROJ.ann_file,'w') do |fd|
|
15
|
-
fd.puts("#{PROJ.name} version #{PROJ.version}")
|
16
|
-
fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
|
17
|
-
fd.puts(" #{PROJ.url}") if PROJ.url
|
18
|
-
fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
|
19
|
-
fd.puts
|
20
|
-
fd.puts("== DESCRIPTION")
|
21
|
-
fd.puts
|
22
|
-
fd.puts(PROJ.description)
|
23
|
-
fd.puts
|
24
|
-
fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
|
25
|
-
fd.puts
|
26
|
-
PROJ.ann_paragraphs.each do |p|
|
27
|
-
fd.puts "== #{p.upcase}"
|
28
|
-
fd.puts
|
29
|
-
fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
|
30
|
-
fd.puts
|
31
|
-
end
|
32
|
-
fd.puts PROJ.ann_text if PROJ.ann_text
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
desc "Create an announcement file"
|
37
|
-
task :announcement => PROJ.ann_file
|
38
|
-
|
39
|
-
desc "Send an email announcement"
|
40
|
-
task :email => PROJ.ann_file do
|
41
|
-
from = PROJ.ann_email[:from] || PROJ.email
|
42
|
-
to = Array(PROJ.ann_email[:to])
|
43
|
-
|
44
|
-
### build a mail header for RFC 822
|
45
|
-
rfc822msg = "From: #{from}\n"
|
46
|
-
rfc822msg << "To: #{to.join(',')}\n"
|
47
|
-
rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
|
48
|
-
rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
|
49
|
-
rfc822msg << "\n"
|
50
|
-
rfc822msg << "Date: #{Time.new.rfc822}\n"
|
51
|
-
rfc822msg << "Message-Id: "
|
52
|
-
rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{PROJ.ann_email[:domain]}>\n\n"
|
53
|
-
rfc822msg << File.read(PROJ.ann_file)
|
54
|
-
|
55
|
-
params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
|
56
|
-
PROJ.ann_email[key]
|
57
|
-
end
|
58
|
-
|
59
|
-
params[3] = PROJ.email if params[3].nil?
|
60
|
-
|
61
|
-
if params[4].nil?
|
62
|
-
STDOUT.write "Please enter your e-mail password (#{params[3]}): "
|
63
|
-
params[4] = STDIN.gets.chomp
|
64
|
-
end
|
65
|
-
|
66
|
-
### send email
|
67
|
-
Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
|
68
|
-
end
|
69
|
-
end # namespace :ann
|
70
|
-
|
71
|
-
desc 'Alias to ann:announcement'
|
72
|
-
task :ann => 'ann:announcement'
|
73
|
-
|
74
|
-
CLOBBER << PROJ.ann_file
|
75
|
-
|
76
|
-
# EOF
|
data/tasks/annotations.rake
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
|
-
if HAVE_BONES
|
4
|
-
|
5
|
-
desc "Enumerate all annotations"
|
6
|
-
task :notes do
|
7
|
-
Bones::AnnotationExtractor.enumerate(
|
8
|
-
PROJ, PROJ.annotation_tags.join('|'), :tag => true)
|
9
|
-
end
|
10
|
-
|
11
|
-
namespace :notes do
|
12
|
-
PROJ.annotation_tags.each do |tag|
|
13
|
-
desc "Enumerate all #{tag} annotations"
|
14
|
-
task tag.downcase.to_sym do
|
15
|
-
Bones::AnnotationExtractor.enumerate(PROJ, tag)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end # if HAVE_BONES
|
21
|
-
|
22
|
-
# EOF
|
data/tasks/doc.rake
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
|
5
|
-
namespace :doc do
|
6
|
-
|
7
|
-
desc 'Generate RDoc documentation'
|
8
|
-
Rake::RDocTask.new do |rd|
|
9
|
-
rd.main = PROJ.rdoc_main
|
10
|
-
rd.rdoc_dir = PROJ.rdoc_dir
|
11
|
-
|
12
|
-
incl = Regexp.new(PROJ.rdoc_include.join('|'))
|
13
|
-
excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
|
14
|
-
files = PROJ.files.find_all do |fn|
|
15
|
-
case fn
|
16
|
-
when excl; false
|
17
|
-
when incl; true
|
18
|
-
else false end
|
19
|
-
end
|
20
|
-
rd.rdoc_files.push(*files)
|
21
|
-
|
22
|
-
title = "#{PROJ.name}-#{PROJ.version} Documentation"
|
23
|
-
title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
|
24
|
-
|
25
|
-
rd.options << "-t #{title}"
|
26
|
-
rd.options.concat(PROJ.rdoc_opts)
|
27
|
-
end
|
28
|
-
|
29
|
-
desc 'Generate ri locally for testing'
|
30
|
-
task :ri => :clobber_ri do
|
31
|
-
sh "#{RDOC} --ri -o ri ."
|
32
|
-
end
|
33
|
-
|
34
|
-
task :clobber_ri do
|
35
|
-
rm_r 'ri' rescue nil
|
36
|
-
end
|
37
|
-
|
38
|
-
end # namespace :doc
|
39
|
-
|
40
|
-
desc 'Alias to doc:rdoc'
|
41
|
-
task :doc => 'doc:rdoc'
|
42
|
-
|
43
|
-
desc 'Remove all build products'
|
44
|
-
task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
|
45
|
-
|
46
|
-
remove_desc_for_task %w(doc:clobber_rdoc)
|
47
|
-
|
48
|
-
# EOF
|
data/tasks/gem.rake
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
|
-
require 'rake/gempackagetask'
|
4
|
-
|
5
|
-
namespace :gem do
|
6
|
-
|
7
|
-
PROJ.spec = Gem::Specification.new do |s|
|
8
|
-
s.name = PROJ.name
|
9
|
-
s.version = PROJ.version
|
10
|
-
s.summary = PROJ.summary
|
11
|
-
s.authors = Array(PROJ.authors)
|
12
|
-
s.email = PROJ.email
|
13
|
-
s.homepage = Array(PROJ.url).first
|
14
|
-
s.rubyforge_project = PROJ.rubyforge_name
|
15
|
-
s.post_install_message = PROJ.post_install_message
|
16
|
-
|
17
|
-
s.description = PROJ.description
|
18
|
-
|
19
|
-
PROJ.dependencies.each do |dep|
|
20
|
-
s.add_dependency(*dep)
|
21
|
-
end
|
22
|
-
|
23
|
-
s.files = PROJ.files
|
24
|
-
s.executables = PROJ.executables.map {|fn| File.basename(fn)}
|
25
|
-
s.extensions = PROJ.files.grep %r/extconf\.rb$/
|
26
|
-
|
27
|
-
s.bindir = 'bin'
|
28
|
-
dirs = Dir["{#{PROJ.libs.join(',')}}"]
|
29
|
-
s.require_paths = dirs unless dirs.empty?
|
30
|
-
|
31
|
-
incl = Regexp.new(PROJ.rdoc_include.join('|'))
|
32
|
-
excl = PROJ.rdoc_exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
|
33
|
-
excl = Regexp.new(excl.join('|'))
|
34
|
-
rdoc_files = PROJ.files.find_all do |fn|
|
35
|
-
case fn
|
36
|
-
when excl; false
|
37
|
-
when incl; true
|
38
|
-
else false end
|
39
|
-
end
|
40
|
-
s.rdoc_options = PROJ.rdoc_opts + ['--main', PROJ.rdoc_main]
|
41
|
-
s.extra_rdoc_files = rdoc_files
|
42
|
-
s.has_rdoc = true
|
43
|
-
|
44
|
-
if test ?f, PROJ.test_file
|
45
|
-
s.test_file = PROJ.test_file
|
46
|
-
else
|
47
|
-
s.test_files = PROJ.tests.to_a
|
48
|
-
end
|
49
|
-
|
50
|
-
# Do any extra stuff the user wants
|
51
|
-
# spec_extras.each do |msg, val|
|
52
|
-
# case val
|
53
|
-
# when Proc
|
54
|
-
# val.call(s.send(msg))
|
55
|
-
# else
|
56
|
-
# s.send "#{msg}=", val
|
57
|
-
# end
|
58
|
-
# end
|
59
|
-
end
|
60
|
-
|
61
|
-
desc 'Show information about the gem'
|
62
|
-
task :debug do
|
63
|
-
puts PROJ.spec.to_ruby
|
64
|
-
end
|
65
|
-
|
66
|
-
pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
|
67
|
-
pkg.need_tar = PROJ.need_tar
|
68
|
-
pkg.need_zip = PROJ.need_zip
|
69
|
-
pkg.package_files += PROJ.spec.files
|
70
|
-
end
|
71
|
-
Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
|
72
|
-
|
73
|
-
gem_file = if PROJ.spec.platform == Gem::Platform::RUBY
|
74
|
-
"#{pkg.package_name}.gem"
|
75
|
-
else
|
76
|
-
"#{pkg.package_name}-#{PROJ.spec.platform}.gem"
|
77
|
-
end
|
78
|
-
|
79
|
-
desc "Build the gem file #{gem_file}"
|
80
|
-
task :package => "#{pkg.package_dir}/#{gem_file}"
|
81
|
-
|
82
|
-
file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.spec.files do
|
83
|
-
when_writing("Creating GEM") {
|
84
|
-
Gem::Builder.new(PROJ.spec).build
|
85
|
-
verbose(true) {
|
86
|
-
mv gem_file, "#{pkg.package_dir}/#{gem_file}"
|
87
|
-
}
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
desc 'Install the gem'
|
92
|
-
task :install => [:clobber, :package] do
|
93
|
-
sh "#{SUDO} #{GEM} install pkg/#{PROJ.spec.full_name}"
|
94
|
-
end
|
95
|
-
|
96
|
-
desc 'Uninstall the gem'
|
97
|
-
task :uninstall do
|
98
|
-
sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -x #{PROJ.name}"
|
99
|
-
end
|
100
|
-
|
101
|
-
end # namespace :gem
|
102
|
-
|
103
|
-
desc 'Alias to gem:package'
|
104
|
-
task :gem => 'gem:package'
|
105
|
-
|
106
|
-
task :clobber => 'gem:clobber_package'
|
107
|
-
|
108
|
-
remove_desc_for_task %w(gem:clobber_package)
|
109
|
-
|
110
|
-
# EOF
|