scalarium_cli 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/scalarium/application.rb +16 -7
- data/lib/scalarium/cli.rb +19 -9
- data/lib/scalarium/version.rb +1 -1
- data/spec/scalarium/application_spec.rb +19 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,10 +2,25 @@ module Scalarium
|
|
2
2
|
class Application
|
3
3
|
attr_accessor :email, :password, :slug
|
4
4
|
|
5
|
-
|
5
|
+
%w{deploy rollback start stop restart undeploy}.each do |command|
|
6
|
+
class_eval <<-EOF
|
7
|
+
def #{command}(options={})
|
8
|
+
run('#{command}', options)
|
9
|
+
end
|
10
|
+
EOF
|
11
|
+
end
|
12
|
+
|
13
|
+
def config
|
14
|
+
yield(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def run(deploy_command, options={})
|
6
20
|
login do
|
7
21
|
agent.get("https://manage.scalarium.com/applications/#{slug}/deployments/new") do |page|
|
8
22
|
form = page.forms.first
|
23
|
+
form["deployment[command]"] = deploy_command
|
9
24
|
form["deployment[migrate]"] = 1 if options[:run_migrations]
|
10
25
|
form["deployment[comment]"] = options[:comment]
|
11
26
|
form.click_button
|
@@ -13,12 +28,6 @@ module Scalarium
|
|
13
28
|
end
|
14
29
|
end
|
15
30
|
|
16
|
-
def config
|
17
|
-
yield(self)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
31
|
def login
|
23
32
|
agent.get("https://manage.scalarium.com/session/new") do |page|
|
24
33
|
manage_page = page.form_with(:action => "/session") do |f|
|
data/lib/scalarium/cli.rb
CHANGED
@@ -2,12 +2,22 @@ require "thor"
|
|
2
2
|
|
3
3
|
module Scalarium
|
4
4
|
class CLI < Thor
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
%w{deploy rollback start stop restart undeploy}.each do |command|
|
6
|
+
class_eval <<-EOF
|
7
|
+
desc "#{command} [staging|production]", "#{command} to specified env"
|
8
|
+
method_options :migrate => :boolean,
|
9
|
+
:config => :string,
|
10
|
+
:comment => :string
|
9
11
|
|
10
|
-
|
12
|
+
def #{command}(env="production")
|
13
|
+
run(:#{command}, env)
|
14
|
+
end
|
15
|
+
EOF
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def run(command, env)
|
11
21
|
application = Scalarium::Application.new
|
12
22
|
|
13
23
|
application.config do |x|
|
@@ -16,13 +26,13 @@ module Scalarium
|
|
16
26
|
x.slug = config[env]["slug"]
|
17
27
|
end
|
18
28
|
|
19
|
-
|
29
|
+
deploy_options = {
|
20
30
|
:run_migrations => options.migrate?,
|
21
31
|
:comment => options[:comment]
|
22
|
-
|
23
|
-
end
|
32
|
+
}
|
24
33
|
|
25
|
-
|
34
|
+
application.send(command, deploy_options)
|
35
|
+
end
|
26
36
|
|
27
37
|
def config
|
28
38
|
@config ||= begin
|
data/lib/scalarium/version.rb
CHANGED
@@ -87,5 +87,24 @@ describe Scalarium::Application do
|
|
87
87
|
it { should have_requested(:post, "https://manage.scalarium.com/applications/railslove/deployments").
|
88
88
|
with {|req| req.body.match(/comment%5D=Hello/) } }
|
89
89
|
end
|
90
|
+
|
91
|
+
%w{deploy rollback start stop restart undeploy}.each do |command|
|
92
|
+
context "when performing a #{command}" do
|
93
|
+
before do
|
94
|
+
@application.config do |c|
|
95
|
+
c.email = "test@email.com"
|
96
|
+
c.password = "password"
|
97
|
+
c.slug = "railslove"
|
98
|
+
end
|
99
|
+
|
100
|
+
@application.send(command)
|
101
|
+
end
|
102
|
+
|
103
|
+
subject { WebMock::API }
|
104
|
+
|
105
|
+
it { should have_requested(:post, "https://manage.scalarium.com/applications/railslove/deployments").
|
106
|
+
with {|req| req.body.match(/command%5D=#{command}/) } }
|
107
|
+
end
|
108
|
+
end
|
90
109
|
end
|
91
110
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scalarium_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Davis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-30 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|