Skip to content

Instantly share code, notes, and snippets.

@mwunsch
Created December 7, 2009 15:33
Show Gist options
  • Save mwunsch/250871 to your computer and use it in GitHub Desktop.
Save mwunsch/250871 to your computer and use it in GitHub Desktop.
require 'pp'
require 'rubygems'
require 'weary'
class Repository < Weary::Base
# inherit from Base
get "show_weary" do |r|
r.url = 'http://github.com/api/v2/json/repos/show/mwunsch/weary'
r.with = :login, :token
end
# 'show_weary' becomes an instance method of Repository,
# generating a Weary::Request for this Resource
end
repo = Repository.new
request = repo.show_weary
response = request.perform
if response.success?
pp response.parse
else
puts "Something went wrong. Request failed with #{response.code}: #{response.message}"
end
require 'pp'
require 'rubygems'
require 'weary'
request = Weary::Request.new('http://github.com/api/v2/json/repos/show/mwunsch/weary')
response = request.perform
if response.success?
pp response.parse
else
puts "Something went wrong. Request failed with #{response.code}: #{response.message}"
end
require 'pp'
require 'rubygems'
require 'weary'
resource = Weary::Resource.new("weary_repo")
resource.url = 'http://github.com/api/v2/json/repos/show/mwunsch/weary'
resource.with = :login, :token
request = resource.build!
response = request.perform
if response.success?
pp response.parse
else
puts "Something went wrong. Request failed with #{response.code}: #{response.message}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment