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.
-
#skip_direct_upload ⇒ Object
Returns the value of attribute skip_direct_upload.
-
#uri_prefix ⇒ Object
Returns the value of attribute uri_prefix.
Class Method Summary collapse
Instance Method Summary collapse
- #base_url(req) ⇒ 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
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/shutterbug/configuration.rb', line 19 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 self.skip_direct_upload = opts[:skip_direct_upload] 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 |
#skip_direct_upload ⇒ Object
Returns the value of attribute skip_direct_upload.
13 14 15 |
# File 'lib/shutterbug/configuration.rb', line 13 def skip_direct_upload @skip_direct_upload 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
15 16 17 |
# File 'lib/shutterbug/configuration.rb', line 15 def self.instance(opts={}) return @instance || @instance = self.new(opts) end |
Instance Method Details
#base_url(req) ⇒ Object
39 40 41 |
# File 'lib/shutterbug/configuration.rb', line 39 def base_url(req) req.POST()['base_url'] || req.referrer || "#{req.scheme}://#{req.host_with_port}" end |
#fs_path_for(filename) ⇒ Object
31 32 33 |
# File 'lib/shutterbug/configuration.rb', line 31 def fs_path_for(filename) File.join(resource_dir, "phantom_#{filename}") end |
#storage ⇒ Object
43 44 45 |
# File 'lib/shutterbug/configuration.rb', line 43 def storage use_s3? ? Storage::S3Storage : Storage::FileStorage end |
#url_prefix ⇒ Object
35 36 37 |
# File 'lib/shutterbug/configuration.rb', line 35 def url_prefix "#{uri_prefix}#{path_prefix}" end |
#use_s3? ⇒ Boolean
47 48 49 |
# File 'lib/shutterbug/configuration.rb', line 47 def use_s3? return (self.s3_bin && self.s3_key && self.s3_secret) end |