bushido 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ["s@bushi.do"]
11
11
  s.homepage = "http://gem.bushi.do"
12
12
  s.summary = %q{Command-lin interface for bushi.do}
13
- s.description = %q{A command line tool to do everything with bushido, from signing up and deploying new apps, to claiming, restarting, and updating existing apps}
13
+ s.description = %q{A module for a Bushido app to manipulate everything about itself while running on Bushido, from deploying new apps, to claiming, restarting, updating existing apps, changing public domain, subdomains, etc.}
14
14
 
15
15
  s.add_dependency "rest-client", ">=1.6.1"
16
16
  s.add_dependency "json", ">=1.4.6"
@@ -50,11 +50,17 @@ module Bushido
50
50
 
51
51
  def add_var(key, value)
52
52
  put :add_var, {:key => key, :value => value}
53
+ if Bushido::Command.last_command_successful?
54
+ ENV[key.upcase] = value
55
+ end
53
56
  end
54
57
 
55
58
 
56
59
  def remove_var(key)
57
60
  put :remove_var, {:key => key}
61
+ if Bushido::Command.last_command_successful?
62
+ ENV[key.upcase] = nil
63
+ end
58
64
  end
59
65
 
60
66
 
@@ -78,17 +84,24 @@ module Bushido
78
84
 
79
85
 
80
86
  def set_subdomain(subdomain)
81
- put :set_subdomain, {:subdomain => subdomain}
87
+ result = put :set_subdomain!, {:subdomain => subdomain}
88
+ if Bushido::Command.last_command_successful?
89
+ ENV["BUSHIDO_SUBDOMAIN"] = subdomain
90
+ ENV["PUBLIC_URL"] = "http://#{subdomain}.#{ENV['APP_TLD']}/"
91
+ return result
92
+ end
93
+
94
+ result
82
95
  end
83
96
 
84
97
 
85
98
  def add_domain(domain)
86
- put :add_domain, {:domain => domain}
99
+ put :add_domain!, {:domain => domain}
87
100
  end
88
101
 
89
102
 
90
103
  def remove_domain(domain)
91
- put :remove_domain, {:domain => domain}
104
+ put :remove_domain!, {:domain => domain}
92
105
  end
93
106
 
94
107
 
@@ -2,6 +2,7 @@ module Bushido
2
2
  class Command
3
3
  @@last_request = nil
4
4
  @@request_count = 0
5
+ @@last_request_successful = true
5
6
 
6
7
  class << self
7
8
  def request_count
@@ -12,7 +13,15 @@ module Bushido
12
13
  @@request_count += 1
13
14
  params.merge!({:auth_token => Bushido::Platform.key}) if params[:auth_token].nil? unless Bushido::Platform.key.nil?
14
15
 
15
- raw = RestClient.get(url, {:params => params, :accept => :json})
16
+ begin
17
+ raw = RestClient.get(url, {:params => params, :accept => :json})
18
+ rescue => e
19
+ puts e.inspect
20
+ @@last_request_successful = false
21
+ return nil
22
+ end
23
+
24
+ @@last_request_successful = true
16
25
  @@last_request = JSON.parse raw
17
26
  end
18
27
 
@@ -20,7 +29,15 @@ module Bushido
20
29
  @@request_count += 1
21
30
  params.merge!({:auth_token => Bushido::Platform.key}) if params[:auth_token].nil? unless Bushido::Platform.key.nil?
22
31
 
23
- raw = RestClient.post(url, params.to_json, :content_type => :json, :accept => :json)
32
+ begin
33
+ raw = RestClient.post(url, params.to_json, :content_type => :json, :accept => :json)
34
+ rescue => e
35
+ puts e.inspect
36
+ @@last_request_successful = false
37
+ return nil
38
+ end
39
+
40
+ @@last_request_successful = true
24
41
  @@last_request = JSON.parse raw
25
42
  end
26
43
 
@@ -29,13 +46,29 @@ module Bushido
29
46
  if meta[:force]
30
47
  params.merge!({:auth_token => Bushido::Platform.key}) if params[:auth_token].nil? unless Bushido::Platform.key.nil?
31
48
 
32
- raw = RestClient.put(url, params.to_json, :content_type => :json)
49
+ begin
50
+ raw = RestClient.put(url, params.to_json, :content_type => :json)
51
+ rescue => e
52
+ puts e.inspect
53
+ @@last_request_successful = false
54
+ return nil
55
+ end
56
+
57
+ @@last_request_successful = true
33
58
  @@last_request = JSON.parse raw
34
59
 
35
60
  else
36
61
  params.merge!({:auth_token => Bushido::Platform.key}) if params[:auth_token].nil? unless Bushido::Platform.key.nil?
37
62
 
38
- raw = RestClient.put(url, params.to_json, :content_type => :json)
63
+ begin
64
+ raw = RestClient.put(url, params.to_json, :content_type => :json)
65
+ rescue => e
66
+ puts e.inspect
67
+ @@last_request_successful = false
68
+ return nil
69
+ end
70
+
71
+ @@last_request_successful = true
39
72
  @@last_request = JSON.parse raw
40
73
  end
41
74
  end
@@ -64,7 +97,7 @@ module Bushido
64
97
  end
65
98
 
66
99
  def last_command_successful?
67
- @@last_request.nil? or @@last_request["errors"].nil?
100
+ @@last_request_successful
68
101
  end
69
102
 
70
103
  def last_command_errored?
@@ -1,6 +1,9 @@
1
1
  module Bushido
2
2
  class Utils
3
3
  class << self
4
+ # TODO: Make this update all the available ENV variables
5
+ def refresh_env!
6
+ end
4
7
  end
5
8
  end
6
9
  end
@@ -1,3 +1,3 @@
1
1
  module Bushido
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bushido
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.11
5
+ version: 0.0.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sean Grove
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-28 00:00:00 -07:00
13
+ date: 2011-03-31 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: 1.6.1
47
47
  type: :runtime
48
48
  version_requirements: *id003
49
- description: A command line tool to do everything with bushido, from signing up and deploying new apps, to claiming, restarting, and updating existing apps
49
+ description: A module for a Bushido app to manipulate everything about itself while running on Bushido, from deploying new apps, to claiming, restarting, updating existing apps, changing public domain, subdomains, etc.
50
50
  email:
51
51
  - s@bushi.do
52
52
  executables: