Class: BundleDepot::FileSystemStore

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileSystemStore

Returns a new instance of FileSystemStore.



13
14
15
16
# File 'lib/bundle_depot/cache.rb', line 13

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/bundle_depot/cache.rb', line 11

def path
  @path
end

Instance Method Details

#cached?(file) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/bundle_depot/cache.rb', line 18

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

#fetch(file, dest_dir) ⇒ Object



26
27
28
# File 'lib/bundle_depot/cache.rb', line 26

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

#store(file) ⇒ Object



22
23
24
# File 'lib/bundle_depot/cache.rb', line 22

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