imagizer_engine 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +3 -0
- data/imagizer_engine.gemspec +26 -0
- data/lib/imagizer_engine.rb +55 -0
- data/lib/imagizer_engine/mount.rb +22 -0
- data/lib/imagizer_engine/url.rb +28 -0
- data/lib/imagizer_engine/version.rb +3 -0
- data/spec/imagizer_engine_spec.rb +65 -0
- data/spec/spec_helper.rb +1 -0
- data/tasks/rspec.rake +3 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f232591d95762a8f90eb723df028f516c2600731
|
4
|
+
data.tar.gz: 4ab835f05a91d5a61831ac0b5adb5c79318ae4e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da4d926b0566f232676ae0623f94dd272bd5e6e01d6f679c5581cb9b0bd27f31fe40c633566cd4efc54ae8640f18f53e9e0889af8f71f54b969fcf437d513946
|
7
|
+
data.tar.gz: 1a9ccbbfe1bb62f4943bf90e9179d6790abe671fb66e48d9f620255eb1b3dde84fb99f1924d0ce2427cfa23adbe716612452803d2f13f155586f3d098ad00372
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 sfkaos
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# ImagizerEngine
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'imagizer_engine'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install imagizer_engine
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/imagizer_engine/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'imagizer_engine/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "imagizer_engine"
|
8
|
+
spec.version = ImagizerEngine::VERSION
|
9
|
+
spec.authors = ["sfkaos"]
|
10
|
+
spec.email = ["win@vangoart.co"]
|
11
|
+
spec.summary = %q{Ruby client for using the Imagizer Media Engine from nvnentify.}
|
12
|
+
spec.description = %q{Super simple ruby client to use the Imagizer Media Engine created by nventify. Imagizer is a real-time image processing engine on top of AMAZON aws.
|
13
|
+
Install the engine using the AWS Marketplace. =You can find it at www.imagizercdn.com.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "activesupport", ">= 4.0.0"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "imagizer_engine/version"
|
2
|
+
require "imagizer_engine/mount"
|
3
|
+
module ImagizerEngine
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def public_ip
|
7
|
+
@public_ip ||= "0.0.0.0"
|
8
|
+
end
|
9
|
+
|
10
|
+
def public_ip=(ip)
|
11
|
+
@public_ip = ip
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(&block)
|
15
|
+
instance_eval(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def definitions
|
19
|
+
@definitions ||= Hash.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def version(name, options={})
|
23
|
+
definitions[name.to_sym] = Version.new(name, options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def [](name)
|
27
|
+
definitions[name.to_sym]
|
28
|
+
end
|
29
|
+
|
30
|
+
class Version
|
31
|
+
|
32
|
+
@@valid_config_keys = [:scale, :crop, :width, :height, :quality, :dpr, :filter]
|
33
|
+
|
34
|
+
def initialize(name, options)
|
35
|
+
@name = name.to_sym
|
36
|
+
@processes = options[:processes]
|
37
|
+
@parent = options[:parent]
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_reader :parent
|
41
|
+
|
42
|
+
def processes
|
43
|
+
return validated_processes unless parent
|
44
|
+
ImagizerEngine[parent].processes.merge(validated_processes)
|
45
|
+
end
|
46
|
+
|
47
|
+
def validated_processes
|
48
|
+
@processes.select{|key| @@valid_config_keys.include? key.to_sym}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
require "imagizer_engine/url"
|
55
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ImagizerEngine
|
2
|
+
module Mount
|
3
|
+
def mount_engine(column)
|
4
|
+
mod = Module.new
|
5
|
+
include mod
|
6
|
+
mod.class_eval <<-RUBY, __FILE__, __LINE__+1
|
7
|
+
|
8
|
+
def #{column}_url(version=nil)
|
9
|
+
raise NoMethodError, "define `#{column}_original_url' for #{self.inspect}" unless respond_to?(:#{column}_original_url)
|
10
|
+
to_imagizer_url(((#{column}_original_url)), version)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def to_imagizer_url(url, version)
|
16
|
+
Url.new.to_url(url, version)
|
17
|
+
end
|
18
|
+
|
19
|
+
RUBY
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ImagizerEngine
|
2
|
+
class Url
|
3
|
+
def to_url(url, version)
|
4
|
+
"http://" + ImagizerEngine.public_ip + "/c/" + sanitized_url(url) + process_params(version)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def sanitized_url(url)
|
10
|
+
url.sub(/^https?\:\/\/?([\da-z\.-]+)\.([a-z\.]{2,6}\/)/, '')
|
11
|
+
end
|
12
|
+
|
13
|
+
def process_params(version)
|
14
|
+
return "" if version.nil? || ImagizerEngine[version].nil?
|
15
|
+
temp_params = serialized_processes(version)
|
16
|
+
temp_params.empty? ? "" : "?" + temp_params
|
17
|
+
end
|
18
|
+
|
19
|
+
def serialized_processes(version)
|
20
|
+
ImagizerEngine[version].processes.map{|k,v| "#{k}=#{sanitized_value(v)}"}.join('&')
|
21
|
+
end
|
22
|
+
|
23
|
+
def sanitized_value(value)
|
24
|
+
value.kind_of?(Array) ? value.join(',') : value
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ImagizerEngine do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@class = Class.new
|
7
|
+
@class.send(:extend, ImagizerEngine::Mount)
|
8
|
+
|
9
|
+
@class.mount_engine(:image)
|
10
|
+
@class.mount_engine(:cover)
|
11
|
+
@instance = @class.new
|
12
|
+
@instance.define_singleton_method(:image_original_url) do
|
13
|
+
"path/to/file.png"
|
14
|
+
end
|
15
|
+
|
16
|
+
ImagizerEngine.public_ip = "141.123.12.9"
|
17
|
+
|
18
|
+
ImagizerEngine.configure do
|
19
|
+
version :thumb,
|
20
|
+
:processes => {
|
21
|
+
width: 250,
|
22
|
+
height: 100,
|
23
|
+
scale: 1
|
24
|
+
}
|
25
|
+
|
26
|
+
version :cover,
|
27
|
+
:parent => :thumb,
|
28
|
+
:processes => {
|
29
|
+
scale: 2,
|
30
|
+
crop: [1,2,3,4]
|
31
|
+
}
|
32
|
+
|
33
|
+
version :invalid,
|
34
|
+
:processes => {
|
35
|
+
test: 100
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should send the correct url without a version" do
|
41
|
+
expect(@instance.image_url).to eq("http://141.123.12.9/c/path/to/file.png")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should send the correct url with a version" do
|
45
|
+
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
|
+
end
|
47
|
+
|
48
|
+
it "should raise error if `cover_original_url is not defined" do
|
49
|
+
expect{@instance.cover_url}.to raise_error(NoMethodError)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have `_url method defined" do
|
53
|
+
expect(@instance.respond_to?(:image_url)).to be true
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should allow configuring of #public_ip" do
|
57
|
+
ImagizerEngine.public_ip = "1.2.3.4"
|
58
|
+
expect(ImagizerEngine.public_ip).to eq("1.2.3.4")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should ignore keys that are not used in the Imagizer API" do
|
62
|
+
expect(@instance.image_url(:invalid)).to eq("http://141.123.12.9/c/path/to/file.png")
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'imagizer_engine'
|
data/tasks/rspec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: imagizer_engine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sfkaos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: "Super simple ruby client to use the Imagizer Media Engine created by
|
70
|
+
nventify. Imagizer is a real-time image processing engine on top of AMAZON aws.
|
71
|
+
\n Install the engine using the AWS Marketplace. =You can find it at www.imagizercdn.com."
|
72
|
+
email:
|
73
|
+
- win@vangoart.co
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- imagizer_engine.gemspec
|
84
|
+
- lib/imagizer_engine.rb
|
85
|
+
- lib/imagizer_engine/mount.rb
|
86
|
+
- lib/imagizer_engine/url.rb
|
87
|
+
- lib/imagizer_engine/version.rb
|
88
|
+
- spec/imagizer_engine_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- tasks/rspec.rake
|
91
|
+
homepage: ''
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.2.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Ruby client for using the Imagizer Media Engine from nvnentify.
|
115
|
+
test_files:
|
116
|
+
- spec/imagizer_engine_spec.rb
|
117
|
+
- spec/spec_helper.rb
|