Class: Rmk::VFile
- Inherits:
-
Object
- Object
- Rmk::VFile
- Defined in:
- lib/rmk/vfile.rb,
lib/rmk/rmk.rb
Overview
virtual file which represent a real OS file
Instance Attribute Summary collapse
-
#is_src ⇒ Object
Returns the value of attribute is_src.
-
#output_ref_build ⇒ Rmk::Build
build which include this file as output file.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#state ⇒ Object
get or set out file state return [:eixst, :create, true, nil].
-
#vpath ⇒ Object
readonly
Returns the value of attribute vpath.
Class Method Summary collapse
Instance Method Summary collapse
-
#change_to_out!(outfile) ⇒ self
change to out file.
-
#check_for_build ⇒ Object
check build’s to run as srcfile, means file must be exist and can’t check more than one time.
-
#check_for_parse ⇒ Object
check outdated or not as srcfile at parse phaze(not build phaze).
-
#generate_modified_id ⇒ Object
generate file’s modified id from current disk content.
-
#initialize(rmk:, path:, vpath: nil, is_src: false) ⇒ VFile
constructor
create VFile.
-
#input_ref_builds ⇒ Object
builds which include this file as input file.
-
#load_modified_id ⇒ Object
load last time modified id from system database.
-
#order_ref_builds ⇒ Object
builds which include this file as order-only file.
- #src? ⇒ Boolean
-
#store_modified_id(mid) ⇒ Object
store modified id to system database for next time check.
- #updated!(modified) ⇒ Object
Constructor Details
#initialize(rmk:, path:, vpath: nil, is_src: false) ⇒ VFile
create VFile
26 27 28 29 30 |
# 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 |
Instance Attribute Details
#is_src ⇒ Object
Returns the value of attribute is_src.
6 7 8 |
# File 'lib/rmk/vfile.rb', line 6 def is_src @is_src end |
#output_ref_build ⇒ Rmk::Build
build which include this file as output file
20 21 22 |
# File 'lib/rmk/vfile.rb', line 20 def output_ref_build @output_ref_build end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/rmk/vfile.rb', line 5 def path @path end |
#state ⇒ Object
get or set out file state return [:eixst, :create, true, nil]
34 35 36 |
# File 'lib/rmk/vfile.rb', line 34 def state @state end |
#vpath ⇒ Object (readonly)
Returns the value of attribute vpath.
5 6 7 |
# File 'lib/rmk/vfile.rb', line 5 def vpath @vpath end |
Class Method Details
.generate_modified_id(path) ⇒ Object
8 |
# File 'lib/rmk/vfile.rb', line 8 def self.generate_modified_id(path) File.mtime(path).to_i end |
Instance Method Details
#change_to_out!(outfile) ⇒ self
change to out file
51 52 53 54 55 56 57 58 59 60 61 62 |
# 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_for_build ⇒ Object
check build’s to run as srcfile, means file must be exist and can’t check more than one time
70 71 72 73 74 75 |
# 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_for_parse ⇒ Object
check outdated or not as srcfile at parse phaze(not build phaze)
78 79 80 |
# File 'lib/rmk/vfile.rb', line 78 def check_for_parse load_modified_id != generate_modified_id end |
#generate_modified_id ⇒ Object
generate file’s modified id from current disk content
37 |
# File 'lib/rmk/vfile.rb', line 37 def generate_modified_id; Rmk::VFile.generate_modified_id @path end |
#input_ref_builds ⇒ Object
builds which include this file as input file
13 |
# File 'lib/rmk/vfile.rb', line 13 def input_ref_builds; @input_ref_builds end |
#load_modified_id ⇒ Object
load last time modified id from system database
41 |
# File 'lib/rmk/vfile.rb', line 41 def load_modified_id; @rmk.mid_storage[@path] end |
#order_ref_builds ⇒ Object
builds which include this file as order-only file
16 |
# File 'lib/rmk/vfile.rb', line 16 def order_ref_builds; @order_ref_builds end |
#src? ⇒ Boolean
10 |
# File 'lib/rmk/vfile.rb', line 10 def src?; @is_src end |
#store_modified_id(mid) ⇒ Object
store modified id to system database for next time check
46 |
# File 'lib/rmk/vfile.rb', line 46 def store_modified_id(mid) @rmk.mid_storage[@path] = mid end |
#updated!(modified) ⇒ Object
64 65 66 67 |
# 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 |