Sha256: 16dd688c766655f8c54f4c1a6b62241b37ca2444133394f4600fedf2bc8c6d33
Contents?: true
Size: 1.39 KB
Versions: 9
Compression:
Stored size: 1.39 KB
Contents
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 'writer/fetcher-microdata/person_user' require 'writer/fetcher-microdata/article_small' require 'writer/fetcher-microdata/review'
Version data entries
9 entries across 9 versions & 1 rubygems