imagizer_engine 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -6
- data/lib/imagizer_engine.rb +4 -6
- data/lib/imagizer_engine/url.rb +2 -1
- data/lib/imagizer_engine/version.rb +1 -1
- data/spec/imagizer_engine_spec.rb +16 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 956b59f5de6433f155bb6cf38feb4f031e9ef56d
|
4
|
+
data.tar.gz: 0711177d26275f317f5ec4083464c00dab451f52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f86ca0b0f712a7e06c4c4cd9de7d1c7736ed224a944fcb878d26d84806f449a280f452a1971544a162ae8d12700aa15d6f74e7027b06f1508d90e2ec120a10d5
|
7
|
+
data.tar.gz: 7d73500d66761465cc984ea9fb87b920b7a54268ba431faa3350240e34aebcab6eca72b85cc62e21b255de50fde9469da07e739cdb40d1fad41da84b9d846825
|
data/README.md
CHANGED
@@ -23,11 +23,11 @@ Or install it yourself as:
|
|
23
23
|
Rails
|
24
24
|
|
25
25
|
1. Create a config file like config/imagizer_engine.rb
|
26
|
-
2. Define the
|
26
|
+
2. Define the host (either IP or URL) found in your EC2 instance.
|
27
27
|
3. Define all of the different versions available to use.
|
28
28
|
4. Use the Imagizer API to configure each of the different versions. All of the Image API parameters are supported. http://demo.imagizercdn.com/doc/
|
29
29
|
```ruby
|
30
|
-
ImagizerEngine.
|
30
|
+
ImagizerEngine.host = "141.123.12.9"
|
31
31
|
ImagizerEngine.configure do
|
32
32
|
version :thumb,
|
33
33
|
:processes => {
|
@@ -52,7 +52,7 @@ end
|
|
52
52
|
|
53
53
|
## Usage
|
54
54
|
|
55
|
-
|
55
|
+
In the class that has the original image url, invoke `mount_imagizer_engine' method. This method takes two parameters: the image name and the method to be called to get the original url of the image.
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
class User
|
@@ -61,8 +61,8 @@ class User
|
|
61
61
|
|
62
62
|
end
|
63
63
|
```
|
64
|
+
Since we passed `:original_url_method_name` as the method which contains the full image url, we should define it somehow. It can be a column if using on Rails/ActiveRecord for instance, or simply define:
|
64
65
|
|
65
|
-
2. Since we passed `original_url_method_name` as the method which contains the full image url, we should define it somehow. It can be a column if using on Rails/ActiveRecord for instance, or simply define:
|
66
66
|
```ruby
|
67
67
|
class User
|
68
68
|
|
@@ -72,7 +72,7 @@ class User
|
|
72
72
|
end
|
73
73
|
```
|
74
74
|
|
75
|
-
|
75
|
+
To use the Imagizer Engine use the `profile_image_url()` method. This also takes an optional parameter that could be one of the versions defined in the config file
|
76
76
|
|
77
77
|
```
|
78
78
|
user = User.new
|
@@ -81,7 +81,6 @@ user.profile_image_url(:cover) => "http://143.123.12.9/c/path/to/file?scale=2&cr
|
|
81
81
|
|
82
82
|
```
|
83
83
|
|
84
|
-
4.Profit
|
85
84
|
|
86
85
|
## Contributing
|
87
86
|
|
data/lib/imagizer_engine.rb
CHANGED
@@ -3,14 +3,12 @@ require "imagizer_engine/mount"
|
|
3
3
|
module ImagizerEngine
|
4
4
|
extend self
|
5
5
|
|
6
|
-
|
7
|
-
@public_ip ||= "0.0.0.0"
|
8
|
-
end
|
6
|
+
attr_accessor :host, :use_ssl
|
9
7
|
|
10
|
-
def
|
11
|
-
@
|
8
|
+
def host
|
9
|
+
@host ||= "0.0.0.0"
|
12
10
|
end
|
13
|
-
|
11
|
+
|
14
12
|
def configure(&block)
|
15
13
|
instance_eval(&block)
|
16
14
|
end
|
data/lib/imagizer_engine/url.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module ImagizerEngine
|
2
2
|
class Url
|
3
3
|
def to_url(url, version)
|
4
|
-
|
4
|
+
protocol = ImagizerEngine.use_ssl ? 'https://' : 'http://'
|
5
|
+
protocol + ImagizerEngine.host + "/c/" + sanitized_url(url) + process_params(version)
|
5
6
|
end
|
6
7
|
|
7
8
|
private
|
@@ -2,7 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ImagizerEngine do
|
4
4
|
|
5
|
-
before do
|
5
|
+
before(:each) do
|
6
|
+
ImagizerEngine.use_ssl = false
|
6
7
|
@class = Class.new
|
7
8
|
@class.send(:extend, ImagizerEngine::Mount)
|
8
9
|
|
@@ -13,7 +14,7 @@ describe ImagizerEngine do
|
|
13
14
|
"path/to/file.png"
|
14
15
|
end
|
15
16
|
|
16
|
-
ImagizerEngine.
|
17
|
+
ImagizerEngine.host = "141.123.12.9"
|
17
18
|
|
18
19
|
ImagizerEngine.configure do
|
19
20
|
version :thumb,
|
@@ -45,6 +46,11 @@ describe ImagizerEngine do
|
|
45
46
|
expect(@instance.image_url(:cover)).to eq("http://141.123.12.9/c/path/to/file.png?width=250&height=100&scale=2&crop=1,2,3,4")
|
46
47
|
end
|
47
48
|
|
49
|
+
it "should send the correct url with https if use_ssl is set to true" do
|
50
|
+
ImagizerEngine.use_ssl = true
|
51
|
+
expect(@instance.image_url).to eq("https://141.123.12.9/c/path/to/file.png")
|
52
|
+
end
|
53
|
+
|
48
54
|
it "should raise error if `cover_original_url is not defined" do
|
49
55
|
@class.mount_imagizer_engine(:main, :undefined_method)
|
50
56
|
instance = @class.new
|
@@ -55,9 +61,14 @@ describe ImagizerEngine do
|
|
55
61
|
expect(@instance.respond_to?(:image_url)).to be true
|
56
62
|
end
|
57
63
|
|
58
|
-
it "should allow configuring of #
|
59
|
-
ImagizerEngine.
|
60
|
-
expect(ImagizerEngine.
|
64
|
+
it "should allow configuring of #host" do
|
65
|
+
ImagizerEngine.host = "1.2.3.4"
|
66
|
+
expect(ImagizerEngine.host).to eq("1.2.3.4")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should allow configuring of #host" do
|
70
|
+
ImagizerEngine.use_ssl = true
|
71
|
+
expect(ImagizerEngine.use_ssl).to eq(true)
|
61
72
|
end
|
62
73
|
|
63
74
|
it "should ignore keys that are not used in the Imagizer API" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagizer_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sfkaos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|