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.



12
13
14
15
16
# File 'lib/rabbit/source/file.rb', line 12

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

Class Method Details

.initial_args_descriptionObject



8
9
10
# File 'lib/rabbit/source/file.rb', line 8

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

Instance Method Details

#_readObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# 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

#extensionObject



36
37
38
# File 'lib/rabbit/source/file.rb', line 36

def extension
  extract_extension(@name)
end

#need_read?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/rabbit/source/file.rb', line 32

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