class Tilt::Fs::FileSystem::File
Attributes
content[R]
data_path[R]
logger[R]
real_path[R]
Public Class Methods
new(new_real_path, new_data_path = nil)
click to toggle source
# File lib/tilt/fs/file_system/file.rb, line 10 def initialize(new_real_path, new_data_path = nil) @real_path = new_real_path @logger = FS_LOGGER @data_path = new_data_path @content = render_content logger.debug "file#new(): created, real_path = #{real_path}, data_path = #{data_path}" end
Public Instance Methods
attr()
click to toggle source
# File lib/tilt/fs/file_system/file.rb, line 72 def attr ::RFuse::Stat.file FS_DEFAULT_FILE_MODE, stat end
is_dir?()
click to toggle source
# File lib/tilt/fs/file_system/file.rb, line 54 def is_dir? false end
is_file?()
click to toggle source
# File lib/tilt/fs/file_system/file.rb, line 58 def is_file? true end
load_template_data()
click to toggle source
# File lib/tilt/fs/file_system/file.rb, line 34 def load_template_data if data_path.nil? || (not ::FileTest.file? data_path) logger.debug "file#load_template_data(): no data" {} else logger.debug "file#load_template_data(): data_path = #{data_path}" ::YAML.load_file data_path end end
name()
click to toggle source
e.g. “foo.txt.erb” => “foo.txt”
# File lib/tilt/fs/file_system/file.rb, line 45 def name res = ::Pathname.new(real_path).basename.to_s if /\.erb$/ === res res.gsub /\.erb$/, "" else res end end
render_content()
click to toggle source
# File lib/tilt/fs/file_system/file.rb, line 19 def render_content if ::Tilt.templates_for(real_path).empty? ::File.read real_path else template_data = load_template_data template = ::Tilt.new(real_path, nil) begin template.render self, template_data rescue => e logger.warn "file#render_content(): #{e}" raise "error on file#render_content()" end end end
stat()
click to toggle source
# File lib/tilt/fs/file_system/file.rb, line 62 def stat { :uid => ::Process.uid, :gid => ::Process.gid, :atime => ::Time.now, :mtime => ::Time.now, :size => content.length, } end