Class: GeneralTimeChecker
Overview
TODO check generate api
Constant Summary collapse
- @@app_path =
nil- @@is_run_always =
false- @@cached_time =
nil- @@time_cache_path =
nil
Instance Method Summary collapse
- #check(xmlpath) ⇒ Object
- #find_latest_modified_date(path) ⇒ Object
- #init(startdir, app_path, timename) ⇒ Object
- #update ⇒ Object
Instance Method Details
#check(xmlpath) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/build/GeneralTimeChecker.rb', line 65 def check(xmlpath) generate_xml = false xml_time = File.mtime(File.new(xmlpath)) #puts "xmlpath: #{xmlpath}; xml_time : #{xml_time}" # for generate in first time if @@is_run_always @@do_cache = true generate_xml = true elsif @@cached_time < xml_time puts "!!!" generate_xml = true end generate_xml end |
#find_latest_modified_date(path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/build/GeneralTimeChecker.rb', line 12 def find_latest_modified_date(path) #puts 'find_latest_modified_date.path=' + path.to_s latest_mod_time = nil templates_dir = Dir.new(path) templates_dir.each { |item| if item == '.' || item == '..' next end full_path = File.join(path, item) mod_time = nil if File.directory?(full_path) mod_time = find_latest_modified_date(full_path) if mod_time.nil? next end else mod_time = File.mtime(full_path) end if latest_mod_time.nil? latest_mod_time = mod_time else if latest_mod_time < mod_time latest_mod_time = mod_time end end } return latest_mod_time end |
#init(startdir, app_path, timename) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/build/GeneralTimeChecker.rb', line 48 def init(startdir, app_path, timename) @@app_path = app_path @@time_cache_path = File.join(@@app_path, "bin", "tmp", timename+".time") if File.exist? @@time_cache_path time_cache_file = File.new(@@time_cache_path) @@cached_time = Time.parse(time_cache_file.gets) time_cache_file.close puts "cached_time : #{@@cached_time}" else @@is_run_always = true end end |
#update ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/build/GeneralTimeChecker.rb', line 83 def update() FileUtils.mkdir(File.join(@@app_path, "bin") ) unless File.exist? File.join(@@app_path, "bin") FileUtils.mkdir(File.join(@@app_path, "bin", "tmp") ) unless File.exist? File.join(@@app_path, "bin", "tmp") time_cache_file = File.new(@@time_cache_path, "w+") time_cache_file.puts Time.new time_cache_file.close() end |