Updating code to consistent coding style.
git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@15 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef
This commit is contained in:
parent
6331247e7a
commit
e6ba0f6860
26
Rakefile
26
Rakefile
|
@ -1,6 +1,6 @@
|
||||||
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "lib"))
|
lib_dir = File.expand_path('../lib', __FILE__)
|
||||||
$:.unshift(lib_dir)
|
$LOAD_PATH.unshift(lib_dir)
|
||||||
$:.uniq!
|
$LOAD_PATH.uniq!
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rake'
|
require 'rake'
|
||||||
|
@ -12,37 +12,37 @@ require 'rake/gempackagetask'
|
||||||
begin
|
begin
|
||||||
require 'spec/rake/spectask'
|
require 'spec/rake/spectask'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
STDERR.puts "Please install RSpec."
|
STDERR.puts 'Please install RSpec.'
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), 'lib/google/api_client', 'version')
|
require File.join(File.dirname(__FILE__), 'lib/google/api_client', 'version')
|
||||||
|
|
||||||
PKG_DISPLAY_NAME = 'Google API Client'
|
PKG_DISPLAY_NAME = 'Google API Client'
|
||||||
PKG_NAME = PKG_DISPLAY_NAME.downcase.gsub(/\s/, "-")
|
PKG_NAME = PKG_DISPLAY_NAME.downcase.gsub(/\s/, '-')
|
||||||
PKG_VERSION = Google::APIClient::VERSION::STRING
|
PKG_VERSION = Google::APIClient::VERSION::STRING
|
||||||
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
||||||
PKG_HOMEPAGE = "http://code.google.com/p/google-api-ruby-client/"
|
PKG_HOMEPAGE = 'http://code.google.com/p/google-api-ruby-client/'
|
||||||
|
|
||||||
RELEASE_NAME = "REL #{PKG_VERSION}"
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
||||||
|
|
||||||
PKG_SUMMARY = "Package Summary"
|
PKG_SUMMARY = 'Package Summary'
|
||||||
PKG_DESCRIPTION = <<-TEXT
|
PKG_DESCRIPTION = <<-TEXT
|
||||||
The Google API Ruby Client makes it trivial to discover and access supported
|
The Google API Ruby Client makes it trivial to discover and access supported
|
||||||
APIs.
|
APIs.
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
PKG_FILES = FileList[
|
PKG_FILES = FileList[
|
||||||
"lib/**/*", "spec/**/*", "vendor/**/*",
|
'lib/**/*', 'spec/**/*', 'vendor/**/*',
|
||||||
"tasks/**/*", "website/**/*",
|
'tasks/**/*', 'website/**/*',
|
||||||
"[A-Z]*", "Rakefile"
|
'[A-Z]*', 'Rakefile'
|
||||||
].exclude(/database\.yml/).exclude(/[_\.]git$/)
|
].exclude(/database\.yml/).exclude(/[_\.]git$/)
|
||||||
|
|
||||||
RCOV_ENABLED = (RUBY_PLATFORM != "java" && RUBY_VERSION =~ /^1\.8/)
|
RCOV_ENABLED = (RUBY_PLATFORM != 'java' && RUBY_VERSION =~ /^1\.8/)
|
||||||
if RCOV_ENABLED
|
if RCOV_ENABLED
|
||||||
task :default => "spec:verify"
|
task :default => 'spec:verify'
|
||||||
else
|
else
|
||||||
task :default => "spec"
|
task :default => 'spec'
|
||||||
end
|
end
|
||||||
|
|
||||||
WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
|
WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
require "google/api_client/version"
|
require 'google/api_client/version'
|
||||||
|
|
||||||
module Google #:nodoc:
|
module Google #:nodoc:
|
||||||
##
|
##
|
||||||
|
@ -23,12 +23,12 @@ module Google #:nodoc:
|
||||||
# TODO: What configuration options need to go here?
|
# TODO: What configuration options need to go here?
|
||||||
}.merge(options)
|
}.merge(options)
|
||||||
unless @options[:authentication]
|
unless @options[:authentication]
|
||||||
require "google/api_client/auth/oauth_1"
|
require 'google/api_client/auth/oauth_1'
|
||||||
# NOTE: Do not rely on this default value, as it may change
|
# NOTE: Do not rely on this default value, as it may change
|
||||||
@options[:authentication] = OAuth1.new
|
@options[:authentication] = OAuth1.new
|
||||||
end
|
end
|
||||||
unless @options[:transport]
|
unless @options[:transport]
|
||||||
require "google/api_client/transport/http_transport"
|
require 'google/api_client/transport/http_transport'
|
||||||
@options[:transport] = HTTPTransport
|
@options[:transport] = HTTPTransport
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,14 +12,15 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
require "addressable/uri"
|
require 'addressable/uri'
|
||||||
require "oauth"
|
require 'oauth'
|
||||||
|
|
||||||
module Google #:nodoc:
|
module Google #:nodoc:
|
||||||
class APIClient #:nodoc:
|
class APIClient #:nodoc:
|
||||||
##
|
##
|
||||||
# An OAuth 1.0a handler.
|
# An OAuth 1.0a handler.
|
||||||
class OAuth1
|
class OAuth1
|
||||||
|
|
||||||
##
|
##
|
||||||
# The default OAuth 1.0a configuration values. These may be overrided
|
# The default OAuth 1.0a configuration values. These may be overrided
|
||||||
# simply by passing in the same key to the constructor.
|
# simply by passing in the same key to the constructor.
|
||||||
|
@ -33,8 +34,8 @@ module Google #:nodoc:
|
||||||
:scopes => [],
|
:scopes => [],
|
||||||
:callback => OAuth::OUT_OF_BAND,
|
:callback => OAuth::OUT_OF_BAND,
|
||||||
:display_name => nil,
|
:display_name => nil,
|
||||||
:consumer_key => "anonymous",
|
:consumer_key => 'anonymous',
|
||||||
:consumer_secret => "anonymous"
|
:consumer_secret => 'anonymous'
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -44,7 +45,12 @@ module Google #:nodoc:
|
||||||
:buzz => {
|
:buzz => {
|
||||||
:authorization_uri =>
|
:authorization_uri =>
|
||||||
'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken',
|
'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken',
|
||||||
:scopes => ["https://www.googleapis.com/auth/buzz"]
|
:scopes => ['https://www.googleapis.com/auth/buzz']
|
||||||
|
},
|
||||||
|
:latitude => {
|
||||||
|
:authorization_uri =>
|
||||||
|
'https://www.google.com/latitude/apps/OAuthAuthorizeToken',
|
||||||
|
:scopes => ['https://www.googleapis.com/auth/latitude']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +102,7 @@ module Google #:nodoc:
|
||||||
@options[:authorization_uri].site) ||
|
@options[:authorization_uri].site) ||
|
||||||
(@options[:request_token_uri].site !=
|
(@options[:request_token_uri].site !=
|
||||||
@options[:authorization_uri].site)
|
@options[:authorization_uri].site)
|
||||||
raise ArgumentError, "All OAuth endpoints must be on the same site."
|
raise ArgumentError, 'All OAuth endpoints must be on the same site.'
|
||||||
end
|
end
|
||||||
@oauth_consumer = ::OAuth::Consumer.new(
|
@oauth_consumer = ::OAuth::Consumer.new(
|
||||||
@options[:consumer_key], @options[:consumer_secret], {
|
@options[:consumer_key], @options[:consumer_secret], {
|
||||||
|
@ -131,7 +137,7 @@ module Google #:nodoc:
|
||||||
:oauth_callback => @options[:callback]
|
:oauth_callback => @options[:callback]
|
||||||
}
|
}
|
||||||
app_parameters = {
|
app_parameters = {
|
||||||
:scope => @options[:scopes].join(" ")
|
:scope => @options[:scopes].join(' ')
|
||||||
}
|
}
|
||||||
if @options[:display_name]
|
if @options[:display_name]
|
||||||
app_parameters[:xoauth_displayname] = @options[:display_name]
|
app_parameters[:xoauth_displayname] = @options[:display_name]
|
||||||
|
|
|
@ -12,14 +12,15 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
require "json"
|
require 'json'
|
||||||
require "addressable/template"
|
require 'addressable/template'
|
||||||
|
|
||||||
module Google #:nodoc:
|
module Google #:nodoc:
|
||||||
class APIClient #:nodoc:
|
class APIClient #:nodoc:
|
||||||
##
|
##
|
||||||
# A discovery document handler.
|
# A discovery document handler.
|
||||||
class Discovery
|
class Discovery
|
||||||
|
|
||||||
##
|
##
|
||||||
# The default discovery configuration values. These may be overrided
|
# The default discovery configuration values. These may be overrided
|
||||||
# simply by passing in the same key to the constructor.
|
# simply by passing in the same key to the constructor.
|
||||||
|
@ -53,14 +54,14 @@ module Google #:nodoc:
|
||||||
@options.merge!(options)
|
@options.merge!(options)
|
||||||
if @options[:service] && !@options[:discovery_uri]
|
if @options[:service] && !@options[:discovery_uri]
|
||||||
service_id = @options[:service]
|
service_id = @options[:service]
|
||||||
service_version = @options[:service_version] || "1.0"
|
service_version = @options[:service_version] || '1.0'
|
||||||
@options[:discovery_uri] =
|
@options[:discovery_uri] =
|
||||||
"http://www.googleapis.com/discovery/0.1/describe" +
|
"http://www.googleapis.com/discovery/0.1/describe" +
|
||||||
"?api=#{service_id}&apiVersion=#{service_version}"
|
"?api=#{service_id}&apiVersion=#{service_version}"
|
||||||
end
|
end
|
||||||
unless @options[:discovery_uri]
|
unless @options[:discovery_uri]
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
"Missing required configuration value, :discovery_uri."
|
'Missing required configuration value, :discovery_uri.'
|
||||||
end
|
end
|
||||||
# Handle any remaining configuration here
|
# Handle any remaining configuration here
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,58 +12,58 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
require "spec_helper"
|
require 'spec_helper'
|
||||||
|
|
||||||
require "oauth"
|
require 'oauth'
|
||||||
require "google/api_client/auth/oauth_1"
|
require 'google/api_client/auth/oauth_1'
|
||||||
|
|
||||||
describe Google::APIClient::OAuth1, "in the default configuration" do
|
describe Google::APIClient::OAuth1, 'in the default configuration' do
|
||||||
before do
|
before do
|
||||||
@oauth = Google::APIClient::OAuth1.new
|
@oauth = Google::APIClient::OAuth1.new
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct request_token_uri" do
|
it 'should have the correct request_token_uri' do
|
||||||
@oauth.request_token_uri.should ==
|
@oauth.request_token_uri.should ==
|
||||||
"https://www.google.com/accounts/OAuthGetRequestToken"
|
'https://www.google.com/accounts/OAuthGetRequestToken'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct authorization_uri" do
|
it 'should have the correct authorization_uri' do
|
||||||
@oauth.authorization_endpoint_uri.should ==
|
@oauth.authorization_endpoint_uri.should ==
|
||||||
"https://www.google.com/accounts/OAuthAuthorizeToken"
|
'https://www.google.com/accounts/OAuthAuthorizeToken'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct access_token_uri" do
|
it 'should have the correct access_token_uri' do
|
||||||
@oauth.access_token_uri.should ==
|
@oauth.access_token_uri.should ==
|
||||||
"https://www.google.com/accounts/OAuthGetAccessToken"
|
'https://www.google.com/accounts/OAuthGetAccessToken'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct consumer_key" do
|
it 'should have the correct consumer_key' do
|
||||||
@oauth.consumer_key.should == "anonymous"
|
@oauth.consumer_key.should == 'anonymous'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct consumer_secret" do
|
it 'should have the correct consumer_secret' do
|
||||||
@oauth.consumer_secret.should == "anonymous"
|
@oauth.consumer_secret.should == 'anonymous'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should allow the request_token to be set manually" do
|
it 'should allow the request_token to be set manually' do
|
||||||
@oauth.request_token = OAuth::RequestToken.new(@oauth, "key", "secret")
|
@oauth.request_token = OAuth::RequestToken.new(@oauth, 'key', 'secret')
|
||||||
@oauth.request_token.token.should == "key"
|
@oauth.request_token.token.should == 'key'
|
||||||
@oauth.request_token.secret.should == "secret"
|
@oauth.request_token.secret.should == 'secret'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not allow the request_token to be set to bogus value" do
|
it 'should not allow the request_token to be set to bogus value' do
|
||||||
(lambda do
|
(lambda do
|
||||||
@oauth.request_token = 42
|
@oauth.request_token = 42
|
||||||
end).should raise_error(TypeError)
|
end).should raise_error(TypeError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Google::APIClient::OAuth1, "configured for use with bogus service" do
|
describe Google::APIClient::OAuth1, 'configured for use with bogus service' do
|
||||||
before do
|
before do
|
||||||
@oauth = Google::APIClient::OAuth1.new(:service => :bogus)
|
@oauth = Google::APIClient::OAuth1.new(:service => :bogus)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the default configuration" do
|
it 'should have the default configuration' do
|
||||||
@oauth.request_token_uri.should ==
|
@oauth.request_token_uri.should ==
|
||||||
Google::APIClient::OAuth1::DEFAULTS[:request_token_uri]
|
Google::APIClient::OAuth1::DEFAULTS[:request_token_uri]
|
||||||
@oauth.authorization_endpoint_uri.should ==
|
@oauth.authorization_endpoint_uri.should ==
|
||||||
|
|
|
@ -12,49 +12,49 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
require "spec_helper"
|
require 'spec_helper'
|
||||||
|
|
||||||
require "oauth"
|
require 'oauth'
|
||||||
require "google/api_client/auth/oauth_1"
|
require 'google/api_client/auth/oauth_1'
|
||||||
require "addressable/uri"
|
require 'addressable/uri'
|
||||||
|
|
||||||
describe Google::APIClient::OAuth1, "configured for use with Buzz" do
|
describe Google::APIClient::OAuth1, 'configured for use with Buzz' do
|
||||||
before do
|
before do
|
||||||
@oauth = Google::APIClient::OAuth1.new(:service => :buzz)
|
@oauth = Google::APIClient::OAuth1.new(:service => :buzz)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not have the default configuration" do
|
it 'should not have the default configuration' do
|
||||||
@oauth.authorization_endpoint_uri.should_not ==
|
@oauth.authorization_endpoint_uri.should_not ==
|
||||||
Google::APIClient::OAuth1::DEFAULTS[:authorization_uri]
|
Google::APIClient::OAuth1::DEFAULTS[:authorization_uri]
|
||||||
@oauth.scopes.should_not ==
|
@oauth.scopes.should_not ==
|
||||||
Google::APIClient::OAuth1::DEFAULTS[:scopes]
|
Google::APIClient::OAuth1::DEFAULTS[:scopes]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct authorization_uri" do
|
it 'should have the correct authorization_uri' do
|
||||||
@oauth.authorization_endpoint_uri.should ==
|
@oauth.authorization_endpoint_uri.should ==
|
||||||
"https://www.google.com/buzz/api/auth/OAuthAuthorizeToken"
|
'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct scope" do
|
it 'should have the correct scope' do
|
||||||
@oauth.scopes.should include("https://www.googleapis.com/auth/buzz")
|
@oauth.scopes.should include('https://www.googleapis.com/auth/buzz')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to get a request token" do
|
it 'should be able to get a request token' do
|
||||||
@oauth.request_token.token.should =~ /^[a-zA-Z0-9\/\-\_\+]+$/
|
@oauth.request_token.token.should =~ /^[a-zA-Z0-9\/\-\_\+]+$/
|
||||||
@oauth.request_token.secret.should =~ /^[a-zA-Z0-9\/\-\_\+]+$/
|
@oauth.request_token.secret.should =~ /^[a-zA-Z0-9\/\-\_\+]+$/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should issue only a single request token" do
|
it 'should issue only a single request token' do
|
||||||
@oauth.request_token.token.should == @oauth.request_token.token
|
@oauth.request_token.token.should == @oauth.request_token.token
|
||||||
@oauth.request_token.secret.should == @oauth.request_token.secret
|
@oauth.request_token.secret.should == @oauth.request_token.secret
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should build the correct authorization URI" do
|
it 'should build the correct authorization URI' do
|
||||||
icon_uri = "http://www.google.com/images/icons/feature/padlock-g128.png"
|
icon_uri = 'http://www.google.com/images/icons/feature/padlock-g128.png'
|
||||||
uri = @oauth.authorization_uri(
|
uri = @oauth.authorization_uri(
|
||||||
:domain => @oauth.consumer_key,
|
:domain => @oauth.consumer_key,
|
||||||
:iconUrl => icon_uri,
|
:iconUrl => icon_uri,
|
||||||
:scope => @oauth.scopes.join(" ")
|
:scope => @oauth.scopes.join(' ')
|
||||||
)
|
)
|
||||||
uri.should =~
|
uri.should =~
|
||||||
/^https:\/\/www.google.com\/buzz\/api\/auth\/OAuthAuthorizeToken/
|
/^https:\/\/www.google.com\/buzz\/api\/auth\/OAuthAuthorizeToken/
|
||||||
|
|
|
@ -12,25 +12,25 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
require "spec_helper"
|
require 'spec_helper'
|
||||||
|
|
||||||
require "oauth"
|
require 'oauth'
|
||||||
require "google/api_client/discovery/discovery"
|
require 'google/api_client/discovery/discovery'
|
||||||
|
|
||||||
describe Google::APIClient::Discovery, "configured for use with a service" do
|
describe Google::APIClient::Discovery, 'configured for use with a service' do
|
||||||
before do
|
before do
|
||||||
@discovery = Google::APIClient::Discovery.new(:service => :magic)
|
@discovery = Google::APIClient::Discovery.new(:service => :magic)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct discovery document URI" do
|
it 'should have the correct discovery document URI' do
|
||||||
@discovery.discovery_uri.should ==
|
@discovery.discovery_uri.should ==
|
||||||
"http://www.googleapis.com/discovery/0.1/describe" +
|
'http://www.googleapis.com/discovery/0.1/describe' +
|
||||||
"?api=magic&apiVersion=1.0"
|
'?api=magic&apiVersion=1.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Google::APIClient::Discovery,
|
describe Google::APIClient::Discovery,
|
||||||
"configured for use with a specific service version" do
|
'configured for use with a specific service version' do
|
||||||
before do
|
before do
|
||||||
@discovery = Google::APIClient::Discovery.new(
|
@discovery = Google::APIClient::Discovery.new(
|
||||||
:service => :magic,
|
:service => :magic,
|
||||||
|
@ -38,9 +38,9 @@ describe Google::APIClient::Discovery,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have the correct discovery document URI" do
|
it 'should have the correct discovery document URI' do
|
||||||
@discovery.discovery_uri.should ==
|
@discovery.discovery_uri.should ==
|
||||||
"http://www.googleapis.com/discovery/0.1/describe" +
|
'http://www.googleapis.com/discovery/0.1/describe' +
|
||||||
"?api=magic&apiVersion=42.0"
|
'?api=magic&apiVersion=42.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
spec_dir = File.expand_path(File.dirname(__FILE__))
|
spec_dir = File.expand_path("..", __FILE__)
|
||||||
lib_dir = File.expand_path(File.join(spec_dir, "../lib"))
|
lib_dir = File.expand_path("../lib", spec_dir)
|
||||||
|
|
||||||
$:.unshift(lib_dir)
|
$LOAD_PATH.unshift(lib_dir)
|
||||||
$:.uniq!
|
$LOAD_PATH.uniq!
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
desc "Remove all build products"
|
desc 'Remove all build products'
|
||||||
task "clobber"
|
task 'clobber'
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
require "rake/gempackagetask"
|
require 'rake/gempackagetask'
|
||||||
|
|
||||||
namespace :gem do
|
namespace :gem do
|
||||||
GEM_SPEC = Gem::Specification.new do |s|
|
GEM_SPEC = Gem::Specification.new do |s|
|
||||||
unless s.respond_to?(:add_development_dependency)
|
unless s.respond_to?(:add_development_dependency)
|
||||||
puts "The gem spec requires a newer version of RubyGems."
|
puts 'The gem spec requires a newer version of RubyGems.'
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,18 +16,18 @@ namespace :gem do
|
||||||
|
|
||||||
s.has_rdoc = true
|
s.has_rdoc = true
|
||||||
s.extra_rdoc_files = %w( README )
|
s.extra_rdoc_files = %w( README )
|
||||||
s.rdoc_options.concat ["--main", "README"]
|
s.rdoc_options.concat ['--main', 'README']
|
||||||
|
|
||||||
s.add_runtime_dependency("oauth", ">= 0.4.1")
|
s.add_runtime_dependency('oauth', '>= 0.4.1')
|
||||||
s.add_runtime_dependency("addressable", ">= 2.2.0")
|
s.add_runtime_dependency('addressable', '>= 2.2.0')
|
||||||
s.add_runtime_dependency("json", ">= 1.1.9")
|
s.add_runtime_dependency('json', '>= 1.1.9')
|
||||||
|
|
||||||
s.add_development_dependency("rake", ">= 0.7.3")
|
s.add_development_dependency('rake', '>= 0.7.3')
|
||||||
s.add_development_dependency("rspec", ">= 1.0.8")
|
s.add_development_dependency('rspec', '>= 1.0.8')
|
||||||
s.add_development_dependency("launchy", ">= 0.3.2")
|
s.add_development_dependency('launchy', '>= 0.3.2')
|
||||||
s.add_development_dependency("diff-lcs", ">= 1.1.2")
|
s.add_development_dependency('diff-lcs', '>= 1.1.2')
|
||||||
|
|
||||||
s.require_path = "lib"
|
s.require_path = 'lib'
|
||||||
|
|
||||||
s.homepage = PKG_HOMEPAGE
|
s.homepage = PKG_HOMEPAGE
|
||||||
end
|
end
|
||||||
|
@ -38,17 +38,17 @@ namespace :gem do
|
||||||
p.need_zip = true
|
p.need_zip = true
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Show information about the gem"
|
desc 'Show information about the gem'
|
||||||
task :debug do
|
task :debug do
|
||||||
puts GEM_SPEC.to_ruby
|
puts GEM_SPEC.to_ruby
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Install the gem"
|
desc 'Install the gem'
|
||||||
task :install => ["clobber", "gem:package"] do
|
task :install => ['clobber', 'gem:package'] do
|
||||||
sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
|
sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Uninstall the gem"
|
desc 'Uninstall the gem'
|
||||||
task :uninstall do
|
task :uninstall do
|
||||||
installed_list = Gem.source_index.find_name(PKG_NAME)
|
installed_list = Gem.source_index.find_name(PKG_NAME)
|
||||||
if installed_list &&
|
if installed_list &&
|
||||||
|
@ -60,11 +60,11 @@ namespace :gem do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Reinstall the gem"
|
desc 'Reinstall the gem'
|
||||||
task :reinstall => [:uninstall, :install]
|
task :reinstall => [:uninstall, :install]
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Alias to gem:package"
|
desc 'Alias to gem:package'
|
||||||
task "gem" => "gem:package"
|
task 'gem' => 'gem:package'
|
||||||
|
|
||||||
task "clobber" => ["gem:clobber_package"]
|
task 'clobber' => ['gem:clobber_package']
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
namespace :git do
|
namespace :git do
|
||||||
namespace :tag do
|
namespace :tag do
|
||||||
desc "List tags from the Git repository"
|
desc 'List tags from the Git repository'
|
||||||
task :list do
|
task :list do
|
||||||
tags = `git tag -l`
|
tags = `git tag -l`
|
||||||
tags.gsub!("\r", "")
|
tags.gsub!('\r', '')
|
||||||
tags = tags.split("\n").sort {|a, b| b <=> a }
|
tags = tags.split('\n').sort {|a, b| b <=> a }
|
||||||
puts tags.join("\n")
|
puts tags.join('\n')
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Create a new tag in the Git repository"
|
desc 'Create a new tag in the Git repository'
|
||||||
task :create do
|
task :create do
|
||||||
changelog = File.open("CHANGELOG", "r") { |file| file.read }
|
changelog = File.open('CHANGELOG', 'r') { |file| file.read }
|
||||||
puts "-" * 80
|
puts '-' * 80
|
||||||
puts changelog
|
puts changelog
|
||||||
puts "-" * 80
|
puts '-' * 80
|
||||||
puts
|
puts
|
||||||
|
|
||||||
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
||||||
abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
|
abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
|
||||||
|
|
||||||
tag = "#{PKG_NAME}-#{PKG_VERSION}"
|
tag = "#{PKG_NAME}-#{PKG_VERSION}"
|
||||||
msg = "Release #{PKG_NAME}-#{PKG_VERSION}"
|
msg = "Release #{PKG_NAME}-#{PKG_VERSION}"
|
||||||
|
|
||||||
existing_tags = `git tag -l #{PKG_NAME}-*`.split("\n")
|
existing_tags = `git tag -l #{PKG_NAME}-*`.split('\n')
|
||||||
if existing_tags.include?(tag)
|
if existing_tags.include?(tag)
|
||||||
warn("Tag already exists, deleting...")
|
warn('Tag already exists, deleting...')
|
||||||
unless system "git tag -d #{tag}"
|
unless system "git tag -d #{tag}"
|
||||||
abort "Tag deletion failed."
|
abort 'Tag deletion failed.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "Creating git tag '#{tag}'..."
|
puts "Creating git tag '#{tag}'..."
|
||||||
unless system "git tag -a -m \"#{msg}\" #{tag}"
|
unless system "git tag -a -m \"#{msg}\" #{tag}"
|
||||||
abort "Tag creation failed."
|
abort 'Tag creation failed.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task "gem:release" => "git:tag:create"
|
task 'gem:release' => 'git:tag:create'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
namespace :metrics do
|
namespace :metrics do
|
||||||
task :lines do
|
task :lines do
|
||||||
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
|
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
|
||||||
for file_name in FileList["lib/**/*.rb"]
|
for file_name in FileList['lib/**/*.rb']
|
||||||
f = File.open(file_name)
|
f = File.open(file_name)
|
||||||
while line = f.gets
|
while line = f.gets
|
||||||
lines += 1
|
lines += 1
|
||||||
|
@ -9,8 +9,8 @@ namespace :metrics do
|
||||||
next if line =~ /^\s*#/
|
next if line =~ /^\s*#/
|
||||||
codelines += 1
|
codelines += 1
|
||||||
end
|
end
|
||||||
puts "L: #{sprintf("%4d", lines)}, " +
|
puts "L: #{sprintf('%4d', lines)}, " +
|
||||||
"LOC #{sprintf("%4d", codelines)} | #{file_name}"
|
"LOC #{sprintf('%4d', codelines)} | #{file_name}"
|
||||||
total_lines += lines
|
total_lines += lines
|
||||||
total_codelines += codelines
|
total_codelines += codelines
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
require "rake/rdoctask"
|
require 'rake/rdoctask'
|
||||||
|
|
||||||
namespace :doc do
|
namespace :doc do
|
||||||
desc "Generate RDoc documentation"
|
desc 'Generate RDoc documentation'
|
||||||
Rake::RDocTask.new do |rdoc|
|
Rake::RDocTask.new do |rdoc|
|
||||||
rdoc.rdoc_dir = "doc"
|
rdoc.rdoc_dir = 'doc'
|
||||||
rdoc.title = "#{PKG_NAME}-#{PKG_VERSION} Documentation"
|
rdoc.title = "#{PKG_NAME}-#{PKG_VERSION} Documentation"
|
||||||
rdoc.options << "--line-numbers" << "--inline-source" <<
|
rdoc.options << '--line-numbers' << '--inline-source' <<
|
||||||
"--accessor" << "cattr_accessor=object" << "--charset" << "utf-8"
|
'--accessor' << 'cattr_accessor=object' << '--charset' << 'utf-8'
|
||||||
rdoc.template = "#{ENV["template"]}.rb" if ENV["template"]
|
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
||||||
rdoc.rdoc_files.include("README", "CHANGELOG", "LICENSE")
|
rdoc.rdoc_files.include('README', 'CHANGELOG', 'LICENSE')
|
||||||
rdoc.rdoc_files.include("lib/**/*.rb")
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Generate ri locally for testing"
|
desc 'Generate ri locally for testing'
|
||||||
task :ri do
|
task :ri do
|
||||||
sh "rdoc --ri -o ri ."
|
sh 'rdoc --ri -o ri .'
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Remove ri products"
|
desc 'Remove ri products'
|
||||||
task :clobber_ri do
|
task :clobber_ri do
|
||||||
rm_r "ri" rescue nil
|
rm_r 'ri' rescue nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task "clobber" => ["doc:clobber_rdoc", "doc:clobber_ri"]
|
task 'clobber' => ['doc:clobber_rdoc', 'doc:clobber_ri']
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace :spec do
|
||||||
task :verify => :rcov
|
task :verify => :rcov
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Generate HTML Specdocs for all specs"
|
desc 'Generate HTML Specdocs for all specs'
|
||||||
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
||||||
specdoc_path = File.expand_path(
|
specdoc_path = File.expand_path(
|
||||||
File.join(File.dirname(__FILE__), '../specdoc/'))
|
File.join(File.dirname(__FILE__), '../specdoc/'))
|
||||||
|
@ -47,25 +47,25 @@ namespace :spec do
|
||||||
|
|
||||||
output_file = File.join(specdoc_path, 'index.html')
|
output_file = File.join(specdoc_path, 'index.html')
|
||||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||||
t.spec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
|
t.spec_opts = ['--format', "\"html:#{output_file}\"", '--diff']
|
||||||
t.fail_on_error = false
|
t.fail_on_error = false
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :rcov do
|
namespace :rcov do
|
||||||
desc "Browse the code coverage report."
|
desc 'Browse the code coverage report.'
|
||||||
task :browse => "spec:rcov" do
|
task :browse => 'spec:rcov' do
|
||||||
require "launchy"
|
require 'launchy'
|
||||||
Launchy::Browser.run("coverage/index.html")
|
Launchy::Browser.run('coverage/index.html')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if RCOV_ENABLED
|
if RCOV_ENABLED
|
||||||
desc "Alias to spec:verify"
|
desc 'Alias to spec:verify'
|
||||||
task "spec" => "spec:verify"
|
task 'spec' => 'spec:verify'
|
||||||
else
|
else
|
||||||
desc "Alias to spec:all"
|
desc 'Alias to spec:all'
|
||||||
task "spec" => "spec:all"
|
task 'spec' => 'spec:all'
|
||||||
end
|
end
|
||||||
|
|
||||||
task "clobber" => ["spec:clobber_rcov"]
|
task 'clobber' => ['spec:clobber_rcov']
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
require "rake"
|
require 'rake'
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require "yard"
|
require 'yard'
|
||||||
require "yard/rake/yardoc_task"
|
require 'yard/rake/yardoc_task'
|
||||||
|
|
||||||
namespace :doc do
|
namespace :doc do
|
||||||
desc "Generate Yardoc documentation"
|
desc 'Generate Yardoc documentation'
|
||||||
YARD::Rake::YardocTask.new do |yardoc|
|
YARD::Rake::YardocTask.new do |yardoc|
|
||||||
yardoc.name = "yard"
|
yardoc.name = 'yard'
|
||||||
yardoc.options = ["--verbose"]
|
yardoc.options = ['--verbose']
|
||||||
yardoc.files = [
|
yardoc.files = [
|
||||||
"lib/**/*.rb", "ext/**/*.c", "README", "CHANGELOG", "LICENSE"
|
'lib/**/*.rb', 'ext/**/*.c', 'README', 'CHANGELOG', 'LICENSE'
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task "clobber" => ["doc:clobber_yard"]
|
task 'clobber' => ['doc:clobber_yard']
|
||||||
|
|
||||||
desc "Alias to doc:yard"
|
desc 'Alias to doc:yard'
|
||||||
task "doc" => "doc:yard"
|
task 'doc' => 'doc:yard'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
# If yard isn't available, it's not the end of the world
|
# If yard isn't available, it's not the end of the world
|
||||||
desc "Alias to doc:rdoc"
|
desc 'Alias to doc:rdoc'
|
||||||
task "doc" => "doc:rdoc"
|
task 'doc' => 'doc:rdoc'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue