Class: Plezi::Base::Assets

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

Instance Method Summary collapse

Instance Method Details

#indexObject


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

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


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

def show
  index
end