Class: Adva::Static::Export
- Inherits:
-
Object
- Object
- Adva::Static::Export
- 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
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
-
#initialize(app, options = {}) ⇒ Export
constructor
A new instance of Export.
- #run ⇒ Object
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, = {}) .reject! { |key, value| value.blank? } @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
#app ⇒ Object (readonly)
Returns the value of attribute app.
13 14 15 |
# File 'lib/adva/static/export.rb', line 13 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/adva/static/export.rb', line 13 def @options end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
13 14 15 |
# File 'lib/adva/static/export.rb', line 13 def queue @queue end |
#store ⇒ Object (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
#run ⇒ Object
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 |