mole 0.0.1

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.
Files changed (46) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +45 -0
  3. data/README.txt +140 -0
  4. data/Rakefile +47 -0
  5. data/bin/mole +8 -0
  6. data/bin/molify +64 -0
  7. data/config/database.yml +21 -0
  8. data/config/test_database.yml +69 -0
  9. data/lib/mole/db/migrate.rb +90 -0
  10. data/lib/mole/e_mole.rb +74 -0
  11. data/lib/mole/logger.rb +131 -0
  12. data/lib/mole/models/mole_feature.rb +45 -0
  13. data/lib/mole/models/mole_log.rb +56 -0
  14. data/lib/mole/module.rb +274 -0
  15. data/lib/mole/moler.rb +51 -0
  16. data/lib/mole/utils/frameworks.rb +22 -0
  17. data/lib/mole/version.rb +15 -0
  18. data/lib/mole.rb +175 -0
  19. data/spec/data/blee.rb +53 -0
  20. data/spec/db/migrate_spec.rb +19 -0
  21. data/spec/emole_spec.rb +43 -0
  22. data/spec/logger_spec.rb +56 -0
  23. data/spec/models/mole_feature_spec.rb +37 -0
  24. data/spec/models/mole_log_spec.rb +73 -0
  25. data/spec/module_spec.rb +171 -0
  26. data/spec/mole_spec.rb +38 -0
  27. data/spec/moler_spec.rb +65 -0
  28. data/spec/spec_helper.rb +59 -0
  29. data/spec/utils/framework_spec.rb +46 -0
  30. data/tasks/ann.rake +76 -0
  31. data/tasks/annotations.rake +22 -0
  32. data/tasks/doc.rake +48 -0
  33. data/tasks/gem.rake +110 -0
  34. data/tasks/manifest.rake +49 -0
  35. data/tasks/mole.rake +115 -0
  36. data/tasks/post_load.rake +26 -0
  37. data/tasks/rubyforge.rake +57 -0
  38. data/tasks/setup.rb +227 -0
  39. data/tasks/spec.rake +54 -0
  40. data/tasks/svn.rake +44 -0
  41. data/tasks/test.rake +38 -0
  42. data/templates/mole/e_mole/exception_alerts.rhtml +14 -0
  43. data/templates/mole/e_mole/feature_alerts.rhtml +11 -0
  44. data/templates/mole/e_mole/perf_alerts.rhtml +12 -0
  45. data/test/test_mole.rb +0 -0
  46. metadata +120 -0
