duke 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/VERSION +1 -1
- data/duke.gemspec +1 -1
- data/lib/duke.rb +3 -0
- data/lib/duke/app.rb +3 -3
- data/lib/duke/controller.rb +5 -1
- data/spec/duke/controller_spec.rb +18 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -32,7 +32,9 @@ Duke will clone the repo and configure it with some defaults.
|
|
32
32
|
=== Default Configuration
|
33
33
|
|
34
34
|
host: localhost
|
35
|
-
Used to generate links to cijoes
|
35
|
+
Used to generate links to cijoes and the main duke url.
|
36
|
+
port: nil
|
37
|
+
Used to generate the main duke url.
|
36
38
|
runner: rake
|
37
39
|
When duke checks out a new repo it will configure it to build using this command.
|
38
40
|
pid_dir: tmp/pids
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/duke.gemspec
CHANGED
data/lib/duke.rb
CHANGED
@@ -28,4 +28,7 @@ module Duke
|
|
28
28
|
config_yml = File.exist?(config_path) ? YAML.load_file(config_path) : {}
|
29
29
|
config = CONFIG_DEFAULT.merge(config_yml)
|
30
30
|
Config = OpenStruct.new(config)
|
31
|
+
url = "http://#{Config.host}"
|
32
|
+
url += ":#{Config.port}" if Config.port
|
33
|
+
Config.host_url = url
|
31
34
|
end
|
data/lib/duke/app.rb
CHANGED
@@ -23,15 +23,15 @@ module Duke
|
|
23
23
|
@project = Project.find(:repo_dir => params[:id])
|
24
24
|
if @project.running?
|
25
25
|
@project.stop
|
26
|
-
|
26
|
+
elsif params[:project][:port]
|
27
27
|
@project.start(params[:project][:port])
|
28
28
|
end
|
29
|
-
redirect
|
29
|
+
redirect Config.host_url
|
30
30
|
end
|
31
31
|
|
32
32
|
post '/projects' do
|
33
33
|
Project.create(params[:project])
|
34
|
-
redirect
|
34
|
+
redirect Config.host_url
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/duke/controller.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Duke
|
2
2
|
class Controller
|
3
3
|
extend Forwardable
|
4
|
-
def_delegators :controller, :start, :stop, :
|
4
|
+
def_delegators :controller, :start, :stop, :pid
|
5
5
|
attr_reader :dir, :repo_dir, :timeout, :port
|
6
6
|
|
7
7
|
def self.pid_files
|
@@ -27,6 +27,10 @@ module Duke
|
|
27
27
|
nil
|
28
28
|
end
|
29
29
|
|
30
|
+
def running?
|
31
|
+
port.nil? ? false : controller.running?
|
32
|
+
end
|
33
|
+
|
30
34
|
def identifier
|
31
35
|
"#{repo_dir}.#{port}"
|
32
36
|
end
|
@@ -89,6 +89,24 @@ describe Controller do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
describe "#running" do
|
93
|
+
context "when port is nil" do
|
94
|
+
it "is false" do
|
95
|
+
@controller.stub(:port).and_return(nil)
|
96
|
+
@controller.running?.should be_false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when port is not nil" do
|
101
|
+
it "is delegates to controller" do
|
102
|
+
controller = double("controller")
|
103
|
+
controller.should_receive(:running?).and_return('running?')
|
104
|
+
@controller.stub(:controller).and_return(controller)
|
105
|
+
@controller.running?.should == "running?"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
92
110
|
describe "#controller" do
|
93
111
|
it "instantiates a DaemonController" do
|
94
112
|
@controller.stub(:identifier).and_return("identifier")
|