lib/wombat/crawler.rb in wombat-0.1.2 vs lib/wombat/crawler.rb in wombat-0.1.3

- old
+ new

@@ -1,48 +1,51 @@ #coding: utf-8 -require 'wombat/properties' require 'wombat/metadata' +require 'wombat/property' require 'wombat/parser' require 'active_support' require 'date' module Wombat module Crawler + include Parser extend ActiveSupport::Concern module InstanceMethods def crawl - parser.parse self.class.send(:metadata) + parse self.class.send(:metadata) end def supports_city? end - - def parser - @parser ||= Parser.new - end - - def parser= parser - @parser = parser - end end module ClassMethods - [:event, :venue, :location].each do |m| - define_method(m) do |&block| - block.call(metadata["#{m.to_s}_props".to_sym]) if block + def method_missing method, *args, &block + if args.empty? && block + metadata["#{method.to_s}"] = PropertyContainer.new unless metadata["#{method.to_s}"] + block.call(metadata["#{method.to_s}"]) + else + metadata.send method, *args, &block end end - def method_missing method, *args, &block - metadata[method] = args.first - end - def with_details_page yield metadata if block_given? end + def for_each selector + + end + + def follow_links selector + + end + def supported_cities + end + + def to_ary end private def metadata @metadata ||= Metadata.new \ No newline at end of file