httpthumbnailer 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
@@ -0,0 +1,56 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager">
13
+ <content url="file://$MODULE_DIR$" />
14
+ <orderEntry type="inheritedJdk" />
15
+ <orderEntry type="sourceFolder" forTests="false" />
16
+ <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.0, RVM: ruby-1.9.3-p429) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.5, RVM: ruby-1.9.3-p429) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="capybara (v1.1.4, RVM: ruby-1.9.3-p429) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="childprocess (v0.3.9, RVM: ruby-1.9.3-p429) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="cli (v1.3.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="cuba (v3.1.0, RVM: ruby-1.9.3-p429) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="cucumber (v1.3.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="daemon (v1.1.0, RVM: ruby-1.9.3-p429) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.4, RVM: ruby-1.9.3-p429) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="facter (v1.6.18, RVM: ruby-1.9.3-p429) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.8.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="gherkin (v2.12.0, RVM: ruby-1.9.3-p429) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="git (v1.2.5, RVM: ruby-1.9.3-p429) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="httpclient (v2.3.3, RVM: ruby-1.9.3-p429) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="jeweler (v1.8.4, RVM: ruby-1.9.3-p429) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="json (v1.7.7, RVM: ruby-1.9.3-p429) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="kgio (v2.8.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v1.23, RVM: ruby-1.9.3-p429) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.7.3, RVM: ruby-1.9.3-p429) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="multipart-parser (v0.1.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.5.9, RVM: ruby-1.9.3-p429) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="rack (v1.5.2, RVM: ruby-1.9.3-p429) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.2, RVM: ruby-1.9.3-p429) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="raindrops (v0.12.0, RVM: ruby-1.9.3-p429) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.0.4, RVM: ruby-1.9.3-p429) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rdoc (v3.12.2, RVM: ruby-1.9.3-p429) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rmagick (v2.13.2, RVM: ruby-1.9.3-p429) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v2.13.0, RVM: ruby-1.9.3-p429) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.13.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.13.0, RVM: ruby-1.9.3-p429) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.13.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="ruby-ip (v0.9.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="rubyzip (v0.9.9, RVM: ruby-1.9.3-p429) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v2.32.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="unicorn (v4.6.3, RVM: ruby-1.9.3-p429) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="unicorn-cuba-base (v1.1.1, RVM: ruby-1.9.3-p429) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="websocket (v1.0.7, RVM: ruby-1.9.3-p429) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="xpath (v0.1.4, RVM: ruby-1.9.3-p429) [gem]" level="application" />
54
+ </component>
55
+ </module>
56
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p429" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/httpthumbnailer.iml" filepath="$PROJECT_DIR$/.idea/httpthumbnailer.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ group :development do
11
11
  gem "rspec-mocks", "~> 2.13"
12
12
  gem "cucumber", ">= 0"
13
13
  gem "capybara", "~> 1.1"
14
- gem "jeweler", "~> 1.8.4"
14
+ gem "jeweler", "~> 1.8.8"
15
15
  gem "httpclient", "~> 2.3"
16
16
  gem "rdoc", "~> 3.9"
17
17
  gem "multipart-parser", "~> 0.1.1"
data/Gemfile.lock CHANGED
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ addressable (2.3.5)
4
5
  builder (3.2.0)
5
6
  capybara (1.1.4)
6
7
  mime-types (>= 1.16)
@@ -22,27 +23,54 @@ GEM
22
23
  daemon (1.1.0)
23
24
  diff-lcs (1.2.4)
24
25
  facter (1.6.18)
26
+ faraday (0.8.8)
27
+ multipart-post (~> 1.2.0)
25
28
  ffi (1.8.1)
26
29
  gherkin (2.12.0)
27
30
  multi_json (~> 1.3)
28
- git (1.2.5)
31
+ git (1.2.6)
32
+ github_api (0.10.1)
33
+ addressable
34
+ faraday (~> 0.8.1)
35
+ hashie (>= 1.2)
36
+ multi_json (~> 1.4)
37
+ nokogiri (~> 1.5.2)
38
+ oauth2
39
+ hashie (2.0.5)
40
+ highline (1.6.20)
41
+ httpauth (0.2.0)
29
42
  httpclient (2.3.3)
30
- jeweler (1.8.4)
43
+ jeweler (1.8.8)
44
+ builder
31
45
  bundler (~> 1.0)
32
46
  git (>= 1.2.5)
47
+ github_api (= 0.10.1)
48
+ highline (>= 1.6.15)
49
+ nokogiri (= 1.5.10)
33
50
  rake
34
51
  rdoc
35
52
  json (1.7.7)
53
+ jwt (0.1.8)
54
+ multi_json (>= 1.5)
36
55
  kgio (2.8.1)
37
56
  mime-types (1.23)
38
57
  multi_json (1.7.3)
58
+ multi_xml (0.5.5)
39
59
  multipart-parser (0.1.1)
40
- nokogiri (1.5.9)
60
+ multipart-post (1.2.0)
61
+ nokogiri (1.5.10)
62
+ oauth2 (0.9.2)
63
+ faraday (~> 0.8)
64
+ httpauth (~> 0.2)
65
+ jwt (~> 0.1.4)
66
+ multi_json (~> 1.0)
67
+ multi_xml (~> 0.5)
68
+ rack (~> 1.2)
41
69
  rack (1.5.2)
