Class: Rubytoolbox::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/rubytoolbox/api.rb,
lib/rubytoolbox/api/health.rb,
lib/rubytoolbox/api/project.rb,
lib/rubytoolbox/api/rubygem.rb,
lib/rubytoolbox/api/version.rb,
lib/rubytoolbox/api/category.rb,
lib/rubytoolbox/api/github_repo.rb,
lib/rubytoolbox/api/category_group.rb,
lib/rubytoolbox/api/response_wrapper.rb

Defined Under Namespace

Classes: Category, CategoryGroup, GithubRepo, Health, Project, RequestError, ResponseWrapper, Rubygem

Constant Summary collapse

DEFAULT_URL =
"https://www.ruby-toolbox.com/api/"
VERSION =
"0.2.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url: DEFAULT_URL) ⇒ Api

Returns a new instance of Api.



24
25
26
# File 'lib/rubytoolbox/api.rb', line 24

def initialize(url: DEFAULT_URL)
  self.endpoint_url = url.clone.freeze
end

Instance Attribute Details

#endpoint_urlObject

Returns the value of attribute endpoint_url.



21
22
23
# File 'lib/rubytoolbox/api.rb', line 21

def endpoint_url
  @endpoint_url
end

Instance Method Details

#compare(*names) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/rubytoolbox/api.rb', line 28

def compare(*names)
  url = URI(File.join(endpoint_url, "projects", "compare", names.join(",")))

  data = handle_response! Net::HTTP.get_response(url)

  data.fetch("projects").map do |project_data|
    Project.new project_data
  end
end