Class: Rtml::ReverseEngineering::Crawler
- Inherits:
-
Object
- Object
- Rtml::ReverseEngineering::Crawler
- Defined in:
- lib/rtml/reverse_engineering/crawler.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#simulator ⇒ Object
readonly
Returns the value of attribute simulator.
Instance Method Summary collapse
- #current_screen ⇒ Object
-
#initialize(options = {}) ⇒ Crawler
constructor
A new instance of Crawler.
- #split_path_and_screen_name_out_of(path) ⇒ Object
- #tml=(tml) ⇒ Object
- #visit(path, screen = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Crawler
Returns a new instance of Crawler.
11 12 13 14 |
# File 'lib/rtml/reverse_engineering/crawler.rb', line 11 def initialize( = {}) @simulator = Rtml::ReverseEngineering::Simulator.new(.delete(:tml)) @session = ActionController::Integration::Session.new end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
2 3 4 |
# File 'lib/rtml/reverse_engineering/crawler.rb', line 2 def session @session end |
#simulator ⇒ Object (readonly)
Returns the value of attribute simulator.
2 3 4 |
# File 'lib/rtml/reverse_engineering/crawler.rb', line 2 def simulator @simulator end |
Instance Method Details
#current_screen ⇒ Object
38 39 40 |
# File 'lib/rtml/reverse_engineering/crawler.rb', line 38 def current_screen route.last end |
#split_path_and_screen_name_out_of(path) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/rtml/reverse_engineering/crawler.rb', line 29 def split_path_and_screen_name_out_of(path) path, screen = path.split(/#/) if screen =~ /\?/ screen, query = screen.split(/\?/) path = "#{path}?#{query}" end [path, screen] end |
#tml=(tml) ⇒ Object
6 7 8 9 |
# File 'lib/rtml/reverse_engineering/crawler.rb', line 6 def tml=(tml) @path = nil simulator.tml = tml end |
#visit(path, screen = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rtml/reverse_engineering/crawler.rb', line 16 def visit(path, screen = nil) path, screen = split_path_and_screen_name_out_of(path) unless screen unless path.blank? or path == @path get @path = path format = response.template.template_format if format == :rtml then simulator.tml = response.body else raise Rtml::Errors::InvalidFormat, "Response must be in :rtml format; found #{format.inspect}:\n#{response.body}" end end @simulator.visit screen end |