Sha256: cd00cf711015e0e6fb0d7caf2e1f2155c72bc54ad493cf2f8249200f987a3294

Contents?: true

Size: 1006 Bytes

Versions: 2

Compression:

Stored size: 1006 Bytes

Contents

module Bubbles
  module Uploaders
    class LocalDir
      extend Forwardable
      include Bubbles::CommonUploaderInterface

      def call
        config.logger.debug("#{self.class.name}: transfering #{uid_file} to #{local_dir_uploader_path}")
        FileUtils.cp(uid_file, local_dir_uploader_path)
        write_metadata
      rescue Errno::ENOENT => e
        config.logger.error("#{e.message}")
        command_queue.reschedule(self)
      end

      def inspect
        "<##{self.class.name} uid_file: #{uid_file} to: #{local_dir_uploader_path}>"
      end

      private
        def_delegators :config, :local_dir_uploader_path, :local_dir_metadata_file_path
        def_delegators :bfile, :uid_file, :uid_file_name, :metadata

        def write_metadata
          File.open(local_dir_metadata_file_path, 'a') do |f|
            f.write yaml_append
          end
        end

        def yaml_append
<<EOF
-
  key: #{uid_file_name}
  metadata: #{metadata.to_json}
EOF
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bubbles-0.0.5 lib/bubbles/uploaders/local_dir.rb
bubbles-0.0.4.1 lib/bubbles/uploaders/local_dir.rb