td 0.11.5 → 0.11.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NDllOTE4NDc3OTE2NmI4MTEyZTE4ZTZlNmI0NTg2ODFhZGRkNzRiOA==
5
- data.tar.gz: !binary |-
6
- ZjBiOWUwYjMwMWEwYTczODYyNjMxMTJiMWY2ODc0ZDEyNTVjYmQ4ZA==
2
+ SHA1:
3
+ metadata.gz: fbc07ea58b09419ef7a3ba5dd850af222c8af299
4
+ data.tar.gz: db4fd8cfdece04ac1c94b3b68d8a642488c07be5
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDMyNTc0YjNmNmM4ODlhYWE4M2ZlNWVlNGJjYzUzYTg4MmJhYzZhZjAyYTJj
10
- ZmZhYTYxNTg4NmZmNzczYjg0ZWM4ZmU5Y2E2MWIxYjE3N2Y0YmEyZmNjZjVj
11
- YTE5NzFkMjY3NzA5YTM3MThhMTU2NjNhNTBlM2UxM2JmMzI5NTI=
12
- data.tar.gz: !binary |-
13
- ODBiOTk0ZmYzMzgyMDgxNDRkMDI0Njc0YmE5YTI1NTlmZDUwYzNiODk1M2Iw
14
- MmE2ODk4N2E0MjIzNTRmY2I0ZDU2OWIwYWIxZjFkNmZiOTkxZTY0MTBkYzAz
15
- MGVlNjE1MDJhMzRmNjk1OTMxYzVlNzRkOTFhMmQyNDNmYzIyZTc=
6
+ metadata.gz: cebcfe70d4474b64ae1b440981f9aee6c200f3b6b3e4b09c2dc1137faa7a2495e6f9e86ef8527181613c9d41af569d77ebf9091327d3e088e3e79bcfb95e7107
7
+ data.tar.gz: a261af1042634927563564043865d7e41e232c1bf048af3759025c5a46039fd64391b3d54900beb427371b93c3e6f19349194aa4246a14cc93ba3b17df1da2e0
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 2014-12-03 version 0.11.6
2
+
3
+ * Support HTTP proxy for bulk import
4
+
1
5
  == 2014-10-16 version 0.11.5
2
6
 
3
7
  * Updated 'td-client' gem dependency to 0.8.66. The new gem addresses the
@@ -25,11 +25,13 @@ module Command
25
25
  end
26
26
 
27
27
  def import_jar_version(op)
28
+ op.cmd_parse
28
29
  version = find_version_file
29
30
  puts "td-import-java #{File.open(version, 'r').read}"
30
31
  end
31
32
 
32
33
  def import_jar_update(op)
34
+ op.cmd_parse
33
35
  check_n_update_jar(false)
34
36
  end
35
37
 
@@ -233,7 +235,9 @@ module Command
233
235
  end
234
236
 
235
237
  sysprops << "-Dhttp.proxyHost=#{proxy_host}" if proxy_host
238
+ sysprops << "-Dhttps.proxyHost=#{ proxy_host}" if proxy_host
236
239
  sysprops << "-Dhttp.proxyPort=#{proxy_port}" if proxy_port
240
+ sysprops << "-Dhttps.proxyPort=#{ proxy_port}" if proxy_port
237
241
  end
238
242
 
239
243
  #
data/lib/td/updater.rb CHANGED
@@ -9,37 +9,38 @@ module Updater
9
9
  # Toolbelt upgrade
10
10
  #
11
11
 
12
- def self.raise_error(message)
12
+ module ModuleDefinition
13
+ def raise_error(message)
13
14
  # TODO: Replace better Exception class
14
15
  raise Command::UpdateError, message
15
16
  end
16
17
 
17
18
  # copied from TreasureData::Helpers to avoid load issue.
18
- def self.home_directory
19
+ def home_directory
19
20
  on_windows? ? ENV['USERPROFILE'].gsub("\\","/") : ENV['HOME']
20
21
  end
21
22
 
22
- def self.on_windows?
23
+ def on_windows?
23
24
  RUBY_PLATFORM =~ /mswin32|mingw32/
24
25
  end
25
26
 
26
- def self.on_mac?
27
+ def on_mac?
27
28
  RUBY_PLATFORM =~ /-darwin\d/
28
29
  end
29
30
 
30
- def self.updating_lock_path
31
+ def updating_lock_path
31
32
  File.join(home_directory, ".td", "updating")
32
33
  end
33
34
 
34
- def self.installed_client_path
35
+ def installed_client_path
35
36
  File.expand_path("../../../../../..", __FILE__)
