class Quick::FS::CodeFile
Constants
- Parser
Attributes
in_use[R]
Public Class Methods
new(mod, name)
click to toggle source
# File lib/quick/fs.rb, line 78 def initialize(mod, name) @mod, @name = mod, name @source = '' @in_use = ROCodeFile.new @source end
Public Instance Methods
read_file(path)
click to toggle source
# File lib/quick/fs.rb, line 84 def read_file(path) @atime = Time.now @source end
size(path)
click to toggle source
# File lib/quick/fs.rb, line 89 def size(path) @source.bytesize end
times(path)
click to toggle source
# File lib/quick/fs.rb, line 104 def times(path) now = Time.now [@atime ||= now, @mtime ||= now, @ctime ||= now] end
touch(path)
click to toggle source
# File lib/quick/fs.rb, line 100 def touch(path) @mtime = Time.now end
write_to(path, source)
click to toggle source
# File lib/quick/fs.rb, line 93 def write_to(path, source) @source = source @mtime = @ctime = Time.now eval! rescue ArgumentError end
Private Instance Methods
eval!()
click to toggle source
# File lib/quick/fs.rb, line 111 def eval! sexp = Parser.parse @source raise ArgumentError, "no source" unless sexp is_meth = sexp.node_type == :defn is_meths = sexp.node_type == :block && sexp.rest.all? {|n| n.node_type == :defn} unless is_meth or is_meths or @name == 'header.rb' raise ArgumentError, "not 1 or more method definitions" end @mod.module_eval @source @in_use.source = @source @in_use.mtime = @in_use.ctime = Time.now rescue Racc::ParseError => e raise ArgumentError, e.message rescue StandardError => e raise ArgumentError, e.message end