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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/hanami/interactor.rb +2 -2
- data/lib/hanami/logger.rb +12 -6
- data/lib/hanami/logger/colorizer.rb +15 -6
- data/lib/hanami/utils/files.rb +1 -1
- data/lib/hanami/utils/hash.rb +8 -8
- data/lib/hanami/utils/string.rb +7 -7
- data/lib/hanami/utils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf90917997534d92623b70db435517bd1f209f2225ccd749877f27dcff9037c8
|
4
|
+
data.tar.gz: cdb5703c3d960dda031f075039b5fe2d295611868795b1723d3433a8aaf06b51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be115da3e0bf2c9fcab0f7fd98b662afba7681dd1b3e44a9916ed4d59ca686a9176fe9856098df8d0d0fd5ea9d904837058f66ca5f66be571f25dfc4746998b
|
7
|
+
data.tar.gz: fa533c2d40d70758bc97bb027a886bc270f9190e09a077961e67e9d96b6f4dba3d2b6f97cd2b79a9a1a91003b3eb6cc46d6cfe2326b21e21bd95b12c53fd3f64
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/hanami/interactor.rb
CHANGED
data/lib/hanami/logger.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
-
|
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
|
data/lib/hanami/utils/files.rb
CHANGED
@@ -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.
|
data/lib/hanami/utils/hash.rb
CHANGED
@@ -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|
|
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|
|
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|
|
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(
|
494
|
-
raise NoMethodError.new(%(undefined method `#{
|
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__(
|
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?(
|
506
|
-
@hash.respond_to?(
|
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
|
data/lib/hanami/utils/string.rb
CHANGED
@@ -160,8 +160,8 @@ module Hanami
|
|
160
160
|
#
|
161
161
|
# @since 1.1.0
|
162
162
|
# @api private
|
163
|
-
def self.bind(value, binding,
|
164
|
-
binding.instance_exec(value, &
|
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(
|
713
|
-
raise NoMethodError.new(%(undefined method `#{
|
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__(
|
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?(
|
725
|
-
@string.respond_to?(
|
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
|
data/lib/hanami/utils/version.rb
CHANGED
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.
|
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-
|
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.
|
142
|
+
rubygems_version: 2.7.6
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: Ruby core extentions and Hanami utilities
|