36
37
  end
37
38
 
38
- def self.updated_client_path
39
+ def updated_client_path
39
40
  File.join(home_directory, ".td", "updated")
40
41
  end
41
42
 
42
- def self.latest_local_version
43
+ def latest_local_version
43
44
  installed_version = client_version_from_path(installed_client_path)
44
45
  updated_version = client_version_from_path(updated_client_path)
45
46
  if compare_versions(updated_version, installed_version) > 0
@@ -49,7 +50,7 @@ module Updater
49
50
  end
50
51
  end
51
52
 
52
- def self.get_client_version_file(path)
53
+ def get_client_version_file(path)
53
54
  td_gems = Dir[File.join(path, "vendor/gems/td-*")]
54
55
  td_gems.each { |td_gem|
55
56
  if td_gem =~ /#{"#{Regexp.escape(path)}\/vendor\/gems\/td-\\d*.\\d*.\\d*"}/
@@ -59,7 +60,7 @@ module Updater
59
60
  nil
60
61
  end
61
62
 
62
- def self.client_version_from_path(path)
63
+ def client_version_from_path(path)
63
64
  if version_file = get_client_version_file(path)
64
65
  File.read(version_file).match(/TOOLBELT_VERSION = '([^']+)'/)[1]
65
66
  else
@@ -67,19 +68,19 @@ module Updater
67
68
  end
68
69
  end
69
70
 
70
- def self.disable(message)
71
+ def disable(message)
71
72
  @disable = message
72
73
  end
73
74
 
74
- def self.disable?
75
+ def disable?
75
76
  !@disable.nil?
76
77
  end
77
78
 
78
- def self.disable_message
79
+ def disable_message
79
80
  @disable
80
81
  end
81
82
 
82
- def self.wait_for_lock(path, wait_for = 5, check_every = 0.5)
83
+ def wait_for_lock(path, wait_for = 5, check_every = 0.5)
83
84
  start = Time.now.to_i
84
85
  while File.exists?(path)
85
86
  sleep check_every
@@ -96,7 +97,7 @@ module Updater
96
97
  ret
97
98
  end
98
99
 
99
- def self.package_category
100
+ def package_category
100
101
  case
101
102
  when on_windows?
102
103
  'exe'
@@ -107,7 +108,7 @@ module Updater
107
108
  end
108
109
  end
109
110
 
110
- def self.fetch(url)
111
+ def fetch(url)
111
112
  require 'net/http'
112
113
  require 'openssl'
113
114
 
@@ -118,8 +119,7 @@ module Updater
118
119
  # So we use following code to avoid these issues.
119
120
  uri = URI(url)
120
121
  response =
121
- if uri.scheme == 'https' and ENV['HTTP_PROXY'].nil?
122
- # NOTE: SSL is force off for communications over proxy
122
+ if uri.scheme == 'https'
123
123
  http = http_class.new(uri.host, uri.port)
124
124
  http.use_ssl = true
125
125
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -137,23 +137,19 @@ module Updater
137
137
  end
138
138
  end
139
139
 
140
- def self.endpoint_root
140
+ def endpoint_root
141
141
  ENV['TD_TOOLBELT_UPDATE_ROOT'] || "http://toolbelt.treasuredata.com"
142
142
  end
143
143
 
144
- def maven_repo_root
145
- ENV['TD_TOOLBELT_JARUPDATE_ROOT'] || "http://central.maven.org"
146
- end
147
-
148
- def self.version_endpoint
144
+ def version_endpoint
149
145
  "#{endpoint_root}/version.#{package_category}"
150
146
  end
151
147
 
152
- def self.update_package_endpoint
148
+ def update_package_endpoint
153
149
  "#{endpoint_root}/td-update-#{package_category}.zip"
154
150
  end
155
151
 
156
- def self.update(autoupdate = false)
152
+ def update(autoupdate = false)
157
153
  wait_for_lock(updating_lock_path, 5) do
158
154
  require "td"
159
155
  require 'open-uri'
@@ -210,11 +206,11 @@ module Updater
210
206
  FileUtils.rm_f(updating_lock_path)
211
207
  end
212
208
 
213
- def self.compare_versions(first_version, second_version)
209
+ def compare_versions(first_version, second_version)
214
210
  first_version.split('.').map { |part| Integer(part) rescue part } <=> second_version.split('.').map { |part| Integer(part) rescue part }
215
211
  end
216
212
 
217
- def self.inject_libpath
213
+ def inject_libpath
218
214
  old_version = client_version_from_path(installed_client_path)
