class Ruhoh::Resources::Theme::Compiler
Public Instance Methods
files()
click to toggle source
Returns list of all files from the theme to be compiled. @returns relative filepaths
# File lib/ruhoh/resources/theme/compiler.rb, line 21 def files FileUtils.cd(@ruhoh.cascade.theme) { return Dir["**/*"].select { |filepath| is_valid_asset?(filepath) } } end
is_valid_asset?(filepath)
click to toggle source
Checks a given asset filepath against any user-defined exclusion rules in config Omit layouts, stylesheets, javascripts, media as they are handled by their respective resources. @returns
# File lib/ruhoh/resources/theme/compiler.rb, line 32 def is_valid_asset?(filepath) return false unless File.exist? filepath return false if FileTest.directory?(filepath) return false if filepath.start_with?('.', 'layouts', 'stylesheets', 'javascripts', 'media') excludes = Array(@collection.config['exclude']).map { |node| Regexp.new(node) } excludes.each { |regex| return false if filepath =~ regex } true end
run()
click to toggle source
Copies all assets over to the compiled site. Note the compiled assets are namespaced at /assets/
# File lib/ruhoh/resources/theme/compiler.rb, line 7 def run return unless setup_compilable self.files.each do |file| original_file = File.join(@ruhoh.cascade.theme, file) compiled_file = File.join(@collection.compiled_path, file) FileUtils.mkdir_p File.dirname(compiled_file) FileUtils.cp_r original_file, compiled_file Ruhoh::Friend.say { green " > #{file}" } end end