Class: JitPipe

Inherits:
Object
  • Object
show all
Defined in:
lib/jitpipe.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#account=(value) ⇒ Object (writeonly)

Sets the attribute account

Parameters:

  • value

    the value to set the attribute account to.



5
6
7
# File 'lib/jitpipe.rb', line 5

def account=(value)
  @account = value
end

#fitObject



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

Parameters:

  • value

    the value to set the attribute height to.



5
6
7
# File 'lib/jitpipe.rb', line 5

def height=(value)
  @height = value
end

#key=(value) ⇒ Object (writeonly)

Sets the attribute key

Parameters:

  • value

    the value to set the attribute key to.



5
6
7
# File 'lib/jitpipe.rb', line 5

def key=(value)
  @key = value
end

#quality=(value) ⇒ Object (writeonly)

Sets the attribute quality

Parameters:

  • value

    the value to set the attribute quality to.



5
6
7
# File 'lib/jitpipe.rb', line 5

def quality=(value)
  @quality = value
end

#secret=(value) ⇒ Object (writeonly)

Sets the attribute secret

Parameters:

  • value

    the value to set the attribute secret to.



5
6
7
# File 'lib/jitpipe.rb', line 5

def secret=(value)
  @secret = value
end

#width=(value) ⇒ Object (writeonly)

Sets the attribute width

Parameters:

  • value

    the value to set the attribute width to.



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. = cred[:account]
  jp
end

#cropObject



47
48
49
50
51
# File 'lib/jitpipe.rb', line 47

def crop
  jp = clone
  jp.fit = ''
  jp
end

#default_qualityObject



41
42
43
44
45
# File 'lib/jitpipe.rb', line 41

def default_quality
  jp = clone
  jp.quality = ''
  jp
end

#high_qualityObject



35
36
37
38
39
# File 'lib/jitpipe.rb', line 35

def high_quality
  jp = clone
  jp.quality = '/hi'
  jp
end

#low_qualityObject



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