Class: Stratagem::Crawler::SiteModel::PageSet
- Includes:
- HtmlUtils
- Defined in:
- lib/stratagem/crawler/site_model/page_set.rb
Constant Summary
Constants included from HtmlUtils
HtmlUtils::INPUT_BUTTON, HtmlUtils::INPUT_RADIO, HtmlUtils::INPUT_TEXT, HtmlUtils::INPUT_TOGGLE
Instance Attribute Summary collapse
-
#authentication ⇒ Object
Returns the value of attribute authentication.
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
Instance Method Summary collapse
- #add(route, controller, request, response, invocations = [], model_changes = {}, &block) ⇒ Object
- #add_edge(from, to, type) ⇒ Object
- #export ⇒ Object
-
#initialize(name) ⇒ PageSet
constructor
A new instance of PageSet.
- #pages_for(id) ⇒ Object
Methods included from HtmlUtils
#find_login_form, #parse_forms
Constructor Details
#initialize(name) ⇒ PageSet
Returns a new instance of PageSet.
9 10 11 12 13 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 9 def initialize(name) @name = name @pages = [] @edges = [] end |
Instance Attribute Details
#authentication ⇒ Object
Returns the value of attribute authentication.
7 8 9 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 7 def authentication @authentication end |
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
6 7 8 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 6 def edges @edges end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 6 def name @name end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
6 7 8 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 6 def pages @pages end |
Instance Method Details
#add(route, controller, request, response, invocations = [], model_changes = {}, &block) ⇒ Object
43 44 45 46 47 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 43 def add(route, controller, request, response, invocations=[], model_changes={}, &block) page = Page.new(self, controller, request, response, invocations, model_changes, &block) self.pages << page page end |
#add_edge(from, to, type) ⇒ Object
39 40 41 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 39 def add_edge(from,to,type) self.edges << Edge.new(from,to,type) end |
#export ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/stratagem/crawler/site_model/page_set.rb', line 15 def export puts "Exporting page set #{name} with #{@pages.size} initial pages" pages = @pages.select {|page| page.response_body && page.response_body.size > 0 } puts "\t#{pages.size} filtered pages" pages = pages.map {|page| page.export } pages << authentication.login_page.export if authentication && authentication.login_page pages << authentication.response_page.export if authentication && authentication.response_page puts "\t#{pages.size} exported pages" { :name => name, :pages_attributes => pages, :edges_attributes => @edges.map {|edge| edge.export }, :authentication_attributes => authentication.nil? ? nil : { :authenticated_user_id => authentication.authenticated_with.object_id, :success => authentication.success, :login_page_external_id => authentication.login_page ? authentication.login_page.object_id : nil, :response_page_external_id => authentication.response_page ? authentication.response_page.object_id : nil, :ssl => authentication.ssl }, } end |