ubalo 0.15 → 0.16

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ubalo CHANGED
@@ -259,9 +259,13 @@ end
259
259
 
260
260
  desc 'Push files to Ubalo'
261
261
  command :push do |c|
262
+ c.switch :detached
263
+
262
264
  c.action do |global_options,options,args|
263
265
  pod.push_from(pod_dir)
264
- pod.tail_process
266
+ unless options.detached
267
+ pod.tail_process
268
+ end
265
269
  puts pod.printable_result
266
270
  end
267
271
  end
@@ -282,6 +286,15 @@ command 'push-run' do |c|
282
286
  end
283
287
  end
284
288
 
289
+ desc 'Cancel a pod compilation'
290
+ command 'push:cancel' do |c|
291
+ c.action do |global_options,options,args|
292
+ pod.cancel_push!
293
+ pod.tail_process
294
+ puts pod.printable_result
295
+ end
296
+ end
297
+
285
298
  pre do |global,command,options,args|
286
299
  @connect_url = ENV['UBALO_CONNECT_URL'] || "https://ubalo.com"
287
300
 
@@ -12,10 +12,50 @@ module Ubalo
12
12
  end
13
13
 
14
14
  def request method, path = nil, options = {}
15
+ url = url_for(path)
16
+ headers = ubalo_headers.merge({:accept => :json})
17
+
15
18
  if authorization and !options[:skip_authorization]
16
- options[:authorization] = authorization
19
+ headers[:authorization] = authorization
20
+ end
21
+
22
+ params = options.delete(:params) || {}
23
+
24
+ if Util.debug_mode?
25
+ $stderr.puts "request method=#{method.inspect} url=#{url.inspect} options=#{options.inspect} headers=#{headers.inspect} params=#{params.inspect}"
26
+ end
27
+
28
+ resource = RestClient::Resource.new url, :timeout => 60
29
+ case method
30
+ when :get
31
+ response = resource.get headers.merge(:params => params)
32
+ when :post
33
+ response = resource.post params, headers
34
+ when :put
35
+ response = resource.put params, headers
36
+ when :delete
37
+ response = resource.delete headers
38
+ else
39
+ raise "don't understand request method #{method.inspect}"
17
40
  end
18
- Util.http_request(method, url_for(path), options)
41
+
42
+ if response.code == 204
43
+ nil
44
+ elsif options.delete(:parse) == false
45
+ response
46
+ else
47
+ JSON.load(response)
48
+ end
49
+ rescue RestClient::Request::Unauthorized
50
+ raise Ubalo::Error, "Your credentials are invalid. #{Util.login_suggestion}"
51
+ rescue RestClient::BadRequest => e
52
+ if message = JSON.load(e.response.to_s)["upgrade_message"]
53
+ raise Ubalo::Error, message
54
+ else
55
+ raise e
56
+ end
57
+ rescue RestClient::BadGateway, RestClient::ServiceUnavailable => e
58
+ raise Ubalo::Error, "Ubalo is unable to handle your request at this time"
19
59
  end
20
60
 
21
61
  def url_for(path)
@@ -87,5 +127,14 @@ module Ubalo
87
127
  def update_attributes(attributes)
88
128
  @username = attributes['username']
89
129
  end
130
+
131
+ def ubalo_headers
132
+ {
133
+ 'X-Ubalo-Version' => Ubalo.version,
134
+ 'User-Agent' => "ubalo-cli/#{Ubalo.version}",
135
+ 'X-Ruby-Version' => RUBY_VERSION,
136
+ 'X-Ruby-Platform' => RUBY_PLATFORM,
137
+ }
138
+ end
90
139
  end
91
140
  end
@@ -84,6 +84,11 @@ module Ubalo
84
84
  logger.puts " done."
85
85
  end
86
86
 
87
+ def cancel_push!
88
+ request(:put, "/stop")
89
+ refresh!
90
+ end
91
+
87
92
  def clone_to(pod_dir)
88
93
  refresh!
89
94
  archive.extract_to(pod_dir)
@@ -18,7 +18,7 @@ module Ubalo
18
18
  def update(output)
