Class: Adva::Static::Server::Export

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/adva/static/server/export.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Export

Returns a new instance of Export.



11
12
13
14
15
# File 'lib/adva/static/server/export.rb', line 11

def initialize(app, options = {})
  @app = app
  @target = Pathname.new(options[:target] || File.expand_path('./export'))
  @store  = Adva::Static::Export::Store.new(target)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



9
10
11
# File 'lib/adva/static/server/export.rb', line 9

def app
  @app
end

#storeObject (readonly)

Returns the value of attribute store.



9
10
11
# File 'lib/adva/static/server/export.rb', line 9

def store
  @store
end

#targetObject (readonly)

Returns the value of attribute target.



9
10
11
# File 'lib/adva/static/server/export.rb', line 9

def target
  @target
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/adva/static/server/export.rb', line 17

def call(env)
  path = env['PATH_INFO'].dup # gets modified by routing_filter
  app.call(env).tap do |status, headers, response|
    export(path, response) if export?(env, status)
    if headers.key?(PURGE_HEADER)
      paths = normalize_paths(headers[PURGE_HEADER])
      paths.each do |path|
        purge(path)
        request(path)
      end
    end
  end
end