google-ads-common 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ 0.6.3:
2
+ - Support for CAPTCHA challenge handling.
3
+ - Added .gemspec and updated packaging process.
4
+ - Removed explicit require for RubyGems.
5
+ - Added configuration directive to choose HTTPI adapter (connection.adapter)
6
+ and read / open timeouts (connection.read_timeout, connection.open_timeout).
7
+
1
8
  0.6.2:
2
9
  - Requiring Savon as "~>" now.
3
10
  - Updates to file headers.
data/README CHANGED
@@ -19,7 +19,8 @@ Install it using the gem install command.
19
19
  The following gem libraries are required:
20
20
  - savon v0.9.7 or greater;
21
21
  - httpi v0.9.3 or greater;
22
- - httpclient v2.2.3 or greater.
22
+ - httpclient v2.2.3 or greater;
23
+ - oauth v0.4.5 or greater.
23
24
 
24
25
  = Docs for Developers
25
26
 
@@ -36,8 +37,8 @@ The following gem libraries are required:
36
37
 
37
38
  == 2 - Commands
38
39
 
39
- $ rake package
40
- to package the gem and create a release
40
+ $ gem build google-ads-common.gemspec
41
+ to build the gem
41
42
 
42
43
  $ rake test
43
44
  to run unit tests on the library
@@ -21,13 +21,13 @@
21
21
  # Helper methods for loading and managing services for an API. Defines methods
22
22
  # to be included as class modules in a service class for a specific API.
23
23
 
24
+ require 'ads_common/version.rb'
25
+
24
26
  module AdsCommon
25
27
 
26
28
  # Contains helper methods for loading and managing the available services.
27
29
  # This module is meant to be imported into API-specific modules.
28
30
  module ApiConfig
29
- ADS_COMMON_VERSION = '0.6.2'
30
-
31
31
  # Get the available API versions.
32
32
  #
33
33
  # Returns:
@@ -33,6 +33,7 @@ module AdsCommon
33
33
  class ClientLoginHandler < AdsCommon::Auth::BaseHandler
34
34
  ACCOUNT_TYPE = 'GOOGLE'
35
35
  AUTH_PATH = '/accounts/ClientLogin'
36
+ CAPTCHA_PATH = '/accounts/'
36
37
  IGNORED_FIELDS = [:email, :password, :auth_token]
37
38
 
38
39
  # Initializes the ClientLoginHandler with all the necessary details.
@@ -139,24 +140,43 @@ module AdsCommon
139
140
 
140
141
  data = "accountType=%s&Email=%s&Passwd=%s&service=%s" %
141
142
  [ACCOUNT_TYPE, email, password, @service_name]
143
+
144
+ if credentials[:logintoken] and credentials[:logincaptcha]
145
+ data += "&logintoken=%s&logincaptcha=%s" %
146
+ [CGI.escape(credentials[:logintoken]),
147
+ CGI.escape(credentials[:logincaptcha])]
148
+ end
149
+
142
150
  headers = {'Content-Type' => 'application/x-www-form-urlencoded'}
143
151
 
144
152
  response = AdsCommon::Http.post_response(url, data, @config, headers)
145
153
  results = parse_token_text(response.body)
146
154
 
147
- if response.code == 200 and results.include?(:Auth)
148
- return results[:Auth]
155
+ if response.code == 200 and results.include?('Auth')
156
+ return results['Auth']
149
157
  else
150
- error_message = "Login failed for email %s: HTTP code %d." %
151
- [credentials[:email], response.code]
152
- error_str = results[:Error] || response.body
153
- error_message += " Error: %s." % error_str if error_str
154
- if results.include?(:Info)
155
- error_message += " Info: %s." % results[:Info]
156
- end
157
- raise AdsCommon::Errors::AuthError.new(error_message, error_str,
158
- results[:Info])
158
+ handle_login_error(credentials, response, results)
159
+ end
160
+ end
161
+
162
+ # Raises relevant error based on response and parsed results.
163
+ def handle_login_error(credentials, response, results)
164
+ # Handling for known errors.
165
+ if 'CaptchaRequired'.eql?(results['Error'])
166
+ captcha_url = @server + CAPTCHA_PATH + results['CaptchaUrl']
167
+ raise AdsCommon::Errors::CaptchaRequiredError.new(results['Error'],
168
+ results['CaptchaToken'], captcha_url, results['Url'])
159
169
  end
