lesspainful 0.9.1 → 0.9.2
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/bin/lesspainful +28 -3
- data/lib/version.rb +1 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/bin/lesspainful
CHANGED
@@ -87,8 +87,15 @@ def all_files
|
|
87
87
|
{:prefix => dir, :files => files.find_all { |file_or_dir| File.file? file_or_dir }}
|
88
88
|
end
|
89
89
|
|
90
|
-
def http_post(address, args)
|
91
|
-
|
90
|
+
def http_post(address, args, &block)
|
91
|
+
if block_given?
|
92
|
+
response = RestClient.post "#{host}/#{address}", args do |response, request, result, &other_block|
|
93
|
+
block.call(response,request,result, &other_block)
|
94
|
+
end
|
95
|
+
else
|
96
|
+
response = RestClient.post "#{host}/#{address}", args
|
97
|
+
end
|
98
|
+
|
92
99
|
response.body
|
93
100
|
end
|
94
101
|
|
@@ -259,6 +266,7 @@ verify_files
|
|
259
266
|
|
260
267
|
|
261
268
|
log_header("Negotiating upload")
|
269
|
+
|
262
270
|
response = http_post("check_hash", {"hashes" => hashes})
|
263
271
|
|
264
272
|
cache_status = JSON.parse(response)
|
@@ -280,7 +288,24 @@ end
|
|
280
288
|
app_file = cache_status[digest(app)] ? digest(app) : File.new(app)
|
281
289
|
|
282
290
|
log_header("Uploading negotiated files")
|
283
|
-
response = http_post("upload", {"files" => files,
|
291
|
+
response = http_post("upload", {"files" => files,
|
292
|
+
"paths" => paths,
|
293
|
+
"app" => app_file,
|
294
|
+
"api_key" => api_key,
|
295
|
+
"app_filename" => File.basename(app)}) do |response, request, result, &block|
|
296
|
+
case response.code
|
297
|
+
when 200
|
298
|
+
response
|
299
|
+
when 403
|
300
|
+
abort do
|
301
|
+
puts "Invalid API key"
|
302
|
+
end
|
303
|
+
else
|
304
|
+
abort do
|
305
|
+
log "Unexpected Error. Please contact contact@lesspainful.com and provide the timestamp on your left."
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
284
309
|
|
285
310
|
end_at = Time.now
|
286
311
|
|
data/lib/version.rb
CHANGED