Skip to content

Commit

Permalink
Refactoring property locators.
Browse files Browse the repository at this point in the history
Turning iterator (for_each) into a property locator.
Integration specs are failing. Need to refactor Parser
since it doenst have select_nodes and locate methods anymore.
Need to refactor the DSL to support new iterator format.
Need to get rid of Crawler#for_each and move that logic into
a property factory.
  • Loading branch information
felipecsl committed Jul 27, 2012
1 parent c4657ad commit b5d186e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 125 deletions.
12 changes: 0 additions & 12 deletions lib/wombat/crawler.rb
Expand Up @@ -41,10 +41,6 @@ def for_each(selector, &block)
self.class.for_each selector, &block
end

def follow_links(selector, options, &block)
self.class.follow_links selector, options, &block
end

module ClassMethods
def method_missing(method, *args, &block)
metadata.send method, *args, &block
Expand All @@ -54,14 +50,6 @@ def for_each(selector, &block)
metadata.for_each(selector).instance_eval(&block) if block
end

def follow_links(selector, options, &block)

end

def follow_links(selector)

end

def to_ary
end

Expand Down
4 changes: 2 additions & 2 deletions lib/wombat/node_selector.rb
Expand Up @@ -2,8 +2,8 @@ module Wombat
module NodeSelector
def select_nodes(selector, namespaces = nil)
return [selector.to_s] if selector.is_a? Symbol
return context.xpath selector[6..-1], namespaces if selector.start_with? "xpath="
return context.css selector[4..-1] if selector.start_with? "css="
return @context.xpath selector[6..-1], namespaces if selector.start_with? "xpath="
return @context.css selector[4..-1] if selector.start_with? "css="
[selector]
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/wombat/parser.rb
@@ -1,11 +1,10 @@
#coding: utf-8
require 'wombat/property_locator'
require 'wombat/locators/factory'
require 'mechanize'
require 'restclient'

module Wombat
module Parser
include PropertyLocator
attr_accessor :mechanize, :context, :response_code, :page

def initialize
Expand Down
32 changes: 0 additions & 32 deletions lib/wombat/property_locator.rb

This file was deleted.

3 changes: 1 addition & 2 deletions spec/integration/integration_spec.rb
Expand Up @@ -187,7 +187,6 @@
end

it 'should follow links' do
pending('Not implemented yet.')
VCR.use_cassette('follow_links') do
crawler = Class.new
crawler.send(:include, Wombat::Crawler)
Expand All @@ -197,7 +196,7 @@
crawler.list_page "/"

crawler.github 'xpath=//ul[@class="footer_nav"][1]//a', :follow do
heading 'css=h1'
#heading 'css=h1'
end

crawler_instance = crawler.new
Expand Down
75 changes: 0 additions & 75 deletions spec/property_locator_spec.rb

This file was deleted.

0 comments on commit b5d186e

Please sign in to comment.