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.
Files changed (4) hide show
  1. data/Gemfile.lock +1 -1
  2. data/bin/lesspainful +28 -3
  3. data/lib/version.rb +1 -1
  4. metadata +1 -1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lesspainful (0.9.0)
4
+ lesspainful (0.9.2)
5
5
  bundler (~> 1.2)
6
6
  json
7
7
  rest-client
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
- response = RestClient.post "#{host}/#{address}", args
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, "paths" => paths, "app" => app_file, "api_key" => api_key, "app_filename" => File.basename(app)})
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
@@ -1,3 +1,3 @@
1
1
  module LessPainful
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesspainful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: