Class: Ricotta::Fetcher::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ricotta/fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
# File 'lib/ricotta/fetcher.rb', line 7

def initialize(url)
  @connection = Faraday.new(:url => url) do |builder|
    builder.use FaradayMiddleware::FollowRedirects
    builder.adapter :net_http
  end
end

Instance Method Details

#fetch(project, branch, language, template, subset) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/ricotta/fetcher.rb', line 13

def fetch(project, branch, language, template, subset)
  path = "/proj/#{project}/branch/#{branch}/lang/#{language}/templ/#{template}/"
  path.concat("subset/#{subset}/") if subset
  
  @connection.get(path).on_complete do |env|
    yield env[:status], env[:body] if block_given?
  end
end