Class: Rabbit::Source::File

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/rabbit/source/file.rb

Instance Attribute Summary

Attributes included from Base

#base, #encoding, #force_modified, #tmp_base

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

append_features, #full_path, #modified?, #old?, #open_full_path, #read, #reset, #source=, #tmp_dir_name

Constructor Details

#initialize(encoding, logger, name) ⇒ File

Returns a new instance of File.


28
29
30
31
32
# File 'lib/rabbit/source/file.rb', line 28

def initialize(encoding, logger, name)
  @name = name
  super(encoding, logger)
  @mtime = nil
end

Class Method Details

.initial_args_descriptionObject


24
25
26
# File 'lib/rabbit/source/file.rb', line 24

def self.initial_args_description
  N_("[FILENAME]")
end

Instance Method Details

#_readObject


34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rabbit/source/file.rb', line 34

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

#extensionObject


52
53
54
# File 'lib/rabbit/source/file.rb', line 52

def extension
  extract_extension(@name)
end

#need_read?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/rabbit/source/file.rb', line 48

def need_read?
  super or old?(@mtime, :mtime)
end