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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75814d493d7bd8f5ca2cc0b071397d78c4e0795e
4
- data.tar.gz: 5df620e7a39ef3b2bd32aa7becbae89798bbd159
3
+ metadata.gz: 956b59f5de6433f155bb6cf38feb4f031e9ef56d
4
+ data.tar.gz: 0711177d26275f317f5ec4083464c00dab451f52
5
5
  SHA512:
6
- metadata.gz: 52ce25853aab820d8f59b09902cdcfc9f634d4a3514ae6a4de25f7eebd6f628ddbf815a49ec04c30906fb0c765bdc5716c148b44333b71952afe1ca75d2e7662
7
- data.tar.gz: ecbd83c5095fa1f396729ada0992710d9ec4255d2e498600286a20b60d0b24bd06307dd4b62dfdd038e3d428b9d1bd6a2e1aeba54c18c34fb957fe0d5c1d0802
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 public ip found in your EC2 instance.
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.public_ip = "141.123.12.9"
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
- 1. 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.
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
- 3. 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
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
 
@@ -3,14 +3,12 @@ require "imagizer_engine/mount"
3
3
  module ImagizerEngine
4
4
  extend self
5
5
 
6
- def public_ip
7
- @public_ip ||= "0.0.0.0"
8
- end
6
+ attr_accessor :host, :use_ssl
9
7
 
10
- def public_ip=(ip)
11
- @public_ip = ip
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
@@ -1,7 +1,8 @@
1
1
  module ImagizerEngine
2
2
  class Url
3
3
  def to_url(url, version)
4
- "http://" + ImagizerEngine.public_ip + "/c/" + sanitized_url(url) + process_params(version)
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
@@ -1,3 +1,3 @@
1
1
  module ImagizerEngine
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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.public_ip = "141.123.12.9"
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 #public_ip" do
59
- ImagizerEngine.public_ip = "1.2.3.4"
60
- expect(ImagizerEngine.public_ip).to eq("1.2.3.4")
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.3
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-04 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler