hanami-utils 1.2.0.rc1 → 1.2.0.rc2

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: 86da2fce7ef69bfbd91366caa3abcc403dcacbf581fca38eb3b242f4dcbca5e7
4
- data.tar.gz: 34213163f0aff44ee06516a4ceb7fdcbe96802a4b101a1bb5c45b6220c8e8736
3
+ metadata.gz: bf90917997534d92623b70db435517bd1f209f2225ccd749877f27dcff9037c8
4
+ data.tar.gz: cdb5703c3d960dda031f075039b5fe2d295611868795b1723d3433a8aaf06b51
5
5
  SHA512:
6
- metadata.gz: 607969cb2bc3673ef48a15102342409b5e383433c55dc39543f51dd4436e384f56050e8d48be9defddba15d2933644d001c59ce6863bffd203f020a58b34753d
7
- data.tar.gz: c9374f9627a418002d7753536025f9b3724cfea6fb18a77344ccdfcc0a8d94375cf26c687fd8d91edda8fb036b75d7dda16674785260f37a8507672d62935a9c
6
+ metadata.gz: 8be115da3e0bf2c9fcab0f7fd98b662afba7681dd1b3e44a9916ed4d59ca686a9176fe9856098df8d0d0fd5ea9d904837058f66ca5f66be571f25dfc4746998b
7
+ data.tar.gz: fa533c2d40d70758bc97bb027a886bc270f9190e09a077961e67e9d96b6f4dba3d2b6f97cd2b79a9a1a91003b3eb6cc46d6cfe2326b21e21bd95b12c53fd3f64
@@ -1,6 +1,10 @@
1
1
  # Hanami::Utils
2
2
  Ruby core extentions and class utilities for Hanami
3
3
 
4
+ ## v1.2.0.rc2 - 2018-04-06
5
+ ### Added
6
+ - [Luca Guidi] Use different colors for each `Hanami::Logger` level
7
+
4
8
  ## v1.2.0.rc1 - 2018-03-30
5
9
  ### Added
6
10
  - [Oana Sipos & Sean Collins & Luca Guidi] Colored logging
@@ -119,8 +119,8 @@ module Hanami
119
119
 
120
120
  # @since 0.3.5
121
121
  # @api private
122
- def method_missing(m, *)
123
- @payload.fetch(m) { super }
122
+ def method_missing(method_name, *)
123
+ @payload.fetch(method_name) { super }
124
124
  end
125
125
 
126
126
  # @since 0.3.5
@@ -140,6 +140,17 @@ module Hanami
140
140
  "unknown" => UNKNOWN
141
141
  ].freeze
142
142
 
143
+ # @since 1.2.0
144
+ # @api private
145
+ def self.level(level)
146
+ case level
147
+ when DEBUG..UNKNOWN
148
+ level
149
+ else
150
+ LEVELS.fetch(level.to_s.downcase, DEBUG)
151
+ end
152
+ end
153
+
143
154
  # @since 0.5.0
144
155
  # @api private
145
156
  attr_writer :application_name
@@ -329,12 +340,7 @@ module Hanami
329
340
  # @since 0.8.0
330
341
  # @api private
331
342
  def _level(level)
332
- case level
333
- when DEBUG..UNKNOWN
334
- level
335
- else
336
- LEVELS.fetch(level.to_s.downcase, DEBUG)
337
- end
343
+ self.class.level(level)
338
344
  end
339
345
 
340
346
  # @since 1.2.0
@@ -52,18 +52,26 @@ module Hanami
52
52
 
53
53
  private
54
54
 
55
- # The colors defined for the four parts of the log message
56
- #
57
- # These can be overridden, keeping the name keys, with acceptable values
58
- # being any from Hanami::Utils::ShellColor::COLORS
55
+ # The colors defined for the three parts of the log message
59
56
  #
60
57
  # @since 1.2.0
58
+ # @api private
61
59
  COLORS = ::Hash[
62
60
  app: :blue,
63
- severity: :magenta,
64
61
  datetime: :cyan,
65
62
  ].freeze
66
63
 
64
+ # @since 1.2.0
65
+ # @api private
66
+ LEVELS = ::Hash[
67
+ Hanami::Logger::DEBUG => :cyan,
68
+ Hanami::Logger::INFO => :magenta,
69
+ Hanami::Logger::WARN => :yellow,
70
+ Hanami::Logger::ERROR => :red,
71
+ Hanami::Logger::FATAL => :red,
72
+ Hanami::Logger::UNKNOWN => :blue,
73
+ ].freeze
74
+
67
75
  attr_reader :colors
68
76
 
69
77
  # @since 1.2.0
@@ -75,7 +83,8 @@ module Hanami
75
83
  # @since 1.2.0
76
84
  # @api private
77
85
  def severity(input)
78
- colorize(input, color: colors.fetch(:severity, nil))
86
+ color = LEVELS.fetch(Hanami::Logger.level(input), :gray)
87
+ colorize(input, color: color)
79
88
  end
80
89
 
81
90
  # @since 1.2.0
@@ -29,7 +29,7 @@ module Hanami
29
29
  # @since 1.1.0
