Class: BundleDepot::FileSystemStore

Inherits:
Store
  • Object
show all
Defined in:
lib/bundle_depot/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Store

#with_packing

Constructor Details

#initialize(path) ⇒ FileSystemStore

Returns a new instance of FileSystemStore.



77
78
79
80
# File 'lib/bundle_depot/cache.rb', line 77

def initialize(path)
  @path = path
  FileUtils.mkdir_p(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



71
72
73
# File 'lib/bundle_depot/cache.rb', line 71

def path
  @path
end

Instance Method Details

#cached?(file) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/bundle_depot/cache.rb', line 73

def cached?(file)
  File.exists? File.join(path, file)
end

#fetch(file, dest_dir) ⇒ Object



86
87
88
# File 'lib/bundle_depot/cache.rb', line 86

def fetch(file, dest_dir)
  FileUtils.cp_r File.join(path, file), dest_dir
end

#store(file) ⇒ Object



82
83
84
# File 'lib/bundle_depot/cache.rb', line 82

def store(file)
  FileUtils.cp_r file, File.join(path, File.basename(file))
end