class RapperLite::Engine
Public Class Methods
find_config_path()
click to toggle source
# File lib/rapper_lite.rb, line 27 def self.find_config_path ["./", "config/"].each do |folder| ["rapper.yml", "assets.yml"].each do |file| path = File.expand_path( file, folder ) return path if File.exists?( path ) end end raise "No config file found." end
new( config_path )
click to toggle source
# File lib/rapper_lite.rb, line 23 def initialize( config_path ) self.load_config( config_path ) end
Public Instance Methods
all_component_paths()
click to toggle source
All absolute file paths for the component files
# File lib/rapper_lite/watch_support.rb, line 40 def all_component_paths [:css, :js].map do |type| (@definitions[type].keys - self.config_keys).map do |name| self.file_paths( type, name ) end end.flatten.uniq.map do |path| File.expand_path( path ) end end
common_root()
click to toggle source
LCD for JS and CSS roots
# File lib/rapper_lite/watch_support.rb, line 28 def common_root js_path = File.expand_path( self.root( :js ) ).split( "/" ) css_path = File.expand_path( self.root( :css ) ).split( "/" ) path = [] while js_component = js_path.shift && css_component = css_path.shift break if js_component != css_component path << js_component end path.join( "/" ) end
noisy_package()
click to toggle source
# File lib/rapper_lite/watch_support.rb, line 21 def noisy_package print( "Compiling static assets..." ) && STDOUT.flush self.package puts " Done!" end
package()
click to toggle source
# File lib/rapper_lite.rb, line 37 def package [:js, :css].each do |type| definition = @definitions[type] source = File.expand_path( self.root( type ) ) definition.each do |name, spec| next if self.config_key?( name ) # Skip config settings next unless self.needs_packaging?( type, name ) self.build_package( type, name ) end end self.refresh_versions self.save_config end
watch()
click to toggle source
# File lib/rapper_lite/watch_support.rb, line 4 def watch rapper = self rapper.noisy_package FSSM.monitor( rapper.common_root, '**/*.{css,js,coffee,sass}' ) do begin component_files = rapper.all_component_paths update do |base, relative| if component_files.include?( File.join( base, relative) ) rapper.noisy_package end end rescue FSSM::CallbackError # no-op end end end