hanami-utils 1.1.0.beta1 → 1.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/lib/hanami-utils.rb +1 -1
- data/lib/hanami/logger.rb +10 -2
- data/lib/hanami/utils/basic_object.rb +4 -3
- data/lib/hanami/utils/duplicable.rb +1 -1
- data/lib/hanami/utils/escape.rb +2 -2
- data/lib/hanami/utils/hash.rb +23 -8
- data/lib/hanami/utils/inflector.rb +15 -2
- data/lib/hanami/utils/path_prefix.rb +1 -1
- data/lib/hanami/utils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e83a3e9a076efd62198e77eaced47f088e0cb51
|
4
|
+
data.tar.gz: c23f56620e1d7164f8ccc16a896846f3d88e73f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f5d9b11a03d752cb1b8ce489f9f34d8b4353e68e734f1a9c825b476756e00fa4101d57d04a2f8f19fe7beb78610f089a0bc85d5163116caa30683bafef00acc
|
7
|
+
data.tar.gz: 51b354ac98bd76b1c04ed159bec4f98be12a2444c824b20fe1691bbc1f419c124a53a237cd548394cc70f5979ce6f3068aeb69bd072af3a035084d1190934c41
|
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.1.0.beta2 - 2017-10-03
|
5
|
+
### Added
|
6
|
+
- [Alfonso Uceda] Auto create directory for `Hanami::Logger`
|
7
|
+
|
4
8
|
## v1.1.0.beta1 - 2017-08-11
|
5
9
|
### Added
|
6
10
|
- [Marion Duprey] Allow `Hanami::Interactor#call` to accept arguments. `#initialize` should be used for Dependency Injection, while `#call` should be used for input
|
@@ -10,12 +14,21 @@ Ruby core extentions and class utilities for Hanami
|
|
10
14
|
- [Luca Guidi] Introduce `Utils::String.transform` a pipelined transformations for strings
|
11
15
|
- [Marion Duprey & Gabriel Gizotti] Filter sensitive informations for `Hanami::Logger`
|
12
16
|
|
17
|
+
## v1.0.4 - 2017-10-02
|
18
|
+
### Fixed
|
19
|
+
- [Luca Guidi] Make `Hanami::Utils::BasicObject` to be fully compatible with Ruby's `pp` and to be inspected by Pry.
|
20
|
+
- [Thiago Kenji Okada] Fix pluralization/singularization for `"release" => "releases"`
|
21
|
+
|
22
|
+
## v1.0.3 - 2017-09-06
|
23
|
+
### Fixed
|
24
|
+
- [Malina Sulca] Fix pluralization/singularization for `"exercise" => "exercises"`
|
25
|
+
- [Xavier Barbosa] Fix pluralization/singularization for `"area" => "areas"`
|
26
|
+
|
13
27
|
## v1.0.2 - 2017-07-10
|
14
28
|
### Fixed
|
15
29
|
- [Anton Davydov] Fix pluralization/singularization for `"phrase" => "phrases"`
|
16
30
|
|
17
31
|
## v1.0.1 - 2017-06-23
|
18
|
-
|
19
32
|
### Added
|
20
33
|
- [Luca Guidi] Introduced `Utils::Hash.symbolize` and `.deep_symbolize`
|
21
34
|
- [Luca Guidi] Introduced `Utils::Hash.deep_dup`
|
data/lib/hanami-utils.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'hanami/utils' # rubocop:disable
|
1
|
+
require 'hanami/utils' # rubocop:disable Naming/FileName
|
data/lib/hanami/logger.rb
CHANGED
@@ -5,6 +5,7 @@ require 'hanami/utils/string'
|
|
5
5
|
require 'hanami/utils/json'
|
6
6
|
require 'hanami/utils/hash'
|
7
7
|
require 'hanami/utils/class_attribute'
|
8
|
+
require 'hanami/utils/files'
|
8
9
|
|
9
10
|
module Hanami
|
10
11
|
# Hanami logger
|
@@ -111,7 +112,7 @@ module Hanami
|
|
111
112
|
|
112
113
|
# @since 1.0.0
|
113
114
|
# @api private
|
114
|
-
RESERVED_KEYS = %i
|
115
|
+
RESERVED_KEYS = %i[app severity time].freeze
|
115
116
|
|
116
117
|
include Utils::ClassAttribute
|
117
118
|
|
@@ -453,7 +454,14 @@ module Hanami
|
|
453
454
|
# logger.info "Hello World"
|
454
455
|
#
|
455
456
|
# # => {"app":"Hanami","severity":"DEBUG","time":"2017-03-30T13:57:59Z","message":"Hello World"}
|
456
|
-
|
457
|
+
# rubocop:disable Lint/HandleExceptions
|
458
|
+
# rubocop:disable Metrics/ParameterLists
|
459
|
+
def initialize(application_name = nil, *args, stream: $stdout, level: DEBUG, formatter: nil, filter: [])
|
460
|
+
begin
|
461
|
+
Utils::Files.mkdir_p(stream)
|
462
|
+
rescue TypeError
|
463
|
+
end
|
464
|
+
|
457
465
|
super(stream, *args)
|
458
466
|
|
459
467
|
@level = _level(level)
|
@@ -21,7 +21,7 @@ module Hanami
|
|
21
21
|
#
|
22
22
|
# @see http://ruby-doc.org/core/Object.html#method-i-inspect
|
23
23
|
def inspect
|
24
|
-
"#<#{self.class}:#{'%x' % (__id__ << 1)}#{__inspect}>" # rubocop:disable Style/FormatString
|
24
|
+
"#<#{self.class}:#{'0x0000%x' % (__id__ << 1)}#{__inspect}>" # rubocop:disable Style/FormatString
|
25
25
|
end
|
26
26
|
|
27
27
|
# Alias for __id__
|
@@ -37,13 +37,14 @@ module Hanami
|
|
37
37
|
|
38
38
|
# Interface for pp
|
39
39
|
#
|
40
|
+
# @param printer [PP] the Pretty Printable printer
|
40
41
|
# @return [String] the pretty-printable inspection of the object
|
41
42
|
#
|
42
43
|
# @since 0.9.0
|
43
44
|
#
|
44
45
|
# @see https://ruby-doc.org/stdlib/libdoc/pp/rdoc/PP.html
|
45
|
-
def pretty_print(
|
46
|
-
inspect
|
46
|
+
def pretty_print(printer)
|
47
|
+
printer.text(inspect)
|
47
48
|
end
|
48
49
|
|
49
50
|
# Returns true if responds to the given method.
|
data/lib/hanami/utils/escape.rb
CHANGED
@@ -362,7 +362,7 @@ module Hanami
|
|
362
362
|
# @api private
|
363
363
|
#
|
364
364
|
# @see Hanami::Utils::Escape.url
|
365
|
-
DEFAULT_URL_SCHEMES = %w
|
365
|
+
DEFAULT_URL_SCHEMES = %w[http https mailto].freeze
|
366
366
|
|
367
367
|
# The output of an escape.
|
368
368
|
#
|
@@ -511,7 +511,7 @@ module Hanami
|
|
511
511
|
return input if input.is_a?(SafeString)
|
512
512
|
|
513
513
|
SafeString.new(
|
514
|
-
URI::
|
514
|
+
URI::DEFAULT_PARSER.extract(
|
515
515
|
URI.decode_www_form_component(input),
|
516
516
|
schemes
|
517
517
|
).first.to_s
|
data/lib/hanami/utils/hash.rb
CHANGED
@@ -69,6 +69,26 @@ module Hanami
|
|
69
69
|
self[:deep_symbolize_keys].call(input)
|
70
70
|
end
|
71
71
|
|
72
|
+
# Stringify the given hash
|
73
|
+
#
|
74
|
+
# @param input [::Hash] the input
|
75
|
+
#
|
76
|
+
# @return [::Hash] the stringified hash
|
77
|
+
#
|
78
|
+
# @since 1.0.1
|
79
|
+
#
|
80
|
+
# @example Basic Usage
|
81
|
+
# require 'hanami/utils/hash'
|
82
|
+
#
|
83
|
+
# hash = Hanami::Utils::Hash.stringify(foo: "bar", baz: {a: 1})
|
84
|
+
# # => {"foo"=>"bar", "baz"=>{:a=>1}}
|
85
|
+
#
|
86
|
+
# hash.class
|
87
|
+
# # => Hash
|
88
|
+
def self.stringify(input)
|
89
|
+
self[:stringify_keys].call(input)
|
90
|
+
end
|
91
|
+
|
72
92
|
# Deep duplicate hash values
|
73
93
|
#
|
74
94
|
# The output of this function is a shallow duplicate of the input.
|
@@ -161,7 +181,7 @@ module Hanami
|
|
161
181
|
# hash.keys # => [:a, :b]
|
162
182
|
# hash.inspect # => { :a => 23, :b => { 'c' => ["x", "y", "z"] } }
|
163
183
|
def symbolize!
|
164
|
-
keys.each do |k|
|
184
|
+
keys.each do |k| # rubocop:disable Performance/HashEachMethods (this breaks the build)
|
165
185
|
v = delete(k)
|
166
186
|
self[k.to_sym] = v
|
167
187
|
end
|
@@ -184,7 +204,7 @@ module Hanami
|
|
184
204
|
# hash.keys # => [:a, :b]
|
185
205
|
# hash.inspect # => {:a=>23, :b=>{:c=>["x", "y", "z"]}}
|
186
206
|
def deep_symbolize!
|
187
|
-
keys.each do |k|
|
207
|
+
keys.each do |k| # rubocop:disable Performance/HashEachMethods (this breaks the build)
|
188
208
|
v = delete(k)
|
189
209
|
v = self.class.new(v).deep_symbolize! if v.respond_to?(:to_hash)
|
190
210
|
|
@@ -208,9 +228,8 @@ module Hanami
|
|
208
228
|
#
|
209
229
|
# hash.keys # => [:a, :b]
|
210
230
|
# hash.inspect # => {"a"=>23, "b"=>{"c"=>["x", "y", "z"]}}
|
211
|
-
|
212
231
|
def stringify!
|
213
|
-
keys.each do |k|
|
232
|
+
keys.each do |k| # rubocop:disable Performance/HashEachMethods (this breaks the build)
|
214
233
|
v = delete(k)
|
215
234
|
v = self.class.new(v).stringify! if v.respond_to?(:to_hash)
|
216
235
|
|
@@ -220,10 +239,6 @@ module Hanami
|
|
220
239
|
self
|
221
240
|
end
|
222
241
|
|
223
|
-
def self.stringify(input)
|
224
|
-
self[:stringify_keys].call(input)
|
225
|
-
end
|
226
|
-
|
227
242
|
# Return a deep copy of the current Hanami::Utils::Hash
|
228
243
|
#
|
229
244
|
# @return [Hash] a deep duplicated self
|
@@ -226,7 +226,8 @@ module Hanami
|
|
226
226
|
'police' => 'police',
|
227
227
|
# regressions
|
228
228
|
# https://github.com/hanami/utils/issues/106
|
229
|
-
'album' => 'albums'
|
229
|
+
'album' => 'albums',
|
230
|
+
'area' => 'areas'
|
230
231
|
)
|
231
232
|
|
232
233
|
# Irregular rules for singulars
|
@@ -267,8 +268,11 @@ module Hanami
|
|
267
268
|
'species' => 'species',
|
268
269
|
'police' => 'police',
|
269
270
|
# fallback
|
271
|
+
'areas' => 'area',
|
270
272
|
'hives' => 'hive',
|
271
|
-
'phases' => 'phase'
|
273
|
+
'phases' => 'phase',
|
274
|
+
'exercises' => 'exercise',
|
275
|
+
'releases' => 'release'
|
272
276
|
)
|
273
277
|
|
274
278
|
# Block for custom inflection rules.
|
@@ -309,10 +313,19 @@ module Hanami
|
|
309
313
|
# exception 'alga', 'algae'
|
310
314
|
# end
|
311
315
|
def self.exception(singular, plural)
|
316
|
+
add_to_inflecto(singular, plural)
|
312
317
|
singulars.add(plural, singular)
|
313
318
|
plurals.add(singular, plural)
|
314
319
|
end
|
315
320
|
|
321
|
+
# Since ROM uses Inflecto for it inferences, we need to add an exception to it
|
322
|
+
# when one is registered against our Inflector.
|
323
|
+
# @api private
|
324
|
+
def self.add_to_inflecto(singular, plural)
|
325
|
+
return unless defined? Inflecto
|
326
|
+
Inflecto.inflections.irregular(singular, plural)
|
327
|
+
end
|
328
|
+
|
316
329
|
# Add an uncountable word
|
317
330
|
#
|
318
331
|
# @param [Array<String>] words
|
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.1.0.
|
4
|
+
version: 1.1.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: transproc
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: 1.3.1
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.6.
|
137
|
+
rubygems_version: 2.6.13
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Ruby core extentions and Hanami utilities
|