From 61b2a4027363baef17740b74a639590cf2303a01 Mon Sep 17 00:00:00 2001 From: Ian Vaughan Date: Wed, 25 Apr 2012 21:37:13 +0100 Subject: [PATCH] Allow links like auth to auto open in browser Add method `open_link` to use mac `open` command line only if mac Add method `is_mac` to determin if its a mac OS --- lib/console_tweet/cli.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/console_tweet/cli.rb b/lib/console_tweet/cli.rb index bb1fb87..10c3b3a 100644 --- a/lib/console_tweet/cli.rb +++ b/lib/console_tweet/cli.rb @@ -48,6 +48,7 @@ def get_access_token request_token = @client.request_token # ask the user to visit the auth url puts "To authenticate your client, visit the URL: #{request_token.authorize_url}" + open_link request_token.authorize_url # wait for the user to give us the PIN back print 'Enter PIN: ' begin @@ -230,6 +231,14 @@ def print_tweets(tweets) end end + def open_link url + exec "open #{url}" if is_mac? + end + + def is_mac? + RUBY_PLATFORM.downcase.include?("darwin") + end + end end