Class: Adva::Static::Export::Page
- Inherits:
-
Object
- Object
- Adva::Static::Export::Page
- Defined in:
- lib/adva/static/export/page.rb
Constant Summary collapse
- URL_ATTRIBUTES =
{ '//a[@href]' => 'href', '//script[@src]' => 'src', '//link[@rel="stylesheet"]' => 'href' }
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(url, response) ⇒ Page
constructor
A new instance of Page.
- #urls ⇒ Object
Constructor Details
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
13 14 15 |
# File 'lib/adva/static/export/page.rb', line 13 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/adva/static/export/page.rb', line 13 def url @url end |
Instance Method Details
#body ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/adva/static/export/page.rb', line 26 def body @body ||= case response when ActionDispatch::Response response.body when ::Rack::File File.read(response.path) else response.to_s end end |
#urls ⇒ Object
20 21 22 23 24 |
# File 'lib/adva/static/export/page.rb', line 20 def urls URL_ATTRIBUTES.inject([]) do |urls, (xpath, name)| urls += dom.xpath(xpath).map { |node| Path.new(node.attributes[name]) } end end |