tee_logger 3.0.3 → 3.1.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
  SHA1:
3
- metadata.gz: 6c8a72c49080cdf67b57ba78fd480cbe99cb4e05
4
- data.tar.gz: 98be6da99a89f38ab7543b8f448a5a8d89bb0c15
3
+ metadata.gz: 42308c52d2bc5ef56c767672b7ae3176649252a9
4
+ data.tar.gz: 2e8b699ed7291753b0e6c0b124ddcebf612617b0
5
5
  SHA512:
6
- metadata.gz: eabb749828cb2247faac7382e621f31283e1f450a04a0517de3412a16276fe348b86a3fd4b3e8479cd6559aaf939265d3225219dd8fe5dad662892092c6d7f9a
7
- data.tar.gz: 74b47c66dc590844949118221f9aaf2425e4da4db37c705d909224a35de0eecfe4da62807ca9522e5508a7b5f3a4c484a4cb1590c31a773529d4c611f5445e3f
6
+ metadata.gz: 346a26ebc18965a8a0b12f449b159c42a8caab094abea47cc1318ff4ea04ed3607d5a18d6d4013b63224c00a2b7bfea46a86811dcebf471ae536c1c299a2fe67
7
+ data.tar.gz: dd67b9fc88b165ddd134870fa42806207a1b19ff9a9f1319e68c2c795ba1e88f9519efd842ee1a41a40fa455a3be36142f3237aaf0bb4304da2b5b51a24f185a
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - ruby-head
4
+ - 2.2.3
4
5
  - 2.2.2
5
6
  - 2.1.5
6
7
  - 2.0.0
@@ -1,3 +1,7 @@
1
+ # v3.1.0
2
+ - [issue #12](https://github.com/k-ta-yamada/tee_logger/issues/12)
3
+ Include and Extend support
4
+
1
5
  # v3.0.3
2
6
  - shared_examples_for_tee_logger_spec.rb [ae1e481](https://github.com/k-ta-yamada/tee_logger/commit/ae1e481)
3
7
  - new constant for disabling formatter [478eccb](https://github.com/k-ta-yamada/tee_logger/commit/478eccb)
@@ -11,6 +11,32 @@ module TeeLogger
11
11
  TeeLogger.new(logdev, shift_age, shift_size)
12
12
  end
13
13
 
14
+ # define singleton method .logger for your module.
15
+ # and TeeLogger.progname is your module name.
16
+ def self.extended(mod)
17
+ mod.class_eval do
18
+ define_singleton_method(:logger) do |logdev = DEFAULT_FILE|
19
+ return @logger if @logger
20
+ @logger = TeeLogger.new(logdev)
21
+ @logger.progname = self
22
+ @logger
23
+ end
24
+ end
25
+ end
26
+
27
+ # define instance method #logger for your class.
28
+ # and TeeLogger.progname is your class name.
29
+ def self.included(klass)
30
+ klass.class_eval do
31
+ define_method(:logger) do |logdev = DEFAULT_FILE|
32
+ return @logger if @logger
33
+ @logger = TeeLogger.new(logdev)
34
+ @logger.progname = self.class.name
35
+ @logger
36
+ end
37
+ end
38
+ end
39
+
14
40
  # main
15
41
  # @see http://www.rubydoc.info/stdlib/logger/Logger Logger
16
42
  class TeeLogger
@@ -13,7 +13,7 @@ module TeeLogger
13
13
 
14
14
  # using private method #parse_to_hash
15
15
  ParsedOption = Struct.new(:logdev_name, :indent_level)
16
- # LOGDEV_NAMES not incuded error
16
+ # LOGDEV_NAMES not included error
17
17
  class IncorrectNameError < StandardError; end
18
18
  # option's class is not allow
19
19
  class IncorrectOptionError < StandardError; end
@@ -4,6 +4,8 @@ module TeeLogger
4
4
  module Utils
5
5
  module_function
6
6
 
7
+ # @param options [Array]
8
+ # @return [ParsedOption]
7
9
  def extract_options(options)
8
10
  options.each_with_object(ParsedOption.new(nil, 0)) do |val, obj|
9
11
  case val
@@ -14,6 +16,10 @@ module TeeLogger
14
16
  end
15
17
  end
16
18
 
19
+ # @params progname
20
+ # @params block
21
+ # @params indent_level [Fixnum]
22
+ # @return [Array]
17
23
  def indentation(progname, block, indent_level)
18
24
  if block.nil?
19
25
  progname = "#{' ' * indent_level}#{formatting(progname)}"
@@ -24,6 +30,8 @@ module TeeLogger
24
30
  [progname, block]
25
31
  end
26
32
 
33
+ # @params val
34
+ # @return [String]
27
35
  def formatting(val)
28
36
  case val
29
37
  when Symbol then ":#{val}"
@@ -32,25 +40,33 @@ module TeeLogger
32
40
  end
33
41
  end
34
42
 
43
+ # @params val [Symbol]
44
+ # @return [Symbol]
35
45
  def name_reverse(val)
36
46
  correct_name?(val)
37
47
  LOGDEV_REVERSE[val]
38
48
  end
39
49
 
50
+ # @params name [Symbol]
51
+ # @return [true]
40
52
  def correct_name?(name)
41
53
  LOGDEV_NAMES.include?(name) ? true : incorrect_name_error(name)
42
54
  end
43
55
 
56
+ # @params name [Symbol]
44
57
  def incorrect_name_error(name)
45
58
  fail IncorrectNameError,
46
59
  "logdev_name is :console or :logfile. logdev_name=[:#{name}]"
47
60
  end
48
61
 
62
+ # @params name [Symbol]
49
63
  def incorrect_option_error(val)
50
64
  fail IncorrectOptionError,
51
65
  "option params is Symbol or Fixnum. class=[#{val.class}]"
52
66
  end
53
67
 
68
+ # @params logdev_name [Symbol]
69
+ # @return [Logger]
54
70
  def logdev_instance(logdev_name)
55
71
  instance_variable_get("@#{logdev_name}")
56
72
  end
@@ -1,5 +1,5 @@
1
1
  # namespace
2
2
  module TeeLogger
3
3
  # version number
4
- VERSION = '3.0.3'
4
+ VERSION = '3.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tee_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k-ta-yamada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  requirements: []
207
207
  rubyforge_project:
208
- rubygems_version: 2.4.8
208
+ rubygems_version: 2.2.2
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: logging to file and standard output.