loog 0.4.0 → 0.5.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: 36176706198bed42b0858771358d9c016f39437fa5a9fedc6391fab3cf8d1518
4
- data.tar.gz: 9ef77b0a794eb04027e16fbd12cf208488bc6052ee87ba7de9bd839188d6c6a9
3
+ metadata.gz: e1ff618d0107b8ec12ffd303cee8926274b2a8a37593ba60eeece9a1c071a7b3
4
+ data.tar.gz: 44cee88f20b6da00bbd425d9faf718295613bd9e786d0344228c054e4d819373
5
5
  SHA512:
6
- metadata.gz: 9ede844cd2c3f8740de75171320397bdc01ecafe2ec5212dfaf76aa68ea85b7f02f4a5c21d0abf6f15173e2bc3b1e69caebc00d7526dc38a90cbde579fb820bb
7
- data.tar.gz: ccb2526f6c8eb792cf16162e35b2f06638ac53d6aaa2cc1f26de86ddcbd28dc4b2c73a7c0cbecd495bbf29eee76bbc4f5465b1bf617079e5a20e368f8be58bb7
6
+ metadata.gz: 3d5d4f85a2281ed8348bd4cb871d4903fc49eed43d3221592f8d5ed9f89a16fa49d5c493e1e691ffabc182fd4ba33ba911ef903411faf8f0d8d2c5cdfab431d9
7
+ data.tar.gz: 7e6a683fa912743f79d479fef4ae75d7248015158a947aeff80d8705de100499239841185daaf6e4d296eff7a78644bc8bda677a4dc2ddff9cb3e9c608c18d3a
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  matrix:
15
15
  os: [ubuntu-20.04]
16
- ruby: [2.6]
16
+ ruby: [2.7, 3.0]
17
17
  runs-on: ${{ matrix.os }}
18
18
  steps:
19
19
  - uses: actions/checkout@v3
data/Gemfile CHANGED
@@ -23,9 +23,9 @@
23
23
  source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
- gem 'minitest', '5.18.0', require: false
26
+ gem 'minitest', '5.19.0', require: false
27
27
  gem 'rake', '13.0.6', require: false
28
28
  gem 'rdoc', '6.5.0', require: false
29
- gem 'rubocop', '1.48.1', require: false
30
- gem 'rubocop-rspec', '2.19.0', require: false
29
+ gem 'rubocop', '1.54.2', require: false
30
+ gem 'rubocop-rspec', '2.22.0', require: false
31
31
  gem 'simplecov', '0.22.0', require: false
data/lib/loog.rb CHANGED
@@ -46,7 +46,7 @@ module Loog
46
46
  when 'DEBUG'
47
47
  prefix = 'D: '
48
48
  end
49
- "#{prefix}#{msg.to_s.rstrip.gsub(/\n/, "\n#{' ' * prefix.length}")}\n"
49
+ "#{prefix}#{msg.to_s.rstrip.gsub("\n", "\n#{' ' * prefix.length}")}\n"
50
50
  end
51
51
 
52
52
  # Short formatter
@@ -92,12 +92,12 @@ module Loog
92
92
  # messages in one place and then "assert" the presence
93
93
  # of certain strings inside them.
94
94
  class Buffer < Logger
95
- def initialize
95
+ def initialize(formatter: Loog::SHORT)
96
96
  super(
97
97
  $stdout,
98
98
  level: Logger::DEBUG,
99
99
  formatter: proc do |severity, time, target, msg|
100
- @lines.push("#{severity} #{time} #{target} #{msg}")
100
+ @lines.push(formatter.call(severity, time, target, msg))
101
101
  ''
102
102
  end
103
103
  )
@@ -105,7 +105,7 @@ module Loog
105
105
  end
106
106
 
107
107
  def to_s
108
- @lines.join("\n")
108
+ @lines.join
109
109
  end
110
110
  end
111
111
  end
data/loog.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
28
28
  s.required_ruby_version = '>=2.3'
29
29
  s.name = 'loog'
30
- s.version = '0.4.0'
30
+ s.version = '0.5.1'
31
31
  s.license = 'MIT'
32
32
  s.summary = 'Object-oriented logging wrapper'
33
33
  s.description = 'Object-oriented wrapper for Ruby default logging facility'
data/test/test_loog.rb CHANGED
@@ -39,8 +39,18 @@ class LoogTest < Minitest::Test
39
39
  end
40
40
 
41
41
  def test_buffering
42
+ b = Loog::Buffer.new(formatter: Loog::FULL)
43
+ b.debug('Hello, world!')
44
+ stdout = b.to_s
45
+ assert(stdout.include?('Hello'))
46
+ assert(stdout.include?('DEBUG'))
47
+ end
48
+
49
+ def test_quiet_buffering
42
50
  b = Loog::Buffer.new
43
- b.info('Hello, world!')
44
- assert b.to_s.include?('Hello')
51
+ b.info('Hey, друг!')
52
+ b.info('Bye!')
53
+ b.info('+')
54
+ assert_equal("Hey, друг!\nBye!\n+\n", b.to_s)
45
55
  end
46
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko