snapimage 0.0.6 → 0.1.0
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.
- data/.gitignore +2 -0
- data/bin/snapimage_generate_config +9 -11
- data/bin/snapimage_server +1 -1
- data/lib/snapimage.rb +12 -12
- data/lib/snapimage/config.rb +2 -9
- data/lib/snapimage/exceptions.rb +7 -10
- data/lib/snapimage/rack/request.rb +1 -6
- data/lib/snapimage/rack/request_file.rb +3 -6
- data/lib/snapimage/rack/response.rb +13 -13
- data/lib/snapimage/server.rb +24 -28
- data/lib/snapimage/version.rb +1 -1
- data/spec/acceptance/delete_resource_images_spec.rb +166 -166
- data/spec/acceptance/list_resource_images_spec.rb +158 -158
- data/spec/acceptance/modify_spec.rb +165 -165
- data/spec/acceptance/sync_spec.rb +237 -237
- data/spec/acceptance/upload_spec.rb +28 -189
- data/spec/snapimage/config_spec.rb +5 -13
- data/spec/snapimage/image/image_name_utils_spec.rb +113 -113
- data/spec/snapimage/image/image_spec.rb +55 -55
- data/spec/snapimage/rack/request_file_spec.rb +0 -11
- data/spec/snapimage/rack/request_spec.rb +6 -25
- data/spec/snapimage/server_actions/server_actions.authorize_spec.rb +56 -56
- data/spec/snapimage/server_actions/server_actions.generate_image_spec.rb +146 -146
- data/spec/snapimage/server_actions/server_actions.sync_resource_spec.rb +81 -81
- data/spec/snapimage/server_spec.rb +57 -20
- data/spec/snapimage/storage/storage_server.local_spec.rb +150 -150
- data/spec/snapimage/storage/storage_server_spec.rb +83 -83
- data/spec/snapimage/storage/storage_spec.rb +42 -42
- data/spec/support/assets/config.json +2 -6
- data/spec/support/assets/config.yml +2 -9
- metadata +4 -4
@@ -1,97 +1,97 @@
|
|
1
|
-
require "spec_helper"
|
1
|
+
#require "spec_helper"
|
2
2
|
|
3
|
-
describe SnapImage::StorageServer::Base do
|
4
|
-
before do
|
5
|
-
|
6
|
-
class TestServer < SnapImage::StorageServer::Base; end
|
7
|
-
|
8
|
-
"name" => "Test",
|
9
|
-
"public_url" => "//example.com/storage",
|
10
|
-
"max_width" => 1024,
|
11
|
-
"max_height" => 2048
|
12
|
-
)
|
13
|
-
end
|
3
|
+
#describe SnapImage::StorageServer::Base do
|
4
|
+
#before do
|
5
|
+
#@image_path = File.join(RSpec.root, "support/assets/stub-1x1.png")
|
6
|
+
#class TestServer < SnapImage::StorageServer::Base; end
|
7
|
+
#@server = TestServer.new(
|
8
|
+
#"name" => "Test",
|
9
|
+
#"public_url" => "//example.com/storage",
|
10
|
+
#"max_width" => 1024,
|
11
|
+
#"max_height" => 2048
|
12
|
+
#)
|
13
|
+
#end
|
14
14
|
|
15
|
-
describe "url_regexp" do
|
16
|
-
before do
|
17
|
-
|
18
|
-
end
|
15
|
+
#describe "url_regexp" do
|
16
|
+
#before do
|
17
|
+
#@regexp = @server.url_regexp
|
18
|
+
#end
|
19
19
|
|
20
|
-
it "matches urls handled by the storage server" do
|
21
|
-
"http://example.com/storage/image.png".match(@regexp).should_not be_nil
|
22
|
-
"https://example.com/storage/image.png".match(@regexp).should_not be_nil
|
23
|
-
"http://example.com/storage/sub/dir/image.png".match(@regexp).should_not be_nil
|
24
|
-
"http://example.com/storage/sub/dir/image.gif".match(@regexp).should_not be_nil
|
25
|
-
"http://example.com/storage/sub/dir/image.jpg".match(@regexp).should_not be_nil
|
26
|
-
end
|
20
|
+
#it "matches urls handled by the storage server" do
|
21
|
+
#"http://example.com/storage/image.png".match(@regexp).should_not be_nil
|
22
|
+
#"https://example.com/storage/image.png".match(@regexp).should_not be_nil
|
23
|
+
#"http://example.com/storage/sub/dir/image.png".match(@regexp).should_not be_nil
|
24
|
+
#"http://example.com/storage/sub/dir/image.gif".match(@regexp).should_not be_nil
|
25
|
+
#"http://example.com/storage/sub/dir/image.jpg".match(@regexp).should_not be_nil
|
26
|
+
#end
|
27
27
|
|
28
|
-
it "does not match urls that are not handled by the storage server" do
|
29
|
-
"http://other.com/storage/image.png".match(@regexp).should be_nil
|
30
|
-
"http://example.com/storage/image.jpeg".match(@regexp).should be_nil
|
31
|
-
"http://example.com/storage.png".match(@regexp).should be_nil
|
32
|
-
end
|
33
|
-
end
|
28
|
+
#it "does not match urls that are not handled by the storage server" do
|
29
|
+
#"http://other.com/storage/image.png".match(@regexp).should be_nil
|
30
|
+
#"http://example.com/storage/image.jpeg".match(@regexp).should be_nil
|
31
|
+
#"http://example.com/storage.png".match(@regexp).should be_nil
|
32
|
+
#end
|
33
|
+
#end
|
34
34
|
|
35
|
-
describe "#local?" do
|
36
|
-
it "returns true when the url is local" do
|
37
|
-
|
38
|
-
end
|
35
|
+
#describe "#local?" do
|
36
|
+
#it "returns true when the url is local" do
|
37
|
+
#@server.local?("http://example.com/storage/abc123/image.png").should be_true
|
38
|
+
#end
|
39
39
|
|
40
|
-
it "returns false when the url is not local" do
|
41
|
-
|
42
|
-
end
|
40
|
+
#it "returns false when the url is not local" do
|
41
|
+
#@server.local?("http://another.com/images/abc123/image.png").should be_false
|
42
|
+
#end
|
43
43
|
|
44
|
-
it "returns false when the url is just the public url" do
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
44
|
+
#it "returns false when the url is just the public url" do
|
45
|
+
#@server.local?("http://example.com/storage").should be_false
|
46
|
+
#@server.local?("http://example.com/storage/").should be_false
|
47
|
+
#end
|
48
|
+
#end
|
49
49
|
|
50
|
-
describe "#get_url_parts" do
|
51
|
-
it "returns nil when the url does not match the public url" do
|
52
|
-
|
53
|
-
end
|
50
|
+
#describe "#get_url_parts" do
|
51
|
+
#it "returns nil when the url does not match the public url" do
|
52
|
+
#@server.send(:get_url_parts, "http://another.com/storage/abc123/image.png").should be_nil
|
53
|
+
#end
|
54
54
|
|
55
|
-
it "returns the parts when the url matches the public url" do
|
56
|
-
parts = @server.send(:get_url_parts, "http://example.com/storage/abc123/image.png")
|
57
|
-
parts[:protocol].should eq "http"
|
58
|
-
parts[:public_url].should eq "//example.com/storage"
|
59
|
-
parts[:path].should eq "abc123/image.png"
|
60
|
-
end
|
55
|
+
#it "returns the parts when the url matches the public url" do
|
56
|
+
#parts = @server.send(:get_url_parts, "http://example.com/storage/abc123/image.png")
|
57
|
+
#parts[:protocol].should eq "http"
|
58
|
+
#parts[:public_url].should eq "//example.com/storage"
|
59
|
+
#parts[:path].should eq "abc123/image.png"
|
60
|
+
#end
|
61
61
|
|
62
|
-
it "returns the parts when the url has no protocol" do
|
63
|
-
parts = @server.send(:get_url_parts, "//example.com/storage/abc123/image.png")
|
64
|
-
parts[:protocol].should be_nil
|
65
|
-
parts[:public_url].should eq "//example.com/storage"
|
66
|
-
parts[:path].should eq "abc123/image.png"
|
67
|
-
end
|
68
|
-
end
|
62
|
+
#it "returns the parts when the url has no protocol" do
|
63
|
+
#parts = @server.send(:get_url_parts, "//example.com/storage/abc123/image.png")
|
64
|
+
#parts[:protocol].should be_nil
|
65
|
+
#parts[:public_url].should eq "//example.com/storage"
|
66
|
+
#parts[:path].should eq "abc123/image.png"
|
67
|
+
#end
|
68
|
+
#end
|
69
69
|
|
70
|
-
describe "#resize_to_fit" do
|
71
|
-
before do
|
72
|
-
|
73
|
-
end
|
70
|
+
#describe "#resize_to_fit" do
|
71
|
+
#before do
|
72
|
+
#@image = SnapImage::Image.from_blob(File.new(@image_path, "rb").read)
|
73
|
+
#end
|
74
74
|
|
75
|
-
it "returns the original image and name when the image fits" do
|
76
|
-
result = @server.send(:resize_to_fit, @image, "image")
|
77
|
-
result[:image].should be @image
|
78
|
-
result[:name].should eq "image"
|
79
|
-
end
|
75
|
+
#it "returns the original image and name when the image fits" do
|
76
|
+
#result = @server.send(:resize_to_fit, @image, "image")
|
77
|
+
#result[:image].should be @image
|
78
|
+
#result[:name].should eq "image"
|
79
|
+
#end
|
80
80
|
|
81
|
-
it "returns the resized image and name given a base image" do
|
82
|
-
|
83
|
-
result = @server.send(:resize_to_fit, @image, "12345678-2048x100.png")
|
84
|
-
result[:image].width.should eq 1024
|
85
|
-
result[:image].height.should eq 50
|
86
|
-
result[:name].should eq "12345678-1024x50.png"
|
87
|
-
end
|
81
|
+
#it "returns the resized image and name given a base image" do
|
82
|
+
#@image.resize(2048, 100, false)
|
83
|
+
#result = @server.send(:resize_to_fit, @image, "12345678-2048x100.png")
|
84
|
+
#result[:image].width.should eq 1024
|
85
|
+
#result[:image].height.should eq 50
|
86
|
+
#result[:name].should eq "12345678-1024x50.png"
|
87
|
+
#end
|
88
88
|
|
89
|
-
it "returns the resized image and name given a modified image" do
|
90
|
-
|
91
|
-
result = @server.send(:resize_to_fit, @image, "12345678-1x1-0x0x1x1-2048x100-0.png")
|
92
|
-
result[:image].width.should eq 1024
|
93
|
-
result[:image].height.should eq 50
|
94
|
-
result[:name].should eq "12345678-1x1-0x0x1x1-1024x50-0.png"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
89
|
+
#it "returns the resized image and name given a modified image" do
|
90
|
+
#@image.resize(2048, 100, false)
|
91
|
+
#result = @server.send(:resize_to_fit, @image, "12345678-1x1-0x0x1x1-2048x100-0.png")
|
92
|
+
#result[:image].width.should eq 1024
|
93
|
+
#result[:image].height.should eq 50
|
94
|
+
#result[:name].should eq "12345678-1x1-0x0x1x1-1024x50-0.png"
|
95
|
+
#end
|
96
|
+
#end
|
97
|
+
#end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
require "spec_helper"
|
1
|
+
#require "spec_helper"
|
2
2
|
|
3
|
-
describe SnapImage::Storage do
|
4
|
-
before do
|
5
|
-
|
6
|
-
|
7
|
-
[{
|
8
|
-
"name" => "test",
|
9
|
-
"type" => "LOCAL",
|
10
|
-
"local_root" => @local_root,
|
11
|
-
"public_url" => "//example.com/storage"
|
12
|
-
}],
|
13
|
-
"test",
|
14
|
-
1024,
|
15
|
-
2048
|
16
|
-
)
|
17
|
-
end
|
3
|
+
#describe SnapImage::Storage do
|
4
|
+
#before do
|
5
|
+
#@local_root = File.join(RSpec.root, "storage")
|
6
|
+
#@storage = SnapImage::Storage.new(
|
7
|
+
#[{
|
8
|
+
#"name" => "test",
|
9
|
+
#"type" => "LOCAL",
|
10
|
+
#"local_root" => @local_root,
|
11
|
+
#"public_url" => "//example.com/storage"
|
12
|
+
#}],
|
13
|
+
#"test",
|
14
|
+
#1024,
|
15
|
+
#2048
|
16
|
+
#)
|
17
|
+
#end
|
18
18
|
|
19
|
-
after do
|
20
|
-
FileUtils.rm_rf(@local_root)
|
21
|
-
end
|
19
|
+
#after do
|
20
|
+
#FileUtils.rm_rf(@local_root)
|
21
|
+
#end
|
22
22
|
|
23
|
-
describe "#servers" do
|
24
|
-
it "creates a hash of the servers from the configs" do
|
25
|
-
servers = @storage.send(:servers)
|
26
|
-
servers["test"].should be
|
27
|
-
end
|
28
|
-
end
|
23
|
+
#describe "#servers" do
|
24
|
+
#it "creates a hash of the servers from the configs" do
|
25
|
+
#servers = @storage.send(:servers)
|
26
|
+
#servers["test"].should be
|
27
|
+
#end
|
28
|
+
#end
|
29
29
|
|
30
|
-
describe "#get_server_class" do
|
31
|
-
it "raises when the type is not supported" do
|
32
|
-
expect { @storage.send(:get_server_class, "test") }.should raise_error SnapImage::InvalidStorageConfig
|
33
|
-
end
|
30
|
+
#describe "#get_server_class" do
|
31
|
+
#it "raises when the type is not supported" do
|
32
|
+
#expect { @storage.send(:get_server_class, "test") }.should raise_error SnapImage::InvalidStorageConfig
|
33
|
+
#end
|
34
34
|
|
35
|
-
it "returns the correct class" do
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
35
|
+
#it "returns the correct class" do
|
36
|
+
#@storage.send(:get_server_class, "LOCAL").should eq SnapImage::StorageServer::Local
|
37
|
+
#end
|
38
|
+
#end
|
39
39
|
|
40
|
-
describe "#get_server_by_url" do
|
41
|
-
it "returns the server when there is a match" do
|
42
|
-
|
43
|
-
end
|
40
|
+
#describe "#get_server_by_url" do
|
41
|
+
#it "returns the server when there is a match" do
|
42
|
+
#@storage.send(:get_server_by_url, "http://example.com/storage/abc123/image.png").name.should eq "test"
|
43
|
+
#end
|
44
44
|
|
45
|
-
it "returns nil when there is no match" do
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
45
|
+
#it "returns nil when there is no match" do
|
46
|
+
#@storage.send(:get_server_by_url, "http://another.com/storage/abc123/image.png").should be_nil
|
47
|
+
#end
|
48
|
+
#end
|
49
|
+
#end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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: 2012-
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -222,7 +222,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
segments:
|
224
224
|
- 0
|
225
|
-
hash:
|
225
|
+
hash: -1529708753880950657
|
226
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
227
|
none: false
|
228
228
|
requirements:
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
version: '0'
|
232
232
|
segments:
|
233
233
|
- 0
|
234
|
-
hash:
|
234
|
+
hash: -1529708753880950657
|
235
235
|
requirements: []
|
236
236
|
rubyforge_project:
|
237
237
|
rubygems_version: 1.8.23
|