simplificator-rwebthumb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,11 +37,10 @@ module Simplificator
37
37
  response = Net::HTTP.new(@api_uri.host, @api_uri.port).start {|p| p.request(request) }
38
38
  case response
39
39
  when Net::HTTPOK :
40
- case response.content_type
40
+ case response.content_type.downcase
41
41
  when 'text/xml' : REXML::Document.new(response.body)
42
- when 'image/jpg'
43
- when 'image/jpeg'
44
- when 'image/png'
42
+ when 'image/jpg', 'image/jpeg', 'image/png'
43
+ raise WebthumbException.new("No data returned though content type is #{response.content_type}") if response.body.length == 0
45
44
  response.body
46
45
  else
47
46
  raise WebthumbException.new("usupported content type #{response.content_type}. Body was: \n#{response.body}")
data/lib/rwebthumb/job.rb CHANGED
@@ -34,7 +34,7 @@ module Simplificator
34
34
  @cache = {}
35
35
  end
36
36
 
37
- def request_status
37
+ def check_status
38
38
  response = do_request(build_status_xml())
39
39
  @status = REXML::XPath.first(response, '/webthumb/jobStatus/status').text == 'Complete' ? STATUS_PICKUP : STATUS_PROCESSING
40
40
  if pickup?
@@ -46,9 +46,8 @@ module Simplificator
46
46
 
47
47
  def fetch_when_complete(size = :small)
48
48
  while not pickup?
49
- puts "waiting for #{@duration_estimate}"
50
49
  sleep @duration_estimate
51
- request_status
50
+ check_status
52
51
  end
53
52
  fetch(size)
54
53
  end
@@ -62,9 +61,11 @@ module Simplificator
62
61
  end
63
62
 
64
63
  def write_file(data, name)
64
+ raise WebthumbException.new('NO data given') if data == nil || data.size == 0
65
65
  File.open(name, 'wb+') do |file|
66
66
  file.write(data)
67
67
  file.close
68
+ file
68
69
  end
69
70
  end
70
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplificator-rwebthumb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simplificator GmbH
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies: []
15
15
 
16
16
  description: rwebthumb provides a ruby interface for the webthumb.bluga.net
17
- email: gems@simplificator.com
17
+ email: info@simplificator.com
18
18
  executables: []
19
19
 
20
20
  extensions: []