Class: Shutterbug::Configuration
- Inherits:
-
Object
- Object
- Shutterbug::Configuration
- Defined in:
- lib/shutterbug/configuration.rb
Instance Attribute Summary collapse
-
#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.
-
#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
- #convert_regex ⇒ Object
- #html_path(sha = '') ⇒ Object
- #html_regex ⇒ Object
-
#initialize(opts = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #js_file ⇒ Object
- #js_path ⇒ Object
- #js_regex ⇒ Object
- #png_path(sha = '') ⇒ Object
- #png_regex ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 18 |
# File 'lib/shutterbug/configuration.rb', line 13 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" end |
Instance Attribute Details
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
5 6 7 |
# File 'lib/shutterbug/configuration.rb', line 5 def path_prefix @path_prefix end |
#phantom_bin_path ⇒ Object
Returns the value of attribute phantom_bin_path.
7 8 9 |
# File 'lib/shutterbug/configuration.rb', line 7 def phantom_bin_path @phantom_bin_path end |
#resource_dir ⇒ Object
Returns the value of attribute resource_dir.
6 7 8 |
# File 'lib/shutterbug/configuration.rb', line 6 def resource_dir @resource_dir end |
#uri_prefix ⇒ Object
Returns the value of attribute uri_prefix.
4 5 6 |
# File 'lib/shutterbug/configuration.rb', line 4 def uri_prefix @uri_prefix end |
Class Method Details
.instance(opts = {}) ⇒ Object
9 10 11 |
# File 'lib/shutterbug/configuration.rb', line 9 def self.instance(opts={}) return @instance || @instance = self.new(opts) end |
Instance Method Details
#base_url(req) ⇒ Object
53 54 55 |
# File 'lib/shutterbug/configuration.rb', line 53 def base_url(req) req.POST()['base_url'] || req.referrer || "#{req.scheme}://#{req.host_with_port}" end |
#convert_path ⇒ Object
32 33 34 |
# File 'lib/shutterbug/configuration.rb', line 32 def convert_path "#{uri_prefix}#{path_prefix}/make_snapshot" end |
#convert_regex ⇒ Object
35 36 37 |
# File 'lib/shutterbug/configuration.rb', line 35 def convert_regex /#{path_prefix}\/make_snapshot/ end |
#html_path(sha = '') ⇒ Object
46 47 48 |
# File 'lib/shutterbug/configuration.rb', line 46 def html_path(sha='') "#{uri_prefix}#{path_prefix}/get_html/#{sha}" end |
#html_regex ⇒ Object
49 50 51 |
# File 'lib/shutterbug/configuration.rb', line 49 def html_regex /#{path_prefix}\/get_html\/([^\/]+)/ end |
#js_file ⇒ Object
28 29 30 |
# File 'lib/shutterbug/configuration.rb', line 28 def js_file File.join(File.dirname(__FILE__),"shutterbug.js") end |
#js_path ⇒ Object
20 21 22 |
# File 'lib/shutterbug/configuration.rb', line 20 def js_path "#{uri_prefix}#{path_prefix}/shutterbug.js" end |
#js_regex ⇒ Object
24 25 26 |
# File 'lib/shutterbug/configuration.rb', line 24 def js_regex /#{path_prefix}\/shutterbug.js/ end |
#png_path(sha = '') ⇒ Object
39 40 41 |
# File 'lib/shutterbug/configuration.rb', line 39 def png_path(sha='') "#{uri_prefix}#{path_prefix}/get_png/#{sha}" end |
#png_regex ⇒ Object
42 43 44 |
# File 'lib/shutterbug/configuration.rb', line 42 def png_regex /#{path_prefix}\/get_png\/([^\/]+)/ end |