Class: Rack::Bundle::FileSystemStore
- Inherits:
-
Object
- Object
- Rack::Bundle::FileSystemStore
- Defined in:
- lib/rack/bundle/file_system_store.rb
Instance Attribute Summary collapse
-
#bundles ⇒ Object
Returns the value of attribute bundles.
-
#dir ⇒ Object
Returns the value of attribute dir.
Instance Method Summary collapse
- #has_bundle?(bundle) ⇒ Boolean
-
#initialize(dir = Dir.tmpdir) ⇒ FileSystemStore
constructor
A new instance of FileSystemStore.
- #save! ⇒ Object
Constructor Details
#initialize(dir = Dir.tmpdir) ⇒ FileSystemStore
Returns a new instance of FileSystemStore.
6 7 8 9 |
# File 'lib/rack/bundle/file_system_store.rb', line 6 def initialize dir = Dir.tmpdir @dir = dir @bundles = [] end |
Instance Attribute Details
#bundles ⇒ Object
Returns the value of attribute bundles.
4 5 6 |
# File 'lib/rack/bundle/file_system_store.rb', line 4 def bundles @bundles end |
#dir ⇒ Object
Returns the value of attribute dir.
4 5 6 |
# File 'lib/rack/bundle/file_system_store.rb', line 4 def dir @dir end |
Instance Method Details
#has_bundle?(bundle) ⇒ Boolean
11 12 13 |
# File 'lib/rack/bundle/file_system_store.rb', line 11 def has_bundle? bundle File.exists? "#{dir}/rack-bundle-#{bundle.hash}.#{bundle.extension}" end |
#save! ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/rack/bundle/file_system_store.rb', line 15 def save! @bundles.each do |bundle| next if has_bundle? bundle File.open("#{dir}/rack-bundle-#{bundle.hash}.#{bundle.extension}", 'w') do |file| file << bundle.contents end end end |