42
70
  rack-test (0.6.2)
43
71
  rack (>= 1.0)
44
72
  raindrops (0.12.0)
45
- rake (10.0.4)
73
+ rake (10.1.0)
46
74
  rdoc (3.12.2)
47
75
  json (~> 1.4)
48
76
  rmagick (2.13.2)
@@ -84,7 +112,7 @@ DEPENDENCIES
84
112
  cucumber
85
113
  daemon (~> 1.1)
86
114
  httpclient (~> 2.3)
87
- jeweler (~> 1.8.4)
115
+ jeweler (~> 1.8.8)
88
116
  multipart-parser (~> 0.1.1)
89
117
  rdoc (~> 3.9)
90
118
  rmagick (~> 2)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
data/bin/httpthumbnailer CHANGED
@@ -71,7 +71,7 @@ Application.new('httpthumbnailer', port: 3100) do
71
71
  end
72
72
 
73
73
  on 'health_check' do
74
- write_plain 200, 'OK'
74
+ write_plain 200, 'HTTP Thumbnailer OK'
75
75
  end
76
76
 
77
77
  on root do
@@ -46,14 +46,14 @@ Then /I should get multipart response/ do
46
46
  @response_multipart.should_not be_empty
47
47
  end
48
48
 
49
- Then /response body should be CRLF endend lines like/ do |body|
49
+ Then /response body should be CRLF endend lines like/ do |body|
50
50
  @response.body.should match(body)
51
51
  @response.body.each_line do |line|
52
52
  line[-2,2].should == "\r\n"
53
53
  end
54
54
  end
55
55
 
56
- Then /response body should be CRLF endend lines$/ do |body|
56
+ Then /response body should be CRLF endend lines$/ do |body|
57
57
  @response.body.should == body.gsub("\n", "\r\n") + "\r\n"
58
58
  end
59
59
 
@@ -73,11 +73,11 @@ Then /^([^ ]+) part (.*) header should be (.*)/ do |part, header, value|
73
73
  @response_multipart[part_no(part)].headers[header.downcase].should == value
74
74
  end
75
75
 
76
- Then /^([^ ]+) part body should be CRLF endend lines$/ do |part, body|
76
+ Then /^([^ ]+) part body should be CRLF endend lines$/ do |part, body|
77
77
  @response_multipart[part_no(part)].body.should == body.gsub("\n", "\r\n")
78
78
  end
79
79
 
80
- Then /^([^ ]+) part body should be CRLF endend lines like$/ do |part, body|
80
+ Then /^([^ ]+) part body should be CRLF endend lines like$/ do |part, body|
81
81
  pbody = @response_multipart[part_no(part)].body
82
82
  pbody.should match(body)
83
83
  end
@@ -130,7 +130,11 @@ And /that image pixel at (.*)x(.*) should be of color (.*)/ do |x, y, color|
130
130
  end
131
131
 
132
132
  And /that image should be (.*) bit image/ do |bits|
133
- @image.depth.should == bits.to_i
133
+ if @image.depth < 8
134
+ (@image.depth * 8).should == bits.to_i # newer versions return 1 for 8 bit?!
135
+ else
136
+ @image.depth.should == bits.to_i
137
+ end
134
138
  end
135
139
 
136
140
  And /there should be no leaked images/ do
@@ -169,6 +169,17 @@ Feature: Generating single thumbnail with PUT request
169
169
  at least one image dimension is zero: 0x0