219
215
  new_version = client_version_from_path(updated_client_path)
220
216
 
@@ -247,7 +243,7 @@ module Updater
247
243
  FileUtils.touch last_toolbelt_autoupdate_timestamp
248
244
  end
249
245
 
250
- def self.last_toolbelt_autoupdate_timestamp
246
+ def last_toolbelt_autoupdate_timestamp
251
247
  File.join(home_directory, ".td", "autoupdate.last")
252
248
  end
253
249
 
@@ -256,20 +252,18 @@ module Updater
256
252
  #
257
253
 
258
254
  # locate the root of the td package which is 3 folders up from the location of this file
259
- def self.jarfile_dest_path
255
+ def jarfile_dest_path
260
256
  File.join(home_directory, ".td", "java")
261
257
  end
262
258
 
263
- private
264
- def self.stream_fetch(url, binfile, &progress)
259
+ def stream_fetch(url, binfile, &progress)
265
260
  require 'net/http'
266
261
 
267
262
  uri = URI(url)
268
263
  http_class = Command.get_http_class
269
264
  http = http_class.new(uri.host, uri.port)
270
265
 
271
- # NOTE: keep SSL off when using a proxy
272
- if uri.scheme == 'https' and ENV['HTTP_PROXY'].nil?
266
+ if uri.scheme == 'https'
273
267
  http.use_ssl = true
274
268
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
275
269
  end
@@ -289,13 +283,19 @@ module Updater
289
283
  end
290
284
  return stream_fetch(response['Location'], binfile, &progress)
291
285
  else
292
- raise_error
293
- "An error occurred when fetching from '#{uri}' " +
286
+ raise_error "An error occurred when fetching from '#{uri}' " +
294
287
  "(#{response.class.to_s}: #{response.message})."
295
288
  return false
296
289
  end
297
290
  }
298
291
  end
292
+ end # module ModuleDefinition
293
+
294
+ extend ModuleDefinition
295
+
296
+ def maven_repo_root
297
+ ENV['TD_TOOLBELT_JARUPDATE_ROOT'] || "http://central.maven.org"
298
+ end
299
299
 
300
300
  private
301
301
  def jar_update(hourly = false)
@@ -410,4 +410,4 @@ module Updater
410
410
  end
411
411
 
412
412
  end # module Updater
413
- end # module TreasureData
413
+ end # module TreasureData
data/lib/td/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TreasureData
2
- TOOLBELT_VERSION = '0.11.5'
2
+ TOOLBELT_VERSION = '0.11.6'
3
3
  end
@@ -0,0 +1,23 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIID0DCCArigAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
3
+ MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
4
+ DTA0MDEzMDAwNDIzMloXDTM2MDEyMjAwNDIzMlowPDELMAkGA1UEBgwCSlAxEjAQ
5
+ BgNV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t9YWoFBIqth0L
13
+ mGSYFu9ZhvZkvQNV8eYrAkBJ+rOIaLDsmbrgkeDruH+B/9yrm4McDtQ/rgnOGYnH
14
+ LjLpLLOrgUxqpzLWe++EwSLwK2//dHO+SPsQJ4xsyQJy
15
+ -----END RSA PRIVATE KEY-----
Binary file
@@ -1,5 +1,10 @@
1
1
  require 'spec_helper'
2
+ require 'td/command/common'
2
3
  require 'td/updater'
4
+ require 'webrick'
5
+ require 'webrick/https'
6
+ require 'webrick/httpproxy'
7
+ require 'logger'
3
8
 
4
9
  module TreasureData::Updater
5
10
 
@@ -32,4 +37,175 @@ module TreasureData::Updater
32
37
  ENV.delete 'TD_TOOLBELT_UPDATE_ROOT'
33
38
  end
34
39
  end
