class Alpinist::ProfileFetcher

Public Instance Methods

fetch(url, as: nil, &block) click to toggle source
# File lib/alpinist/profile_fetcher.rb, line 4
def fetch(url, as: nil, &block)
  if url.match(%r|http://alps\.io/|)
    as ||= url
    url = "#{url}.xml"
  end
  if as
    puts "Fetch: #{url} as #{as}"
  else
    puts "Fetch: #{url}"
  end
  block ||= ->(sio) { sio.read }
  open(url, &block)
end