shutterbug 0.2.5 → 0.4.3
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.
- checksums.yaml +8 -8
- data/.travis.yml +3 -3
- data/README.md +6 -0
- data/bower.json +1 -1
- data/demo/The_Scream.jpg +0 -0
- data/demo/canvas_example.html +36 -0
- data/demo/index.html +1 -0
- data/lib/shutterbug.rb +1 -1
- data/lib/shutterbug/cache_manager.rb +2 -2
- data/lib/shutterbug/configuration.rb +4 -8
- data/lib/shutterbug/handlers.rb +5 -4
- data/lib/shutterbug/handlers/convert_handler.rb +38 -16
- data/lib/shutterbug/handlers/direct_upload_handler.rb +30 -0
- data/lib/shutterbug/handlers/file_handler.rb +30 -0
- data/lib/shutterbug/handlers/js_file_handler.rb +13 -10
- data/lib/shutterbug/handlers/shutterbug.js +123 -32
- data/lib/shutterbug/phantom_job.rb +11 -10
- data/lib/shutterbug/rackapp.rb +15 -18
- data/lib/shutterbug/rasterize.js +4 -4
- data/lib/shutterbug/storage.rb +1 -1
- data/lib/shutterbug/storage/file_storage.rb +21 -8
- data/lib/shutterbug/storage/s3_storage.rb +26 -31
- data/shutterbug.gemspec +0 -1
- data/spec/shared_examples_for_handlers.rb +13 -9
- data/spec/shared_examples_for_storage.rb +14 -10
- data/spec/shutterbug/configuration_spec.rb +1 -11
- data/spec/shutterbug/convert_handler_spec.rb +5 -4
- data/spec/shutterbug/direct_upload_handler_spec.rb +7 -0
- data/spec/shutterbug/file_handler_spec.rb +7 -0
- data/spec/shutterbug/file_storage_spec.rb +2 -1
- data/spec/shutterbug/js_file_handler_spec.rb +2 -1
- data/spec/shutterbug/rackapp_spec.rb +14 -28
- data/spec/shutterbug/s3_storage_spec.rb +1 -1
- metadata +10 -12
- data/lib/shutterbug/handlers/file_handlers.rb +0 -9
- data/lib/shutterbug/handlers/file_handlers/base.rb +0 -39
- data/lib/shutterbug/handlers/file_handlers/html_file.rb +0 -22
- data/lib/shutterbug/handlers/file_handlers/png_file.rb +0 -23
- data/spec/shared_examples_for_file_handlers.rb +0 -16
- data/spec/shutterbug/html_file_handler_spec.rb +0 -10
- data/spec/shutterbug/png_file_handler_spec.rb +0 -10
@@ -16,8 +16,6 @@ end
|
|
16
16
|
describe Shutterbug::Rackapp do
|
17
17
|
include Rack::Test::Methods
|
18
18
|
|
19
|
-
let(:config) { Shutterbug::Configuration.instance }
|
20
|
-
|
21
19
|
let(:post_data) do
|
22
20
|
{
|
23
21
|
'content' => "<div class='foo'>foo!</div>",
|
@@ -29,31 +27,31 @@ describe Shutterbug::Rackapp do
|
|
29
27
|
end
|
30
28
|
|
31
29
|
let(:app) do
|
32
|
-
Shutterbug::Rackapp.new
|
33
|
-
config.uri_prefix
|
34
|
-
config.path_prefix
|
30
|
+
Shutterbug::Rackapp.new do |config|
|
31
|
+
config.uri_prefix = "http://localhost:9292"
|
32
|
+
config.path_prefix = "/shutterbug"
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
|
-
let(:filename)
|
39
|
-
let(:url)
|
36
|
+
let(:filename) { "filename" }
|
37
|
+
let(:url) { "url_to_file" }
|
40
38
|
|
41
|
-
let(:mock_file)
|
39
|
+
let(:mock_file) do
|
42
40
|
mock({
|
43
41
|
:get_content => "content",
|
42
|
+
:mime_type => "image/png",
|
44
43
|
:filename => filename,
|
45
44
|
:url => url
|
46
45
|
})
|
47
46
|
end
|
48
47
|
|
49
|
-
let(:test_storage) { mock({ :new => mock_file
|
48
|
+
let(:test_storage) { mock({ :new => mock_file })}
|
50
49
|
|
51
50
|
before(:each) do
|
52
|
-
|
51
|
+
Shutterbug::Configuration.instance.stub!(:storage => test_storage)
|
53
52
|
end
|
54
53
|
|
55
54
|
describe "routing requests in #call" do
|
56
|
-
|
57
55
|
describe "do_convert route" do
|
58
56
|
it "should return a valid image url" do
|
59
57
|
get "/shutterbug/make_snapshot/", post_data
|
@@ -63,32 +61,20 @@ describe Shutterbug::Rackapp do
|
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
66
|
-
describe "get
|
67
|
-
it "should
|
68
|
-
|
69
|
-
get "/shutterbug/get_png/filename.png"
|
64
|
+
describe "get file route" do
|
65
|
+
it "should return without errors" do
|
66
|
+
get "/shutterbug/get_file/foobar.png"
|
70
67
|
last_response.should be_ok
|
71
68
|
last_response.headers['Content-Type'].should match 'image/png'
|
72
69
|
end
|
73
70
|
end
|
74
71
|
|
75
|
-
describe "get html route" do
|
76
|
-
it "should route #do_get_html" do
|
77
|
-
|
78
|
-
get "/shutterbug/get_html/filename.html"
|
79
|
-
last_response.should be_ok
|
80
|
-
last_response.headers['Content-Type'].should match 'text/html'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
72
|
describe "get shutterbug.js javascipt route" do
|
85
|
-
it "should
|
73
|
+
it "should return js file" do
|
86
74
|
get "/shutterbug/shutterbug.js"
|
87
75
|
last_response.should be_ok
|
88
76
|
last_response.headers['Content-Type'].should match 'application/javascript'
|
89
77
|
end
|
90
78
|
end
|
91
|
-
|
92
79
|
end
|
93
|
-
|
94
|
-
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shutterbug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Paessel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -158,6 +158,8 @@ files:
|
|
158
158
|
- Rakefile
|
159
159
|
- bower.json
|
160
160
|
- config.ru
|
161
|
+
- demo/The_Scream.jpg
|
162
|
+
- demo/canvas_example.html
|
161
163
|
- demo/iframe.html
|
162
164
|
- demo/iframe2.html
|
163
165
|
- demo/iframe3.html
|
@@ -180,10 +182,8 @@ files:
|
|
180
182
|
- lib/shutterbug/configuration.rb
|
181
183
|
- lib/shutterbug/handlers.rb
|
182
184
|
- lib/shutterbug/handlers/convert_handler.rb
|
183
|
-
- lib/shutterbug/handlers/
|
184
|
-
- lib/shutterbug/handlers/
|
185
|
-
- lib/shutterbug/handlers/file_handlers/html_file.rb
|
186
|
-
- lib/shutterbug/handlers/file_handlers/png_file.rb
|
185
|
+
- lib/shutterbug/handlers/direct_upload_handler.rb
|
186
|
+
- lib/shutterbug/handlers/file_handler.rb
|
187
187
|
- lib/shutterbug/handlers/js_file_handler.rb
|
188
188
|
- lib/shutterbug/handlers/shutterbug.js
|
189
189
|
- lib/shutterbug/phantom_job.rb
|
@@ -193,15 +193,14 @@ files:
|
|
193
193
|
- lib/shutterbug/storage/file_storage.rb
|
194
194
|
- lib/shutterbug/storage/s3_storage.rb
|
195
195
|
- shutterbug.gemspec
|
196
|
-
- spec/shared_examples_for_file_handlers.rb
|
197
196
|
- spec/shared_examples_for_handlers.rb
|
198
197
|
- spec/shared_examples_for_storage.rb
|
199
198
|
- spec/shutterbug/configuration_spec.rb
|
200
199
|
- spec/shutterbug/convert_handler_spec.rb
|
200
|
+
- spec/shutterbug/direct_upload_handler_spec.rb
|
201
|
+
- spec/shutterbug/file_handler_spec.rb
|
201
202
|
- spec/shutterbug/file_storage_spec.rb
|
202
|
-
- spec/shutterbug/html_file_handler_spec.rb
|
203
203
|
- spec/shutterbug/js_file_handler_spec.rb
|
204
|
-
- spec/shutterbug/png_file_handler_spec.rb
|
205
204
|
- spec/shutterbug/rackapp_spec.rb
|
206
205
|
- spec/shutterbug/s3_storage_spec.rb
|
207
206
|
- spec/spec_helper.rb
|
@@ -230,15 +229,14 @@ signing_key:
|
|
230
229
|
specification_version: 4
|
231
230
|
summary: use Shutterbug::Rackapp
|
232
231
|
test_files:
|
233
|
-
- spec/shared_examples_for_file_handlers.rb
|
234
232
|
- spec/shared_examples_for_handlers.rb
|
235
233
|
- spec/shared_examples_for_storage.rb
|
236
234
|
- spec/shutterbug/configuration_spec.rb
|
237
235
|
- spec/shutterbug/convert_handler_spec.rb
|
236
|
+
- spec/shutterbug/direct_upload_handler_spec.rb
|
237
|
+
- spec/shutterbug/file_handler_spec.rb
|
238
238
|
- spec/shutterbug/file_storage_spec.rb
|
239
|
-
- spec/shutterbug/html_file_handler_spec.rb
|
240
239
|
- spec/shutterbug/js_file_handler_spec.rb
|
241
|
-
- spec/shutterbug/png_file_handler_spec.rb
|
242
240
|
- spec/shutterbug/rackapp_spec.rb
|
243
241
|
- spec/shutterbug/s3_storage_spec.rb
|
244
242
|
- spec/spec_helper.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'tmpdir'
|
2
|
-
module Shutterbug
|
3
|
-
module Handlers
|
4
|
-
module FileHandlers
|
5
|
-
class Base
|
6
|
-
attr_accessor :config
|
7
|
-
|
8
|
-
def self.instance
|
9
|
-
return @instance || self.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(_config = Configuration.instance)
|
13
|
-
self.config = _config
|
14
|
-
end
|
15
|
-
|
16
|
-
def urlify(name)
|
17
|
-
"#{self.config.uri_prefix}#{self.path_prefix}/#{name}"
|
18
|
-
end
|
19
|
-
|
20
|
-
def path_prefix
|
21
|
-
"#{self.config.path_prefix}/get_#{file_extension}"
|
22
|
-
end
|
23
|
-
|
24
|
-
def filename_matcher
|
25
|
-
"(([^\/|\.]+)\.?([^\/]+))?"
|
26
|
-
end
|
27
|
-
|
28
|
-
def regex
|
29
|
-
/#{path_prefix}\/#{filename_matcher}/
|
30
|
-
end
|
31
|
-
|
32
|
-
def filename(base)
|
33
|
-
"#{base}.#{file_extension}"
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Shutterbug
|
2
|
-
module Handlers
|
3
|
-
module FileHandlers
|
4
|
-
class HtmlFile < Base
|
5
|
-
|
6
|
-
def file_extension
|
7
|
-
"html"
|
8
|
-
end
|
9
|
-
|
10
|
-
def mime_type
|
11
|
-
"text/html"
|
12
|
-
end
|
13
|
-
|
14
|
-
def handle(helper, req, env)
|
15
|
-
sha = regex.match(req.path)[1]
|
16
|
-
file = @config.storage.new(filename(sha),self)
|
17
|
-
helper.good_response(file.get_content, self.mime_type)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Shutterbug
|
2
|
-
module Handlers
|
3
|
-
module FileHandlers
|
4
|
-
class PngFile < Base
|
5
|
-
|
6
|
-
def file_extension
|
7
|
-
"png"
|
8
|
-
end
|
9
|
-
|
10
|
-
def mime_type
|
11
|
-
"image/png"
|
12
|
-
end
|
13
|
-
|
14
|
-
def handle(helper, req, env)
|
15
|
-
local_filename = regex.match(req.path)[1]
|
16
|
-
file = @config.storage.new(local_filename,self)
|
17
|
-
helper.good_response(file.get_content, self.mime_type)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'shared_examples_for_handlers'
|
2
|
-
shared_examples "a file handler" do
|
3
|
-
let(:config) { Shutterbug::Configuration.instance}
|
4
|
-
let(:rackapp) { mock }
|
5
|
-
let(:req) { mock }
|
6
|
-
let(:env) { mock }
|
7
|
-
let(:handler) { described_class.new(config) }
|
8
|
-
|
9
|
-
|
10
|
-
it "should have a file extension" do
|
11
|
-
handler.should respond_to :file_extension
|
12
|
-
end
|
13
|
-
it "should have a mime type" do
|
14
|
-
handler.should respond_to :mime_type
|
15
|
-
end
|
16
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'shared_examples_for_file_handlers'
|
2
|
-
require 'shared_examples_for_handlers'
|
3
|
-
describe Shutterbug::Handlers::FileHandlers::HtmlFile do
|
4
|
-
it_behaves_like "a file handler" do
|
5
|
-
let(:req) { mock(:path => "/shutterbug/get_html/foobar.html") }
|
6
|
-
end
|
7
|
-
it_behaves_like "a request handler" do
|
8
|
-
let(:req) { mock(:path => "/shutterbug/get_html/foobar.html") }
|
9
|
-
end
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'shared_examples_for_file_handlers'
|
2
|
-
require 'shared_examples_for_handlers'
|
3
|
-
describe Shutterbug::Handlers::FileHandlers::PngFile do
|
4
|
-
it_behaves_like "a file handler" do
|
5
|
-
let(:req) { mock(:path => "/shutterbug/get_png/foobar.png") }
|
6
|
-
end
|
7
|
-
it_behaves_like "a request handler" do
|
8
|
-
let(:req) { mock(:path => "/shutterbug/get_png/foobar.png") }
|
9
|
-
end
|
10
|
-
end
|