40
+
41
+ describe 'with a proxy' do
42
+ before :each do
43
+ setup_proxy_server
44
+ setup_server
45
+ end
46
+
47
+ after :each do
48
+ if @proxy_server
49
+ @proxy_server.shutdown
50
+ @proxy_server_thread.join
51
+ end
52
+ if @server
53
+ @server.shutdown
54
+ @server_thread.join
55
+ end
56
+ end
57
+
58
+ class TestUpdater
59
+ include TreasureData::Updater::ModuleDefinition
60
+
61
+ def initialize(endpoint_root)
62
+ @endpoint_root = endpoint_root
63
+ end
64
+
65
+ def updating_lock_path
66
+ File.expand_path("updating_lock_path.lock", File.dirname(__FILE__))
67
+ end
68
+
69
+ def on_windows?
70
+ true
71
+ end
72
+
73
+ def endpoint_root
74
+ @endpoint_root
75
+ end
76
+
77
+ def latest_local_version
78
+ '0.11.5'
79
+ end
80
+ end
81
+
82
+ class JarUpdateTester
83
+ include TreasureData::Updater
84
+
85
+ def kick
86
+ jar_update
87
+ end
88
+ end
89
+
90
+ it 'downloads tmp.zip via proxy and raise td version conflict' do
91
+ with_proxy do
92
+ expect {
93
+ TestUpdater.new("https://localhost:#{@server.config[:Port]}").update
94
+ }.to raise_error TreasureData::Command::UpdateError
95
+ end
96
+ end
97
+
98
+ it 'works' do
99
+ with_proxy do
100
+ with_env('TD_TOOLBELT_JARUPDATE_ROOT', "https://localhost:#{@server.config[:Port]}") do
101
+ expect {
102
+ JarUpdateTester.new.kick
103
+ }.not_to raise_error
104
+ end
105
+ end
106
+ end
107
+
108
+ def with_proxy
109
+ with_env('HTTP_PROXY', "http://localhost:#{@proxy_server.config[:Port]}") do
110
+ yield
111
+ end
112
+ end
113
+
114
+ def with_env(name, var)
115
+ backup, ENV[name] = ENV[name], var
116
+ begin
117
+ yield
118
+ ensure
119
+ ENV[name] = backup
120
+ end
121
+ end
122
+
123
+ def setup_proxy_server
124
+ logger = Logger.new(STDERR)
125
+ logger.progname = 'proxy'
126
+ logger.level = Logger::Severity::FATAL # avoid logging
127
+ @proxy_server = WEBrick::HTTPProxyServer.new(
128
+ :BindAddress => "localhost",
129
+ :Logger => logger,
130
+ :Port => 0,
131
+ :AccessLog => []
132
+ )
133
+ @proxy_server_thread = start_server_thread(@proxy_server)
134
+ @proxy_server
135
+ end
136
+
137
+ def setup_server
138
+ logger = Logger.new(STDERR)
139
+ logger.progname = 'server'
140
+ logger.level = Logger::Severity::FATAL # avoid logging
141
+ @server = WEBrick::HTTPServer.new(
142
+ :BindAddress => "localhost",
143
+ :Logger => logger,
144
+ :Port => 0,
145
+ :AccessLog => [],
146
+ :DocumentRoot => '.',
147
+ :SSLEnable => true,
148
+ :SSLCACertificateFile => fixture_file('ca.cert'),
149
+ :SSLCertificate => cert('server.cert'),
150
+ :SSLPrivateKey => key('server.key')
151
+ )
152
+ @serverport = @server.config[:Port]
153
+ @server.mount(
154
+ '/version.exe',
155
+ WEBrick::HTTPServlet::ProcHandler.new(method(:version).to_proc)
156
+ )
157
+ @server.mount(
158
+ '/td-update-exe.zip',
159
+ WEBrick::HTTPServlet::ProcHandler.new(method(:download).to_proc)
160
+ )
161
+ @server.mount(
162
+ '/maven2/com/treasuredata/td-import/maven-metadata.xml',
163
+ WEBrick::HTTPServlet::ProcHandler.new(method(:metadata).to_proc)
164
+ )
165
+ @server_thread = start_server_thread(@server)
166
+ @server
167
+ end
168
+
169
+ def version(req, res)
170
+ res['content-type'] = 'text/plain'
171
+ res.body = '0.11.6'
172
+ end
173
+
174
+ def download(req, res)
175
+ res['content-type'] = 'application/octet-stream'
176
+ res.body = File.read(fixture_file('tmp.zip'))
177
+ end
178
+
179
+ def metadata(req, res)
180
+ res['content-type'] = 'application/xml'
181
+ res.body = '<metadata><versioning><lastUpdated>20141204123456</lastUpdated><release>version</release></versioning></metadata>'
182
+ end
183
+
184
+ def start_server_thread(server)
185
+ t = Thread.new {
186
+ Thread.current.abort_on_exception = true
187
+ server.start
188
+ }
189
+ while server.status != :Running
190
+ sleep 0.1
191
+ unless t.alive?
192
+ t.join
193
+ raise
194
+ end
195
+ end
196
+ t
197
+ end
198
+
199
+ def cert(filename)
200
+ OpenSSL::X509::Certificate.new(File.read(fixture_file(filename)))
201
+ end
202
+
203
+ def key(filename)
204
+ OpenSSL::PKey::RSA.new(File.read(fixture_file(filename)))
205
+ end
206
+
207
+ def fixture_file(filename)
208
+ File.expand_path(File.join('fixture', filename), File.dirname(__FILE__))
209
+ end
210
+ end
35
211
  end
