Class: Shutterbug::Handlers::JsFileHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/shutterbug/handlers/js_file_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_config = Configuration.instance()) ⇒ JsFileHandler

Returns a new instance of JsFileHandler.



17
18
19
20
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 17

def initialize(_config=Configuration.instance())
  @config = _config
  @javascript = File.read(js_file).gsub(/CONVERT_PATH/,@config.convert_path)
end

Class Method Details

.js_pathObject



5
6
7
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 5

def self.js_path
  "#{Configuration.instance.url_prefix}/shutterbug.js"
end

Instance Method Details

#handle(helper, req, env) ⇒ Object



22
23
24
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 22

def handle(helper, req, env)
  helper.good_response(@javascript, 'application/javascript')
end

#js_fileObject



13
14
15
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 13

def js_file
  File.join(File.dirname(__FILE__),"shutterbug.js")
end

#regexObject



9
10
11
# File 'lib/shutterbug/handlers/js_file_handler.rb', line 9

def regex
  /#{@config.path_prefix}\/shutterbug.js/
end