Class: Rack::Bundle::FileSystemStore

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/bundle/file_system_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bundlesObject

Returns the value of attribute bundles.



4
5
6
# File 'lib/rack/bundle/file_system_store.rb', line 4

def bundles
  @bundles
end

#dirObject

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

Returns:

  • (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