class Rabbit::Source::File
Public Class Methods
initial_args_description()
click to toggle source
# File lib/rabbit/source/file.rb, line 8 def self.initial_args_description N_("[FILENAME]") end
new(encoding, logger, name)
click to toggle source
Calls superclass method
Rabbit::Source::Base::new
# File lib/rabbit/source/file.rb, line 12 def initialize(encoding, logger, name) @name = name super(encoding, logger) @mtime = nil end
Public Instance Methods
_read()
click to toggle source
# File lib/rabbit/source/file.rb, line 18 def _read begin check_file ::File.open(@name, "rb") do |f| @mtime = f.mtime f.read end rescue SourceUnreadableError @logger.error($!.message) @mtime = Time.now + LimitAccessInterval::MINIMUM_ACCESS_TIME "" end end
extension()
click to toggle source
# File lib/rabbit/source/file.rb, line 36 def extension extract_extension(@name) end
need_read?()
click to toggle source
Calls superclass method
Rabbit::Source::Base#need_read?
# File lib/rabbit/source/file.rb, line 32 def need_read? super or old?(@mtime, :mtime) end
Private Instance Methods
check_file()
click to toggle source
# File lib/rabbit/source/file.rb, line 41 def check_file unless ::File.exist?(@name) raise NotExistError.new(@name) end unless ::File.file?(@name) raise NotFileError.new(@name) end unless ::File.readable?(@name) raise NotReadableError.new(@name) end end
init_base()
click to toggle source
# File lib/rabbit/source/file.rb, line 62 def init_base set_base(::File.dirname(@name)) end
mtime()
click to toggle source
# File lib/rabbit/source/file.rb, line 53 def mtime begin check_file ::File.mtime(@name) rescue SourceUnreadableError Time.now end end