170
+ # For other errors throwing a generic error.
171
+ error_message = "ClientLogin failed for email '%s': HTTP code %d." %
172
+ [credentials[:email], response.code]
173
+ error_str = results['Error'] || response.body
174
+ error_message += " Error: %s." % error_str if error_str
175
+ if results.include?('Info')
176
+ error_message += " Info: %s." % results['Info']
177
+ end
178
+ raise AdsCommon::Errors::AuthError.new(error_message, error_str,
179
+ results['Info'])
160
180
  end
161
181
 
162
182
  # Extracts key-value pairs from ClientLogin server response.
@@ -168,12 +188,11 @@ module AdsCommon
168
188
  # Hash of key-value pairs
169
189
  #
170
190
  def parse_token_text(text)
171
- result = {}
172
- text.split("\n").each do |line|
173
- key, value = line.split("=")
174
- result[key.to_sym] = value
191
+ return text.split("\n").inject({}) do |result, line|
192
+ key, *values = line.split('=')
193
+ result[key] = values.join('=')
194
+ result
175
195
  end
176
- return result
177
196
  end
178
197
  end
179
198
  end
@@ -50,7 +50,7 @@ module AdsCommon
50
50
 
51
51
  def prepare_template_strings()
52
52
  @generator_stamp = "Code generated by AdsCommon library %s on %s." %
