Class: Remi::Extractor::LocalFile

Inherits:
FileSystem show all
Defined in:
lib/remi/extractor/local_file.rb

Instance Attribute Summary

Attributes inherited from FileSystem

#group_by, #local_path, #logger, #most_recent_by, #most_recent_only, #pattern, #remote_path

Instance Method Summary collapse

Methods inherited from FileSystem

#entries, #matching_entries, #most_recent_matching_entry, #most_recent_matching_entry_in_group

Constructor Details

#initialize(*args, **kargs) ⇒ LocalFile

Returns a new instance of LocalFile.



5
6
7
8
# File 'lib/remi/extractor/local_file.rb', line 5

def initialize(*args, **kargs)
  super
  init_local_file(*args, **kargs)
end

Instance Method Details

#all_entriesObject

Public: Returns an array of all FileSystemEntry instances that are in the remote_path.



18
19
20
# File 'lib/remi/extractor/local_file.rb', line 18

def all_entries
  @all_entries ||= all_entries!
end

#all_entries!Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/remi/extractor/local_file.rb', line 22

def all_entries!
  dir = @remote_path.directory? ? @remote_path + '*' : @remote_path
  Dir[dir].map do |entry|
    path = Pathname.new(entry)
    if path.file?
      FileSystemEntry.new(
        pathname: path.realpath.to_s,
        create_time: path.ctime,
        modified_time: path.mtime
      )
    end
  end.compact
end

#extractObject

Public: Called to extract files from the source filesystem.

Returns an array with containing the paths to all files extracted.



13
14
15
# File 'lib/remi/extractor/local_file.rb', line 13

def extract
  entries.map(&:pathname)
end