timber 2.6.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -38
- data/CHANGELOG.md +9 -0
- data/README.md +30 -284
- data/Rakefile +78 -0
- data/lib/timber.rb +6 -6
- data/lib/timber/config.rb +1 -83
- data/lib/timber/config/integrations.rb +1 -47
- data/lib/timber/context.rb +3 -24
- data/lib/timber/contexts.rb +2 -30
- data/lib/timber/contexts/http.rb +16 -36
- data/lib/timber/contexts/release.rb +12 -23
- data/lib/timber/contexts/runtime.rb +9 -36
- data/lib/timber/contexts/session.rb +8 -21
- data/lib/timber/contexts/system.rb +9 -16
- data/lib/timber/contexts/user.rb +13 -33
- data/lib/timber/current_context.rb +16 -78
- data/lib/timber/event.rb +12 -9
- data/lib/timber/events.rb +1 -33
- data/lib/timber/events/controller_call.rb +20 -31
- data/lib/timber/events/error.rb +18 -26
- data/lib/timber/events/exception.rb +1 -0
- data/lib/timber/events/sql_query.rb +14 -24
- data/lib/timber/events/template_render.rb +13 -24
- data/lib/timber/integration.rb +1 -1
- data/lib/timber/integrator.rb +1 -1
- data/lib/timber/log_devices/http.rb +98 -19
- data/lib/timber/log_entry.rb +6 -24
- data/lib/timber/logger.rb +5 -14
- data/lib/timber/util.rb +1 -6
- data/lib/timber/util/non_nil_hash_builder.rb +3 -1
- data/lib/timber/version.rb +1 -1
- data/spec/README.md +2 -8
- data/spec/spec_helper.rb +0 -7
- data/spec/support/timber.rb +1 -3
- data/spec/timber/current_context_spec.rb +12 -50
- data/spec/timber/events/controller_call_spec.rb +4 -4
- data/spec/timber/events/error_spec.rb +4 -9
- data/spec/timber/log_devices/http_spec.rb +26 -2
- data/spec/timber/log_entry_spec.rb +12 -6
- data/spec/timber/logger_spec.rb +27 -68
- data/timber.gemspec +1 -1
- metadata +5 -139
- data/gemfiles/rails-3.0.gemfile +0 -5
- data/gemfiles/rails-3.1.gemfile +0 -5
- data/gemfiles/rails-3.2.gemfile +0 -5
- data/gemfiles/rails-4.0.gemfile +0 -9
- data/gemfiles/rails-4.1.gemfile +0 -9
- data/gemfiles/rails-4.2.gemfile +0 -9
- data/gemfiles/rails-5.0.gemfile +0 -9
- data/gemfiles/rails-5.1.gemfile +0 -9
- data/gemfiles/rails-edge.gemfile +0 -7
- data/lib/timber/cli.rb +0 -60
- data/lib/timber/cli/api.rb +0 -183
- data/lib/timber/cli/api/application.rb +0 -34
- data/lib/timber/cli/config_file.rb +0 -71
- data/lib/timber/cli/file_helper.rb +0 -53
- data/lib/timber/cli/installer.rb +0 -70
- data/lib/timber/cli/installers.rb +0 -102
- data/lib/timber/cli/installers/config_file.rb +0 -51
- data/lib/timber/cli/installers/other.rb +0 -59
- data/lib/timber/cli/installers/rails.rb +0 -225
- data/lib/timber/cli/installers/root.rb +0 -116
- data/lib/timber/cli/io.rb +0 -100
- data/lib/timber/cli/io/ansi.rb +0 -22
- data/lib/timber/cli/io/messages.rb +0 -198
- data/lib/timber/cli/os_helper.rb +0 -74
- data/lib/timber/config/integrations/rack.rb +0 -74
- data/lib/timber/contexts/custom.rb +0 -44
- data/lib/timber/contexts/organization.rb +0 -48
- data/lib/timber/events/custom.rb +0 -53
- data/lib/timber/events/http_request.rb +0 -71
- data/lib/timber/events/http_response.rb +0 -81
- data/lib/timber/frameworks.rb +0 -19
- data/lib/timber/frameworks/rails.rb +0 -27
- data/lib/timber/integrations.rb +0 -29
- data/lib/timber/integrations/action_controller.rb +0 -18
- data/lib/timber/integrations/action_controller/log_subscriber.rb +0 -27
- data/lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb +0 -46
- data/lib/timber/integrations/action_dispatch.rb +0 -23
- data/lib/timber/integrations/action_dispatch/debug_exceptions.rb +0 -53
- data/lib/timber/integrations/action_view.rb +0 -18
- data/lib/timber/integrations/action_view/log_subscriber.rb +0 -27
- data/lib/timber/integrations/action_view/log_subscriber/timber_log_subscriber.rb +0 -83
- data/lib/timber/integrations/active_record.rb +0 -18
- data/lib/timber/integrations/active_record/log_subscriber.rb +0 -26
- data/lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb +0 -53
- data/lib/timber/integrations/rack.rb +0 -27
- data/lib/timber/integrations/rack/error_event.rb +0 -64
- data/lib/timber/integrations/rack/http_context.rb +0 -27
- data/lib/timber/integrations/rack/http_events.rb +0 -210
- data/lib/timber/integrations/rack/middleware.rb +0 -28
- data/lib/timber/integrations/rack/session_context.rb +0 -65
- data/lib/timber/integrations/rack/user_context.rb +0 -135
- data/lib/timber/integrations/rails.rb +0 -22
- data/lib/timber/integrations/rails/rack_logger.rb +0 -60
- data/lib/timber/overrides.rb +0 -12
- data/lib/timber/overrides/active_support_3_tagged_logging.rb +0 -111
- data/lib/timber/overrides/active_support_buffered_logger.rb +0 -22
- data/lib/timber/overrides/active_support_tagged_logging.rb +0 -66
- data/lib/timber/overrides/lograge.rb +0 -18
- data/lib/timber/overrides/rails_stdout_logging.rb +0 -21
- data/lib/timber/util/active_support_log_subscriber.rb +0 -37
- data/lib/timber/util/attribute_normalizer.rb +0 -89
- data/lib/timber/util/hash.rb +0 -90
- data/lib/timber/util/request.rb +0 -72
- data/lib/timber/util/struct.rb +0 -16
- data/spec/rails/tagged_logging_spec.rb +0 -44
- data/spec/support/action_controller.rb +0 -8
- data/spec/support/active_record.rb +0 -32
- data/spec/support/rails.rb +0 -67
- data/spec/support/rails/templates/_partial.html +0 -1
- data/spec/support/rails/templates/template.html +0 -1
- data/spec/timber/cli/config_file_spec.rb +0 -26
- data/spec/timber/cli/installers/config_file_spec.rb +0 -36
- data/spec/timber/cli/installers/other_spec.rb +0 -49
- data/spec/timber/cli/installers/rails_spec.rb +0 -364
- data/spec/timber/cli/installers/root_spec.rb +0 -73
- data/spec/timber/config_spec.rb +0 -28
- data/spec/timber/contexts/custom_spec.rb +0 -11
- data/spec/timber/contexts/organization_spec.rb +0 -11
- data/spec/timber/contexts/runtime_spec.rb +0 -11
- data/spec/timber/contexts/system_spec.rb +0 -11
- data/spec/timber/contexts/user_spec.rb +0 -11
- data/spec/timber/contexts_spec.rb +0 -49
- data/spec/timber/event_spec.rb +0 -10
- data/spec/timber/events/custom_spec.rb +0 -36
- data/spec/timber/events/http_request_spec.rb +0 -32
- data/spec/timber/events/http_response_spec.rb +0 -12
- data/spec/timber/events_spec.rb +0 -55
- data/spec/timber/integrations/action_controller/log_subscriber_spec.rb +0 -55
- data/spec/timber/integrations/action_dispatch/debug_exceptions_spec.rb +0 -53
- data/spec/timber/integrations/action_view/log_subscriber_spec.rb +0 -115
- data/spec/timber/integrations/active_record/log_subscriber_spec.rb +0 -46
- data/spec/timber/integrations/rack/error_event_spec.rb +0 -63
- data/spec/timber/integrations/rack/http_context_spec.rb +0 -60
- data/spec/timber/integrations/rack/http_events_spec.rb +0 -101
- data/spec/timber/integrations/rack/session_context_spec.rb +0 -62
- data/spec/timber/integrations/rails/rack_logger_spec.rb +0 -58
- data/spec/timber/util/attribute_normalizer_spec.rb +0 -90
- data/spec/timber/util/hash_spec.rb +0 -30
- data/spec/timber/util/request_spec.rb +0 -10
data/timber.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "https://github.com/timberio/timber-ruby"
|
12
12
|
s.summary = "Log Better. Solve Problems Faster. https://timber.io"
|
13
13
|
|
14
|
-
s.required_ruby_version = '>= 1.9.
|
14
|
+
s.required_ruby_version = '>= 1.9.3'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timber Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -152,40 +152,14 @@ files:
|
|
152
152
|
- Gemfile
|
153
153
|
- LICENSE.md
|
154
154
|
- README.md
|
155
|
+
- Rakefile
|
155
156
|
- bin/timber
|
156
|
-
- gemfiles/rails-3.0.gemfile
|
157
|
-
- gemfiles/rails-3.1.gemfile
|
158
|
-
- gemfiles/rails-3.2.gemfile
|
159
|
-
- gemfiles/rails-4.0.gemfile
|
160
|
-
- gemfiles/rails-4.1.gemfile
|
161
|
-
- gemfiles/rails-4.2.gemfile
|
162
|
-
- gemfiles/rails-5.0.gemfile
|
163
|
-
- gemfiles/rails-5.1.gemfile
|
164
|
-
- gemfiles/rails-edge.gemfile
|
165
157
|
- lib/timber.rb
|
166
|
-
- lib/timber/cli.rb
|
167
|
-
- lib/timber/cli/api.rb
|
168
|
-
- lib/timber/cli/api/application.rb
|
169
|
-
- lib/timber/cli/config_file.rb
|
170
|
-
- lib/timber/cli/file_helper.rb
|
171
|
-
- lib/timber/cli/installer.rb
|
172
|
-
- lib/timber/cli/installers.rb
|
173
|
-
- lib/timber/cli/installers/config_file.rb
|
174
|
-
- lib/timber/cli/installers/other.rb
|
175
|
-
- lib/timber/cli/installers/rails.rb
|
176
|
-
- lib/timber/cli/installers/root.rb
|
177
|
-
- lib/timber/cli/io.rb
|
178
|
-
- lib/timber/cli/io/ansi.rb
|
179
|
-
- lib/timber/cli/io/messages.rb
|
180
|
-
- lib/timber/cli/os_helper.rb
|
181
158
|
- lib/timber/config.rb
|
182
159
|
- lib/timber/config/integrations.rb
|
183
|
-
- lib/timber/config/integrations/rack.rb
|
184
160
|
- lib/timber/context.rb
|
185
161
|
- lib/timber/contexts.rb
|
186
|
-
- lib/timber/contexts/custom.rb
|
187
162
|
- lib/timber/contexts/http.rb
|
188
|
-
- lib/timber/contexts/organization.rb
|
189
163
|
- lib/timber/contexts/release.rb
|
190
164
|
- lib/timber/contexts/runtime.rb
|
191
165
|
- lib/timber/contexts/session.rb
|
@@ -195,37 +169,11 @@ files:
|
|
195
169
|
- lib/timber/event.rb
|
196
170
|
- lib/timber/events.rb
|
197
171
|
- lib/timber/events/controller_call.rb
|
198
|
-
- lib/timber/events/custom.rb
|
199
172
|
- lib/timber/events/error.rb
|
200
173
|
- lib/timber/events/exception.rb
|
201
|
-
- lib/timber/events/http_request.rb
|
202
|
-
- lib/timber/events/http_response.rb
|
203
174
|
- lib/timber/events/sql_query.rb
|
204
175
|
- lib/timber/events/template_render.rb
|
205
|
-
- lib/timber/frameworks.rb
|
206
|
-
- lib/timber/frameworks/rails.rb
|
207
176
|
- lib/timber/integration.rb
|
208
|
-
- lib/timber/integrations.rb
|
209
|
-
- lib/timber/integrations/action_controller.rb
|
210
|
-
- lib/timber/integrations/action_controller/log_subscriber.rb
|
211
|
-
- lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
|
212
|
-
- lib/timber/integrations/action_dispatch.rb
|
213
|
-
- lib/timber/integrations/action_dispatch/debug_exceptions.rb
|
214
|
-
- lib/timber/integrations/action_view.rb
|
215
|
-
- lib/timber/integrations/action_view/log_subscriber.rb
|
216
|
-
- lib/timber/integrations/action_view/log_subscriber/timber_log_subscriber.rb
|
217
|
-
- lib/timber/integrations/active_record.rb
|
218
|
-
- lib/timber/integrations/active_record/log_subscriber.rb
|
219
|
-
- lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
|
220
|
-
- lib/timber/integrations/rack.rb
|
221
|
-
- lib/timber/integrations/rack/error_event.rb
|
222
|
-
- lib/timber/integrations/rack/http_context.rb
|
223
|
-
- lib/timber/integrations/rack/http_events.rb
|
224
|
-
- lib/timber/integrations/rack/middleware.rb
|
225
|
-
- lib/timber/integrations/rack/session_context.rb
|
226
|
-
- lib/timber/integrations/rack/user_context.rb
|
227
|
-
- lib/timber/integrations/rails.rb
|
228
|
-
- lib/timber/integrations/rails/rack_logger.rb
|
229
177
|
- lib/timber/integrator.rb
|
230
178
|
- lib/timber/log_devices.rb
|
231
179
|
- lib/timber/log_devices/http.rb
|
@@ -233,68 +181,22 @@ files:
|
|
233
181
|
- lib/timber/log_devices/http/request_attempt.rb
|
234
182
|
- lib/timber/log_entry.rb
|
235
183
|
- lib/timber/logger.rb
|
236
|
-
- lib/timber/overrides.rb
|
237
|
-
- lib/timber/overrides/active_support_3_tagged_logging.rb
|
238
|
-
- lib/timber/overrides/active_support_buffered_logger.rb
|
239
|
-
- lib/timber/overrides/active_support_tagged_logging.rb
|
240
|
-
- lib/timber/overrides/lograge.rb
|
241
|
-
- lib/timber/overrides/rails_stdout_logging.rb
|
242
184
|
- lib/timber/timer.rb
|
243
185
|
- lib/timber/util.rb
|
244
|
-
- lib/timber/util/active_support_log_subscriber.rb
|
245
|
-
- lib/timber/util/attribute_normalizer.rb
|
246
|
-
- lib/timber/util/hash.rb
|
247
186
|
- lib/timber/util/non_nil_hash_builder.rb
|
248
|
-
- lib/timber/util/request.rb
|
249
|
-
- lib/timber/util/struct.rb
|
250
187
|
- lib/timber/version.rb
|
251
188
|
- spec/README.md
|
252
|
-
- spec/rails/tagged_logging_spec.rb
|
253
189
|
- spec/spec_helper.rb
|
254
|
-
- spec/support/action_controller.rb
|
255
|
-
- spec/support/active_record.rb
|
256
|
-
- spec/support/rails.rb
|
257
|
-
- spec/support/rails/templates/_partial.html
|
258
|
-
- spec/support/rails/templates/template.html
|
259
190
|
- spec/support/socket_hostname.rb
|
260
191
|
- spec/support/timber.rb
|
261
192
|
- spec/support/timecop.rb
|
262
193
|
- spec/support/webmock.rb
|
263
|
-
- spec/timber/cli/config_file_spec.rb
|
264
|
-
- spec/timber/cli/installers/config_file_spec.rb
|
265
|
-
- spec/timber/cli/installers/other_spec.rb
|
266
|
-
- spec/timber/cli/installers/rails_spec.rb
|
267
|
-
- spec/timber/cli/installers/root_spec.rb
|
268
|
-
- spec/timber/config_spec.rb
|
269
|
-
- spec/timber/contexts/custom_spec.rb
|
270
|
-
- spec/timber/contexts/organization_spec.rb
|
271
|
-
- spec/timber/contexts/runtime_spec.rb
|
272
|
-
- spec/timber/contexts/system_spec.rb
|
273
|
-
- spec/timber/contexts/user_spec.rb
|
274
|
-
- spec/timber/contexts_spec.rb
|
275
194
|
- spec/timber/current_context_spec.rb
|
276
|
-
- spec/timber/event_spec.rb
|
277
195
|
- spec/timber/events/controller_call_spec.rb
|
278
|
-
- spec/timber/events/custom_spec.rb
|
279
196
|
- spec/timber/events/error_spec.rb
|
280
|
-
- spec/timber/events/http_request_spec.rb
|
281
|
-
- spec/timber/events/http_response_spec.rb
|
282
|
-
- spec/timber/events_spec.rb
|
283
|
-
- spec/timber/integrations/action_controller/log_subscriber_spec.rb
|
284
|
-
- spec/timber/integrations/action_dispatch/debug_exceptions_spec.rb
|
285
|
-
- spec/timber/integrations/action_view/log_subscriber_spec.rb
|
286
|
-
- spec/timber/integrations/active_record/log_subscriber_spec.rb
|
287
|
-
- spec/timber/integrations/rack/error_event_spec.rb
|
288
|
-
- spec/timber/integrations/rack/http_context_spec.rb
|
289
|
-
- spec/timber/integrations/rack/http_events_spec.rb
|
290
|
-
- spec/timber/integrations/rack/session_context_spec.rb
|
291
|
-
- spec/timber/integrations/rails/rack_logger_spec.rb
|
292
197
|
- spec/timber/log_devices/http_spec.rb
|
293
198
|
- spec/timber/log_entry_spec.rb
|
294
199
|
- spec/timber/logger_spec.rb
|
295
|
-
- spec/timber/util/attribute_normalizer_spec.rb
|
296
|
-
- spec/timber/util/hash_spec.rb
|
297
|
-
- spec/timber/util/request_spec.rb
|
298
200
|
- timber.gemspec
|
299
201
|
homepage: https://github.com/timberio/timber-ruby
|
300
202
|
licenses: []
|
@@ -307,63 +209,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
307
209
|
requirements:
|
308
210
|
- - ">="
|
309
211
|
- !ruby/object:Gem::Version
|
310
|
-
version: 1.9.
|
212
|
+
version: 1.9.3
|
311
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
214
|
requirements:
|
313
215
|
- - ">="
|
314
216
|
- !ruby/object:Gem::Version
|
315
217
|
version: '0'
|
316
218
|
requirements: []
|
317
|
-
|
318
|
-
rubygems_version: 2.4.5.2
|
219
|
+
rubygems_version: 3.0.1
|
319
220
|
signing_key:
|
320
221
|
specification_version: 4
|
321
222
|
summary: Log Better. Solve Problems Faster. https://timber.io
|
322
223
|
test_files:
|
323
224
|
- spec/README.md
|
324
|
-
- spec/rails/tagged_logging_spec.rb
|
325
225
|
- spec/spec_helper.rb
|
326
|
-
- spec/support/action_controller.rb
|
327
|
-
- spec/support/active_record.rb
|
328
|
-
- spec/support/rails.rb
|
329
|
-
- spec/support/rails/templates/_partial.html
|
330
|
-
- spec/support/rails/templates/template.html
|
331
226
|
- spec/support/socket_hostname.rb
|
332
227
|
- spec/support/timber.rb
|
333
228
|
- spec/support/timecop.rb
|
334
229
|
- spec/support/webmock.rb
|
335
|
-
- spec/timber/cli/config_file_spec.rb
|
336
|
-
- spec/timber/cli/installers/config_file_spec.rb
|
337
|
-
- spec/timber/cli/installers/other_spec.rb
|
338
|
-
- spec/timber/cli/installers/rails_spec.rb
|
339
|
-
- spec/timber/cli/installers/root_spec.rb
|
340
|
-
- spec/timber/config_spec.rb
|
341
|
-
- spec/timber/contexts/custom_spec.rb
|
342
|
-
- spec/timber/contexts/organization_spec.rb
|
343
|
-
- spec/timber/contexts/runtime_spec.rb
|
344
|
-
- spec/timber/contexts/system_spec.rb
|
345
|
-
- spec/timber/contexts/user_spec.rb
|
346
|
-
- spec/timber/contexts_spec.rb
|
347
230
|
- spec/timber/current_context_spec.rb
|
348
|
-
- spec/timber/event_spec.rb
|
349
231
|
- spec/timber/events/controller_call_spec.rb
|
350
|
-
- spec/timber/events/custom_spec.rb
|
351
232
|
- spec/timber/events/error_spec.rb
|
352
|
-
- spec/timber/events/http_request_spec.rb
|
353
|
-
- spec/timber/events/http_response_spec.rb
|
354
|
-
- spec/timber/events_spec.rb
|
355
|
-
- spec/timber/integrations/action_controller/log_subscriber_spec.rb
|
356
|
-
- spec/timber/integrations/action_dispatch/debug_exceptions_spec.rb
|
357
|
-
- spec/timber/integrations/action_view/log_subscriber_spec.rb
|
358
|
-
- spec/timber/integrations/active_record/log_subscriber_spec.rb
|
359
|
-
- spec/timber/integrations/rack/error_event_spec.rb
|
360
|
-
- spec/timber/integrations/rack/http_context_spec.rb
|
361
|
-
- spec/timber/integrations/rack/http_events_spec.rb
|
362
|
-
- spec/timber/integrations/rack/session_context_spec.rb
|
363
|
-
- spec/timber/integrations/rails/rack_logger_spec.rb
|
364
233
|
- spec/timber/log_devices/http_spec.rb
|
365
234
|
- spec/timber/log_entry_spec.rb
|
366
235
|
- spec/timber/logger_spec.rb
|
367
|
-
- spec/timber/util/attribute_normalizer_spec.rb
|
368
|
-
- spec/timber/util/hash_spec.rb
|
369
|
-
- spec/timber/util/request_spec.rb
|
data/gemfiles/rails-3.0.gemfile
DELETED
data/gemfiles/rails-3.1.gemfile
DELETED
data/gemfiles/rails-3.2.gemfile
DELETED
data/gemfiles/rails-4.0.gemfile
DELETED
data/gemfiles/rails-4.1.gemfile
DELETED
data/gemfiles/rails-4.2.gemfile
DELETED
data/gemfiles/rails-5.0.gemfile
DELETED
data/gemfiles/rails-5.1.gemfile
DELETED
data/gemfiles/rails-edge.gemfile
DELETED
data/lib/timber/cli.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require "optparse"
|
2
|
-
require "yaml"
|
3
|
-
|
4
|
-
require "timber/cli/api"
|
5
|
-
require "timber/cli/installers"
|
6
|
-
require "timber/cli/io"
|
7
|
-
require "timber/version"
|
8
|
-
|
9
|
-
module Timber
|
10
|
-
# @private
|
11
|
-
class CLI
|
12
|
-
AVAILABLE_COMMANDS = %w(install).freeze
|
13
|
-
|
14
|
-
class << self
|
15
|
-
attr_accessor :options
|
16
|
-
|
17
|
-
def run(argv = ARGV)
|
18
|
-
global = global_option_parser
|
19
|
-
global.order!(argv)
|
20
|
-
command = argv.shift
|
21
|
-
|
22
|
-
case command
|
23
|
-
when nil
|
24
|
-
# Print help
|
25
|
-
puts global
|
26
|
-
exit(0)
|
27
|
-
|
28
|
-
when "install"
|
29
|
-
api_key = argv.shift
|
30
|
-
io = IO.new
|
31
|
-
Installers.run(api_key, io)
|
32
|
-
|
33
|
-
else
|
34
|
-
puts "Command '#{command}' does not exist, run timber -h to "\
|
35
|
-
"see the help"
|
36
|
-
exit(1)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def global_option_parser
|
41
|
-
OptionParser.new do |o|
|
42
|
-
o.banner = "Usage: timber <command> [options]"
|
43
|
-
|
44
|
-
o.on "-v", "--version", "Print version and exit" do |_arg|
|
45
|
-
puts "Timber #{Timber::VERSION}"
|
46
|
-
exit(0)
|
47
|
-
end
|
48
|
-
|
49
|
-
o.on "-h", "--help", "Show help and exit" do
|
50
|
-
puts o
|
51
|
-
exit(0)
|
52
|
-
end
|
53
|
-
|
54
|
-
o.separator ""
|
55
|
-
o.separator "Available commands: #{AVAILABLE_COMMANDS.join(", ")}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/lib/timber/cli/api.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
require "base64"
|
2
|
-
require "json"
|
3
|
-
require "net/https"
|
4
|
-
require "securerandom"
|
5
|
-
require "uri"
|
6
|
-
|
7
|
-
require "timber/cli/api/application"
|
8
|
-
require "timber/cli/io/messages"
|
9
|
-
require "timber/version"
|
10
|
-
|
11
|
-
module Timber
|
12
|
-
class CLI
|
13
|
-
# The API class provides an interface for all Timber API requests, parsing response
|
14
|
-
# and returning the appropriate objects.
|
15
|
-
class API
|
16
|
-
|
17
|
-
# Raise when the API key provided is invalid.
|
18
|
-
class APIKeyInvalidError < StandardError
|
19
|
-
def message
|
20
|
-
"Uh oh! The API key supplied is invalid. Please ensure that you copied the \n" \
|
21
|
-
"key properly.\n\n#{IO::Messages.obtain_key_instructions}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class LogsNotReceivedError< StandardError
|
26
|
-
def message
|
27
|
-
"Bummer, we couldn't confirm log delivery with the Timber API, something is off. " \
|
28
|
-
"If you email support@timber.io, we'll work with you to figure out what's going on. " \
|
29
|
-
"And as a thank you sticking with us, we'll set you up with a 25% indefinite discount."
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Raised when Timber is returning 500s
|
34
|
-
class ServerError < StandardError
|
35
|
-
def message
|
36
|
-
"Crap, it looks like the Timber API is returning 500s :/. In order to properly " \
|
37
|
-
"install Timber and test integration we need the Timber API to work correctly. " \
|
38
|
-
"Chances are we're aware of the issue and if you try again later the API should " \
|
39
|
-
"be working. \n\n" \
|
40
|
-
"Status updates: http://status.timber.io \n" \
|
41
|
-
"Yell at us via email: support@timber.io \n"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Raised when the API returns a response that a particular method is not expecting.
|
46
|
-
class UnrecognizedAPIResponse < StandardError
|
47
|
-
def initialize(res)
|
48
|
-
@res = res
|
49
|
-
end
|
50
|
-
|
51
|
-
def message
|
52
|
-
"Uh oh, we received a response from the Timber API that was not recognized " \
|
53
|
-
"(#{res.code}). We've been notified of the issue, but please feel free to " \
|
54
|
-
"yell at us via email to make sure we're aware: support@timber.io"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
TIMBER_PRODUCTION_API_URL = "https://api.timber.io".freeze
|
59
|
-
TIMBER_STAGING_API_URL = "https://api.timber-staging.io".freeze
|
60
|
-
TIMBER_API_URL = ENV['TIMBER_STAGING'] ? TIMBER_STAGING_API_URL : TIMBER_PRODUCTION_API_URL
|
61
|
-
TIMBER_API_URI = URI.parse(TIMBER_API_URL)
|
62
|
-
APPLICATION_PATH = "/installer/application".freeze
|
63
|
-
EVENT_PATH = "/installer/events".freeze
|
64
|
-
HAS_LOGS_PATH = "/installer/has_logs".freeze
|
65
|
-
USER_AGENT = "Timber Ruby/#{Timber::VERSION} (HTTP)".freeze
|
66
|
-
|
67
|
-
attr_accessor :api_key
|
68
|
-
|
69
|
-
def initialize(api_key)
|
70
|
-
@api_key = api_key
|
71
|
-
@session_id = SecureRandom.uuid
|
72
|
-
end
|
73
|
-
|
74
|
-
# Returns the application for the given API key.
|
75
|
-
def application!
|
76
|
-
res = get!(APPLICATION_PATH)
|
77
|
-
build_application(res)
|
78
|
-
end
|
79
|
-
|
80
|
-
# Hits the API to clone the app for the provided API key to the specified environment.
|
81
|
-
def clone_application!(environment)
|
82
|
-
return nil
|
83
|
-
end
|
84
|
-
|
85
|
-
# Sends an event to Timber so that we can understand how the installer is performing
|
86
|
-
# an ensure a top notch user experience. We do not raise here because it is not
|
87
|
-
# critical for the install process.
|
88
|
-
def event(name, data = {})
|
89
|
-
post!(EVENT_PATH, event: {name: name, data: data})
|
90
|
-
true
|
91
|
-
rescue Exception
|
92
|
-
false
|
93
|
-
end
|
94
|
-
|
95
|
-
# After test logs are sent to the Timber API this method waits for them to be
|
96
|
-
# received. This is how we test integration.
|
97
|
-
def wait_for_logs(iteration = 0, &block)
|
98
|
-
if block_given?
|
99
|
-
yield iteration
|
100
|
-
end
|
101
|
-
|
102
|
-
case iteration
|
103
|
-
when 20
|
104
|
-
event(:excessive_log_waiting)
|
105
|
-
when 60
|
106
|
-
raise LogsNotReceivedError.new
|
107
|
-
end
|
108
|
-
|
109
|
-
sleep 0.5
|
110
|
-
|
111
|
-
res = get!(HAS_LOGS_PATH)
|
112
|
-
|
113
|
-
case res.code
|
114
|
-
when "202"
|
115
|
-
wait_for_logs(iteration + 1, &block)
|
116
|
-
when "204"
|
117
|
-
true
|
118
|
-
else
|
119
|
-
raise UnrecognizedAPIResponse.new(res)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
private
|
124
|
-
def build_application(res)
|
125
|
-
parsed_body = JSON.parse(res.body)
|
126
|
-
attributes = parsed_body.fetch("data")
|
127
|
-
Application.new(attributes)
|
128
|
-
end
|
129
|
-
|
130
|
-
def get!(path)
|
131
|
-
req = Net::HTTP::Get.new(path)
|
132
|
-
issue!(req)
|
133
|
-
end
|
134
|
-
|
135
|
-
def post!(path, body)
|
136
|
-
req = Net::HTTP::Post.new(path)
|
137
|
-
req.body = body.to_json
|
138
|
-
req['Content-Type'] = "application/json"
|
139
|
-
issue!(req)
|
140
|
-
end
|
141
|
-
|
142
|
-
def issue!(req)
|
143
|
-
if api_key
|
144
|
-
req['Authorization'] = "Basic #{encoded_api_key}"
|
145
|
-
end
|
146
|
-
|
147
|
-
req['User-Agent'] = USER_AGENT
|
148
|
-
req['X-Installer-Session-Id'] = @session_id
|
149
|
-
res = http.start do |http|
|
150
|
-
http.request(req)
|
151
|
-
end
|
152
|
-
|
153
|
-
code = Integer(res.code)
|
154
|
-
|
155
|
-
if [401, 403].include?(code)
|
156
|
-
raise APIKeyInvalidError.new
|
157
|
-
elsif code >= 500
|
158
|
-
raise ServerError.new
|
159
|
-
else
|
160
|
-
res
|
161
|
-
end
|
162
|
-
rescue OpenSSL::SSL::SSLError => _e
|
163
|
-
if http.ssl_version != :TLSv1_2
|
164
|
-
http.ssl_version = :TLSv1_2
|
165
|
-
issue!(req)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def http
|
170
|
-
@http ||= begin
|
171
|
-
http = Net::HTTP.new(TIMBER_API_URI.host, TIMBER_API_URI.port)
|
172
|
-
http.use_ssl = true
|
173
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
174
|
-
http
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def encoded_api_key
|
179
|
-
Base64.urlsafe_encode64(@api_key).chomp
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|