53
- [AdsCommon::ApiConfig::ADS_COMMON_VERSION,
53
+ [AdsCommon::ApiConfig::CLIENT_LIB_VERSION,
54
54
  Time.now.strftime("%Y-%m-%d %H:%M:%S")]
55
55
  @modules_open_string = 'module ' +
56
56
  [@api_name, @version.to_s.upcase, @service_name].join('; module ')
@@ -20,7 +20,6 @@
20
20
  # Configuration handler, can load data from a YAML configuration file and
21
21
  # rewrite it in memory.
22
22
 
23
- require 'rubygems'
24
23
  require 'yaml'
25
24
 
26
25
  require 'ads_common/errors'
@@ -48,6 +48,17 @@ module AdsCommon
48
48
  end
49
49
  end
50
50
 
51
+ # Raised when ClientLogin Captcha challenge occurs.
52
+ class CaptchaRequiredError < AuthError
53
+ attr_reader :error, :captcha_token
54
+ attr_reader :captcha_url, :auth_url
55
+ def initialize(error, captcha_token, captcha_url, auth_url)
56
+ super()
57
+ @error, @captcha_token = error, captcha_token
58
+ @captcha_url, @auth_url = captcha_url, auth_url
59
+ end
60
+ end
61
+
51
62
  # Raised if a required property on an object is missing.
52
63
  class MissingPropertyError < Error
53
64
  attr_reader :property, :object_type
@@ -26,6 +26,9 @@ require 'ads_common/errors'
26
26
 
27
27
  module AdsCommon
28
28
  module Http
29
+ # HTTP read and open timeouts in seconds.
30
+ HTTP_READ_TIMEOUT = 15 * 60
31
+ HTTP_OPEN_TIMEOUT = 5 * 60
29
32
 
30
33
  # Performs a get on a URL, using all of the connection options in the
31
34
  # client library, returning a HTTPI::Response.
@@ -45,8 +48,7 @@ module AdsCommon
45
48
  # client library, returning a HTTPI::Response.
46
49
  def self.post_response(url, data, config = nil, headers = nil)
47
50
  request = prepare_request(url, config, headers, data)
48
- response = HTTPI.post(request)
49
- return response
51
+ return HTTPI.post(request)
50
52
  end
51
53
 
52
54
  # Performs a post on a URL, using all of the connection options in the
@@ -63,19 +65,32 @@ module AdsCommon
63
65
  request = HTTPI::Request.new(url)
64
66
  request.headers = headers if headers
65
67
  request.body = data if data
68
+ configure_httpi(config, request)
69
+ return request
70
+ end
71
+
72
+ # Configures HTTPI request according to the config provided.
73
+ def self.configure_httpi(config, httpi)
66
74
  if config
67
- proxy = config.read('connection.proxy', nil)
68
- request.proxy = proxy if !proxy.nil?
69
- strict_ssl =
70
- !(config.read('connection.strict_ssl_verification') == 'false')
71
- request.auth.ssl.verify_mode = strict_ssl ? :peer : :none
75
+ adapter = config.read('connection.adapter')
76
+ HTTPI.adapter = adapter if adapter
77
+ proxy = config.read('connection.proxy')
78
+ httpi.proxy = proxy if proxy
79
+ enable_gzip = config.read('connection.enable_gzip', false)
80
+ httpi.gzip if enable_gzip
72
81
  logger = config.read('library.logger')
73
82
  if logger
74
83
  HTTPI.logger = logger
75
84
  HTTPI.log_level = :debug
76
85
  end
77
86
  end
78
- return request
87
+ httpi.read_timeout = (config.nil?) ? HTTP_READ_TIMEOUT :
88
+ config.read('connection.read_timeout', HTTP_READ_TIMEOUT)
89
+ httpi.open_timeout = (config.nil?) ? HTTP_OPEN_TIMEOUT :
90
+ config.read('connection.open_timeout', HTTP_OPEN_TIMEOUT)
91
+ strict_ssl = config.nil? or
92
+ config.read('connection.strict_ssl_verification', true)
93
+ httpi.auth.ssl.verify_mode = strict_ssl ? :peer : :none
79
94
  end
80
95
  end
81
96
  end
@@ -89,7 +89,7 @@ module AdsCommon
89
89
  app_name = credentials[:userAgent] || credentials[:useragent]
90
90
  # We don't know the library version here. A breaking change needs to be
91
91
  # introduced. This is scheduled for 0.7.0, using Common version for now.
92
- lib_version = '0.6.2'
92
+ lib_version = '0.6.3'
93
93
  soap_user_agent = "Common-Ruby-%s; %s" % [lib_version, app_name]
94
94
  user_agent = "Savon/%s (%s)" % [Savon::Version, soap_user_agent]
95
95
  user_agent += ' (gzip)' if @config.read('connection.enable_gzip', false)
@@ -22,13 +22,11 @@
22
22
  require 'httpi'
23
23
  require 'savon'
24
24
 
25
+ require 'ads_common/http'
25
26
  require 'ads_common/parameters_validator'
26
27
 
27
28
  module AdsCommon
28
29
  class SavonService
29
- # HTTP read timeout in seconds.
30
- HTTP_READ_TIMEOUT = 15 * 60
31
-
32
30
  attr_accessor :headerhandler
33
31
  attr_reader :api
34
32
  attr_reader :version
@@ -52,8 +50,6 @@ module AdsCommon
52
50
  config.log_level = :debug
53
51
  config.logger = logger
54
52
  end
55
- HTTPI.logger = logger
56
- HTTPI.log_level = :debug
57
53
  end
58
54
 
59
55
  # Returns ServiceRegistry for the current service. Has to be overridden.
@@ -68,14 +64,10 @@ module AdsCommon
68
64
 
69
65
  # Creates and sets up Savon client.
70
66
  def create_savon_client(endpoint, namespace)
71
- proxy = @api.config.read('connection.proxy')
72
- enable_gzip = @api.config.read('connection.enable_gzip', false)
73
- client = Savon::Client.new do |wsdl, http|
67
+ client = Savon::Client.new do |wsdl, httpi|
74
68
  wsdl.endpoint = endpoint
75
69
  wsdl.namespace = namespace
76
- http.read_timeout = HTTP_READ_TIMEOUT
77
- http.proxy = proxy if proxy
78
- http.gzip if enable_gzip
70
+ AdsCommon::Http.configure_httpi(@api.config, httpi)
79
71
  end
80
72
  return client
81
73
  end
@@ -92,6 +84,7 @@ module AdsCommon
92
84
  end
93
85
 
94
86
  # Logs response headers.
87
+ # TODO: this needs to go on http or httpi level.
95
88
  def log_headers(headers)
96
89
  @api.logger.debug(headers.map {|k, v| [k, v].join(': ')}.join(', '))
97
90
  end
@@ -0,0 +1,26 @@
1
+ # Encoding: utf-8
2
+ #
3
+ # Authors:: api.dklimkin@gmail.com (Danial Klimkin)
4
+ #
5
+ # Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
6
+ #
7
+ # License:: Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16
+ # implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # Module to keep the current library version.
21
+
22
+ module AdsCommon
23
+ module ApiConfig
24
+ CLIENT_LIB_VERSION = '0.6.3'
25
+ end
26
+ end
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
7
+ #
8
+ # License:: Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
+ # implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+ # Tests client login handler methods.
22
+
23
+ require 'test/unit'
24
+
25
+ require 'ads_common/config'
26
+ require 'ads_common/auth/client_login_handler'
27
+
28
+ module AdsCommon
29
+ module Auth
30
+ class ClientLoginHandler
31
+ public :parse_token_text
32
+ public :handle_login_error
33
+ end
34
+ end
35
+ end
36
+
37
+ # Stub class for HTTP response.
38
+ class ResponseStub
39
+ attr_reader :code
40
+ attr_reader :body
41
+
42
+ def initialize(code, body)
43
+ @code, @body = code, body
44
+ end
45
+ end
46
+
47
+ class TestParametersValidator < Test::Unit::TestCase
48
+ def setup
49
+ config = AdsCommon::Config.new({})
50
+ @handler = AdsCommon::Auth::ClientLoginHandler.new(
51
+ config, 'http://www.google.com', nil)
52
+ end
53
+
54
+ def test_handle_login_error_captcha
55
+ assert_raises (AdsCommon::Errors::CaptchaRequiredError) do
56
+ response = ResponseStub.new(403, '')
57
+ results = {
58
+ 'Error' => 'CaptchaRequired',
59
+ 'CaptchaUrl' => '/account/test-captcha'
60
+ }
61
+ @handler.handle_login_error({}, response, results)
62
+ end
63
+ end
64
+
65
+ def test_handle_login_error_other
66
+ assert_raises (AdsCommon::Errors::AuthError) do
67
+ response = ResponseStub.new(403, 'Body')
68
+ results = {'Error' => 'SomeError', 'Info' => 'SomeInfo'}
69
+ @handler.handle_login_error({}, response, results)
70
+ end
71
+ end
72
+
73
+ def test_parse_token_text_simple
74
+ error_str = "BadAuthentication"
75
+ text = "Error=%s\n" % error_str
76
+ result = @handler.parse_token_text(text)
77
+ assert_equal(error_str, result['Error'])
78
+ assert_equal(['Error'], result.keys)
79
+ end
80
+
81
+ def test_parse_token_text_captcha
82
+ captcha_token = "3u6_27iOel71j525g2tg252ge6t35g345XJtRuHYEYiTyAxsMPz2222442"
83
+ captcha_url = "Captcha?ctoken=3u245245rgfwrg5g2fw5x3xGqQBrk_AoXXJtRuHY%3a-V"
84
+ error_str = "CaptchaRequired"
85
+ url_str = "https://www.google.com/accounts/ErrorMsg?Email=example%40goog" +
86
+ "le.com&service=adwords&id=cr&timeStmp=1327400499&secTok=.AG5fkgtw45" +
87
+ "25gfref25gttrefwwrPeB8Xw%3D%3D"
88
+ text = "CaptchaToken=%s\nCaptchaUrl=%s\nError=%s\nUrl=%s\n" %
89
+ [captcha_token, captcha_url, error_str, url_str]
90
+ result = @handler.parse_token_text(text)
91
+ assert_equal(captcha_token, result['CaptchaToken'])
92
+ assert_equal(captcha_url, result['CaptchaUrl'])
93
+ assert_equal(error_str, result['Error'])
94
+ assert_equal(url_str, result['Url'])
95
+ assert_equal(['CaptchaToken', 'CaptchaUrl', 'Error', 'Url'],
96
+ result.keys.sort)
97
+ end
98
+ end
@@ -20,8 +20,8 @@
20
20
  #
21
21
  # Tests the array replies from services.
22
22
 
23
- require 'rubygems'
24
23
  require 'test/unit'
24
+
25
25
  require 'ads_common/config'
26
26
 
27
27
  class TestConfig < Test::Unit::TestCase
@@ -0,0 +1,11 @@
1
+ ---
2
+ # This is a test configuration file for Ads Common library.
3
+ :authentication:
4
+ :method: ClientLogin
5
+ :application_name: ruby_test_suit
6
+ :password: mySecretPassword
7
+ :email: root@example.com
8
+ :network_code: 1234567
9
+ :service:
10
+ :environment: sandbox
11
+ :use_ruby_names: false
@@ -20,7 +20,6 @@
20
20
  #
21
21
  # Tests validator methods.
22
22
 
23
- require 'rubygems'
24
23
  require 'test/unit'
25
24
 
26
25
  require 'ads_common/errors'
@@ -20,7 +20,6 @@
20
20
  #
21
21
  # Tests the array replies from services.
22
22
 
23
- require 'rubygems'
24
23
  require 'test/unit'
25
24
 
26
25
  require 'ads_common/config'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-ads-common
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Gomes
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-01-16 00:00:00 +04:00
19
+ date: 2012-03-13 00:00:00 +04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -83,43 +83,44 @@ dependencies:
83
83
  version: 0.4.5
84
84
  type: :runtime
85
85
  version_requirements: *id004
86
- description: google-ads-common provides essential utilities shared by all Ads Ruby client libraries.
87
- email: api.dklimkin@gmail.com
86
+ description: Essential utilities shared by all Ads Ruby client libraries
87
+ email:
88
+ - api.dklimkin@gmail.com
88
89
  executables: []
89
90
 
90
91
  extensions: []
91
92
 
92
- extra_rdoc_files:
93
- - README
94
- - COPYING
95
- - ChangeLog
93
+ extra_rdoc_files: []
94
+
96
95
  files:
97
- - lib/ads_common/auth/client_login_handler.rb
98
- - lib/ads_common/auth/base_handler.rb
99
- - lib/ads_common/auth/oauth_handler.rb
100
- - lib/ads_common/credential_handler.rb
101
- - lib/ads_common/build/savon_generator.rb
102
- - lib/ads_common/build/savon_registry_generator.rb
103
- - lib/ads_common/build/savon_registry.rb
104
- - lib/ads_common/build/savon_service_generator.rb
105
- - lib/ads_common/build/savon_abstract_generator.rb
106
- - lib/ads_common/api_config.rb
107
- - lib/ads_common/config.rb
108
96
  - lib/ads_common/api.rb
109
- - lib/ads_common/savon_headers/base_header_handler.rb
110
- - lib/ads_common/savon_headers/simple_header_handler.rb
111
- - lib/ads_common/savon_headers/oauth_header_handler.rb
112
- - lib/ads_common/savon_headers/httpi_request_proxy.rb
97
+ - lib/ads_common/version.rb
98
+ - lib/ads_common/credential_handler.rb
113
99
  - lib/ads_common/savon_service.rb
100
+ - lib/ads_common/api_config.rb
101
+ - lib/ads_common/auth/client_login_handler.rb
102
+ - lib/ads_common/auth/oauth_handler.rb
103
+ - lib/ads_common/auth/base_handler.rb
114
104
  - lib/ads_common/http.rb
115
- - lib/ads_common/parameters_validator.rb
116
105
  - lib/ads_common/errors.rb
117
- - Rakefile
118
- - test/test_config.rb
119
- - test/test_parameters_validator.rb
106
+ - lib/ads_common/parameters_validator.rb
107
+ - lib/ads_common/savon_headers/oauth_header_handler.rb
108
+ - lib/ads_common/savon_headers/base_header_handler.rb
109
+ - lib/ads_common/savon_headers/httpi_request_proxy.rb
110
+ - lib/ads_common/savon_headers/simple_header_handler.rb
111
+ - lib/ads_common/build/savon_abstract_generator.rb
112
+ - lib/ads_common/build/savon_service_generator.rb
113
+ - lib/ads_common/build/savon_registry.rb
114
+ - lib/ads_common/build/savon_registry_generator.rb
115
+ - lib/ads_common/build/savon_generator.rb
116
+ - lib/ads_common/config.rb
120
117
  - test/test_savon_service.rb
121
- - README
118
+ - test/test_client_login_handler.rb
119
+ - test/test_parameters_validator.rb
120
+ - test/test_config.rb
121
+ - test/test_config.yml
122
122
  - COPYING
123
+ - README
123
124
  - ChangeLog
124
125
  has_rdoc: true
125
126
  homepage: http://code.google.com/p/google-api-ads-ruby/
@@ -144,18 +145,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
145
  requirements:
145
146
  - - ">="
146
147
  - !ruby/object:Gem::Version
147
- hash: 3
148
+ hash: 23
148
149
  segments:
149
- - 0
150
- version: "0"
150
+ - 1
151
+ - 3
152
+ - 6
153
+ version: 1.3.6
151
154
  requirements: []
152
155
 
153
- rubyforge_project:
156
+ rubyforge_project: google-ads-common
154
157
  rubygems_version: 1.3.7
155
158
  signing_key:
156
159
  specification_version: 3
157
- summary: Common code for Google Ads APIs.
160
+ summary: Common code for Google Ads APIs
158
161
  test_files:
159
- - test/test_config.rb
160
- - test/test_parameters_validator.rb
161
162
  - test/test_savon_service.rb
163
+ - test/test_client_login_handler.rb
164
+ - test/test_parameters_validator.rb
165
+ - test/test_config.rb
data/Rakefile DELETED
@@ -1,77 +0,0 @@
1
- # Encoding: utf-8
2
- #
3
- # Authors:: api.dklimkin@gmail.com (Danial Klimkin)
4
- #
5
- # Copyright:: Copyright 2010, Google Inc. All Rights Reserved.
6
- #
7
- # License:: Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16
- # implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
- # Rakefile for the ads_common package.
21
-
22
- require 'rubygems'
23
- require 'rubygems/package_task'
24
- require 'rake/testtask'
25
- require 'rdoc/task'
26
- require './lib/ads_common/api_config'
27
-
28
- GEM_NAME = 'google-ads-common'
29
-
30
- files = FileList['lib/**/*', 'Rakefile'].to_a
31
- tests = FileList['test/**/test_*.rb']
32
- docs = ['README', 'COPYING', 'ChangeLog']
33
- extra_files = ['test/test_config.yml']
34
-
35
- spec = Gem::Specification.new do |s|
36
- s.platform = Gem::Platform::RUBY
37
- s.name = GEM_NAME
38
- s.version = AdsCommon::ApiConfig::ADS_COMMON_VERSION
39
- s.summary = 'Common code for Google Ads APIs.'
40
- s.description = ("%s provides essential utilities shared by all Ads Ruby " +
41
- "client libraries.") % GEM_NAME
42
- s.authors = ['Sergio Gomes', 'Danial Klimkin']
43
- s.email = 'api.dklimkin@gmail.com'
44
- s.homepage = 'http://code.google.com/p/google-api-ads-ruby/'
45
- s.require_path = 'lib'
46
- s.files = files
47
- s.test_files = tests
48
- s.has_rdoc = true
49
- s.extra_rdoc_files = docs
50
- s.add_dependency('savon', '~> 0.9.7')
51
- s.add_dependency('httpclient', '~> 2.2.3')
52
- s.add_dependency('httpi', '~> 0.9.3')
53
- s.add_dependency('oauth', '~> 0.4.5')
54
- end
55
-
56
- desc 'Default target - build'
57
- task :default => [:package]
58
-
59
- # Create a task that will package the Common library into a gem file.
60
- Gem::PackageTask.new(spec) do |pkg|
61
- pkg.need_tar = true
62
- pkg.package_files.include(extra_files)
63
- end
64
-
65
- # Create a task to build the RDOC documentation tree.
66
- RDoc::Task.new do |rdoc|
67
- rdoc.rdoc_dir = 'doc'
68
- rdoc.title = "%s -- Common code for Google Ads APIs" % GEM_NAME
69
- rdoc.main = 'README'
70
- rdoc.rdoc_files.include(docs)
71
- rdoc.rdoc_files.include(files)
72
- end
73
-
74
- # Create a task to perform the unit testing.
75
- Rake::TestTask.new do |t|
76
- t.test_files = tests
77
- end