wackamole 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.
- data/.bnsignore +16 -0
- data/.gitignore +2 -0
- data/History.txt +4 -0
- data/README.rdoc +88 -0
- data/Rakefile +42 -0
- data/aa.rb +25 -0
- data/aaa.txt +13 -0
- data/bin/wackamole +77 -0
- data/lib/app.rb +63 -0
- data/lib/controllers/dashboard.rb +30 -0
- data/lib/controllers/features.rb +41 -0
- data/lib/controllers/logs.rb +49 -0
- data/lib/controllers/mission.rb +27 -0
- data/lib/controllers/users.rb +41 -0
- data/lib/helpers/dashboard_helper.rb +32 -0
- data/lib/helpers/features_helper.rb +13 -0
- data/lib/helpers/flash_helper.rb +16 -0
- data/lib/helpers/logs_helper.rb +116 -0
- data/lib/helpers/main_helper.rb +182 -0
- data/lib/helpers/mission_helper.rb +59 -0
- data/lib/helpers/rails_helper.rb +7 -0
- data/lib/wackamole.rb +47 -0
- data/lib/wackamole/core_ext/date_time.rb +8 -0
- data/lib/wackamole/core_ext/time.rb +9 -0
- data/lib/wackamole/models/control.rb +132 -0
- data/lib/wackamole/models/feature.rb +74 -0
- data/lib/wackamole/models/log.rb +45 -0
- data/lib/wackamole/models/mission.rb +164 -0
- data/lib/wackamole/models/mole_info.rb +94 -0
- data/lib/wackamole/models/search_filter.rb +192 -0
- data/lib/wackamole/models/user.rb +46 -0
- data/public/favicon.ico +0 -0
- data/public/images/.DS_Store +0 -0
- data/public/images/browsers/.DS_Store +0 -0
- data/public/images/browsers/MSIE 6.png +0 -0
- data/public/images/browsers/MSIE 8.0 +0 -0
- data/public/images/browsers/MSIE 8.0.png +0 -0
- data/public/images/browsers/chrome.png +0 -0
- data/public/images/browsers/firefox.png +0 -0
- data/public/images/browsers/ie 6.0.png +0 -0
- data/public/images/browsers/ie6.jpg +0 -0
- data/public/images/browsers/ie7.jpg +0 -0
- data/public/images/browsers/ie7.png +0 -0
- data/public/images/browsers/msie 6.0.png +0 -0
- data/public/images/browsers/msie 7.0.png +0 -0
- data/public/images/browsers/opera.jpg +0 -0
- data/public/images/browsers/opera.png +0 -0
- data/public/images/browsers/safari.jpg +0 -0
- data/public/images/browsers/safari.png +0 -0
- data/public/images/browsers/unknown_browser.png +0 -0
- data/public/images/close.png +0 -0
- data/public/images/error.png +0 -0
- data/public/images/fade.png +0 -0
- data/public/images/fault_big.png +0 -0
- data/public/images/fault_small.png +0 -0
- data/public/images/feature.png +0 -0
- data/public/images/h300.png +0 -0
- data/public/images/hori_large.png +0 -0
- data/public/images/info_big.png +0 -0
- data/public/images/info_small.png +0 -0
- data/public/images/loading.gif +0 -0
- data/public/images/loading1.gif +0 -0
- data/public/images/mole_error.png +0 -0
- data/public/images/more.gif +0 -0
- data/public/images/next.png +0 -0
- data/public/images/perf_big.png +0 -0
- data/public/images/perf_small.png +0 -0
- data/public/images/powered_by.png +0 -0
- data/public/images/prev.png +0 -0
- data/public/images/row_fade.png +0 -0
- data/public/images/search.png +0 -0
- data/public/images/small_logo.png +0 -0
- data/public/images/spaceball.gif +0 -0
- data/public/images/tick.png +0 -0
- data/public/images/users.png +0 -0
- data/public/images/wackamole_logo.png +0 -0
- data/public/javascripts/.DS_Store +0 -0
- data/public/javascripts/application.js +28 -0
- data/public/javascripts/g.dot.min.js +7 -0
- data/public/javascripts/g.raphael.min.js +7 -0
- data/public/javascripts/jit.js +9052 -0
- data/public/javascripts/jit.min.js +1 -0
- data/public/javascripts/jquery-ui.js +188 -0
- data/public/javascripts/jquery.example.js +160 -0
- data/public/javascripts/jquery.js +19 -0
- data/public/javascripts/jquery.tools.min.js +38 -0
- data/public/javascripts/jquery_ba-url.js +9 -0
- data/public/javascripts/jquery_min.js +19 -0
- data/public/javascripts/jquery_ui_min.js +298 -0
- data/public/javascripts/raphael.min.js +7 -0
- data/public/stylesheets/tabs-slideshow.css +95 -0
- data/public/stylesheets/wackamole.css +684 -0
- data/spec/config/bogus_test.yml +3 -0
- data/spec/config/test.yml +3 -0
- data/spec/core_ext/date_time_spec.rb +8 -0
- data/spec/core_ext/time_spec.rb +12 -0
- data/spec/data/fixtures.rb +92 -0
- data/spec/models/control_spec.rb +98 -0
- data/spec/models/feature_spec.rb +52 -0
- data/spec/models/log_spec.rb +43 -0
- data/spec/models/mission_spec.rb +225 -0
- data/spec/models/moled_info_spec.rb +30 -0
- data/spec/models/search_filter_spec.rb +151 -0
- data/spec/models/user_spec.rb +44 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/wackamole_spec.rb +20 -0
- data/tasks/bones.rake +20 -0
- data/tasks/fixtures.rake +13 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +32 -0
- data/tasks/rdoc.rake +54 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +290 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +46 -0
- data/views/dashboard/_report.erb +118 -0
- data/views/dashboard/index.erb +4 -0
- data/views/dashboard/refresh_js.erb +3 -0
- data/views/features/_rows.erb +26 -0
- data/views/features/filter.js.erb +2 -0
- data/views/features/index.erb +24 -0
- data/views/features/index.js.erb +2 -0
- data/views/layout.erb +47 -0
- data/views/logs/_array.erb +12 -0
- data/views/logs/_hash.erb +14 -0
- data/views/logs/_rows.erb +65 -0
- data/views/logs/filter.js.erb +4 -0
- data/views/logs/index.erb +13 -0
- data/views/logs/index.js.erb +2 -0
- data/views/logs/show.erb +66 -0
- data/views/mission/_report.erb +49 -0
- data/views/mission/index.erb +7 -0
- data/views/mission/refresh_js.erb +3 -0
- data/views/shared/_filter.erb +63 -0
- data/views/shared/_flash.erb +3 -0
- data/views/shared/_search.erb +25 -0
- data/views/shared/_timestamp.erb +1 -0
- data/views/shared/_wait.erb +1 -0
- data/views/shared/flash.js.erb +10 -0
- data/views/users/_rows.erb +26 -0
- data/views/users/filter.js.erb +4 -0
- data/views/users/index.erb +24 -0
- data/views/users/index.js.erb +2 -0
- metadata +347 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
require 'chronic'
|
|
3
|
+
|
|
4
|
+
describe Wackamole::MoledInfo do
|
|
5
|
+
before( :all ) do
|
|
6
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
7
|
+
Wackamole::Control.connection.should_not be_nil
|
|
8
|
+
Wackamole::Control.db( "mole_fred_test_mdb" )
|
|
9
|
+
@test_time = Chronic.parse( "2010/01/01 01:00:00" ).utc
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should gather dashboard info correctly" do
|
|
13
|
+
info = Wackamole::MoledInfo.collect_dashboard_info( @test_time )
|
|
14
|
+
|
|
15
|
+
info[:total_users].should == 10
|
|
16
|
+
info[:user_load].should == 2
|
|
17
|
+
info[:total_features].should == 10
|
|
18
|
+
info[:feature_load].should == 2
|
|
19
|
+
info[:fault_load].should == 2
|
|
20
|
+
info[:perf_load].should == 2
|
|
21
|
+
|
|
22
|
+
series = 24.times.collect { |i| 0 }
|
|
23
|
+
series[0] = 5
|
|
24
|
+
series[1] = 2
|
|
25
|
+
info[:user_series].should == series
|
|
26
|
+
info[:feature_series].should == series
|
|
27
|
+
info[:fault_series].should == series
|
|
28
|
+
info[:perf_series].should == series
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
|
|
3
|
+
describe Wackamole::SearchFilter do
|
|
4
|
+
before( :each ) do
|
|
5
|
+
@filter = Wackamole::SearchFilter.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should initialize with the correct defaults" do
|
|
9
|
+
@filter = Wackamole::SearchFilter.new
|
|
10
|
+
check_filter( @filter, "today", "All", "", -1)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should reset a filter correctly" do
|
|
14
|
+
@filter = Wackamole::SearchFilter.new
|
|
15
|
+
@filter.time_frame = "1 year"
|
|
16
|
+
@filter.browser_type = "Safari"
|
|
17
|
+
@filter.search_terms = "blee"
|
|
18
|
+
@filter.feature_id = 10
|
|
19
|
+
check_filter( @filter, "1 year", "Safari", "blee", 10 )
|
|
20
|
+
@filter.reset!
|
|
21
|
+
check_filter( @filter, "today", "All", "", -1)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "series" do
|
|
25
|
+
it "should generate the correct time_ids" do
|
|
26
|
+
@filter.time_frame = "7 days"
|
|
27
|
+
@filter.time_ids.should have(8).items
|
|
28
|
+
@filter.time_ids.each { |did| did.size.should == 8 }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should generate the correct time series" do
|
|
32
|
+
@filter.time_frame = "10 days"
|
|
33
|
+
@filter.time_series.should have(11).items
|
|
34
|
+
@filter.time_series.each { |date| date.should match( /\d{4}\-\d{2}\-\d{2}/) }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should populate correctly from request params" do
|
|
39
|
+
@filter.from_options( {:time_frame => '1 year', :browser_type => 'Safari', :search_terms => "blee", :feature_id => 100 } )
|
|
40
|
+
check_filter( @filter, "1 year", "Safari", "blee", 100 )
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "#to_conds"
|
|
44
|
+
before :all do
|
|
45
|
+
@now = Time.now
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should spews default filter query conds correctly" do
|
|
49
|
+
conds = @filter.to_conds
|
|
50
|
+
conds.should have(1).item
|
|
51
|
+
conds.key?( :did ).should == true
|
|
52
|
+
conds[:did].should == { "$gte" => @now.to_date_id.to_s }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should include browser if specified correctly" do
|
|
56
|
+
@filter.browser_type = 'Safari'
|
|
57
|
+
conds = @filter.to_conds
|
|
58
|
+
time = Chronic.parse( "now" ).utc
|
|
59
|
+
conds.should have(2).items
|
|
60
|
+
conds.key?( :did ).should == true
|
|
61
|
+
conds[:did].should == { "$gte" => @now.to_date_id.to_s }
|
|
62
|
+
conds[:bro].should == "Safari"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should include mole type is specfied" do
|
|
66
|
+
@filter.browser_type = 'Safari'
|
|
67
|
+
@filter.type = Wackamole::SearchFilter.mole_types[1]
|
|
68
|
+
conds = @filter.to_conds
|
|
69
|
+
time = Chronic.parse( "now" ).utc
|
|
70
|
+
conds.should have(3).items
|
|
71
|
+
conds.key?( :did ).should == true
|
|
72
|
+
conds[:did].should == { "$gte" => @now.to_date_id.to_s }
|
|
73
|
+
conds[:bro].should == "Safari"
|
|
74
|
+
conds[:typ].should == Rackamole.feature
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should include feature is specfied" do
|
|
78
|
+
@filter.feature_id = "4b25b0049983a8a193000010"
|
|
79
|
+
conds = @filter.to_conds
|
|
80
|
+
time = Chronic.parse( "now" ).utc
|
|
81
|
+
conds.should have(2).items
|
|
82
|
+
conds.key?( :did ).should == true
|
|
83
|
+
conds[:did].should == { "$gte" => @now.to_date_id.to_s }
|
|
84
|
+
conds[:fid].should == Mongo::ObjectID.from_string( "4b25b0049983a8a193000010" )
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe "search terms" do
|
|
88
|
+
before( :all ) do
|
|
89
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
90
|
+
Wackamole::Control.connection.should_not be_nil
|
|
91
|
+
Wackamole::Control.db( "mole_fred_test_mdb" )
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should include user if specified" do
|
|
95
|
+
@filter.search_terms = "user:blee_0@fred.test"
|
|
96
|
+
conds = @filter.to_conds
|
|
97
|
+
conds.should have(2).items
|
|
98
|
+
conds[:uid].should_not be_nil
|
|
99
|
+
conds[:uid].key?( "$in" ).should == true
|
|
100
|
+
conds[:uid]["$in"].should have(1).item
|
|
101
|
+
conds[:uid]["$in"].first.to_s.size.should == 24
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should include an adoc regexp if specified" do
|
|
105
|
+
@filter.search_terms = "key:blee"
|
|
106
|
+
conds = @filter.to_conds
|
|
107
|
+
conds.should have(2).items
|
|
108
|
+
conds['key'].should_not be_nil
|
|
109
|
+
conds['key'].should == /blee/
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should include an adoc regexp if specified" do
|
|
113
|
+
@filter.search_terms = "key:blee:duh"
|
|
114
|
+
conds = @filter.to_conds
|
|
115
|
+
conds.should have(2).items
|
|
116
|
+
conds['key.blee'].should_not be_nil
|
|
117
|
+
conds['key.blee'].should == /duh/
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "should raise an exception is search exp cannot be parsed" do
|
|
121
|
+
lambda {
|
|
122
|
+
@filter.search_terms = "key:blee:duh:booba"
|
|
123
|
+
conds = @filter.to_conds
|
|
124
|
+
}.should raise_error /Unable to evaluate search terms/
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe "#map_mole_type" do
|
|
129
|
+
it "should map mole types correctly" do
|
|
130
|
+
%w[Feature Perf Fault].each { |type| @filter.send( :map_mole_type, type ).should == Rackamole.send( type.downcase ) }
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "should crap out for invalid mole types" do
|
|
134
|
+
lambda {
|
|
135
|
+
@filter.send( :map_mole_type, "bozo" )
|
|
136
|
+
}.should raise_error( /Invalid mole type `bozo/ )
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should reset a time stamp correctly" do
|
|
141
|
+
@filter.send( :now ).strftime( "%H:%M:%S" ).should match( /00\:00\:00/ )
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def check_filter( filter, time_frame, browser, terms, feature_id )
|
|
147
|
+
filter.time_frame.should == time_frame
|
|
148
|
+
filter.browser_type.should == browser
|
|
149
|
+
filter.search_terms.should == terms
|
|
150
|
+
filter.feature_id.should == feature_id
|
|
151
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
require 'chronic'
|
|
3
|
+
|
|
4
|
+
describe Wackamole::User do
|
|
5
|
+
before( :all ) do
|
|
6
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
7
|
+
Wackamole::Control.connection.should_not be_nil
|
|
8
|
+
Wackamole::Control.db( "mole_fred_test_mdb" )
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should paginate a user collection correctly" do
|
|
12
|
+
cltn = Wackamole::User.paginate_tops( {}, 1, 2 )
|
|
13
|
+
cltn.total_entries.should == 7
|
|
14
|
+
cltn.size.should == 2
|
|
15
|
+
cltn.total_pages.should == 4
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "indexes" do
|
|
19
|
+
before :all do
|
|
20
|
+
@cltn = Wackamole::User.users_cltn
|
|
21
|
+
@cltn.should_not be_nil
|
|
22
|
+
@cltn.drop_indexes
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should set up indexes correctly" do
|
|
26
|
+
indexes = @cltn.index_information
|
|
27
|
+
indexes.should have(1).item
|
|
28
|
+
count = Wackamole::User.ensure_indexes!
|
|
29
|
+
count.should == 1
|
|
30
|
+
indexes = @cltn.index_information
|
|
31
|
+
indexes.should have(2).items
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should do nothing if indexes are already present" do
|
|
35
|
+
indexes = @cltn.index_information
|
|
36
|
+
indexes.should have(2).items
|
|
37
|
+
count = Wackamole::User.ensure_indexes!
|
|
38
|
+
count.should == 1
|
|
39
|
+
indexes = @cltn.index_information
|
|
40
|
+
indexes.should have(2).items
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'mongo'
|
|
3
|
+
require 'rackamole'
|
|
4
|
+
gem 'agnostic-will_paginate'
|
|
5
|
+
require 'will_paginate'
|
|
6
|
+
require 'forwardable'
|
|
7
|
+
|
|
8
|
+
require File.expand_path( File.join(File.dirname(__FILE__), %w[data fixtures]))
|
|
9
|
+
require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib wackamole]))
|
|
10
|
+
|
|
11
|
+
# BOZO !! To run test you'll need to start a mongo instance
|
|
12
|
+
# mongod --dbpath /data/wackamole/ --port 27777
|
|
13
|
+
Spec::Runner.configure do |config|
|
|
14
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
|
2
|
+
|
|
3
|
+
describe Wackamole do
|
|
4
|
+
before( :all ) do
|
|
5
|
+
@root = ::File.expand_path( ::File.join(::File.dirname(__FILE__), ".." ) )
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "is versioned" do
|
|
9
|
+
Wackamole.version.should =~ /\d+\.\d+\.\d+/
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "generates a correct path relative to root" do
|
|
13
|
+
Wackamole.path( "wackamole.rb" ).should == ::File.join(@root, "wackamole.rb" )
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "generates a correct path relative to lib" do
|
|
17
|
+
Wackamole.libpath(%w[ models control.rb]).should == ::File.join( @root, "lib", "models", "control.rb" )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
data/tasks/bones.rake
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
if HAVE_BONES
|
|
3
|
+
|
|
4
|
+
namespace :bones do
|
|
5
|
+
|
|
6
|
+
desc 'Show the PROJ open struct'
|
|
7
|
+
task :debug do |t|
|
|
8
|
+
atr = if t.application.top_level_tasks.length == 2
|
|
9
|
+
t.application.top_level_tasks.pop
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if atr then Bones::Debug.show_attr(PROJ, atr)
|
|
13
|
+
else Bones::Debug.show PROJ end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end # namespace :bones
|
|
17
|
+
|
|
18
|
+
end # HAVE_BONES
|
|
19
|
+
|
|
20
|
+
# EOF
|
data/tasks/fixtures.rake
ADDED
data/tasks/gem.rake
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
|
|
2
|
+
require 'find'
|
|
3
|
+
require 'rake/packagetask'
|
|
4
|
+
require 'rubygems/user_interaction'
|
|
5
|
+
require 'rubygems/builder'
|
|
6
|
+
|
|
7
|
+
module Bones
|
|
8
|
+
class GemPackageTask < Rake::PackageTask
|
|
9
|
+
# Ruby GEM spec containing the metadata for this package. The
|
|
10
|
+
# name, version and package_files are automatically determined
|
|
11
|
+
# from the GEM spec and don't need to be explicitly provided.
|
|
12
|
+
#
|
|
13
|
+
attr_accessor :gem_spec
|
|
14
|
+
|
|
15
|
+
# Tasks from the Bones gem directory
|
|
16
|
+
attr_reader :bones_files
|
|
17
|
+
|
|
18
|
+
# Create a GEM Package task library. Automatically define the gem
|
|
19
|
+
# if a block is given. If no block is supplied, then +define+
|
|
20
|
+
# needs to be called to define the task.
|
|
21
|
+
#
|
|
22
|
+
def initialize(gem_spec)
|
|
23
|
+
init(gem_spec)
|
|
24
|
+
yield self if block_given?
|
|
25
|
+
define if block_given?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Initialization tasks without the "yield self" or define
|
|
29
|
+
# operations.
|
|
30
|
+
#
|
|
31
|
+
def init(gem)
|
|
32
|
+
super(gem.name, gem.version)
|
|
33
|
+
@gem_spec = gem
|
|
34
|
+
@package_files += gem_spec.files if gem_spec.files
|
|
35
|
+
@bones_files = []
|
|
36
|
+
|
|
37
|
+
local_setup = File.join(Dir.pwd, %w[tasks setup.rb])
|
|
38
|
+
if !test(?e, local_setup)
|
|
39
|
+
Dir.glob(::Bones.path(%w[lib bones tasks *])).each {|fn| bones_files << fn}
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Create the Rake tasks and actions specified by this
|
|
44
|
+
# GemPackageTask. (+define+ is automatically called if a block is
|
|
45
|
+
# given to +new+).
|
|
46
|
+
#
|
|
47
|
+
def define
|
|
48
|
+
super
|
|
49
|
+
task :prereqs
|
|
50
|
+
task :package => ['gem:prereqs', "#{package_dir_path}/#{gem_file}"]
|
|
51
|
+
file "#{package_dir_path}/#{gem_file}" => [package_dir_path] + package_files + bones_files do
|
|
52
|
+
when_writing("Creating GEM") {
|
|
53
|
+
chdir(package_dir_path) do
|
|
54
|
+
Gem::Builder.new(gem_spec).build
|
|
55
|
+
verbose(true) {
|
|
56
|
+
mv gem_file, "../#{gem_file}"
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
file package_dir_path => bones_files do
|
|
63
|
+
mkdir_p package_dir rescue nil
|
|
64
|
+
|
|
65
|
+
gem_spec.files = (gem_spec.files +
|
|
66
|
+
bones_files.map {|fn| File.join('tasks', File.basename(fn))}).sort
|
|
67
|
+
|
|
68
|
+
bones_files.each do |fn|
|
|
69
|
+
base_fn = File.join('tasks', File.basename(fn))
|
|
70
|
+
f = File.join(package_dir_path, base_fn)
|
|
71
|
+
fdir = File.dirname(f)
|
|
72
|
+
mkdir_p(fdir) if !File.exist?(fdir)
|
|
73
|
+
if File.directory?(fn)
|
|
74
|
+
mkdir_p(f)
|
|
75
|
+
else
|
|
76
|
+
raise "file name conflict for '#{base_fn}' (conflicts with '#{fn}')" if test(?e, f)
|
|
77
|
+
safe_ln(fn, f)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def gem_file
|
|
84
|
+
if @gem_spec.platform == Gem::Platform::RUBY
|
|
85
|
+
"#{package_name}.gem"
|
|
86
|
+
else
|
|
87
|
+
"#{package_name}-#{@gem_spec.platform}.gem"
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end # class GemPackageTask
|
|
91
|
+
end # module Bones
|
|
92
|
+
|
|
93
|
+
namespace :gem do
|
|
94
|
+
|
|
95
|
+
PROJ.gem._spec = Gem::Specification.new do |s|
|
|
96
|
+
s.name = PROJ.name
|
|
97
|
+
s.version = PROJ.version
|
|
98
|
+
s.summary = PROJ.summary
|
|
99
|
+
s.authors = Array(PROJ.authors)
|
|
100
|
+
s.email = PROJ.email
|
|
101
|
+
s.homepage = Array(PROJ.url).first
|
|
102
|
+
s.rubyforge_project = PROJ.rubyforge.name
|
|
103
|
+
|
|
104
|
+
s.description = PROJ.description
|
|
105
|
+
|
|
106
|
+
PROJ.gem.dependencies.each do |dep|
|
|
107
|
+
s.add_dependency(*dep)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
PROJ.gem.development_dependencies.each do |dep|
|
|
111
|
+
s.add_development_dependency(*dep)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
s.files = PROJ.gem.files
|
|
115
|
+
s.executables = PROJ.gem.executables.map {|fn| File.basename(fn)}
|
|
116
|
+
s.extensions = PROJ.gem.files.grep %r/extconf\.rb$/
|
|
117
|
+
|
|
118
|
+
s.bindir = 'bin'
|
|
119
|
+
dirs = Dir["{#{PROJ.libs.join(',')}}"]
|
|
120
|
+
s.require_paths = dirs unless dirs.empty?
|
|
121
|
+
|
|
122
|
+
incl = Regexp.new(PROJ.rdoc.include.join('|'))
|
|
123
|
+
excl = PROJ.rdoc.exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
|
|
124
|
+
excl = Regexp.new(excl.join('|'))
|
|
125
|
+
rdoc_files = PROJ.gem.files.find_all do |fn|
|
|
126
|
+
case fn
|
|
127
|
+
when excl; false
|
|
128
|
+
when incl; true
|
|
129
|
+
else false end
|
|
130
|
+
end
|
|
131
|
+
s.rdoc_options = PROJ.rdoc.opts + ['--main', PROJ.rdoc.main]
|
|
132
|
+
s.extra_rdoc_files = rdoc_files
|
|
133
|
+
s.has_rdoc = true
|
|
134
|
+
|
|
135
|
+
if test ?f, PROJ.test.file
|
|
136
|
+
s.test_file = PROJ.test.file
|
|
137
|
+
else
|
|
138
|
+
s.test_files = PROJ.test.files.to_a
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Do any extra stuff the user wants
|
|
142
|
+
PROJ.gem.extras.each do |msg, val|
|
|
143
|
+
case val
|
|
144
|
+
when Proc
|
|
145
|
+
val.call(s.send(msg))
|
|
146
|
+
else
|
|
147
|
+
s.send "#{msg}=", val
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end # Gem::Specification.new
|
|
151
|
+
|
|
152
|
+
Bones::GemPackageTask.new(PROJ.gem._spec) do |pkg|
|
|
153
|
+
pkg.need_tar = PROJ.gem.need_tar
|
|
154
|
+
pkg.need_zip = PROJ.gem.need_zip
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
desc 'Show information about the gem'
|
|
158
|
+
task :debug => 'gem:prereqs' do
|
|
159
|
+
puts PROJ.gem._spec.to_ruby
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
desc 'Write the gemspec '
|
|
163
|
+
task :spec => 'gem:prereqs' do
|
|
164
|
+
File.open("#{PROJ.name}.gemspec", 'w') do |f|
|
|
165
|
+
f.write PROJ.gem._spec.to_ruby
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
desc 'Install the gem'
|
|
170
|
+
task :install => [:clobber, 'gem:package'] do
|
|
171
|
+
sh "#{SUDO} #{GEM} install --local pkg/#{PROJ.gem._spec.full_name}"
|
|
172
|
+
|
|
173
|
+
# use this version of the command for rubygems > 1.0.0
|
|
174
|
+
#sh "#{SUDO} #{GEM} install --no-update-sources pkg/#{PROJ.gem._spec.full_name}"
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
desc 'Uninstall the gem'
|
|
178
|
+
task :uninstall do
|
|
179
|
+
installed_list = Gem.source_index.find_name(PROJ.name)
|
|
180
|
+
if installed_list and installed_list.collect { |s| s.version.to_s}.include?(PROJ.version) then
|
|
181
|
+
sh "#{SUDO} #{GEM} uninstall --version '#{PROJ.version}' --ignore-dependencies --executables #{PROJ.name}"
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
desc 'Reinstall the gem'
|
|
186
|
+
task :reinstall => [:uninstall, :install]
|
|
187
|
+
|
|
188
|
+
desc 'Cleanup the gem'
|
|
189
|
+
task :cleanup do
|
|
190
|
+
sh "#{SUDO} #{GEM} cleanup #{PROJ.gem._spec.name}"
|
|
191
|
+
end
|
|
192
|
+
end # namespace :gem
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
desc 'Alias to gem:package'
|
|
196
|
+
task :gem => 'gem:package'
|
|
197
|
+
|
|
198
|
+
task :clobber => 'gem:clobber_package'
|
|
199
|
+
remove_desc_for_task 'gem:clobber_package'
|
|
200
|
+
|
|
201
|
+
# EOF
|