170
170
  """
171
171
 
172
+ @error_handling
173
+ Scenario: Reporitng of bad color value
174
+ Given test.jpg file content as request body
175
+ When I do PUT request http://localhost:3100/thumbnail/pad,240,200,input,background-color:ff11
176
+ Then response status should be 400
177
+ And response content type should be text/plain
178
+ And response body should be CRLF endend lines
179
+ """
180
+ invalid color name: ff11
181
+ """
182
+
172
183
  @optimization
173
184
  Scenario: Handing of large image data - possible thanks to loading size optimization
174
185
  Given test-large.jpg file content as request body
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "httpthumbnailer"
8
- s.version = "1.1.1"
8
+ s.version = "1.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jakub Pastuszek"]
12
- s.date = "2013-10-07"
12
+ s.date = "2013-11-04"
13
13
  s.description = "Provides HTTP API for thumbnailing images"
14
14
  s.email = "jpastuszek@gmail.com"
15
15
  s.executables = ["httpthumbnailer"]
@@ -19,6 +19,12 @@ Gem::Specification.new do |s|
19
19
  ]
20
20
  s.files = [
21
21
  ".document",
22
+ ".idea/encodings.xml",
23
+ ".idea/httpthumbnailer.iml",
24
+ ".idea/misc.xml",
25
+ ".idea/modules.xml",
26
+ ".idea/scopes/scope_settings.xml",
27
+ ".idea/vcs.xml",
22
28
  ".rspec",
23
29
  "Gemfile",
24
30
  "Gemfile.lock",
@@ -82,7 +88,7 @@ Gem::Specification.new do |s|
82
88
  s.add_development_dependency(%q<rspec-mocks>, ["~> 2.13"])
83
89
  s.add_development_dependency(%q<cucumber>, [">= 0"])
84
90
  s.add_development_dependency(%q<capybara>, ["~> 1.1"])
85
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
91
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.8"])
86
92
  s.add_development_dependency(%q<httpclient>, ["~> 2.3"])
87
93
  s.add_development_dependency(%q<rdoc>, ["~> 3.9"])
88
94
  s.add_development_dependency(%q<multipart-parser>, ["~> 0.1.1"])
@@ -94,7 +100,7 @@ Gem::Specification.new do |s|
94
100
  s.add_dependency(%q<rspec-mocks>, ["~> 2.13"])
95
101
  s.add_dependency(%q<cucumber>, [">= 0"])
96
102
  s.add_dependency(%q<capybara>, ["~> 1.1"])
97
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
103
+ s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
98
104
  s.add_dependency(%q<httpclient>, ["~> 2.3"])
99
105
  s.add_dependency(%q<rdoc>, ["~> 3.9"])
100
106
  s.add_dependency(%q<multipart-parser>, ["~> 0.1.1"])
@@ -107,7 +113,7 @@ Gem::Specification.new do |s|
107
113
  s.add_dependency(%q<rspec-mocks>, ["~> 2.13"])
108
114
  s.add_dependency(%q<cucumber>, [">= 0"])
109
115
  s.add_dependency(%q<capybara>, ["~> 1.1"])
110
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
116
+ s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
111
117
  s.add_dependency(%q<httpclient>, ["~> 2.3"])
112
118
  s.add_dependency(%q<rdoc>, ["~> 3.9"])
113
119
  s.add_dependency(%q<multipart-parser>, ["~> 0.1.1"])
@@ -14,7 +14,8 @@ class ErrorReporter < Controler
14
14
  on error(
15
15
  ThumbnailSpec::BadThubnailSpecError,
16
16
  Plugin::Thumbnailer::ZeroSizedImageError,
17
- Plugin::Thumbnailer::UnsupportedMethodError
17
+ Plugin::Thumbnailer::UnsupportedMethodError,
18
+ Plugin::Thumbnailer::InvalidColorNameError
18
19
  ) do |error|
19
20
  write_error 400, error
20
21
  end
@@ -50,6 +50,12 @@ module Plugin
50
50
  end
51
51
  end
52
52
 
53
+ class InvalidColorNameError < ArgumentError
54
+ def initialize(color)
55
+ super("invalid color name: #{color}")
56
+ end
57
+ end
58
+
53
59
  module ImageProcessing
54
60
  def replace
55
61
  @use_count ||= 0
@@ -187,13 +193,13 @@ module Plugin
187
193
 
188
194
  extend Stats
189
195
  def_stats(
190
- :total_images_loaded,
191
- :total_images_reloaded,
192
- :total_images_downscaled,
193
- :total_thumbnails_created,
194
- :images_loaded,
195
- :max_images_loaded,
196
- :max_images_loaded_worker,
196
+ :total_images_loaded,
197
+ :total_images_reloaded,
198
+ :total_images_downscaled,
199
+ :total_thumbnails_created,
200
+ :images_loaded,
201
+ :max_images_loaded,
202
+ :max_images_loaded_worker,
197
203
  :total_images_created,
198
204
  :total_images_destroyed,
199
205
  :total_images_created_from_blob,
@@ -396,7 +402,11 @@ class Magick::Image
396
402
 
397
403
  def render_on_background(background_color, width = nil, height = nil)
398
404
  Magick::Image.new(width || self.columns, height || self.rows) {
399
- self.background_color = background_color
405
+ begin
406
+ self.background_color = background_color
407
+ rescue ArgumentError
408
+ raise Plugin::Thumbnailer::InvalidColorNameError.new(background_color)
409
+ end
400
410
  self.depth = 8
401
411
  }.replace do |background|
402
412
  background.composite!(self, Magick::CenterGravity, Magick::OverCompositeOp)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpthumbnailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-07 00:00:00.000000000 Z
12
+ date: 2013-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: unicorn-cuba-base
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.8.4
117
+ version: 1.8.8
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.8.4
125
+ version: 1.8.8
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: httpclient
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -197,6 +197,12 @@ extra_rdoc_files:
197
197
  - README.md
198
198
  files:
199
199
  - .document
200
+ - .idea/encodings.xml
201
+ - .idea/httpthumbnailer.iml
202
+ - .idea/misc.xml
203
+ - .idea/modules.xml
204
+ - .idea/scopes/scope_settings.xml
205
+ - .idea/vcs.xml
200
206
  - .rspec
201
207
  - Gemfile
202
208
  - Gemfile.lock
@@ -258,7 +264,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
264
  version: '0'
259
265
  segments:
260
266
  - 0
261
- hash: -997329938697643917
267
+ hash: 626389733843602187
262
268
  required_rubygems_version: !ruby/object:Gem::Requirement
263
269
  none: false
264
270
  requirements: