add initial Cache class
This commit is contained in:
parent
c008350d87
commit
5634b8856d
@ -1,4 +1,5 @@
|
|||||||
require "rscons/builder"
|
require "rscons/builder"
|
||||||
|
require "rscons/cache"
|
||||||
require "rscons/environment"
|
require "rscons/environment"
|
||||||
require "rscons/version"
|
require "rscons/version"
|
||||||
|
|
||||||
|
41
lib/rscons/cache.rb
Normal file
41
lib/rscons/cache.rb
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
require 'yaml'
|
||||||
|
require 'fileutils'
|
||||||
|
require 'digest/md5'
|
||||||
|
|
||||||
|
module Rscons
|
||||||
|
class Cache
|
||||||
|
# Constants
|
||||||
|
CACHE_FILE = '.rsconscache'
|
||||||
|
|
||||||
|
# Class Methods
|
||||||
|
def self.clear
|
||||||
|
FileUtils.rm_f(CACHE_FILE)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Instance Methods
|
||||||
|
def initialize
|
||||||
|
@cache = YAML.load(File.read(CACHE_FILE)) rescue {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def write
|
||||||
|
File.open(CACHE_FILE, 'w') do |fh|
|
||||||
|
fh.puts(YAML.dump(@cache))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def up_to_date?(file, deps = nil)
|
||||||
|
# TODO
|
||||||
|
end
|
||||||
|
|
||||||
|
def register_build(target, deps)
|
||||||
|
# TODO
|
||||||
|
end
|
||||||
|
|
||||||
|
# Private Instance Methods
|
||||||
|
private
|
||||||
|
|
||||||
|
def calculate_checksum(file)
|
||||||
|
Digest::MD5.hexdigest(File.read(file)).encode(__ENCODING__)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -57,6 +57,8 @@ module Rscons
|
|||||||
end
|
end
|
||||||
|
|
||||||
def process
|
def process
|
||||||
|
cache = Cache.new
|
||||||
|
cache.write
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :orig_method_missing, :method_missing
|
alias_method :orig_method_missing, :method_missing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user