Updating CLI and explorer to match recent changes.

git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@65 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef
This commit is contained in:
Bob Aman 2010-10-12 23:07:36 +00:00
parent ecf330f177
commit be265da6d4
2 changed files with 10 additions and 3 deletions

View File

@ -161,6 +161,7 @@ def oauth_login(options={})
end end
def execute(options={}) def execute(options={})
require 'signet/oauth_1/client'
config_file = File.expand_path('~/.google-api.yaml') config_file = File.expand_path('~/.google-api.yaml')
signed = File.exist?(config_file) signed = File.exist?(config_file)
rpcname = ARGV.detect { |p| p =~ /^[a-z0-9_-]+\.[a-z0-9_\.-]+$/i } rpcname = ARGV.detect { |p| p =~ /^[a-z0-9_-]+\.[a-z0-9_\.-]+$/i }
@ -171,7 +172,10 @@ def execute(options={})
exit(1) exit(1)
end end
service_name = options[:service_name] || rpcname[/^([^\.]+)\./, 1] service_name = options[:service_name] || rpcname[/^([^\.]+)\./, 1]
client = Google::APIClient.new(:service => service_name) client = Google::APIClient.new(
:service => service_name,
:authorization => :oauth_1
)
if signed if signed
if !client.authorization.kind_of?(Signet::OAuth1::Client) if !client.authorization.kind_of?(Signet::OAuth1::Client)
STDERR.puts( STDERR.puts(
@ -190,7 +194,8 @@ def execute(options={})
config["token_credential_secret"] config["token_credential_secret"]
end end
service_version = service_version =
options[:service_version] || client.latest_service(service_name).version options[:service_version] ||
client.latest_service_version(service_name).version
service = client.discovered_service(service_name, service_version) service = client.discovered_service(service_name, service_version)
method = service.to_h[rpcname] method = service.to_h[rpcname]
if !method if !method

View File

@ -23,6 +23,8 @@ rescue LoadError
exit(1) exit(1)
end end
enable :sessions
CSS = <<-CSS CSS = <<-CSS
/* http://meyerweb.com/eric/tools/css/reset/ */ /* http://meyerweb.com/eric/tools/css/reset/ */
/* v1.0 | 20080212 */ /* v1.0 | 20080212 */
@ -308,7 +310,7 @@ end
def service(service_name, service_version) def service(service_name, service_version)
unless service_version unless service_version
service_version = client.latest_service(service_name).version service_version = client.latest_service_version(service_name).version
end end
client.discovered_service(service_name, service_version) client.discovered_service(service_name, service_version)
end end