Sha256: bfade423bb51c1b5c7068cb9f2c690e3eeb4397a9e816a54aeee766e93e6f14c

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 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|
        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

11 entries across 11 versions & 1 rubygems

Version Path
spinebox-0.0.13 lib/spinebox/compiler.rb
spinebox-0.0.12 lib/spinebox/compiler.rb
spinebox-0.0.11 lib/spinebox/compiler.rb
spinebox-0.0.10 lib/spinebox/compiler.rb
spinebox-0.0.9 lib/spinebox/compiler.rb
spinebox-0.0.8 lib/spinebox/compiler.rb
spinebox-0.0.7 lib/spinebox/compiler.rb
spinebox-0.0.6 lib/spinebox/compiler.rb
spinebox-0.0.5 lib/spinebox/compiler.rb
spinebox-0.0.4 lib/spinebox/compiler.rb
spinebox-0.0.3 lib/spinebox/compiler.rb