Class: Alpinist::ProfileFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/alpinist/profile_fetcher.rb

Instance Method Summary collapse

Instance Method Details

#fetch(url, as: nil, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# 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