data/td.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency "yajl-ruby", "~> 1.1"
22
22
  gem.add_dependency "hirb", ">= 0.4.5"
23
23
  gem.add_dependency "parallel", "~> 0.6.1"
24
- gem.add_dependency "td-client", "~> 0.8.66"
24
+ gem.add_dependency "td-client", "~> 0.8.67"
25
25
  gem.add_dependency "td-logger", "~> 0.3.21"
26
26
  gem.add_dependency "rubyzip", "~> 0.9.9"
27
27
  gem.add_development_dependency "rake", "~> 0.9"
metadata CHANGED
@@ -1,32 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.5
4
+ version: 0.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Treasure Data, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-16 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.4.4
20
- - - ! '!='
20
+ - - '!='
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.5.0
23
- - - ! '!='
23
+ - - '!='
24
24
  - !ruby/object:Gem::Version
25
25
  version: 0.5.1
26
- - - ! '!='
26
+ - - '!='
27
27
  - !ruby/object:Gem::Version
28
28
  version: 0.5.2
29
- - - ! '!='
29
+ - - '!='
30
30
  - !ruby/object:Gem::Version
31
31
  version: 0.5.3
32
32
  - - <
@@ -36,19 +36,19 @@ dependencies:
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ! '>='
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.4.4
42
- - - ! '!='
42
+ - - '!='
43
43
  - !ruby/object:Gem::Version
44
44
  version: 0.5.0
45
- - - ! '!='
45
+ - - '!='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.5.1
48
- - - ! '!='
48
+ - - '!='
49
49
  - !ruby/object:Gem::Version
50
50
  version: 0.5.2
51
- - - ! '!='
51
+ - - '!='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.5.3
54
54
  - - <
@@ -72,14 +72,14 @@ dependencies:
72
72
  name: hirb
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ! '>='
75
+ - - '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: 0.4.5
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ! '>='
82
+ - - '>='
83
83
  - !ruby/object:Gem::Version
84
84
  version: 0.4.5
85
85
  - !ruby/object:Gem::Dependency
@@ -102,14 +102,14 @@ dependencies:
102
102
  requirements:
103
103
  - - ~>
104
104
  - !ruby/object:Gem::Version
105
- version: 0.8.66
105
+ version: 0.8.67
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - ~>
111
111
  - !ruby/object:Gem::Version
112
- version: 0.8.66
112
+ version: 0.8.67
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: td-logger
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -249,6 +249,10 @@ files:
249
249
  - spec/file_reader_spec.rb
250
250
  - spec/spec_helper.rb
251
251
  - spec/td/common_spec.rb
252
+ - spec/td/fixture/ca.cert
253
+ - spec/td/fixture/server.cert
254
+ - spec/td/fixture/server.key
255
+ - spec/td/fixture/tmp.zip
252
256
  - spec/td/helpers_spec.rb
253
257
  - spec/td/updater_spec.rb
254
258
  - spec/td/version_spec.rb
@@ -262,17 +266,17 @@ require_paths:
262
266
  - lib
263
267
  required_ruby_version: !ruby/object:Gem::Requirement
264
268
  requirements:
265
- - - ! '>='
269
+ - - '>='
266
270
  - !ruby/object:Gem::Version
267
271
  version: '1.9'
268
272
  required_rubygems_version: !ruby/object:Gem::Requirement
269
273
  requirements:
270
- - - ! '>='
274
+ - - '>='
271
275
  - !ruby/object:Gem::Version
272
276
  version: '0'
273
277
  requirements: []
274
278
  rubyforge_project:
275
- rubygems_version: 2.2.2
279
+ rubygems_version: 2.0.14
276
280
  signing_key:
277
281
  specification_version: 4
278
282
  summary: CLI to manage data on Treasure Data, the Hadoop-based cloud data warehousing
@@ -285,6 +289,10 @@ test_files:
285
289
  - spec/file_reader_spec.rb
286
290
  - spec/spec_helper.rb
287
291
  - spec/td/common_spec.rb
292
+ - spec/td/fixture/ca.cert
293
+ - spec/td/fixture/server.cert
294
+ - spec/td/fixture/server.key
295
+ - spec/td/fixture/tmp.zip
288
296
  - spec/td/helpers_spec.rb
289
297
  - spec/td/updater_spec.rb
290
298
  - spec/td/version_spec.rb