Class: Adva::Static::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/adva/static/export.rb,
lib/adva/static/export/page.rb,
lib/adva/static/export/path.rb,
lib/adva/static/export/queue.rb,
lib/adva/static/export/store.rb

Defined Under Namespace

Classes: Page, Path, Queue, Store

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :source => "#{Dir.pwd}/public",
  :target => "#{Dir.pwd}/export"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Export.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/adva/static/export.rb', line 20

def initialize(app, options = {})
  options.reject! { |key, value| value.blank? }
  @options = options.reverse_merge!(DEFAULT_OPTIONS)

  @app   = app
  @store = Store.new(target)
  @queue = Queue.new

  roots = config[:roots] || %w(/)
  queue.push(*roots.map { |path| Path.new(path) })

  FileUtils.rm_r(Dir[target.join('*')] - [target.join('config.ru').to_s])
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



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

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#queueObject (readonly)

Returns the value of attribute queue.



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

def queue
  @queue
end

#storeObject (readonly)

Returns the value of attribute store.



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

def store
  @store
end

Instance Method Details

#runObject



34
35
36
37
38
# File 'lib/adva/static/export.rb', line 34

def run
  configure
  copy_assets
  process(queue.shift) until queue.empty?
end