19
19
  @lines.times do
20
20
  @logger.print "\e[A"
21
- @logger.print " " * ENV.fetch("COLUMNS", 80)
21
+ @logger.print " " * Integer(ENV.fetch("COLUMNS", 80))
22
22
  @logger.print "\r"
23
23
  end
24
24
 
@@ -91,59 +91,6 @@ module Ubalo
91
91
  end
92
92
  end
93
93
 
94
- def ubalo_headers
95
- {
96
- 'X-Ubalo-Version' => Ubalo.version,
97
- 'User-Agent' => "ubalo-cli/#{Ubalo.version}",
98
- 'X-Ruby-Version' => RUBY_VERSION,
99
- 'X-Ruby-Platform' => RUBY_PLATFORM,
100
- }
101
- end
102
-
103
- def http_request(method, url, options)
104
- params = options.delete(:params) || {}
105
-
106
- headers = ubalo_headers.merge({:accept => :json})
107
-
108
- if authorization = options.delete(:authorization)
109
- headers.merge!(:authorization => authorization)
110
- end
111
-
112
- if debug_mode?
113
- $stderr.puts "about to #{method.inspect} to #{url.inspect} with #{options.inspect}"
114
- end
115
-
116
- resource = RestClient::Resource.new url, :timeout => 60
117
- case method
118
- when :get
119
- response = resource.get headers.merge(:params => params)
120
- when :post
121
- response = resource.post params, headers
122
- when :put
123
- response = resource.put params, headers
124
- when :delete
125
- response = resource.delete headers
126
- else
127
- raise "don't understand request method #{method.inspect}"
128
- end
129
-
130
- if response.code == 204
131
- nil
132
- elsif options.delete(:parse) == false
133
- response
134
- else
135
- JSON.load(response)
136
- end
137
- rescue RestClient::Request::Unauthorized
138
- raise Ubalo::Error, "Your credentials are invalid. #{login_suggestion}"
139
- rescue RestClient::BadRequest => e
140
- if message = JSON.load(e.response.to_s)["upgrade_message"]
141
- raise Ubalo::Error, message
142
- else
143
- raise e
144
- end
145
- end
146
-
147
94
  def login_suggestion
148
95
  "Please run ubalo login."
149
96
  end
@@ -211,11 +158,9 @@ module Ubalo
211
158
  end
212
159
  end
213
160
 
214
- private
215
161
  def debug_mode?
216
162
  ENV['UBALO_DEBUG'] == 'true'
217
163
  end
218
-
219
164
  end
220
165
  end
221
166
  end
@@ -1,6 +1,6 @@
1
1
  module Ubalo
2
2
  unless const_defined?('VERSION')
3
- VERSION = "0.15"
3
+ VERSION = "0.16"
4
4
  end
5
5
 
6
6
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ubalo
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.15'
4
+ version: '0.16'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-01 00:00:00.000000000 Z
12
+ date: 2012-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
16
- requirement: &70318706609560 !ruby/object:Gem::Requirement
16
+ requirement: &70197562743800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70318706609560
24
+ version_requirements: *70197562743800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: highline
27
- requirement: &70318706608600 !ruby/object:Gem::Requirement
27
+ requirement: &70197562711140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70318706608600
35
+ version_requirements: *70197562711140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &70318706607400 !ruby/object:Gem::Requirement
38
+ requirement: &70197562707560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70318706607400
46
+ version_requirements: *70197562707560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
- requirement: &70318706606660 !ruby/object:Gem::Requirement
49
+ requirement: &70197562706240 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.3
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70318706606660
57
+ version_requirements: *70197562706240
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: archive-tar-minitar
60
- requirement: &70318706605940 !ruby/object:Gem::Requirement
60
+ requirement: &70197562705480 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70318706605940
68
+ version_requirements: *70197562705480
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: launchy
71
- requirement: &70318706604880 !ruby/object:Gem::Requirement
71
+ requirement: &70197562704740 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70318706604880
79
+ version_requirements: *70197562704740
80
80
  description: CLI and API client for Ubalo
81
81
  email: dev@ubalo.com
82
82
  executables: