Class: JitPipe
- Inherits:
-
Object
- Object
- JitPipe
- Defined in:
- lib/jitpipe.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
writeonly
Sets the attribute account.
- #fit ⇒ Object
-
#height ⇒ Object
writeonly
Sets the attribute height.
-
#key ⇒ Object
writeonly
Sets the attribute key.
-
#quality ⇒ Object
writeonly
Sets the attribute quality.
-
#secret ⇒ Object
writeonly
Sets the attribute secret.
-
#width ⇒ Object
writeonly
Sets the attribute width.
Class Method Summary collapse
-
.auth(cred) ⇒ Object
cred.
Instance Method Summary collapse
- #auth(cred) ⇒ Object
- #crop ⇒ Object
- #default_quality ⇒ Object
- #high_quality ⇒ Object
- #low_quality ⇒ Object
-
#size(w, h) ⇒ Object
config.
-
#url(src) ⇒ Object
bakery.
Instance Attribute Details
#account=(value) ⇒ Object (writeonly)
Sets the attribute account
5 6 7 |
# File 'lib/jitpipe.rb', line 5 def account=(value) @account = value end |
#fit ⇒ Object
53 54 55 56 57 |
# File 'lib/jitpipe.rb', line 53 def fit jp = clone jp.fit = '/fit' jp end |
#height=(value) ⇒ Object (writeonly)
Sets the attribute height
5 6 7 |
# File 'lib/jitpipe.rb', line 5 def height=(value) @height = value end |
#key=(value) ⇒ Object (writeonly)
Sets the attribute key
5 6 7 |
# File 'lib/jitpipe.rb', line 5 def key=(value) @key = value end |
#quality=(value) ⇒ Object (writeonly)
Sets the attribute quality
5 6 7 |
# File 'lib/jitpipe.rb', line 5 def quality=(value) @quality = value end |
#secret=(value) ⇒ Object (writeonly)
Sets the attribute secret
5 6 7 |
# File 'lib/jitpipe.rb', line 5 def secret=(value) @secret = value end |
#width=(value) ⇒ Object (writeonly)
Sets the attribute width
5 6 7 |
# File 'lib/jitpipe.rb', line 5 def width=(value) @width = value end |
Class Method Details
.auth(cred) ⇒ Object
cred
62 63 64 |
# File 'lib/jitpipe.rb', line 62 def self.auth(cred) self.new.auth(cred) end |
Instance Method Details
#auth(cred) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jitpipe.rb', line 66 def auth(cred) cred = parse_cred(cred) if cred.is_a? String raise 'jitpipe: Missing key/secret/account.' if !(cred[:key] && cred[:secret] && cred[:account]) jp = clone jp.key = cred[:key] jp.secret = cred[:secret] jp.account = cred[:account] jp end |
#crop ⇒ Object
47 48 49 50 51 |
# File 'lib/jitpipe.rb', line 47 def crop jp = clone jp.fit = '' jp end |
#default_quality ⇒ Object
41 42 43 44 45 |
# File 'lib/jitpipe.rb', line 41 def default_quality jp = clone jp.quality = '' jp end |
#high_quality ⇒ Object
35 36 37 38 39 |
# File 'lib/jitpipe.rb', line 35 def high_quality jp = clone jp.quality = '/hi' jp end |
#low_quality ⇒ Object
29 30 31 32 33 |
# File 'lib/jitpipe.rb', line 29 def low_quality jp = clone jp.quality = '/lo' jp end |
#size(w, h) ⇒ Object
config
19 20 21 22 23 24 25 26 27 |
# File 'lib/jitpipe.rb', line 19 def size(w, h) check_size(w) check_size(h) jp = clone jp.width = w jp.height = h jp end |
#url(src) ⇒ Object
bakery
80 81 82 83 84 85 86 87 88 |
# File 'lib/jitpipe.rb', line 80 def url(src) raise 'jitpipe: Credentials not set.' if !@key raise 'jitpipe: Size not set.' if !@width unsigned = "/v2/#{@account}/#{@key}/#{@width}x#{@height}#{@fit}#{@quality}/#{CGI::escape(src)}" signature = OpenSSL::HMAC.hexdigest('md5', @secret, unsigned) "http://jpeg.jitpipe.com#{unsigned}/#{signature}.jpg" end |