@@ -0,0 +1,65 @@
1
+ require File.join(File.dirname(__FILE__), "spec_helper" )
2
+
3
+ describe Mole::Moler do
4
+ TEST_LOG = "/tmp/test.log"
5
+ before( :each ) do
6
+ ::Mole.reset_configuration!
7
+ @io = StringIO.new
8
+ ::Mole.initialize( :mode => :transient, :logger_name => "Test", :log_file => @io, :moleable => true )
9
+ end
10
+
11
+ it "should log unchecked to the db exceptions correctly" do
12
+ ::Mole.switch_mode :persistent
13
+ ::Mole::Moler.check_it( self, 100, :blee => "Hello", :duh => "World" )
14
+ except_feature = MoleFeature.find_exception_feature( ::Mole.application )
15
+ except_feature.should_not be_nil
16
+
17
+ log = MoleLog.find( :all, :conditions => ['mole_feature_id = ?', except_feature.id] )
18
+ log.should_not be_nil
19
+ log.should have(1).mole_log
20
+ log.first.user_id.should == 100
21
+ end
22
+
23
+ it "should log perf exception to the db correctly" do
24
+ ::Mole.switch_mode :persistent
25
+ ::Mole::Moler.perf_it( self, 100, :blee => "Hello", :duh => "World" )
26
+ perf_feature = MoleFeature.find_performance_feature( ::Mole.application )
27
+ perf_feature.should_not be_nil
28
+
29
+ log = MoleLog.find( :all, :conditions => ['mole_feature_id = ?', perf_feature.id] )
30
+ log.should_not be_nil
31
+ log.should have(1).mole_log
32
+ log.first.user_id.should == 100
33
+ end
34
+
35
+ it "should mole a feature to the db correctly" do
36
+ ::Mole.switch_mode :persistent
37
+ ::Mole::Moler.mole_it( "Test", "fred", 100, :blee => "Hello", :duh => "World" )
38
+ feature = MoleFeature.find_feature( "fred", ::Mole.application, "Test".class.name )
39
+ feature.should_not be_nil
40
+
41
+ log = MoleLog.find( :all, :conditions => ['mole_feature_id = ?', feature.id] )
42
+ log.should_not be_nil
43
+ log.should have(1).mole_log
44
+ log.first.user_id.should == 100
45
+ end
46
+
47
+ it "should log unchecked exceptions to the logger correctly" do
48
+ ::Mole.switch_mode :transient
49
+ ::Mole::Moler.check_it( self, 100, :blee => "Hello", :duh => "World" )
50
+ @io.string[@io.string.index( "---" )..@io.string.size].should == "--- 100 -> blee=>Hello, duh=>World\n"
51
+ end
52
+
53
+ it "should log perf exception to the logger correctly" do
54
+ ::Mole.switch_mode :transient
55
+ ::Mole::Moler.perf_it( self, 100, :blee => "Hello", :duh => "World" )
56
+ @io.string[@io.string.index( "---" )..@io.string.size].should == "--- 100 -> blee=>Hello, duh=>World\n"
57
+ end
58
+
59
+ it "should mole a feature to the logger correctly" do
60
+ ::Mole.switch_mode :transient
61
+ ::Mole::Moler.mole_it( "Test", "Fred", 100, :blee => "Hello", :duh => "World" )
62
+ @io.string[@io.string.index( "---" )..@io.string.size].should == "--- 100 -> blee=>Hello, duh=>World\n"
63
+ end
64
+
65
+ end
@@ -0,0 +1,59 @@
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
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), %w[.. spec_helper] )
2
+ require 'merb'
3
+ require 'action_controller'
4
+
5
+ describe Mole::Utils::Frameworks do
6
+ before( :all ) do
7
+ ::Mole.reset_configuration!
8
+ ::Mole.initialize( :moleable => true )
9
+ end
10
+
11
+ it "should retrieve Merb controller actions correctly" do
12
+ actions = Mole::Utils::Frameworks.merb_actions( MerbController )
13
+ actions.sort.should == %w[blee fred]
14
+ end
15
+
16
+ it "should retrieve Rails controller actions correctly" do
17
+ actions = Mole::Utils::Frameworks.rails_actions( RailsController )
18
+ actions.sort.should == %w[blee fred]
19
+ end
20
+
21
+ class MerbController < Merb::Controller
22
+ def fred
23
+ end
24
+
25
+ def blee
26
+ end
27
+
28
+ private
29
+
30
+ def duh
31
+ end
32
+ end
33
+
34
+ class RailsController < ActionController::Base
35
+ def fred
36
+ end
37
+
38
+ def blee
39
+ end
40
+
41
+ private
42
+
43
+ def duh
44
+ end
45
+ end
46
+ end
data/tasks/ann.rake ADDED
@@ -0,0 +1,76 @@
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
@@ -0,0 +1,22 @@
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 ADDED
@@ -0,0 +1,48 @@
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 ADDED
@@ -0,0 +1,110 @@
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
@@ -0,0 +1,49 @@
1
+ # $Id$
2
+
3
+ require 'find'
4
+
5
+ namespace :manifest do
6
+
7
+ desc 'Verify the manifest'
8
+ task :check do
9
+ fn = PROJ.manifest_file + '.tmp'
10
+ files = manifest_files
11
+
12
+ File.open(fn, 'w') {|fp| fp.puts files}
13
+ lines = %x(#{DIFF} -du #{PROJ.manifest_file} #{fn}).split("\n")
14
+ if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
15
+ lines.map! do |line|
16
+ case line
17
+ when %r/^(-{3}|\+{3})/; nil
18
+ when %r/^@/; Console::ANSICode.blue line
19
+ when %r/^\+/; Console::ANSICode.green line
20
+ when %r/^\-/; Console::ANSICode.red line
21
+ else line end
22
+ end
23
+ end
24
+ puts lines.compact
25
+ rm fn rescue nil
26
+ end
27
+
28
+ desc 'Create a new manifest'
29
+ task :create do
30
+ files = manifest_files
31
+ unless test(?f, PROJ.manifest_file)
32
+ files << PROJ.manifest_file
33
+ files.sort!
34
+ end
35
+ File.open(PROJ.manifest_file, 'w') {|fp| fp.puts files}
36
+ end
37
+
38
+ task :assert do
39
+ files = manifest_files
40
+ manifest = File.read(PROJ.manifest_file).split($/)
41
+ raise "ERROR: #{PROJ.manifest_file} is out of date" unless files == manifest
42
+ end
43
+
44
+ end # namespace :manifest
45
+
46
+ desc 'Alias to manifest:check'
47
+ task :manifest => 'manifest:check'
48
+
49
+ # EOF
data/tasks/mole.rake ADDED
@@ -0,0 +1,115 @@
1
+ # -----------------------------------------------------------------------------
2
+ # MOLE Related rake tasks
3
+ # Mole db setup upon installation
4
+ # -----------------------------------------------------------------------------
5
+ require 'ftools'
6
+
7
+ namespace :mole do
8
+ namespace :db do
9
+ task :environment do
10
+ require 'rubygems'
11
+
12
+ gem "activerecord", "=2.0.2"
13
+ require 'active_record'
14
+
15
+ environment = ENV['MOLE_ENV'] || "test"
16
+ db_config = YAML.load_file( File.join( File.dirname(__FILE__), "..", "config", "test_database.yml") )[environment]
17
+ ::ActiveRecord::Base.establish_connection(db_config)
18
+ end
19
+
20
+ # ---------------------------------------------------------------------
21
+ # Create mole persistence tables and pre-populate
22
+ desc 'Create the database tables needed for the mole plugin.'
23
+ task :migrate_up => :environment do
24
+ # Create the mole_features table if it doesn't exist
25
+ unless ActiveRecord::Schema.tables.include?('mole_features')
26
+ ActiveRecord::Schema.create_table('mole_features') do |t|
27
+ t.column :name, :string
28
+ t.column :context, :string
29
+ t.column :app_name, :string
30
+ t.column :created_at, :datetime
31
+ t.column :updated_at, :datetime
32
+ end
33
+ ActiveRecord::Schema.add_index( 'mole_features', 'name' )
34
+
35
+ # Create some default features
36
+ # MoleFeature.create :id => 0, :name => MoleFeature::ALL
37
+ # MoleFeature.create :id => 1, :name => MoleFeature::EXCEPTION
38
+ # MoleFeature.create :id => 2, :name => MoleFeature::PERFORMANCE
39
+ end
40
+
41
+ # Create the mole_logs table if it doesn't exist
42
+ unless ActiveRecord::Schema.tables.include?('mole_logs')
43
+ ActiveRecord::Schema.create_table('mole_logs') do |t|
44
+ t.column :mole_feature_id, :integer
45
+ t.column :user_id, :integer
46
+ t.column :params, :string
47
+ t.column :ip_address, :string
48
+ t.column :browser_type, :string
49
+ t.column :host_name, :string
50
+ t.column :created_at, :datetime
51
+ t.column :updated_at, :datetime
52
+ end
53
+ ActiveRecord::Schema.add_index( 'mole_logs', ['mole_feature_id','user_id'] )
54
+ ActiveRecord::Schema.add_index( 'mole_logs', ['mole_feature_id','created_at'] )
55
+ end
56
+ end
57
+
58
+ # -------------------------------------------------------------------------
59
+ # Destroys mole persistence tables
60
+ desc 'Drop the database tables needed for the mole plugin.'
61
+ task :migrate_down => :environment do
62
+ # Delete the mole_feature table
63
+ if ActiveRecord::Schema.tables.include?('mole_features')
64
+ ActiveRecord::Schema.drop_table('mole_features')
65
+ end
66
+
67
+ # Delete the mole_logs table
68
+ if ActiveRecord::Schema.tables.include?('mole_logs')
69
+ ActiveRecord::Schema.remove_index('mole_logs', ['mole_feature_id','user_id'] )
70
+ ActiveRecord::Schema.drop_table('mole_logs')
71
+ end
72
+ end
73
+ end
74
+
75
+ # ---------------------------------------------------------------------------
76
+ # Installs the mole plugin
77
+ desc 'The task that is run when you first install the plugin.'
78
+ task :install => :setup do
79
+ # Copy over the sample mole.conf file to the default location
80
+ destination = @plugin_base + '/../../../config'
81
+ File.makedirs(destination) unless File.exists?(destination)
82
+ unless File.exists?(destination + '/mole.conf')
83
+ File.copy(@plugin_base + '/lib/mole.conf.sample', destination + '/mole.conf')
84
+ end
85
+
86
+ # Migrate the database
87
+ Rake::Task["mole:migrate:up"].invoke
88
+ end
89
+
90
+ # ---------------------------------------------------------------------------
91
+ # Removes the mole plugin and cleanup artifacts
92
+ desc 'The task that is run when you want to remove the plugin.'
93
+ task :remove => :setup do
94
+ # Remove the database tables
95
+ Rake::Task["mole:migrate:down"].invoke
96
+
97
+ # Delete the default mole.conf file
98
+ File.delete( "#{RAILS_ROOT}/config/mole.conf" )
99
+ end
100
+
101
+ # ---------------------------------------------------------------------------
102
+ desc 'Setup plugin base dir'
103
+ task :setup do
104
+ @plugin_base = File.dirname(__FILE__) + '/..'
105
+ end
106
+
107
+ # ---------------------------------------------------------------------------
108
+ # Upgrade task from MOLE version 0.002
109
+ # This task will setup the extra mole features columns and reset the indexes
110
+ # on the mole_features table.
111
+ desc 'Ugrade the mole schema from version 0.002'
112
+ task :upgrade do
113
+ Rake::Task["mole:migrate:upgrade"].invoke
114
+ end
115
+ end
@@ -0,0 +1,26 @@
1
+ # $Id$
2
+
3
+ # This file does not define any rake tasks. It is used to load some project
4
+ # settings if they are not defined by the user.
5
+
6
+ PROJ.rdoc_exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
7
+ PROJ.exclude << "^#{Regexp.escape(PROJ.ann_file)}$"
8
+
9
+ PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
10
+
11
+ PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
12
+
13
+ PROJ.summary ||= PROJ.description.split('.').first
14
+
15
+ PROJ.files ||=
16
+ if test(?f, PROJ.manifest_file)
17
+ files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
18
+ files.delete ''
19
+ files
20
+ else [] end
21
+
22
+ PROJ.executables ||= PROJ.files.find_all {|fn| fn =~ %r/^bin/}
23
+
24
+ PROJ.rdoc_main ||= PROJ.readme_file
25
+
26
+ # EOF
@@ -0,0 +1,57 @@
1
+ # $Id$
2
+
3
+ if PROJ.rubyforge_name && HAVE_RUBYFORGE
4
+
5
+ require 'rubyforge'
6
+ require 'rake/contrib/sshpublisher'
7
+
8
+ namespace :gem do
9
+ desc 'Package and upload to RubyForge'
10
+ task :release => [:clobber, :package] do |t|
11
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
12
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
13
+ pkg = "pkg/#{PROJ.spec.full_name}"
14
+
15
+ if $DEBUG then
16
+ puts "release_id = rf.add_release #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, #{PROJ.version.inspect}, \"#{pkg}.tgz\""
17
+ puts "rf.add_file #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
18
+ end
19
+
20
+ rf = RubyForge.new
21
+ puts 'Logging in'
22
+ rf.login
23
+
24
+ c = rf.userconfig
25
+ c['release_notes'] = PROJ.description if PROJ.description
26
+ c['release_changes'] = PROJ.changes if PROJ.changes
27
+ c['preformatted'] = true
28
+
29
+ files = [(PROJ.need_tar ? "#{pkg}.tgz" : nil),
30
+ (PROJ.need_zip ? "#{pkg}.zip" : nil),
31
+ "#{pkg}.gem"].compact
32
+
33
+ puts "Releasing #{PROJ.name} v. #{PROJ.version}"
34
+ rf.add_release PROJ.rubyforge_name, PROJ.name, PROJ.version, *files
35
+ end
36
+ end # namespace :gem
37
+
38
+
39
+ namespace :doc do
40
+ desc "Publish RDoc to RubyForge"
41
+ task :release => %w(doc:clobber_rdoc doc:rdoc) do
42
+ config = YAML.load(
43
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
44
+ )
45
+
46
+ host = "#{config['username']}@rubyforge.org"
47
+ remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge_name}/"
48
+ remote_dir << PROJ.rdoc_remote_dir if PROJ.rdoc_remote_dir
49
+ local_dir = PROJ.rdoc_dir
50
+
51
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
52
+ end
53
+ end # namespace :doc
54
+
55
+ end # if HAVE_RUBYFORGE
56
+
57
+ # EOF