imager 0.0.4 → 0.0.5
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 +17 -17
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +104 -92
- data/imager.gemspec +29 -29
- data/lib/imager.rb +16 -16
- data/lib/imager/link_helper.rb +4 -0
- data/lib/imager/server_client.rb +6 -6
- data/lib/imager/server_interface.rb +129 -94
- data/lib/imager/version.rb +3 -3
- data/spec/fixtures/imagerserver_cassettes/invalid_album_and_collection_post.yml +8518 -52
- data/spec/fixtures/imagerserver_cassettes/no_image_delete.yml +32 -32
- data/spec/fixtures/imagerserver_cassettes/valid_delete.yml +30 -30
- data/spec/fixtures/imagerserver_cassettes/valid_post.yml +8518 -50
- data/spec/fixtures/imagerserver_cassettes/valid_post_with_file.yml +8518 -0
- data/spec/fixtures/imagerserver_cassettes/valid_post_with_io.yml +8518 -0
- data/spec/imager/server_interface_spec.rb +75 -56
- data/spec/imager_spec.rb +43 -43
- data/spec/spec_helper.rb +35 -35
- metadata +143 -117
- checksums.yaml +0 -7
@@ -1,57 +1,76 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Imager::ServerInterface do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
described_class.post("", "",
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Imager::ServerInterface do
|
4
|
+
let(:some_image){ "spec/image.jpg" }
|
5
|
+
let(:some_image_file) { File.new(some_image) }
|
6
|
+
let(:some_image_io) { UploadIO.new(some_image_file, "application/octet-stream") }
|
7
|
+
describe ".post" do
|
8
|
+
|
9
|
+
context "when params are valid" do
|
10
|
+
it "returns true" do
|
11
|
+
VCR.use_cassette('valid_post') do
|
12
|
+
described_class.post("test", "1", some_image, small: { width: 100 }).should be_true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when image is a file" do
|
17
|
+
it "returns true" do
|
18
|
+
VCR.use_cassette('valid_post_with_file') do
|
19
|
+
described_class.post("test", "1", some_image_file, small: { width: 100 }).should be_true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when image is a IO" do
|
25
|
+
it "returns true" do
|
26
|
+
VCR.use_cassette('valid_post_with_io') do
|
27
|
+
described_class.post("test", "1", some_image_io, small: { width: 100 }).should be_true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when no image" do
|
34
|
+
it "raises an error" do
|
35
|
+
# No request made here, because has no image
|
36
|
+
expect {
|
37
|
+
described_class.post("", "", "", size: { width: 100 })
|
38
|
+
}.to raise_error Imager::ImagerError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when other params are wrong" do
|
43
|
+
it "raises an error" do
|
44
|
+
VCR.use_cassette('invalid_album_and_collection_post') do
|
45
|
+
expect {
|
46
|
+
described_class.post("", "", some_image, size: { width: 100 })
|
47
|
+
}.to raise_error Imager::ImagerError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".delete" do
|
54
|
+
context "valid params and existing image" do
|
55
|
+
|
56
|
+
it "returns true" do
|
57
|
+
VCR.use_cassette('valid_post') do
|
58
|
+
described_class.post("test", "1", some_image, small: { width: 100 })
|
59
|
+
end
|
60
|
+
VCR.use_cassette('valid_delete') do
|
61
|
+
described_class.delete("test", "1", "image").should be_true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "some invalid param" do
|
67
|
+
it "raises an error" do
|
68
|
+
VCR.use_cassette('no_image_delete') do
|
69
|
+
expect {
|
70
|
+
described_class.delete("test", "1", "non_existing_image")
|
71
|
+
}.to raise_error Imager::ImagerError
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
57
76
|
end
|
data/spec/imager_spec.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Imager do
|
4
|
-
describe ".configure" do
|
5
|
-
|
6
|
-
it "yields" do
|
7
|
-
described_class.configure do |c|
|
8
|
-
c.should be described_class
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it "sets server_uri" do
|
13
|
-
described_class.configure do |c|
|
14
|
-
c.base_uri = "http://baseuri.bla/"
|
15
|
-
end
|
16
|
-
|
17
|
-
described_class.base_uri.should eq "http://baseuri.bla/"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "sets manager_path" do
|
21
|
-
described_class.configure do |c|
|
22
|
-
c.manager_path = "manager_path"
|
23
|
-
end
|
24
|
-
|
25
|
-
described_class.manager_path.should eq "manager_path"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "sets collection_path" do
|
29
|
-
described_class.configure do |c|
|
30
|
-
c.collection_path = "your_collections_path"
|
31
|
-
end
|
32
|
-
|
33
|
-
described_class.collection_path.should eq "your_collections_path"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "sets auth_code" do
|
37
|
-
described_class.configure do |c|
|
38
|
-
c.auth_code = "your_auth_code"
|
39
|
-
end
|
40
|
-
|
41
|
-
described_class.auth_code.should eq "your_auth_code"
|
42
|
-
end
|
43
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Imager do
|
4
|
+
describe ".configure" do
|
5
|
+
|
6
|
+
it "yields" do
|
7
|
+
described_class.configure do |c|
|
8
|
+
c.should be described_class
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "sets server_uri" do
|
13
|
+
described_class.configure do |c|
|
14
|
+
c.base_uri = "http://baseuri.bla/"
|
15
|
+
end
|
16
|
+
|
17
|
+
described_class.base_uri.should eq "http://baseuri.bla/"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "sets manager_path" do
|
21
|
+
described_class.configure do |c|
|
22
|
+
c.manager_path = "manager_path"
|
23
|
+
end
|
24
|
+
|
25
|
+
described_class.manager_path.should eq "manager_path"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets collection_path" do
|
29
|
+
described_class.configure do |c|
|
30
|
+
c.collection_path = "your_collections_path"
|
31
|
+
end
|
32
|
+
|
33
|
+
described_class.collection_path.should eq "your_collections_path"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "sets auth_code" do
|
37
|
+
described_class.configure do |c|
|
38
|
+
c.auth_code = "your_auth_code"
|
39
|
+
end
|
40
|
+
|
41
|
+
described_class.auth_code.should eq "your_auth_code"
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
require 'imager'
|
2
|
-
|
3
|
-
#dependencies
|
4
|
-
require 'minitest/autorun'
|
5
|
-
require 'webmock/minitest'
|
6
|
-
require 'vcr'
|
7
|
-
require 'turn'
|
8
|
-
|
9
|
-
# Hack for HTTMultiParty And VCR
|
10
|
-
require 'support/httmultiparty'
|
11
|
-
|
12
|
-
RSpec.configure do |c|
|
13
|
-
c.before do
|
14
|
-
Imager.configure do |c|
|
15
|
-
c.base_uri = "http://dev.local/imagerserver"
|
16
|
-
c.auth_code = "ABCDE"
|
17
|
-
c.collection_path = "images"
|
18
|
-
c.manager_path = "manager"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
Turn.config do |c|
|
24
|
-
# :outline - turn's original case/test outline mode [default]
|
25
|
-
c.format = :outline
|
26
|
-
# turn on invoke/execute tracing, enable full backtrace
|
27
|
-
c.trace = true
|
28
|
-
# use humanized test names (works only with :outline format)
|
29
|
-
c.natural = true
|
30
|
-
end
|
31
|
-
|
32
|
-
#VCR config
|
33
|
-
VCR.configure do |c|
|
34
|
-
c.cassette_library_dir = 'spec/fixtures/imagerserver_cassettes'
|
35
|
-
c.hook_into :webmock
|
1
|
+
require 'imager'
|
2
|
+
|
3
|
+
#dependencies
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'webmock/minitest'
|
6
|
+
require 'vcr'
|
7
|
+
require 'turn'
|
8
|
+
|
9
|
+
# Hack for HTTMultiParty And VCR
|
10
|
+
require 'support/httmultiparty'
|
11
|
+
|
12
|
+
RSpec.configure do |c|
|
13
|
+
c.before do
|
14
|
+
Imager.configure do |c|
|
15
|
+
c.base_uri = "http://dev.local/imagerserver"
|
16
|
+
c.auth_code = "ABCDE"
|
17
|
+
c.collection_path = "images"
|
18
|
+
c.manager_path = "manager"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Turn.config do |c|
|
24
|
+
# :outline - turn's original case/test outline mode [default]
|
25
|
+
c.format = :outline
|
26
|
+
# turn on invoke/execute tracing, enable full backtrace
|
27
|
+
c.trace = true
|
28
|
+
# use humanized test names (works only with :outline format)
|
29
|
+
c.natural = true
|
30
|
+
end
|
31
|
+
|
32
|
+
#VCR config
|
33
|
+
VCR.configure do |c|
|
34
|
+
c.cassette_library_dir = 'spec/fixtures/imagerserver_cassettes'
|
35
|
+
c.hook_into :webmock
|
36
36
|
end
|
metadata
CHANGED
@@ -1,134 +1,147 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: imager
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 2958535317820123368
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Guilherme Otranto
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2013-06-13 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
14
21
|
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.3'
|
20
|
-
type: :development
|
21
22
|
prerelease: false
|
22
|
-
|
23
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
24
26
|
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 2609263317959306961
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 3
|
32
|
+
version: "1.3"
|
34
33
|
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
35
37
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 2002549777813010636
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
48
47
|
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
49
51
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 2002549777813010636
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
62
61
|
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: webmock
|
63
65
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 2002549777813010636
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
76
75
|
type: :development
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: vcr
|
77
79
|
prerelease: false
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
- - '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 2002549777813010636
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
90
89
|
type: :development
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: turn
|
91
93
|
prerelease: false
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 2002549777813010636
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
type: :development
|
104
|
+
version_requirements: *id006
|
105
|
+
- !ruby/object:Gem::Dependency
|
98
106
|
name: httmultiparty
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.3.10
|
104
|
-
type: :runtime
|
105
107
|
prerelease: false
|
106
|
-
|
107
|
-
|
108
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
108
111
|
- - ~>
|
109
|
-
- !ruby/object:Gem::Version
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
hash: 3288670328528004693
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
- 3
|
117
|
+
- 10
|
110
118
|
version: 0.3.10
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: json
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
119
|
type: :runtime
|
120
|
+
version_requirements: *id007
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: json
|
119
123
|
prerelease: false
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: 2002549777813010636
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
type: :runtime
|
134
|
+
version_requirements: *id008
|
125
135
|
description: A remote storange and resizer client for images.
|
126
|
-
email:
|
136
|
+
email:
|
127
137
|
- guilherme_otran@hotmail.com
|
128
138
|
executables: []
|
139
|
+
|
129
140
|
extensions: []
|
141
|
+
|
130
142
|
extra_rdoc_files: []
|
131
|
-
|
143
|
+
|
144
|
+
files:
|
132
145
|
- .gitignore
|
133
146
|
- .travis.yml
|
134
147
|
- Gemfile
|
@@ -146,6 +159,8 @@ files:
|
|
146
159
|
- spec/fixtures/imagerserver_cassettes/no_image_delete.yml
|
147
160
|
- spec/fixtures/imagerserver_cassettes/valid_delete.yml
|
148
161
|
- spec/fixtures/imagerserver_cassettes/valid_post.yml
|
162
|
+
- spec/fixtures/imagerserver_cassettes/valid_post_with_file.yml
|
163
|
+
- spec/fixtures/imagerserver_cassettes/valid_post_with_io.yml
|
149
164
|
- spec/image.jpg
|
150
165
|
- spec/imager/link_helper_spec.rb
|
151
166
|
- spec/imager/server_interface_spec.rb
|
@@ -153,34 +168,45 @@ files:
|
|
153
168
|
- spec/spec_helper.rb
|
154
169
|
- spec/support/httmultiparty.rb
|
155
170
|
homepage: https://github.com/guilherme-otran/Imager
|
156
|
-
licenses:
|
171
|
+
licenses:
|
157
172
|
- MIT
|
158
|
-
metadata: {}
|
159
173
|
post_install_message:
|
160
174
|
rdoc_options: []
|
161
|
-
|
175
|
+
|
176
|
+
require_paths:
|
162
177
|
- lib
|
163
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
none: false
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
hash: 2002549777813010636
|
184
|
+
segments:
|
185
|
+
- 0
|
186
|
+
version: "0"
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
none: false
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
hash: 2002549777813010636
|
193
|
+
segments:
|
194
|
+
- 0
|
195
|
+
version: "0"
|
173
196
|
requirements: []
|
197
|
+
|
174
198
|
rubyforge_project:
|
175
|
-
rubygems_version:
|
199
|
+
rubygems_version: 1.8.25
|
176
200
|
signing_key:
|
177
|
-
specification_version:
|
201
|
+
specification_version: 3
|
178
202
|
summary: Imager Client API
|
179
|
-
test_files:
|
203
|
+
test_files:
|
180
204
|
- spec/fixtures/imagerserver_cassettes/invalid_album_and_collection_post.yml
|
181
205
|
- spec/fixtures/imagerserver_cassettes/no_image_delete.yml
|
182
206
|
- spec/fixtures/imagerserver_cassettes/valid_delete.yml
|
183
207
|
- spec/fixtures/imagerserver_cassettes/valid_post.yml
|
208
|
+
- spec/fixtures/imagerserver_cassettes/valid_post_with_file.yml
|
209
|
+
- spec/fixtures/imagerserver_cassettes/valid_post_with_io.yml
|
184
210
|
- spec/image.jpg
|
185
211
|
- spec/imager/link_helper_spec.rb
|
186
212
|
- spec/imager/server_interface_spec.rb
|