Sha256: 1511e8ed2c02b8d5492fec7975cf2c1bf854f49a5e7aabe3091470193e7d46b2

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module Spinebox
  module Compiler
    
    # Compiles the assets and the views into the public folder
    def self.compile
      Spinebox.config.concatenate = true
      create_directories
      compile_javascripts
      compile_stylesheets
      compile_views
      copy_images
    end
    
    private
    def self.create_directories
      Dir.mkdir "public"         unless File.directory?("public")
      Dir.mkdir "public/assets"  unless File.directory?("public/assets")
    end
    
    def self.compile_javascripts
      asset = Spinebox.assets["application.js"]
      asset.write_to(File.join("public/assets", asset.logical_path))
    end
    
    def self.compile_stylesheets
      asset = Spinebox.assets["application.css"]
      asset.write_to(File.join("public/assets", asset.logical_path))
    end
    
    def self.compile_views
      Spinebox.views.each_logical_path do |logical_path|
        next if logical_path.start_with?("_")
        asset = Spinebox.views[logical_path]
        asset.write_to(File.join("public", asset.logical_path))
      end      
    end
    
    def self.copy_images
      FileUtils.cp_r "app/assets/images/.", "public/assets"
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spinebox-0.0.14 lib/spinebox/compiler.rb