upflickr 0.1.7 → 0.1.8

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 (3) hide show
  1. data/CHANGELOG +5 -0
  2. data/lib/upflickr.rb +18 -12
  3. metadata +5 -5
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v0.1.8 - 08-07-2010
2
+ -fixed timeout bug
3
+ -better timeout handling
4
+ -fixed repeat-upload bug
5
+
1
6
  v0.1.7 - 06-15-2010
2
7
  -LICENSE
3
8
  -contact info
@@ -244,25 +244,30 @@ class Upflickr
244
244
  end
245
245
 
246
246
  def post_form(url, query, headers)
247
- Net::HTTP.start(url.host, url.port) {|con|
248
- con.read_timeout = 10
249
- begin
250
- return con.post(url.path, query, headers)
251
- rescue => e
252
- puts "UPFLICKR: POSTING Failed #{e}... #{Time.now}"
247
+ begin
248
+ Net::HTTP.new(url.host, url.port).start do |http|
249
+ return http.post(url.path, query, headers)
253
250
  end
254
- }
251
+ rescue Timeout::Error
252
+ puts "UPFLICKR: Timeout::Error"
253
+ return false
254
+ rescue => e
255
+ puts "UPFLICKR: #{e}"
256
+ return false
257
+ end
255
258
  end
256
259
 
257
- def upload(params)
260
+ def upload(params_in)
258
261
  if self.check_attr(true) == true
259
- params['api_key'] = @api_key
260
- params['auth_token'] = @token
261
- p2s = {}
262
- params.each do |k,v|
262
+ params = {}
263
+ p2s = {}
264
+ params_in['api_key'] = @api_key
265
+ params_in['auth_token'] = @token
266
+ params_in.each do |k,v|
263
267
  if k == 'photo'
264
268
  params['photo'] = File.open(v, 'r')
265
269
  else
270
+ params[k] = v
266
271
  p2s[k] = v
267
272
  end
268
273
  end
@@ -282,6 +287,7 @@ class Upflickr
282
287
 
283
288
  # Do the actual POST, given the right inputs
284
289
  data = self.post_form(url, query, headers)
290
+ return false if data == false
285
291
  doc = REXML::Document.new(data.read_body)
286
292
  if doc.elements["//rsp"].attributes['stat'] == "ok"
287
293
  return doc.elements["//photoid"].text.strip
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upflickr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Baker-Smith
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-15 00:00:00 -05:00
18
+ date: 2010-08-07 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -33,7 +33,7 @@ dependencies:
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  description:
36
- email: bbakersmith@gmail.com
36
+ email: bitsynthesis@gmail.com
37
37
  executables: []
38
38
 
39
39
  extensions: []