Sha256: 14dfd58a7a16b66cf5bf718f6f01792c11c5be382a6d5c837d9bffe319931b0a
Contents?: true
Size: 960 Bytes
Versions: 3
Compression:
Stored size: 960 Bytes
Contents
module Downer class StrategyFinder class << self # Determines a strategy for extracting urls from a media type def find_strategy(url_source, options ={}) strategy = nil if is_local_file?(url_source) strategy = DownloadStrategy::FlatFileStrategy.new(url_source, options) elsif is_remote_source?(url_source) strategy = DownloadStrategy::WebsiteStrategy.new(url_source, options) else raise "Could not find strategy" end strategy end # Determine whether the source is located on a local file system def is_local_file?(url_source) File.exist?(url_source) end # Determine if this is something that lives online def is_remote_source?(url_source) #if url_source =~ /(ftp|https?).*$/ url_source.match(/(ftp|https?).*$/) ? true : false end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
downer-0.3.2 | lib/downer/download_strategy.rb |
downer-0.3.1 | lib/downer/download_strategy.rb |
downer-0.3.0 | lib/downer/download_strategy.rb |