Sha256: bac968e84c10d03c3f986b3e7f3ca6863315b6d07f3711ad29a7fd013eacfd3c
Contents?: true
Size: 952 Bytes
Versions: 1
Compression:
Stored size: 952 Bytes
Contents
# = Fletcher # Author:: Dave Hulihan - 2011 require "uri" module Fletcher autoload :Data, 'fletcher/data' module Item autoload :Base, 'fletcher/item/base' autoload :Amazon, 'fletcher/item/amazon' end # Detect service by url # Fletcher.service("http://www.amazon.com/whatever") => :amazon def self.service(url) if url =~ ::URI::regexp uri = ::URI::parse(url) host = uri.host if host =~ Fletcher::Item::Amazon.regexp service = :amazon else service = :unknown raise ArgumentError, "Fletcher doesn't support #{host} yet." end else raise ArgumentError, "not a url" end end # Fetch information based on url def self.fetch(url) service_sym = service(url) data = Fletcher::Data.read(url) item = Fletcher::Item::Base.generate(service_sym, data) item.parse(data) return item end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fletcher-0.1.0 | lib/fletcher.rb |