ubalo 0.0.23 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ubalo +13 -11
- data/lib/ubalo.rb +19 -9
- data/lib/ubalo/version.rb +1 -1
- metadata +11 -10
data/bin/ubalo
CHANGED
@@ -120,11 +120,13 @@ command :tasks do |c|
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
def process_download
|
124
|
-
name =
|
125
|
-
fullname =
|
126
|
-
url =
|
127
|
-
|
123
|
+
def process_download pod_response, files_response, destination_path=nil
|
124
|
+
name = pod_response.fetch('name')
|
125
|
+
fullname = pod_response.fetch('fullname')
|
126
|
+
url = pod_response.fetch('url')
|
127
|
+
|
128
|
+
files = files_response.fetch('files')
|
129
|
+
|
128
130
|
destination_path ||= name
|
129
131
|
|
130
132
|
if File.exists?(destination_path)
|
@@ -142,7 +144,7 @@ def process_download response, destination_path=nil
|
|
142
144
|
local_filename = File.join(destination_path, filename)
|
143
145
|
FileUtils.mkdir_p(File.dirname(local_filename))
|
144
146
|
File.open(local_filename, "w") do |f|
|
145
|
-
f.
|
147
|
+
f.write content
|
146
148
|
end
|
147
149
|
end
|
148
150
|
|
@@ -157,9 +159,9 @@ command :get do |c|
|
|
157
159
|
destination_path = args.shift
|
158
160
|
|
159
161
|
$stderr.print "Fetching files for #{pod_name}..."
|
160
|
-
|
162
|
+
pod_response, files_response = ubalo.download(pod_name)
|
161
163
|
|
162
|
-
fullname, destination_path = process_download(
|
164
|
+
fullname, destination_path = process_download(pod_response, files_response)
|
163
165
|
$stderr.puts " done."
|
164
166
|
$stderr.puts "Retrieved #{fullname} into #{destination_path}."
|
165
167
|
end
|
@@ -207,9 +209,9 @@ command :create do |c|
|
|
207
209
|
end
|
208
210
|
|
209
211
|
$stderr.print "Creating a new #{template_name} pod called #{pod_name}..."
|
210
|
-
|
212
|
+
pod_response, files_response = ubalo.create_pod(pod_name, template_name)
|
211
213
|
|
212
|
-
fullname, destination_path = process_download(
|
214
|
+
fullname, destination_path = process_download(pod_response, files_response)
|
213
215
|
|
214
216
|
$stderr.puts " done."
|
215
217
|
$stderr.puts "Created #{fullname} and placed in #{destination_path}/."
|
@@ -323,7 +325,7 @@ command :pull do |c|
|
|
323
325
|
menu.prompt = "Changes made to #{filename}. Overwrite your copy? "
|
324
326
|
menu.choice :yes do
|
325
327
|
open(filename, 'w') do |f|
|
326
|
-
f.
|
328
|
+
f.write files.fetch(filename)
|
327
329
|
end
|
328
330
|
puts "Changes saved to #{filename}."
|
329
331
|
end
|
data/lib/ubalo.rb
CHANGED
@@ -131,19 +131,22 @@ class Ubalo
|
|
131
131
|
@base_url = base_url
|
132
132
|
end
|
133
133
|
|
134
|
-
def
|
134
|
+
def raw_request(method, url, params)
|
135
135
|
if method == :get
|
136
|
-
|
136
|
+
RestClient.get url, add_headers(:params => params, :accept => :json)
|
137
137
|
elsif method == :post
|
138
|
-
|
138
|
+
RestClient.post url, params, add_headers(:accept => :json)
|
139
139
|
elsif method == :put
|
140
|
-
|
140
|
+
RestClient.put url, params, add_headers(:accept => :json)
|
141
141
|
elsif method == :delete
|
142
|
-
|
142
|
+
RestClient.delete url, add_headers(:accept => :json)
|
143
143
|
else
|
144
144
|
raise "don't understand request method #{method.inspect}"
|
145
145
|
end
|
146
|
-
|
146
|
+
end
|
147
|
+
|
148
|
+
def request(method, url, params)
|
149
|
+
parse(raw_request(method, url, params))
|
147
150
|
end
|
148
151
|
|
149
152
|
def post(url, params={})
|
@@ -199,7 +202,7 @@ class Ubalo
|
|
199
202
|
end
|
200
203
|
|
201
204
|
def download(pod_name)
|
202
|
-
get("#{base_url}/pods/#{pod_name}
|
205
|
+
[get("#{base_url}/pods/#{pod_name}"), get_files(pod_name)]
|
203
206
|
end
|
204
207
|
|
205
208
|
def pods
|
@@ -243,11 +246,18 @@ class Ubalo
|
|
243
246
|
end
|
244
247
|
|
245
248
|
def create_pod name, template
|
246
|
-
post("#{base_url}/templates/#{template}/pods", :pod => {:name => name})
|
249
|
+
pod_response = post("#{base_url}/templates/#{template}/pods", :pod => {:name => name})
|
250
|
+
files_response = get_files(pod_response.fetch('fullname'))
|
251
|
+
|
252
|
+
[pod_response, files_response]
|
253
|
+
end
|
254
|
+
|
255
|
+
def get_files fullname
|
256
|
+
get("#{base_url}/pods/#{fullname}/files")
|
247
257
|
end
|
248
258
|
|
249
259
|
def push pod_url, files
|
250
|
-
|
260
|
+
raw_request(:put, "#{pod_url}/files", :files => files)
|
251
261
|
end
|
252
262
|
|
253
263
|
def pull pod_url
|
data/lib/ubalo/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.24
|
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-03-
|
12
|
+
date: 2012-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
16
|
-
requirement: &
|
16
|
+
requirement: &70365296916080 !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: *
|
24
|
+
version_requirements: *70365296916080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &70365296914740 !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: *
|
35
|
+
version_requirements: *70365296914740
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70365296913720 !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: *
|
46
|
+
version_requirements: *70365296913720
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &70365296909400 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.6.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70365296909400
|
58
58
|
description: CLI and API client for Ubalo
|
59
59
|
email: dev@ubalo.com
|
60
60
|
executables:
|
@@ -90,3 +90,4 @@ signing_key:
|
|
90
90
|
specification_version: 3
|
91
91
|
summary: CLI and API client for Ubalo
|
92
92
|
test_files: []
|
93
|
+
has_rdoc:
|