Class: Plezi::Base::Assets

Inherits:
Object
  • Object
show all
Defined in:
lib/plezi/router/assets.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/plezi/router/assets.rb', line 5

def index
   name = File.join(Plezi.assets, *params['*'.freeze]).freeze
   data = ::Plezi::AssetBaker.bake(name)
   return false unless data
   name = File.join(Iodine::Rack.public, request.path_info[1..-1]).freeze if Iodine::Rack.public
   if data.is_a?(String)
      FileUtils.mkpath File.dirname(name)
      IO.binwrite(name, data)
   end
   response['X-Sendfile'.freeze] = name
   response.body = File.open(name)
   true
end

#showObject



33
34
35
# File 'lib/plezi/router/assets.rb', line 33

def show
   index
end