loog 0.1.0 → 0.2.0

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: b9a4fe7e73c514b7950b2a99f518ace13de913d549e096c656b48ce08640f049
4
- data.tar.gz: 8a1eaf6616a5e131a118a2b00be537ffb3bb090b0ca20fef7f9d3f8bdb9ee679
3
+ metadata.gz: d57ca2caac95761cdacaad2e4e52a8baa561f83354d6bdeca27132627bb947f4
4
+ data.tar.gz: e5018d5786318529370b8bc7b05e08a27bb72fa8b79a2eff22f0fd2755d2f2f7
5
5
  SHA512:
6
- metadata.gz: 93c0fe3664e25fedd3d3617ed2352bfa0df68d94447209cdfe29f8c2003817a5cfd794004835f749db45f018a22e78ceab6b59923185563a1573172e90f7df0e
7
- data.tar.gz: 418602f9562567576797f1c5d9bde64cbbcc7c6105fff46ffbaf2fba08bbc11d31801b639c1d7d305ad5dcd6d924eef4cd70cb88f104868c2cb44ecf86be7498
6
+ metadata.gz: 5caf550659cfbf682d069b5a3ca9aebda71c00180ee20eca29f3e0f8cca9fbb61c3ec36fa7bd52be2ee3fad8ec57a86449d39eb3664fdcf84dc360d58c459ed5
7
+ data.tar.gz: ae0dc62ef65672dc788b7c52868107a0ba08b7b9b4203bbb21d52d2f865773f18ccc1100dafa66912b1e4e5327a88149c424b8f446501e59a5b05ce637ca2f89
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ Gemfile.lock
3
3
  .bundle/
4
4
  .DS_Store
5
5
  rdoc/
6
+ coverage/
data/.rubocop.yml CHANGED
@@ -18,3 +18,5 @@ Metrics/ParameterLists:
18
18
  Max: 10
19
19
  Layout/AlignParameters:
20
20
  Enabled: false
21
+ Style/ClassAndModuleChildren:
22
+ Enabled: false
data/Rakefile CHANGED
@@ -37,8 +37,8 @@ end
37
37
  task default: %i[clean test rubocop]
38
38
 
39
39
  require 'rake/testtask'
40
- desc 'Run all unit tests'
41
40
  Rake::TestTask.new(:test) do |test|
41
+ Rake::Cleaner.cleanup_files(['coverage'])
42
42
  test.libs << 'lib' << 'test'
43
43
  test.pattern = 'test/**/test_*.rb'
44
44
  test.verbose = false
@@ -52,7 +52,6 @@ RDoc::Task.new do |rdoc|
52
52
  end
53
53
 
54
54
  require 'rubocop/rake_task'
55
- desc 'Run RuboCop on all directories'
56
55
  RuboCop::RakeTask.new(:rubocop) do |task|
57
56
  task.fail_on_error = true
58
57
  task.requires << 'rubocop-rspec'
data/lib/loog/tee.rb ADDED
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (The MIT License)
4
+ #
5
+ # Copyright (c) 2018 Yegor Bugayenko
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the 'Software'), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require_relative '../loog'
26
+
27
+ # A combiner of a few logs together:
28
+ #
29
+ # require 'loog'
30
+ # tee = Loog::Tee.new(Loog::VERBOSE, file_logger)
31
+ # log.info('Hello, world!')
32
+ #
33
+ # This way you can log to console and to the file at the same time.
34
+ #
35
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
36
+ # Copyright:: Copyright (c) 2018 Yegor Bugayenko
37
+ # License:: MIT
38
+ class Loog::Tee
39
+ # Makes an instance.
40
+ def initialize(*logs)
41
+ @logs = logs
42
+ end
43
+
44
+ def debug(msg)
45
+ @logs.each { |g| g.debug(msg) }
46
+ end
47
+
48
+ def debug?
49
+ @logs.any? { |g| g.debug?(msg) }
50
+ end
51
+
52
+ def info(msg)
53
+ @logs.each { |g| g.info(msg) }
54
+ end
55
+
56
+ def info?
57
+ @logs.any? { |g| g.info?(msg) }
58
+ end
59
+
60
+ def error(msg)
61
+ @logs.each { |g| g.error(msg) }
62
+ end
63
+ end
data/loog.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.rubygems_version = '2.3.3'
32
32
  s.required_ruby_version = '>=2.3'
33
33
  s.name = 'loog'
34
- s.version = '0.1.0'
34
+ s.version = '0.2.0'
35
35
  s.license = 'MIT'
36
36
  s.summary = 'Object-oriented logging wrapper'
37
37
  s.description = 'Object-oriented wrapper for Ruby default logging facility'
@@ -42,8 +42,9 @@ Gem::Specification.new do |s|
42
42
  s.test_files = s.files.grep(%r{^(test)/})
43
43
  s.rdoc_options = ['--charset=UTF-8']
44
44
  s.extra_rdoc_files = ['README.md']
45
+ s.add_development_dependency 'codecov', '0.1.10'
45
46
  s.add_development_dependency 'minitest', '5.11.3'
46
- s.add_development_dependency 'rake', '12.3.1'
47
+ s.add_development_dependency 'rake', '12.0.0'
47
48
  s.add_development_dependency 'rdoc', '4.3.0'
48
49
  s.add_development_dependency 'rubocop', '0.62.0'
49
50
  s.add_development_dependency 'rubocop-rspec', '1.31.0'
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2019 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ STDOUT.sync = true
24
+
25
+ require 'simplecov'
26
+ SimpleCov.start
27
+ if ENV['CI'] == 'true'
28
+ require 'codecov'
29
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
30
+ end
data/test/test_tee.rb ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (The MIT License)
4
+ #
5
+ # Copyright (c) 2018 Yegor Bugayenko
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the 'Software'), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require 'minitest/autorun'
26
+ require_relative '../lib/loog'
27
+ require_relative '../lib/loog/tee'
28
+
29
+ # Loog::Tee test.
30
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
+ # Copyright:: Copyright (c) 2018 Yegor Bugayenko
32
+ # License:: MIT
33
+ class TeeTest < Minitest::Test
34
+ def test_simple_logging
35
+ Loog::Tee.new(Loog::VERBOSE, Loog::REGULAR).info('Works?')
36
+ end
37
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-04 00:00:00.000000000 Z
11
+ date: 2019-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: codecov
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.10
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.10
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: minitest
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -30,14 +44,14 @@ dependencies:
30
44
  requirements:
31
45
  - - '='
32
46
  - !ruby/object:Gem::Version
33
- version: 12.3.1
47
+ version: 12.0.0
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - '='
39
53
  - !ruby/object:Gem::Version
40
- version: 12.3.1
54
+ version: 12.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rdoc
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -101,9 +115,12 @@ files:
101
115
  - Rakefile
102
116
  - appveyor.yml
103
117
  - lib/loog.rb
118
+ - lib/loog/tee.rb
104
119
  - logo.svg
105
120
  - loog.gemspec
121
+ - test/test__helper.rb
106
122
  - test/test_loog.rb
123
+ - test/test_tee.rb
107
124
  homepage: http://github.com/yegor256/loog
108
125
  licenses:
109
126
  - MIT
@@ -129,4 +146,6 @@ signing_key:
129
146
  specification_version: 2
130
147
  summary: Object-oriented logging wrapper
131
148
  test_files:
149
+ - test/test__helper.rb
132
150
  - test/test_loog.rb
151
+ - test/test_tee.rb