Class: OverlayMe::App

Inherits:
Object
  • Object
show all
Defined in:
lib/overlay_me.rb

Overview

the App is used to list the images contained into the ‘self.overlays_directory’ directory

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



9
10
11
12
13
14
# File 'lib/overlay_me.rb', line 9

def self.call(env)
  Dir.chdir OverlayMe.root_dir if Dir[OverlayMe.root_dir]
  images_urls = Dir[ OverlayMe.overlays_directory + '/**/*.*' ].map{|path| '/'+path}
  images_urls = images_urls.map{|path| path.sub(/images/, 'assets') } if self.rails_and_assets_pipeline_enabled?
  [200, {"Content-Type" => "text/html"}, images_urls.to_json]
end

.rails_and_assets_pipeline_enabled?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'lib/overlay_me.rb', line 16

def self.rails_and_assets_pipeline_enabled?
  if defined? ::Rails
    rails_config = ::Rails.application.config
    return rails_config.respond_to?(:assets) && rails_config.assets.try(:enabled)
  else
    return false
  end
end