Module: Pod::Metrics

Defined in:
lib/cocoapods-core/metrics.rb

Overview

Allows to access metrics about pods.

This class is stored in Core because it might be used by web services.

Private helpers collapse

Class Method Summary collapse

Class Method Details

.peform_request(url) ⇒ Array, Hash (private)

Performs a get request with the given URL.


30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cocoapods-core/metrics.rb', line 30

def self.peform_request(url)
  require 'rest'
  require 'json'
  headers = { 'User-Agent' => "CocoaPods #{Pod::CORE_VERSION}" }
  response = REST.get(url, headers)
  body = JSON.parse(response.body)
  if response.ok?
    body
  else
    CoreUI.warn "Request to #{url} failed - #{response.status_code}"
    CoreUI.warn body['message']
    nil
  end
end

.pod(name) ⇒ Hash

Returns the metrics of a pod.


14
15
16
# File 'lib/cocoapods-core/metrics.rb', line 14

def self.pod(name)
  peform_request("http://metrics.cocoapods.org/api/v1/pods/#{name}")
end