30
30
  def self.write(path, *content)
31
31
  mkdir_p(path)
32
- open(path, ::File::CREAT | ::File::WRONLY | ::File::TRUNC, *content)
32
+ open(path, ::File::CREAT | ::File::WRONLY | ::File::TRUNC, *content) # rubocop:disable Security/Open - this isn't a call to `::Kernel.open`, but to `self.open`
33
33
  end
34
34
 
35
35
  # Rewrites the contents of an existing file.
@@ -253,7 +253,7 @@ module Hanami
253
253
  # hash.keys # => [:a, :b]
254
254
  # hash.inspect # => { :a => 23, :b => { 'c' => ["x", "y", "z"] } }
255
255
  def symbolize!
256
- keys.each do |k| # rubocop:disable Performance/HashEachMethods (this breaks the build)
256
+ keys.each do |k|
257
257
  v = delete(k)
258
258
  self[k.to_sym] = v
259
259
  end
@@ -276,7 +276,7 @@ module Hanami
276
276
  # hash.keys # => [:a, :b]
277
277
  # hash.inspect # => {:a=>23, :b=>{:c=>["x", "y", "z"]}}
278
278
  def deep_symbolize!
279
- keys.each do |k| # rubocop:disable Performance/HashEachMethods (this breaks the build)
279
+ keys.each do |k|
280
280
  v = delete(k)
281
281
  v = self.class.new(v).deep_symbolize! if v.respond_to?(:to_hash)
282
282
 
@@ -301,7 +301,7 @@ module Hanami
301
301
  # hash.keys # => [:a, :b]
302
302
  # hash.inspect # => {"a"=>23, "b"=>{"c"=>["x", "y", "z"]}}
303
303
  def stringify!
304
- keys.each do |k| # rubocop:disable Performance/HashEachMethods (this breaks the build)
304
+ keys.each do |k|
305
305
  v = delete(k)
306
306
  v = self.class.new(v).stringify! if v.respond_to?(:to_hash)
307
307
 
@@ -490,10 +490,10 @@ module Hanami
490
490
  # @since 0.3.0
491
491
  #
492
492
  # @raise [NoMethodError] If doesn't respond to the given method
493
- def method_missing(m, *args, &blk)
494
- raise NoMethodError.new(%(undefined method `#{m}' for #{@hash}:#{self.class})) unless respond_to?(m)
493
+ def method_missing(method_name, *args, &blk)
494
+ raise NoMethodError.new(%(undefined method `#{method_name}' for #{@hash}:#{self.class})) unless respond_to?(method_name)
495
495
 
496
- h = @hash.__send__(m, *args, &blk)
496
+ h = @hash.__send__(method_name, *args, &blk)
497
497
  h = self.class.new(h) if h.is_a?(::Hash)
498
498
  h
499
499
  end
@@ -502,8 +502,8 @@ module Hanami
502
502
  #
503
503
  # @api private
504
504
  # @since 0.3.0
505
- def respond_to_missing?(m, include_private = false)
506
- @hash.respond_to?(m, include_private)
505
+ def respond_to_missing?(method_name, include_private = false)
506
+ @hash.respond_to?(method_name, include_private)
507
507
  end
508
508
  end
509
509
  # rubocop:enable ClassLength
@@ -160,8 +160,8 @@ module Hanami
160
160
  #
161
161
  # @since 1.1.0
162
162
  # @api private
163
- def self.bind(value, binding, fn)
164
- binding.instance_exec(value, &fn)
163
+ def self.bind(value, binding, fun)
164
+ binding.instance_exec(value, &fun)
165
165
  end
166
166
 
167
167
  # Return a titleized version of the string
@@ -709,10 +709,10 @@ module Hanami
709
709
  # @since 0.3.0
710
710
  #
711
711
  # @raise [NoMethodError] If doesn't respond to the given method
712
- def method_missing(m, *args, &blk)
713
- raise NoMethodError.new(%(undefined method `#{m}' for "#{@string}":#{self.class})) unless respond_to?(m)
712
+ def method_missing(method_name, *args, &blk)
713
+ raise NoMethodError.new(%(undefined method `#{method_name}' for "#{@string}":#{self.class})) unless respond_to?(method_name)
714
714
 
715
- s = @string.__send__(m, *args, &blk)
715
+ s = @string.__send__(method_name, *args, &blk)
716
716
  s = self.class.new(s) if s.is_a?(::String)
717
717
  s
718
718
  end
@@ -721,8 +721,8 @@ module Hanami
721
721
  #
722
722
  # @api private
723
723
  # @since 0.3.0
724
- def respond_to_missing?(m, include_private = false)
725
- @string.respond_to?(m, include_private)
724
+ def respond_to_missing?(method_name, include_private = false)
725
+ @string.respond_to?(method_name, include_private)
726
726
  end
727
727
  end
728
728
  end
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.2.0.rc1'.freeze
6
+ VERSION = '1.2.0.rc2'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.rc1
4
+ version: 1.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-30 00:00:00.000000000 Z
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: transproc
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: 1.3.1
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.7.5
142
+ rubygems_version: 2.7.6
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Ruby core extentions and Hanami utilities