betterlog 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41bb65aafa33ccbe83390a1d8a4a68a98f9a88ff94c50de62b71afe32f81fac2
4
- data.tar.gz: e4c9c13fdb23f7448744ef34dfd6667cb1ce8de6a6e8dda6017ccbf874d19fd2
3
+ metadata.gz: a14afeaf9f071dd35f0ba6fa5ae5a7052e71ea80e6872ef1f00245afcea15164
4
+ data.tar.gz: 1da4a6ab2c4ca3e79bf466dfe06a0d1ac786c8660f89b5dcda47ec5c9052b34d
5
5
  SHA512:
6
- metadata.gz: 55b3b6f9ac7ed4d641902c798cb6c372c082302c2a3a8b93373b333055168e7647f90229c285a287b886d5f90d8cd09ef4c49fefa268e720cd25b3f6590a902b
7
- data.tar.gz: 96415752787e2ac1e3345bdfa448fdb6f752dad4d338d0ef940473c7596c167635ea9e5660ef7d8313af3a1201ae2efd21a80a92eb6838f25cbaa37e1051853d
6
+ metadata.gz: 234235247f8b69eb8d67f9b4c9d24dc6e632ae567b1f4708f52a2d05fe3b4af11f9a726798af60f5c01615816c1cf1420a47dfbd6607f7a20a84f1b250e65429
7
+ data.tar.gz: 0bb91c78f26c795c108a462fbe4e1fbf305fa335eddfa92ebc270f587263dd952e6728d4bf615de73bf0a2144f0b07b627481d4d27fff1dc6206080db03ec8d0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
data/betterlog.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterlog 2.0.0 ruby lib
2
+ # stub: betterlog 2.0.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "betterlog".freeze
6
- s.version = "2.0.0"
6
+ s.version = "2.0.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -20,11 +20,15 @@ module Betterlog
20
20
  keys.each { current.delete(_1) }
21
21
  end
22
22
 
23
- def with_context(data = {})
23
+ def with_meta(data = {}, &block)
24
24
  add data
25
- yield current.dup.freeze
25
+ block.call(current.dup.freeze)
26
26
  ensure
27
27
  remove data
28
28
  end
29
29
  end
30
+
31
+ def self.with_meta(data = {}, &block)
32
+ Betterlog::GlobalMetadata.with_meta(data, &block)
33
+ end
30
34
  end
@@ -1,6 +1,6 @@
1
1
  module Betterlog
2
2
  # Betterlog version
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -33,10 +33,10 @@ describe Betterlog::GlobalMetadata do
33
33
  end
34
34
  end
35
35
 
36
- describe '.with_context' do
36
+ describe '.with_meta' do
37
37
  it 'can add to context and remove it' do
38
38
  expect(Betterlog::GlobalMetadata.current).to be_empty
39
- Betterlog::GlobalMetadata.with_context(
39
+ Betterlog::GlobalMetadata.with_meta(
40
40
  'foo' => 'bar',
41
41
  :bar => 'foo',
42
42
  ) do |my_context|
@@ -49,14 +49,14 @@ describe Betterlog::GlobalMetadata do
49
49
 
50
50
  it 'can add to nested context and remove it' do
51
51
  expect(Betterlog::GlobalMetadata.current).to be_empty
52
- Betterlog::GlobalMetadata.with_context(
52
+ Betterlog::GlobalMetadata.with_meta(
53
53
  'foo' => 'bar',
54
54
  :bar => 'foo',
55
55
  ) do |my_context|
56
56
  expect(Betterlog::GlobalMetadata.current).to eq(foo: 'bar', bar: 'foo')
57
57
  expect(my_context).to eq(foo: 'bar', bar: 'foo')
58
58
  expect(my_context).to be_frozen
59
- Betterlog::GlobalMetadata.with_context('quux' => 'quark') do |my_context|
59
+ Betterlog::GlobalMetadata.with_meta('quux' => 'quark') do |my_context|
60
60
  expect(my_context).to be_frozen
61
61
  expect(Betterlog::GlobalMetadata.current).to eq(foo: 'bar', bar: 'foo', quux: 'quark')
62
62
  expect(my_context).to eq(foo: 'bar', bar: 'foo', quux: 'quark')
@@ -65,6 +65,16 @@ describe Betterlog::GlobalMetadata do
65
65
  end
66
66
  expect(Betterlog::GlobalMetadata.current).to be_empty
67
67
  end
68
+
69
+ it 'has shortcut method Betterlog.with_meta' do
70
+ expect(Betterlog::GlobalMetadata.current).to be_empty
71
+ Betterlog.with_meta(
72
+ 'foo' => 'bar',
73
+ :bar => 'foo',
74
+ ) do
75
+ expect(Betterlog::GlobalMetadata.current).to eq(foo: 'bar', bar: 'foo')
76
+ end
77
+ end
68
78
  end
69
79
 
70
80
  class FakeNotifierClass
@@ -115,7 +115,7 @@ describe Betterlog::Log do
115
115
  'test',
116
116
  hash_including(meta: { foo: 'bar' }),
117
117
  )
118
- Betterlog::GlobalMetadata.with_context(foo: 'bar') do
118
+ Betterlog.with_meta(foo: 'bar') do
119
119
  Log.info('test', notify: true)
120
120
  end
121
121
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers