Created
December 7, 2009 15:33
-
-
Save mwunsch/250871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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