Class: Configuration
- Inherits:
-
Object
show all
- Defined in:
- lib/httpimagestore/configuration.rb
Defined Under Namespace
Classes: ThumbnailClassDoesNotExistError
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
11
12
13
14
15
16
17
18
19
|
# File 'lib/httpimagestore/configuration.rb', line 11
def initialize(&block)
@thumbnail_classes = Hash.new do |h, k|
raise ThumbnailClassDoesNotExistError, k
end
@thumbnailer_url = "http://localhost:3100"
instance_eval &block
end
|
Class Method Details
.from_file(file) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/httpimagestore/configuration.rb', line 21
def self.from_file(file)
file = Pathname.pwd + file
Configuration.new do
eval(file.read, nil, file.to_s)
end
end
|
Instance Method Details
#get ⇒ Object
45
46
47
|
# File 'lib/httpimagestore/configuration.rb', line 45
def get
Struct.new(:thumbnail_classes, :s3_key_id, :s3_key_secret, :s3_bucket, :thumbnailer_url).new(@thumbnail_classes, @s3_key_id, @s3_key_secret, @s3_bucket, @thumbnailer_url)
end
|
#put(sinatra) ⇒ Object
49
50
51
52
53
|
# File 'lib/httpimagestore/configuration.rb', line 49
def put(sinatra)
get.each_pair do |key, value|
sinatra.set key, value
end
end
|
#s3_bucket(bucket) ⇒ Object
37
38
39
|
# File 'lib/httpimagestore/configuration.rb', line 37
def s3_bucket(bucket)
@s3_bucket = bucket
end
|
#s3_key(id, secret) ⇒ Object
32
33
34
35
|
# File 'lib/httpimagestore/configuration.rb', line 32
def s3_key(id, secret)
@s3_key_id = id
@s3_key_secret = secret
end
|
#thumbnail_class(name, method, width, height, format = 'JPEG', options = {}) ⇒ Object
28
29
30
|
# File 'lib/httpimagestore/configuration.rb', line 28
def thumbnail_class(name, method, width, height, format = 'JPEG', options = {})
@thumbnail_classes[name] = ThumbnailClass.new(name, method, width, height, format, options)
end
|
#thumbnailer_url(url) ⇒ Object
41
42
43
|
# File 'lib/httpimagestore/configuration.rb', line 41
def thumbnailer_url(url)
@thumbnailer_url = url
end
|