class Rmk::VFile
virtual file which represent a real OS file
Attributes
build which include this file as output file @return [Rmk::Build]
get or set out file state return [:eixst, :create, true, nil]
Public Class Methods
# File lib/rmk/vfile.rb, line 8 def self.generate_modified_id(path) File.mtime(path).to_i end
create VFile
@param rmk [Rmk] @param path [String] file's absolute path, must be normalized @param vpath [String] file's virtual path
# File lib/rmk/vfile.rb, line 26 def initialize(rmk:, path:, vpath:nil, is_src:false) @rmk, @path, @vpath, @is_src = rmk, path, vpath || nil, is_src @input_ref_builds, @order_ref_builds = [], [] @output_ref_build = nil unless is_src end
Public Instance Methods
change to out file @param outfile [Rmk::VFile] target file @return [self]
# File lib/rmk/vfile.rb, line 51 def change_to_out!(outfile) raise "outfile '#{@path}' can't change to outfile" if src? raise "outfile '#{@path}' can't change to srcfile" if outfile.src? unless @path == outfile.path && @vpath == outfile.vpath raise "srcfile '#{@path}' can't change to outfile '#{outfile.path}'" end @is_src = false @input_ref_builds.concat outfile.input_ref_builds @order_ref_builds.concat outfile.order_ref_builds @output_ref_build = outfile.output_ref_build self end
check build's to run as srcfile, means file must be exist and can't check more than one time
# File lib/rmk/vfile.rb, line 70 def check_for_build lmid, cmid = load_modified_id, generate_modified_id return updated! false if lmid == cmid store_modified_id cmid updated! true end
check outdated or not as srcfile at parse phaze(not build phaze)
# File lib/rmk/vfile.rb, line 78 def check_for_parse load_modified_id != generate_modified_id end
generate file's modified id from current disk content
# File lib/rmk/vfile.rb, line 37 def generate_modified_id; Rmk::VFile.generate_modified_id @path end
builds which include this file as input file
# File lib/rmk/vfile.rb, line 13 def input_ref_builds; @input_ref_builds end
load last time modified id from system database @return [Object] last stored modified id or nil for no last stored id
# File lib/rmk/vfile.rb, line 41 def load_modified_id; @rmk.mid_storage[@path] end
builds which include this file as order-only file
# File lib/rmk/vfile.rb, line 16 def order_ref_builds; @order_ref_builds end
# File lib/rmk/vfile.rb, line 10 def src?; @is_src end
store modified id to system database for next time check @param mid [Object] modified id @return [Object] stored modified id
# File lib/rmk/vfile.rb, line 46 def store_modified_id(mid) @rmk.mid_storage[@path] = mid end
# File lib/rmk/vfile.rb, line 64 def updated!(modified) input_ref_builds.each{|build| build.input_updated! modified} order_ref_builds.each{|build| build.order_updated! modified} end