Class: Prebundler::FileBackend

Inherits:
Object
  • Object
show all
Defined in:
lib/prebundler/file_backend.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FileBackend

Returns a new instance of FileBackend.



7
8
9
10
# File 'lib/prebundler/file_backend.rb', line 7

def initialize(options = {})
  @local_path = options.fetch(:local_path)
  @docker_mount_point = options.fetch(:docker_mount_point)
end

Instance Attribute Details

#docker_mount_pointObject (readonly)

Returns the value of attribute docker_mount_point.



5
6
7
# File 'lib/prebundler/file_backend.rb', line 5

def docker_mount_point
  @docker_mount_point
end

#local_pathObject (readonly)

Returns the value of attribute local_path.



5
6
7
# File 'lib/prebundler/file_backend.rb', line 5

def local_path
  @local_path
end

Instance Method Details

#docker_flagsObject



24
25
26
# File 'lib/prebundler/file_backend.rb', line 24

def docker_flags
  ['-v', "#{File.expand_path(local_path)}:#{docker_mount_point}"]
end

#list_filesObject



20
21
22
# File 'lib/prebundler/file_backend.rb', line 20

def list_files
  Dir.chdir(docker_mount_point) { Dir.glob('**/*.*') }
end

#retrieve_file(source_file, dest_file) ⇒ Object



16
17
18
# File 'lib/prebundler/file_backend.rb', line 16

def retrieve_file(source_file, dest_file)
  FileUtils.cp(File.join(local_path, source_file), dest_file)
end

#store_file(source_file, dest_file) ⇒ Object



12
13
14
# File 'lib/prebundler/file_backend.rb', line 12

def store_file(source_file, dest_file)
  FileUtils.cp(source_file, File.join(docker_mount_point, dest_file))
end