Class: Shutterbug::Configuration
- Inherits:
-
Object
- Object
- Shutterbug::Configuration
- Defined in:
- lib/shutterbug/configuration.rb
Instance Attribute Summary collapse
-
#cache_manager ⇒ Object
Returns the value of attribute cache_manager.
-
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
-
#phantom_bin_path ⇒ Object
Returns the value of attribute phantom_bin_path.
-
#resource_dir ⇒ Object
Returns the value of attribute resource_dir.
-
#s3_bin ⇒ Object
Returns the value of attribute s3_bin.
-
#s3_key ⇒ Object
Returns the value of attribute s3_key.
-
#s3_secret ⇒ Object
Returns the value of attribute s3_secret.
-
#uri_prefix ⇒ Object
Returns the value of attribute uri_prefix.
Class Method Summary collapse
Instance Method Summary collapse
- #base_url(req) ⇒ Object
- #convert_path ⇒ Object
- #fs_path_for(filename) ⇒ Object
-
#initialize(opts = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #storage ⇒ Object
- #url_prefix ⇒ Object
- #use_s3? ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/shutterbug/configuration.rb', line 18 def initialize(opts={}) self.uri_prefix = opts[:uri_prefix] || "" self.path_prefix = opts[:path_prefix] || "/shutterbug" self.resource_dir = opts[:resource_dir] || Dir.tmpdir self.phantom_bin_path = opts[:phantom_bin_path] || "phantomjs" self.s3_bin = opts[:s3_bin] self.s3_key = opts[:s3_key] self.s3_secret = opts[:s3_secret] self.cache_manager = opts[:cache_manager] || Shutterbug::CacheManager::NoCache.new end |
Instance Attribute Details
#cache_manager ⇒ Object
Returns the value of attribute cache_manager.
12 13 14 |
# File 'lib/shutterbug/configuration.rb', line 12 def cache_manager @cache_manager end |
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
6 7 8 |
# File 'lib/shutterbug/configuration.rb', line 6 def path_prefix @path_prefix end |
#phantom_bin_path ⇒ Object
Returns the value of attribute phantom_bin_path.
8 9 10 |
# File 'lib/shutterbug/configuration.rb', line 8 def phantom_bin_path @phantom_bin_path end |
#resource_dir ⇒ Object
Returns the value of attribute resource_dir.
7 8 9 |
# File 'lib/shutterbug/configuration.rb', line 7 def resource_dir @resource_dir end |
#s3_bin ⇒ Object
Returns the value of attribute s3_bin.
9 10 11 |
# File 'lib/shutterbug/configuration.rb', line 9 def s3_bin @s3_bin end |
#s3_key ⇒ Object
Returns the value of attribute s3_key.
10 11 12 |
# File 'lib/shutterbug/configuration.rb', line 10 def s3_key @s3_key end |
#s3_secret ⇒ Object
Returns the value of attribute s3_secret.
11 12 13 |
# File 'lib/shutterbug/configuration.rb', line 11 def s3_secret @s3_secret end |
#uri_prefix ⇒ Object
Returns the value of attribute uri_prefix.
5 6 7 |
# File 'lib/shutterbug/configuration.rb', line 5 def uri_prefix @uri_prefix end |
Class Method Details
.instance(opts = {}) ⇒ Object
14 15 16 |
# File 'lib/shutterbug/configuration.rb', line 14 def self.instance(opts={}) return @instance || @instance = self.new(opts) end |
Instance Method Details
#base_url(req) ⇒ Object
41 42 43 |
# File 'lib/shutterbug/configuration.rb', line 41 def base_url(req) req.POST()['base_url'] || req.referrer || "#{req.scheme}://#{req.host_with_port}" end |
#convert_path ⇒ Object
37 38 39 |
# File 'lib/shutterbug/configuration.rb', line 37 def convert_path "#{url_prefix}/make_snapshot" end |
#fs_path_for(filename) ⇒ Object
29 30 31 |
# File 'lib/shutterbug/configuration.rb', line 29 def fs_path_for(filename) File.join(resource_dir,"phantom_#{filename}") end |
#storage ⇒ Object
45 46 47 |
# File 'lib/shutterbug/configuration.rb', line 45 def storage use_s3? ? Storage::S3Storage : Storage::FileStorage end |
#url_prefix ⇒ Object
33 34 35 |
# File 'lib/shutterbug/configuration.rb', line 33 def url_prefix "#{uri_prefix}#{path_prefix}" end |
#use_s3? ⇒ Boolean
49 50 51 |
# File 'lib/shutterbug/configuration.rb', line 49 def use_s3? return (self.s3_bin && self.s3_key && self.s3_secret) end |