Class: Eg::Page
- Inherits:
-
Fit::RowFixture
- Object
- Fit::Fixture
- Fit::ColumnFixture
- Fit::RowFixture
- Eg::Page
- Defined in:
- lib/eg/page.rb
Defined Under Namespace
Classes: Row
Constant Summary collapse
- @@url =
nil
- @@text =
''
Constants inherited from Fit::Fixture
Fit::Fixture::GRAY, Fit::Fixture::GREEN, Fit::Fixture::RED, Fit::Fixture::YELLOW
Instance Attribute Summary
Attributes inherited from Fit::RowFixture
Attributes inherited from Fit::Fixture
#args, #counts, #listener, #summary
Instance Method Summary collapse
- #context(url) ⇒ Object
-
#get(url) ⇒ Object
Utility.
- #link(label) ⇒ Object
-
#location(url) ⇒ Object
Actions.
-
#query ⇒ Object
Rows.
- #title ⇒ Object
Methods inherited from Fit::RowFixture
Methods inherited from Fit::ColumnFixture
#check, #do_cell, #do_row, #do_rows, #execute, #reset
Methods inherited from Fit::Fixture
camel, #check, #do_cell, #do_cells, #do_row, #do_rows, #do_table, #do_tables, #error, escape, #exception, #find_class, #fixture_name, #get_args_for_table, #get_linked_fixture_with_args, gray, #ignore, #info, #initialize, #interpret_following_tables, #interpret_tables, label, metadata, #parse, #right, #total_errors, #totals, #wrong
Constructor Details
This class inherits a constructor from Fit::RowFixture
Instance Method Details
#context(url) ⇒ Object
46 47 48 49 50 |
# File 'lib/eg/page.rb', line 46 def context url u = "#{url.scheme}://#{url.host}" u += (url.port == 80 ? '' : ":#{url.port}") + '/' u end |
#get(url) ⇒ Object
Utility
67 68 69 70 |
# File 'lib/eg/page.rb', line 67 def get url response = Net::HTTP.get_response url response.body end |
#link(label) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/eg/page.rb', line 28 def link label links = Fit::Parse.new @@text, ['a'] until links.text =~ /^#{label}/ links = links.more end links.tag =~ /href\s*=\s*"(.*)"\s*>?/i if $1.nil? links.tag =~ /href\s*=\s*(.*)\s*>/i end link = $1 if link =~ /^(http:)?\/\// @@url = URI.parse($1.nil? ? "http:#{link}" : link) else @@url = URI.parse(context(@@url) + link) end @@text = open(@@url) {|stream| stream.read} end |
#location(url) ⇒ Object
Actions
19 20 21 22 |
# File 'lib/eg/page.rb', line 19 def location url @@url = URI.parse url @@text = open(@@url) {|stream| stream.read} end |