timber 2.1.0.rc3 → 2.1.0.rc4
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.
- checksums.yaml +4 -4
- data/README.md +24 -17
- data/lib/timber/cli/api.rb +6 -3
- data/lib/timber/cli/api/application.rb +7 -2
- data/lib/timber/cli/config_file.rb +14 -17
- data/lib/timber/cli/file_helper.rb +21 -9
- data/lib/timber/cli/installer.rb +3 -1
- data/lib/timber/cli/installers.rb +47 -39
- data/lib/timber/cli/installers/config_file.rb +60 -0
- data/lib/timber/cli/installers/other.rb +11 -7
- data/lib/timber/cli/installers/rails.rb +93 -146
- data/lib/timber/cli/installers/root.rb +43 -27
- data/lib/timber/cli/io.rb +15 -3
- data/lib/timber/cli/io/messages.rb +3 -4
- data/lib/timber/current_context.rb +15 -3
- data/lib/timber/log_entry.rb +0 -10
- data/lib/timber/logger.rb +7 -3
- data/lib/timber/util.rb +0 -1
- data/lib/timber/util/http_event.rb +6 -18
- data/lib/timber/util/request.rb +32 -11
- data/lib/timber/version.rb +1 -1
- data/spec/timber/cli/config_file_spec.rb +23 -0
- data/spec/timber/cli/installers/config_file_spec.rb +58 -0
- data/spec/timber/cli/installers/other_spec.rb +50 -0
- data/spec/timber/cli/installers/rails_spec.rb +290 -95
- data/spec/timber/cli/installers/root_spec.rb +8 -7
- data/spec/timber/current_context_spec.rb +15 -15
- data/spec/timber/events/http_server_request_spec.rb +1 -1
- data/spec/timber/log_devices/http_spec.rb +2 -2
- data/spec/timber/logger_spec.rb +5 -5
- data/spec/timber/util/http_event_spec.rb +2 -2
- metadata +9 -3
- data/lib/timber/util/string.rb +0 -21
@@ -25,15 +25,16 @@ describe Timber::CLI::Installers::Root, :rails_23 => true do
|
|
25
25
|
it "should run properly" do
|
26
26
|
input.string = "y\n"
|
27
27
|
|
28
|
-
expect(installer).to receive(:install_platform).with(app).exactly(1).times
|
29
|
-
expect(installer).to receive(:run_sub_installer).with(app).exactly(1).times
|
30
|
-
expect(installer).to receive(:send_test_messages).exactly(1).times
|
31
|
-
expect(installer).to receive(:confirm_log_delivery).exactly(1).times
|
32
|
-
expect(installer).to receive(:
|
28
|
+
expect(installer).to receive(:install_platform).with(app).exactly(1).times
|
29
|
+
expect(installer).to receive(:run_sub_installer).with(app).exactly(1).times
|
30
|
+
expect(installer).to receive(:send_test_messages).exactly(1).times
|
31
|
+
expect(installer).to receive(:confirm_log_delivery).exactly(1).times
|
32
|
+
expect(installer).to receive(:wrap_up).with(app).exactly(1).times
|
33
33
|
expect(api).to receive(:event).with(:success).exactly(1).times
|
34
|
-
expect(installer).to receive(:collect_feedback).exactly(1).times
|
34
|
+
expect(installer).to receive(:collect_feedback).exactly(1).times
|
35
|
+
expect(installer).to receive(:free_data).exactly(1).times
|
35
36
|
|
36
|
-
|
37
|
+
installer.run(app)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -4,7 +4,7 @@ describe Timber::CurrentContext, :rails_23 => true do
|
|
4
4
|
describe ".initialize" do
|
5
5
|
it "should not set the release context" do
|
6
6
|
context = described_class.send(:new)
|
7
|
-
expect(context.send(:hash)).to
|
7
|
+
expect(context.send(:hash)[:release]).to be_nil
|
8
8
|
end
|
9
9
|
|
10
10
|
context "with Heroku dyno metadata" do
|
@@ -24,7 +24,7 @@ describe Timber::CurrentContext, :rails_23 => true do
|
|
24
24
|
|
25
25
|
it "should automatically set the release context" do
|
26
26
|
context = described_class.send(:new)
|
27
|
-
expect(context.send(:hash)).to eq({:
|
27
|
+
expect(context.send(:hash)[:release]).to eq({:commit_hash=>"2c3a0b24069af49b3de35b8e8c26765c1dba9ff0", :created_at=>"2015-04-02T18:00:42Z", :version=>"v2.3.1"})
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -45,7 +45,7 @@ describe Timber::CurrentContext, :rails_23 => true do
|
|
45
45
|
|
46
46
|
it "should automatically set the release context" do
|
47
47
|
context = described_class.send(:new)
|
48
|
-
expect(context.send(:hash)).to eq({:
|
48
|
+
expect(context.send(:hash)[:release]).to eq({:commit_hash=>"2c3a0b24069af49b3de35b8e8c26765c1dba9ff0", :created_at=>"2015-04-02T18:00:42Z", :version=>"v2.3.1"})
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -56,13 +56,13 @@ describe Timber::CurrentContext, :rails_23 => true do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should add the context" do
|
59
|
-
expect(described_class.instance.send(:hash)).to
|
59
|
+
expect(described_class.instance.send(:hash)[:custom]).to be_nil
|
60
60
|
|
61
61
|
described_class.add({build: {version: "1.0.0"}})
|
62
|
-
expect(described_class.instance.send(:hash)).to eq({:
|
62
|
+
expect(described_class.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}})
|
63
63
|
|
64
64
|
described_class.add({testing: {key: "value"}})
|
65
|
-
expect(described_class.instance.send(:hash)).to eq({:
|
65
|
+
expect(described_class.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}, :testing=>{:key=>"value"}})
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -70,37 +70,37 @@ describe Timber::CurrentContext, :rails_23 => true do
|
|
70
70
|
it "should remove the context by object" do
|
71
71
|
context = {:build=>{:version=>"1.0.0"}}
|
72
72
|
described_class.add(context)
|
73
|
-
expect(described_class.instance.send(:hash)).to eq(
|
73
|
+
expect(described_class.instance.send(:hash)[:custom]).to eq(context)
|
74
74
|
|
75
75
|
described_class.remove(context)
|
76
|
-
expect(described_class.instance.send(:hash)).to
|
76
|
+
expect(described_class.instance.send(:hash)[:custom]).to be_nil
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should remove context by key" do
|
80
80
|
context = {:build=>{:version=>"1.0.0"}}
|
81
81
|
described_class.add(context)
|
82
|
-
expect(described_class.instance.send(:hash)).to eq(
|
82
|
+
expect(described_class.instance.send(:hash)[:custom]).to eq(context)
|
83
83
|
|
84
84
|
described_class.remove(:custom)
|
85
|
-
expect(described_class.instance.send(:hash)).to
|
85
|
+
expect(described_class.instance.send(:hash)[:custom]).to be_nil
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
describe ".with" do
|
90
90
|
it "should merge the context and cleanup on block exit" do
|
91
|
-
expect(described_class.instance.send(:hash)).to
|
91
|
+
expect(described_class.instance.send(:hash)[:custom]).to be_nil
|
92
92
|
|
93
93
|
described_class.with({build: {version: "1.0.0"}}) do
|
94
|
-
expect(described_class.instance.send(:hash)).to eq({:
|
94
|
+
expect(described_class.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}})
|
95
95
|
|
96
96
|
described_class.with({testing: {key: "value"}}) do
|
97
|
-
expect(described_class.instance.send(:hash)).to eq({:
|
97
|
+
expect(described_class.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}, :testing=>{:key=>"value"}})
|
98
98
|
end
|
99
99
|
|
100
|
-
expect(described_class.instance.send(:hash)).to eq({:
|
100
|
+
expect(described_class.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}})
|
101
101
|
end
|
102
102
|
|
103
|
-
expect(described_class.instance.send(:hash)).to
|
103
|
+
expect(described_class.instance.send(:hash)[:custom]).to be_nil
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -21,7 +21,7 @@ describe Timber::Events::HTTPServerRequest, :rails_23 => true do
|
|
21
21
|
it "should handle header encoding" do
|
22
22
|
referer = 'http://www.metrojobb.se/jobb/1013893-skadeadministratör'.force_encoding('ASCII-8BIT')
|
23
23
|
event = described_class.new(:headers => {'Referer' => referer}, :host => 'my.host.com', :method => 'GET', :path => '/path', :scheme => 'https')
|
24
|
-
expect(event.headers
|
24
|
+
expect(event.headers.key?("referer")).to eq(false)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -102,7 +102,7 @@ describe Timber::LogDevices::HTTP do
|
|
102
102
|
request_queue = http.instance_variable_get(:@request_queue)
|
103
103
|
request = request_queue.deq
|
104
104
|
expect(request).to be_kind_of(Net::HTTP::Post)
|
105
|
-
expect(request.body).to start_with("\x92\
|
105
|
+
expect(request.body).to start_with("\x92\x84\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z\xA7message\xB2test log message 1".force_encoding("ASCII-8BIT"))
|
106
106
|
|
107
107
|
message_queue = http.instance_variable_get(:@msg_queue)
|
108
108
|
expect(message_queue.size).to eq(0)
|
@@ -127,7 +127,7 @@ describe Timber::LogDevices::HTTP do
|
|
127
127
|
it "should deliver requests on an interval" do
|
128
128
|
stub = stub_request(:post, "https://logs.timber.io/frames").
|
129
129
|
with(
|
130
|
-
:body => start_with("\x92\
|
130
|
+
:body => start_with("\x92\x84\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z\xA7message\xB2test log message 1".force_encoding("ASCII-8BIT")),
|
131
131
|
:headers => {
|
132
132
|
'Authorization' => 'Basic TVlLRVk=',
|
133
133
|
'Content-Type' => 'application/msgpack',
|
data/spec/timber/logger_spec.rb
CHANGED
@@ -163,19 +163,19 @@ describe Timber::Logger, :rails_23 => true do
|
|
163
163
|
let(:logger) { Timber::Logger.new(io) }
|
164
164
|
|
165
165
|
it "should add context" do
|
166
|
-
expect(Timber::CurrentContext.instance.send(:hash)).to
|
166
|
+
expect(Timber::CurrentContext.instance.send(:hash)[:custom]).to be_nil
|
167
167
|
|
168
168
|
logger.with_context(build: {version: "1.0.0"}) do
|
169
|
-
expect(Timber::CurrentContext.instance.send(:hash)).to eq({:
|
169
|
+
expect(Timber::CurrentContext.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}})
|
170
170
|
|
171
171
|
logger.with_context({testing: {key: "value"}}) do
|
172
|
-
expect(Timber::CurrentContext.instance.send(:hash)).to eq({:
|
172
|
+
expect(Timber::CurrentContext.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}, :testing=>{:key=>"value"}})
|
173
173
|
end
|
174
174
|
|
175
|
-
expect(Timber::CurrentContext.instance.send(:hash)).to eq({:
|
175
|
+
expect(Timber::CurrentContext.instance.send(:hash)[:custom]).to eq({:build=>{:version=>"1.0.0"}})
|
176
176
|
end
|
177
177
|
|
178
|
-
expect(Timber::CurrentContext.instance.send(:hash)).to
|
178
|
+
expect(Timber::CurrentContext.instance.send(:hash)[:custom]).to be_nil
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
@@ -4,12 +4,12 @@ describe Timber::Util::HTTPEvent, :rails_23 => true do
|
|
4
4
|
describe ".normalize_headers" do
|
5
5
|
it "should ignore nils" do
|
6
6
|
result = described_class.normalize_headers({"key" => nil})
|
7
|
-
expect(result).to eq({
|
7
|
+
expect(result).to eq({})
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should handle non strings" do
|
11
11
|
result = described_class.normalize_headers({"key" => 1})
|
12
|
-
expect(result).to eq({"key" => 1})
|
12
|
+
expect(result).to eq({"key" => "1"})
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
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: 2.1.0.
|
4
|
+
version: 2.1.0.rc4
|
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: 2017-06-
|
11
|
+
date: 2017-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/timber/cli/file_helper.rb
|
157
157
|
- lib/timber/cli/installer.rb
|
158
158
|
- lib/timber/cli/installers.rb
|
159
|
+
- lib/timber/cli/installers/config_file.rb
|
159
160
|
- lib/timber/cli/installers/other.rb
|
160
161
|
- lib/timber/cli/installers/rails.rb
|
161
162
|
- lib/timber/cli/installers/root.rb
|
@@ -231,7 +232,6 @@ files:
|
|
231
232
|
- lib/timber/util/http_event.rb
|
232
233
|
- lib/timber/util/object.rb
|
233
234
|
- lib/timber/util/request.rb
|
234
|
-
- lib/timber/util/string.rb
|
235
235
|
- lib/timber/util/struct.rb
|
236
236
|
- lib/timber/version.rb
|
237
237
|
- spec/README.md
|
@@ -246,6 +246,9 @@ files:
|
|
246
246
|
- spec/support/timber.rb
|
247
247
|
- spec/support/timecop.rb
|
248
248
|
- spec/support/webmock.rb
|
249
|
+
- spec/timber/cli/config_file_spec.rb
|
250
|
+
- spec/timber/cli/installers/config_file_spec.rb
|
251
|
+
- spec/timber/cli/installers/other_spec.rb
|
249
252
|
- spec/timber/cli/installers/rails_spec.rb
|
250
253
|
- spec/timber/cli/installers/root_spec.rb
|
251
254
|
- spec/timber/config_spec.rb
|
@@ -311,6 +314,9 @@ test_files:
|
|
311
314
|
- spec/support/timber.rb
|
312
315
|
- spec/support/timecop.rb
|
313
316
|
- spec/support/webmock.rb
|
317
|
+
- spec/timber/cli/config_file_spec.rb
|
318
|
+
- spec/timber/cli/installers/config_file_spec.rb
|
319
|
+
- spec/timber/cli/installers/other_spec.rb
|
314
320
|
- spec/timber/cli/installers/rails_spec.rb
|
315
321
|
- spec/timber/cli/installers/root_spec.rb
|
316
322
|
- spec/timber/config_spec.rb
|
data/lib/timber/util/string.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Timber
|
2
|
-
module Util
|
3
|
-
# @private
|
4
|
-
module String
|
5
|
-
UTF8 = "UTF-8".freeze
|
6
|
-
|
7
|
-
# @private
|
8
|
-
def self.normalize_to_utf8(string)
|
9
|
-
if string.encoding.to_s == UTF8
|
10
|
-
string
|
11
|
-
else
|
12
|
-
string.encode(UTF8, {
|
13
|
-
:invalid => :replace,
|
14
|
-
:undef => :replace,
|
15
|
-
:replace => '?'
|
16
|
-
})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|