Module: Twitter::Console

Defined in:
lib/twitter-console.rb

Defined Under Namespace

Classes: ClientProxy

Constant Summary collapse

"Twitter Console-- Type `usage` for examples."
USAGE =
%Q{
Fetch a user
api.get('/1/users/show.json?screen_name=<screen_name>')

Image uploads
image = File.open("/path/to/banner.png")
api.post('/1/account/profile_banner.json', :banner => image)

}.gsub(/^\t{4}/,'')

Instance Method Summary collapse

Instance Method Details

#apiObject



34
35
36
# File 'lib/twitter-console.rb', line 34

def api
  @api ||= ClientProxy.new(:endpoint => endpoint)
end

#endpointObject



30
31
32
# File 'lib/twitter-console.rb', line 30

def endpoint
  ENV['TWITTER_API_ENDPOINT'] || Twitter::Default::ENDPOINT
end

#startObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/twitter-console.rb', line 38

def start
  puts BANNER

  IRB.setup(nil)
  irb = IRB::Irb.new

  IRB.conf[:MAIN_CONTEXT] = irb.context

  irb.context.evaluate("require 'irb/completion'", 0)

  trap("SIGINT") do
    irb.signal_handle
  end

  catch(:IRB_EXIT) do
    irb.eval_input
  end
end

#usageObject



26
27
28
# File 'lib/twitter-console.rb', line 26

def usage
  print USAGE
end