scalarium_cli 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scalarium_cli (0.0.1)
4
+ scalarium_cli (0.0.2)
5
5
  mechanize (~> 1.0.0)
6
6
  thor (~> 0.14.6)
7
7
 
data/README.md CHANGED
@@ -30,6 +30,10 @@ Then from the Root directory, just run
30
30
 
31
31
  sca deploy staging
32
32
 
33
+ You have access to all Scalarium deployment commands
34
+
35
+ sca [deploy|rollback|start|stop|restart|undeploy]
36
+
33
37
  #### Other options
34
38
 
35
39
  Run migrations
@@ -2,10 +2,25 @@ module Scalarium
2
2
  class Application
3
3
  attr_accessor :email, :password, :slug
4
4
 
5
- def deploy(options={})
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
- desc "deploy [staging|production]", "deploy to specified env"
6
- method_options :migrate => :boolean,
7
- :config => :string,
8
- :comment => :string
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
- def deploy(env="production")
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
- application.deploy(
29
+ deploy_options = {
20
30
  :run_migrations => options.migrate?,
21
31
  :comment => options[:comment]
22
- )
23
- end
32
+ }
24
33
 
25
- private
34
+ application.send(command, deploy_options)
35
+ end
26
36
 
27
37
  def config
28
38
  @config ||= begin
@@ -1,3 +1,3 @@
1
1
  module Scalarium
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
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-29 00:00:00 +00:00
18
+ date: 2010-12-30 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency