Class: Hem::Lib::S3::Local::IoHandler
- Inherits:
-
Object
- Object
- Hem::Lib::S3::Local::IoHandler
- Includes:
- Hem::Logging
- Defined in:
- lib/hem/lib/s3/local/iohandler.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ IoHandler
constructor
A new instance of IoHandler.
- #ls ⇒ Object
- #open(file, mode) ⇒ Object
- #rm(file) ⇒ Object
Methods included from Hem::Logging
Constructor Details
#initialize(path) ⇒ IoHandler
Returns a new instance of IoHandler.
8 9 10 |
# File 'lib/hem/lib/s3/local/iohandler.rb', line 8 def initialize path @path = path end |
Instance Method Details
#ls ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hem/lib/s3/local/iohandler.rb', line 12 def ls logger.debug("s3sync: Listing local directory: #{@path}") out = {} dir = "#{@path.chomp('/')}/" files = Dir.glob("#{dir}**/*") files.each do |file| out[file.gsub(/^#{dir}/, '')] = Digest::MD5.file(file).hexdigest end return out end |
#open(file, mode) ⇒ Object
23 24 25 26 27 |
# File 'lib/hem/lib/s3/local/iohandler.rb', line 23 def open file, mode file_path = ::File.join(@path, file) FileUtils.mkdir_p ::File.dirname(file_path) File.new ::File.open(file_path, mode) end |
#rm(file) ⇒ Object
29 30 31 |
# File 'lib/hem/lib/s3/local/iohandler.rb', line 29 def rm file ::File.unlink ::File.join(@path, file) end |