auser-poolparty 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -2
- data/Rakefile +61 -4
- data/bin/instance +3 -1
- data/bin/pool +6 -2
- data/config/sample-config.yml +4 -4
- data/lib/core/object.rb +3 -0
- data/lib/helpers/plugin_spec_helper.rb +59 -0
- data/lib/modules/ec2_wrapper.rb +3 -1
- data/lib/modules/file_writer.rb +1 -1
- data/lib/modules/vlad_override.rb +83 -83
- data/lib/poolparty.rb +31 -13
- data/lib/poolparty/application.rb +22 -15
- data/lib/poolparty/init.rb +1 -1
- data/lib/poolparty/master.rb +41 -28
- data/lib/poolparty/monitors.rb +1 -3
- data/lib/poolparty/monitors/cpu.rb +7 -3
- data/lib/poolparty/monitors/memory.rb +14 -7
- data/lib/poolparty/monitors/web.rb +11 -5
- data/lib/poolparty/provider/packages/essential.rb +1 -1
- data/lib/poolparty/provider/packages/heartbeat.rb +1 -1
- data/lib/poolparty/provider/packages/ruby.rb +1 -10
- data/lib/poolparty/remote_instance.rb +5 -18
- data/lib/poolparty/remoter.rb +55 -4
- data/lib/poolparty/scheduler.rb +15 -25
- data/lib/poolparty/thread_pool.rb +94 -0
- data/poolparty.gemspec +9 -6
- data/spec/application_spec.rb +32 -13
- data/spec/callback_spec.rb +20 -1
- data/spec/file_writer_spec.rb +1 -0
- data/spec/kernel_spec.rb +13 -0
- data/spec/master_spec.rb +50 -20
- data/spec/monitors/cpu_monitor_spec.rb +1 -1
- data/spec/plugin_manager_spec.rb +9 -17
- data/spec/plugin_spec.rb +34 -34
- data/spec/poolparty_spec.rb +41 -1
- data/spec/remote_instance_spec.rb +5 -18
- data/spec/scheduler_spec.rb +7 -6
- data/spec/spec_helper.rb +8 -18
- metadata +19 -6
- data/lib/poolparty/tasks/package.rake +0 -53
@@ -21,7 +21,7 @@ describe "monitors" do
|
|
21
21
|
)
|
22
22
|
end
|
23
23
|
it "should try to collect the cpu for the entire set of remote instances when calling cpu" do
|
24
|
-
@master.nodes.should_receive(:inject).once.and_return 0.0
|
24
|
+
@master.nodes.should_receive(:inject).once.with(0).and_return 0.0
|
25
25
|
@master.cpu
|
26
26
|
end
|
27
27
|
end
|
data/spec/plugin_manager_spec.rb
CHANGED
@@ -4,28 +4,20 @@ describe "Plugin manager" do
|
|
4
4
|
before(:each) do
|
5
5
|
FileUtils.stub!(:mkdir_p).and_return true
|
6
6
|
Dir["./spec/../lib/../vendor/*"].each {|a| FileUtils.rm_rf a}
|
7
|
+
Git.stub!(:clone).and_return true
|
8
|
+
PluginManager.stub!(:extract_git_repos_from_plugin_dirs).and_return %w(git@github.com:auser/poolparty-plugins.git)
|
7
9
|
end
|
8
10
|
it "should git clone the directory when it is installing a plugin" do
|
9
11
|
File.stub!(:directory?).and_return false
|
10
|
-
Git.should_receive(:clone).with("git@github.com:auser/
|
11
|
-
PluginManager.install_plugin "git@github.com:auser/
|
12
|
+
Git.should_receive(:clone).with("git@github.com:auser/poolparty.git", "/Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/pool/vendor/poolparty").and_return true
|
13
|
+
PluginManager.install_plugin "git@github.com:auser/poolparty.git"
|
12
14
|
end
|
13
|
-
it "should keep a list of the installed plugin locations" do
|
15
|
+
it "should keep a list of the installed plugin locations" do
|
16
|
+
PluginManager.should_receive(:install_plugin).and_return true
|
14
17
|
PluginManager.install_plugin "git@github.com:auser/poolparty-plugins.git"
|
15
18
|
PoolParty.installed_plugins.should == ["git@github.com:auser/poolparty-plugins.git"]
|
16
19
|
end
|
17
|
-
it "should be able to rescan the plugin directory and tell which plugins are installed"
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
it "should be able to remove a plugin based on the name" do
|
22
|
-
PluginManager.install_plugin "git@github.com:auser/poolparty-plugins.git"
|
23
|
-
PluginManager.remove_plugin "poolparty-plugins"
|
24
|
-
PluginManager.scan.should == %w()
|
25
|
-
end
|
26
|
-
it "should be able to extract the git repos from the .git/config file" do
|
27
|
-
PluginManager.install_plugin "git@github.com:auser/poolparty-plugins.git"
|
28
|
-
PoolParty.reset!
|
29
|
-
PoolParty.installed_plugins.should == ["git@github.com:auser/poolparty-plugins.git"]
|
30
|
-
end
|
20
|
+
it "should be able to rescan the plugin directory and tell which plugins are installed"
|
21
|
+
it "should be able to remove a plugin based on the name"
|
22
|
+
it "should be able to extract the git repos from the .git/config file"
|
31
23
|
end
|
data/spec/plugin_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
class TestPlugin < PoolParty::Plugin
|
4
4
|
after_define_tasks :takss
|
5
|
-
after_install :
|
5
|
+
after_install :email_updates, :echo_hosts
|
6
6
|
before_configure_cloud :echo_hosts
|
7
7
|
after_start :echo_start
|
8
8
|
|
@@ -10,14 +10,16 @@ class TestPlugin < PoolParty::Plugin
|
|
10
10
|
"start"
|
11
11
|
end
|
12
12
|
def echo_hosts(caller)
|
13
|
-
"hosts"
|
13
|
+
write_out "hosts"
|
14
14
|
end
|
15
15
|
def email_updates(caller)
|
16
|
-
"
|
16
|
+
write_out "email_updates"
|
17
17
|
end
|
18
18
|
def takss(tasks)
|
19
19
|
"tasks"
|
20
20
|
end
|
21
|
+
def write_out(msg="")
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
describe "Plugin" do
|
@@ -33,46 +35,44 @@ describe "Plugin" do
|
|
33
35
|
describe "usage" do
|
34
36
|
before(:each) do
|
35
37
|
stub_option_load
|
36
|
-
@
|
37
|
-
@master =
|
38
|
-
|
39
|
-
@test = TestPlugin.new
|
40
|
-
@test.stub!(:echo_hosts).and_return("true")
|
41
|
-
@test.stub!(:email_updates).and_return("true")
|
42
|
-
@test.stub!(:echo_start).and_return("true")
|
43
|
-
TestPlugin.stub!(:new).and_return(@test)
|
44
|
-
Kernel.stub!(:wait).and_return true
|
45
|
-
|
46
|
-
@master.stub!(:launch_minimum_instances).and_return true
|
47
|
-
@master.stub!(:number_of_pending_instances).and_return 0
|
48
|
-
@master.stub!(:get_node).with(0).and_return @instance
|
49
|
-
|
50
|
-
@instance.stub!(:ssh).and_return "true"
|
51
|
-
@instance.stub!(:scp).and_return "true"
|
52
|
-
Kernel.stub!(:system).and_return "true"
|
38
|
+
@num = 2
|
39
|
+
@test, @master, @instances = PoolParty::PluginSpecHelper.define_stubs(TestPlugin, @num)
|
40
|
+
@instance = @instances.first
|
53
41
|
end
|
54
|
-
it "should should call echo_hosts after calling configure" do
|
55
|
-
@test.
|
56
|
-
# @instance.stub!(:)
|
42
|
+
it "should should call echo_hosts after calling configure" do
|
43
|
+
@test.should_receive_at_least_once(:write_out).with("email_updates")
|
57
44
|
@instance.install
|
58
45
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
46
|
+
describe "installation" do
|
47
|
+
before(:each) do
|
48
|
+
Application.stub!(:install_on_load?).and_return true
|
49
|
+
end
|
50
|
+
it "should call install on each of the instances after calling install_cloud" do
|
51
|
+
@test.should_receive(:email_updates).exactly(@num)
|
52
|
+
@test.should_receive(:echo_hosts).exactly(@num)
|
53
|
+
@master.install_cloud
|
54
|
+
end
|
55
|
+
it "should call email_updates after calling install" do
|
56
|
+
@test.should_receive(:email_updates).twice
|
57
|
+
@master.install_cloud
|
58
|
+
end
|
59
|
+
it "should call echo_hosts before it calls configure" do
|
60
|
+
@test.should_receive(:echo_hosts).at_least(1).and_return "hi"
|
61
|
+
@master.install_cloud
|
62
|
+
end
|
62
63
|
end
|
63
|
-
it "should
|
64
|
-
@
|
65
|
-
@master.
|
64
|
+
it "should say that it started on the master" do
|
65
|
+
@master.stub!(:launch_minimum_instances)
|
66
|
+
@master.stub!(:wait_for_all_instances_to_boot)
|
67
|
+
@master.stub!(:setup_cloud)
|
68
|
+
@test.should_receive(:echo_start).at_least(1).and_return "hi"
|
69
|
+
@master.start
|
66
70
|
end
|
67
71
|
it "should not call echo_hosts after if configures" do
|
72
|
+
@test.stub!(:echo_hosts).and_return true
|
68
73
|
@test.should_not_receive(:email_updates)
|
69
74
|
@master.configure_cloud
|
70
75
|
end
|
71
|
-
it "should say that it started on the master" do
|
72
|
-
@test.should_receive(:echo_start).at_least(1).and_return "hi"
|
73
|
-
@master.stub!(:install_cloud)
|
74
|
-
@master.start
|
75
|
-
end
|
76
76
|
describe "instance methods" do
|
77
77
|
before(:each) do
|
78
78
|
@str = "filename"
|
data/spec/poolparty_spec.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
+
module TestMonitor
|
4
|
+
module Master
|
5
|
+
end
|
6
|
+
module Remote
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
3
10
|
describe "Application options" do
|
4
11
|
before(:each) do
|
5
|
-
|
12
|
+
stub_option_load
|
6
13
|
end
|
7
14
|
it "should be able to say that the plugin directory is the current directory" do
|
8
15
|
File.basename(PoolParty.plugin_dir).should == "vendor"
|
@@ -17,4 +24,37 @@ describe "Application options" do
|
|
17
24
|
Dir.should_receive(:[]).and_return %w()
|
18
25
|
PoolParty.load_plugins
|
19
26
|
end
|
27
|
+
describe "monitors" do
|
28
|
+
before(:each) do
|
29
|
+
PoolParty.reset!
|
30
|
+
end
|
31
|
+
it "should load a monitor and store it into the registered monitor's array" do
|
32
|
+
PoolParty.register_monitor TestMonitor
|
33
|
+
PoolParty.registered_monitors.include?(TestMonitor).should == true
|
34
|
+
end
|
35
|
+
it "should be able to ask if the monitor is a registered monitor" do
|
36
|
+
PoolParty.register_monitor TestMonitor
|
37
|
+
PoolParty.registered_monitor?(TestMonitor).should == true
|
38
|
+
end
|
39
|
+
it "should not register a monitor more than once" do
|
40
|
+
PoolParty::Monitors.should_receive(:extend).once
|
41
|
+
PoolParty.register_monitor TestMonitor
|
42
|
+
PoolParty.register_monitor TestMonitor
|
43
|
+
end
|
44
|
+
it "should try to load from the user directory before the root lib directory" do
|
45
|
+
File.should_receive_at_least_once(:directory?).with("#{user_dir}/monitors").and_return true
|
46
|
+
Dir.should_receive(:[]).with("#{user_dir}/monitors/*").and_return([])
|
47
|
+
PoolParty.load
|
48
|
+
end
|
49
|
+
it "should try to load from the root directory if the user directory monitors don't exist" do
|
50
|
+
File.should_receive_at_least_once(:directory?).with("#{user_dir}/monitors").and_return false
|
51
|
+
Dir.should_receive(:[]).with("#{Application.root_dir}/lib/poolparty/monitors/*").and_return([])
|
52
|
+
PoolParty.load
|
53
|
+
end
|
54
|
+
it "should load the monitors and the plugins" do
|
55
|
+
PoolParty.should_receive(:load_plugins)
|
56
|
+
PoolParty.should_receive(:load_monitors)
|
57
|
+
PoolParty.load
|
58
|
+
end
|
59
|
+
end
|
20
60
|
end
|
@@ -61,22 +61,6 @@ describe "remote instance" do
|
|
61
61
|
Kernel.stub!(:system).and_return true
|
62
62
|
stub_option_load
|
63
63
|
end
|
64
|
-
# it "should try to run the scp build file" do
|
65
|
-
# Master.should_receive(:build_scp_instances_script_for).with(@instance).and_return @tempfile
|
66
|
-
# @instance.configure
|
67
|
-
# end
|
68
|
-
# it "should try to run and build the reconfigure script for the node" do
|
69
|
-
# Master.should_receive(:build_reconfigure_instances_script_for).with(@instance).and_return @tempfile
|
70
|
-
# @instance.configure
|
71
|
-
# end
|
72
|
-
# it "should scp the reconfigure file to the remote instance" do
|
73
|
-
# @instance.should_receive(:scp).once.and_return true
|
74
|
-
# @instance.configure
|
75
|
-
# end
|
76
|
-
# it "should ssh and execute the reconfigure file on the remote instance" do
|
77
|
-
# @instance.should_receive(:ssh).once.with("chmod +x /usr/local/src/reconfigure.sh && /bin/sh /usr/local/src/reconfigure.sh").and_return true
|
78
|
-
# @instance.configure
|
79
|
-
# end
|
80
64
|
describe "with a public ip" do
|
81
65
|
before(:each) do
|
82
66
|
Application.stub!(:public_ip).and_return "127.0.0.1"
|
@@ -88,7 +72,7 @@ describe "remote instance" do
|
|
88
72
|
@master.configure_cloud
|
89
73
|
end
|
90
74
|
it "should run associate_address if there is a public_ip set in the Application.options" do
|
91
|
-
@instance.should_receive(:associate_address_with).with(Application.public_ip, @instance.instance_id).and_return true
|
75
|
+
@instance.should_receive(:associate_address_with).with(Application.public_ip, @instance.instance_id).at_least(1).and_return true
|
92
76
|
@master.configure_cloud
|
93
77
|
end
|
94
78
|
it "should not run associate_address_with if the public_ip is empty" do
|
@@ -96,7 +80,10 @@ describe "remote instance" do
|
|
96
80
|
@instance.should_not_receive(:associate_address_with)
|
97
81
|
@master.configure_cloud
|
98
82
|
end
|
99
|
-
|
83
|
+
it "should untar and move plugin directories around" do
|
84
|
+
dir = File.basename Application.plugin_dir
|
85
|
+
@instance.update_plugin_string.should == "mkdir -p #{dir} && tar -zxf plugins.tar.gz -C #{dir}"
|
86
|
+
end
|
100
87
|
end
|
101
88
|
end
|
102
89
|
describe "in failover" do
|
data/spec/scheduler_spec.rb
CHANGED
@@ -39,10 +39,6 @@ describe "Scheduler" do
|
|
39
39
|
@test.add_task {@klass.pop}
|
40
40
|
@stasks.tasks.size.should == 1
|
41
41
|
end
|
42
|
-
it "should add each task as a thread" do
|
43
|
-
Thread.should_receive(:new).once
|
44
|
-
@stasks.push proc{puts "hi"}
|
45
|
-
end
|
46
42
|
end
|
47
43
|
describe "when running" do
|
48
44
|
before(:each) do
|
@@ -56,8 +52,13 @@ describe "Scheduler" do
|
|
56
52
|
@klass.should_receive(:pop)
|
57
53
|
@test.run_thread_list
|
58
54
|
end
|
59
|
-
it "should
|
60
|
-
|
55
|
+
it "should use the ThreadPool" do
|
56
|
+
p = ThreadPool.new(10)
|
57
|
+
ThreadPool.should_receive(:new).with(10).and_return p
|
58
|
+
@test.run_thread_list
|
59
|
+
end
|
60
|
+
it "should process each of the tasks" do
|
61
|
+
@klass.should_receive(:pop)
|
61
62
|
@test.run_thread_list
|
62
63
|
end
|
63
64
|
it "should empty all the tasks after running them in the loop" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
lpwd = File.dirname(__FILE__)
|
2
|
+
$:.unshift(lpwd)
|
3
|
+
require File.join(lpwd, *%w[.. lib poolparty])
|
2
4
|
|
3
|
-
%w(
|
5
|
+
%w(spec).each do |library|
|
4
6
|
begin
|
5
7
|
require library
|
6
8
|
rescue
|
@@ -20,6 +22,8 @@ def stub_option_load
|
|
20
22
|
@str=<<-EOS
|
21
23
|
:access_key:
|
22
24
|
3.14159
|
25
|
+
:secret_access_key:
|
26
|
+
"pi"
|
23
27
|
EOS
|
24
28
|
@sio = StringIO.new
|
25
29
|
StringIO.stub!(:new).and_return @sio
|
@@ -27,6 +31,7 @@ def stub_option_load
|
|
27
31
|
@sio.stub!(:read).and_return @str
|
28
32
|
PoolParty.stub!(:timer).and_return Timeout
|
29
33
|
PoolParty.timer.stub!(:timeout).and_return lambda {YAML.load(open("http://169.254.169.254/latest/user-data").read)}
|
34
|
+
Application.reset!
|
30
35
|
end
|
31
36
|
|
32
37
|
def wait_launch(time=5)
|
@@ -34,19 +39,4 @@ def wait_launch(time=5)
|
|
34
39
|
wait time
|
35
40
|
Process.kill("INT", pid)
|
36
41
|
Process.wait(pid, 0)
|
37
|
-
end
|
38
|
-
|
39
|
-
module Test::Unit::AssertDifference
|
40
|
-
def assert_difference(object, method = nil, difference = 1)
|
41
|
-
initial_value = object.send(method)
|
42
|
-
yield
|
43
|
-
assert_equal initial_value + difference, object.send(method), "#{object}##{method}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def assert_no_difference(object, method, &block)
|
47
|
-
assert_difference object, method, 0, &block
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
Test::Spec::Should.send(:include, Test::Unit::AssertDifference)
|
52
|
-
Test::Spec::ShouldNot.send(:include, Test::Unit::AssertDifference)
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auser-poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
|
-
date: 2008-
|
11
|
+
date: 2008-07-02 00:00:00 -07:00
|
12
12
|
default_executable:
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
@@ -65,6 +65,15 @@ dependencies:
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: "0"
|
67
67
|
version:
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: echoe
|
70
|
+
version_requirement:
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
68
77
|
description: Run your entire application off EC2, managed and auto-scaling
|
69
78
|
email: ari.lerner@citrusbyte.com
|
70
79
|
executables:
|
@@ -92,6 +101,8 @@ extra_rdoc_files:
|
|
92
101
|
- lib/core/proc.rb
|
93
102
|
- lib/core/string.rb
|
94
103
|
- lib/core/time.rb
|
104
|
+
- lib/helpers
|
105
|
+
- lib/helpers/plugin_spec_helper.rb
|
95
106
|
- lib/modules
|
96
107
|
- lib/modules/callback.rb
|
97
108
|
- lib/modules/ec2_wrapper.rb
|
@@ -134,9 +145,9 @@ extra_rdoc_files:
|
|
134
145
|
- lib/poolparty/tasks/development.rake
|
135
146
|
- lib/poolparty/tasks/ec2.rake
|
136
147
|
- lib/poolparty/tasks/instance.rake
|
137
|
-
- lib/poolparty/tasks/package.rake
|
138
148
|
- lib/poolparty/tasks/plugins.rake
|
139
149
|
- lib/poolparty/tasks/server.rake
|
150
|
+
- lib/poolparty/thread_pool.rb
|
140
151
|
- lib/s3
|
141
152
|
- lib/s3/s3_object_store_folders.rb
|
142
153
|
files:
|
@@ -177,6 +188,8 @@ files:
|
|
177
188
|
- lib/core/proc.rb
|
178
189
|
- lib/core/string.rb
|
179
190
|
- lib/core/time.rb
|
191
|
+
- lib/helpers
|
192
|
+
- lib/helpers/plugin_spec_helper.rb
|
180
193
|
- lib/modules
|
181
194
|
- lib/modules/callback.rb
|
182
195
|
- lib/modules/ec2_wrapper.rb
|
@@ -219,9 +232,9 @@ files:
|
|
219
232
|
- lib/poolparty/tasks/development.rake
|
220
233
|
- lib/poolparty/tasks/ec2.rake
|
221
234
|
- lib/poolparty/tasks/instance.rake
|
222
|
-
- lib/poolparty/tasks/package.rake
|
223
235
|
- lib/poolparty/tasks/plugins.rake
|
224
236
|
- lib/poolparty/tasks/server.rake
|
237
|
+
- lib/poolparty/thread_pool.rb
|
225
238
|
- lib/s3
|
226
239
|
- lib/s3/s3_object_store_folders.rb
|
227
240
|
- spec
|
@@ -257,8 +270,8 @@ files:
|
|
257
270
|
- spec/string_spec.rb
|
258
271
|
- poolparty.gemspec
|
259
272
|
has_rdoc: true
|
260
|
-
homepage: http://
|
261
|
-
post_install_message: "\n \n Get ready to jump in the pool, you just installed PoolParty! (Updated at
|
273
|
+
homepage: http://poolpartyrb.com
|
274
|
+
post_install_message: "\n \n Get ready to jump in the pool, you just installed PoolParty! (Updated at 02:12PM, 07/02/08)\n\n Please check out the documentation for any questions or check out the google groups at\n http://groups.google.com/group/poolpartyrb\n\n Don't forget to check out the plugin tutorial @ http://poolpartyrb.com for extending PoolParty! \n\n For more information, check http://poolpartyrb.com\n On IRC: \n irc.freenode.net\n #poolpartyrb\n *** Ari Lerner @ <ari.lerner@citrusbyte.com> ***\n "
|
262
275
|
rdoc_options:
|
263
276
|
- --line-numbers
|
264
277
|
- --inline-source
|
@@ -1,53 +0,0 @@
|
|
1
|
-
namespace(:pkg) do
|
2
|
-
## Rake task to create/update a .manifest file in your project, as well as update *.gemspec
|
3
|
-
desc %{Update ".manifest" with the latest list of project filenames. Respect\
|
4
|
-
.gitignore by excluding everything that git ignores. Update `files` and\
|
5
|
-
`test_files` arrays in "*.gemspec" file if it's present.}
|
6
|
-
task :manifest do
|
7
|
-
list = Dir['**/*'].sort
|
8
|
-
spec_file = Dir['*.gemspec'].first
|
9
|
-
list -= [spec_file] if spec_file
|
10
|
-
|
11
|
-
File.read('.gitignore').each_line do |glob|
|
12
|
-
glob = glob.chomp.sub(/^\//, '')
|
13
|
-
list -= Dir[glob]
|
14
|
-
list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
|
15
|
-
puts "excluding #{glob}"
|
16
|
-
end
|
17
|
-
|
18
|
-
if spec_file
|
19
|
-
spec = File.read spec_file
|
20
|
-
spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
|
21
|
-
assignment = $1
|
22
|
-
bunch = $2 ? list.grep(/^test\//) : list
|
23
|
-
'%s%%w(%s)' % [assignment, bunch.join(' ')]
|
24
|
-
end
|
25
|
-
|
26
|
-
File.open(spec_file, 'w') {|f| f << spec }
|
27
|
-
end
|
28
|
-
File.open('Manifest', 'w') {|f| f << list.join("\n") }
|
29
|
-
end
|
30
|
-
desc "Build gemspec for github"
|
31
|
-
task :gemspec => :manifest do
|
32
|
-
require "yaml"
|
33
|
-
`rake gem`
|
34
|
-
data = YAML.load(open("poolparty.gemspec").read).to_ruby
|
35
|
-
File.open("poolparty.gemspec", "w+") {|f| f << data }
|
36
|
-
end
|
37
|
-
desc "Update gemspec with the time"
|
38
|
-
task :gemspec_update => :gemspec do
|
39
|
-
data = open("poolparty.gemspec").read
|
40
|
-
str = "Updated at #{Time.now.strftime("%I:%M%p, %D")}"
|
41
|
-
|
42
|
-
if data.scan(/Updated at/).empty?
|
43
|
-
data = data.gsub(/you just installed PoolParty\!/, '\0'+" (#{str})")
|
44
|
-
end
|
45
|
-
|
46
|
-
File.open("poolparty.gemspec", "w+") {|f| f << data }
|
47
|
-
end
|
48
|
-
desc "Release them gem to the gem server"
|
49
|
-
task :release => :gemspec_update do
|
50
|
-
`git ci -a -m "Updated gemspec for github"`
|
51
|
-
`git push gem`
|
52
|
-
end
|
53
|
-
end
|