mirror of
https://github.com/jimeh/twhois.git
synced 2026-02-19 10:56:41 +00:00
core of gem done, spec pass
This commit is contained in:
@@ -1,3 +1,24 @@
|
||||
# encoding: utf-8
|
||||
|
||||
require 'rubygems'
|
||||
require 'net/http'
|
||||
require 'json'
|
||||
require 'hashie'
|
||||
|
||||
require 'twhois/user'
|
||||
require 'twhois/version'
|
||||
|
||||
module Twhois
|
||||
# Your code goes here...
|
||||
|
||||
LOOKUP_HOST = "api.twitter.com"
|
||||
LOOKUP_PATH = "/1/users/show.json?screen_name="
|
||||
|
||||
# Lookup a Twitter user by their username.
|
||||
def self.lookup(username)
|
||||
res = Net::HTTP.start(LOOKUP_HOST) { |http| http.get(LOOKUP_PATH + username) }
|
||||
if res.code == '200'
|
||||
User.new(JSON.parse(res.body))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
7
lib/twhois/user.rb
Normal file
7
lib/twhois/user.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# encoding: utf-8
|
||||
|
||||
module Twhois
|
||||
class User < ::Hashie::Mash
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
# encoding: utf-8
|
||||
|
||||
module Twhois
|
||||
VERSION = "0.0.1"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user