Sha256: fb4738e2ea3b6a92a2159772f3667792d3803b15f73cc19b56df7c090f18f5d5

Contents?: true

Size: 960 Bytes

Versions: 7

Compression:

Stored size: 960 Bytes

Contents

module Bait
  module Assets
    def assets
      Class.new do
        def missing?
          !Bait.public.join('js', 'application.js').exist? &&
          !Bait.public.join('css', 'application.css').exist?
        end

        def remove!
          FileUtils.rm(Bait.public.join('js', 'application.js')) rescue nil
          FileUtils.rm(Bait.public.join('css', 'application.css')) rescue nil
        end

        def dynamic?
          Bait.env != "production"
        end

        def compile!
          Module.new do
            require 'bait/api'
            require 'sinatra/asset_snack'
            extend Sinatra::AssetSnack::InstanceMethods
            Sinatra::AssetSnack.assets.each do |assets|
              path = File.join(Bait.public, assets[:route])
              File.open(path, 'w') do |file|
                file.write compile(assets[:paths])[:body]
              end
            end
          end
        end
      end.new
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bait-0.5.13 lib/bait/assets.rb
bait-0.5.12 lib/bait/assets.rb
bait-0.5.11 lib/bait/assets.rb
bait-0.5.10 lib/bait/assets.rb
bait-0.5.9 lib/bait/assets.rb
bait-0.5.6 lib/bait/assets.rb
bait-0.5.5 lib/bait/assets.rb