Class: BundleDepot::FileSystemStore
- Inherits:
-
Object
- Object
- BundleDepot::FileSystemStore
- Defined in:
- lib/bundle_depot/cache.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #cached?(file) ⇒ Boolean
- #fetch(file, dest_dir) ⇒ Object
-
#initialize(path) ⇒ FileSystemStore
constructor
A new instance of FileSystemStore.
- #store(file) ⇒ Object
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
#path ⇒ Object (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
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 |