require 'discoverer' module Fetcher class Microdata include Discoverer::Writer include Virtus attr_reader :_type def initialize *arguments if arguments.first.is_a? Symbol social_network = arguments.shift self.attributes = coerce social_network, *arguments elsif arguments.first.is_a? Hash self.attributes = arguments.first end end def coerce social_network, *raw_data begin eval("::#{self.class}::#{social_network.to_s.capitalize}::Coercer").call *raw_data rescue NameError => e if e.message.include? "#{self.class}::#{social_network.to_s.capitalize}" raise UnknownSocialNetworkError, "Couldn't find coertion algorithm for '#{social_network}' social network, please require 'fetcher-microdata-#{social_network}' in your project and make sure it has a #{self.class}::#{social_network.to_s.capitalize}::Coercer" else raise e end end end # Exceptions ####################################### class UnknownSocialNetworkError < StandardError; end end end require 'fetcher-microdata/version' require 'fetcher-microdata/person_user' require 'fetcher-microdata/article_small' require 'fetcher-microdata/review' require 'fetcher-microdata/user_comments' require 'writer/fetcher-microdata/person_user' require 'writer/fetcher-microdata/article_small' require 'writer/fetcher-microdata/review' require 'writer/fetcher-microdata/user_comments'