hanami-utils 1.3.8 → 2.0.0.alpha1

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: ad4284f83bc4ccdc21289b5666f0fc63c1f7898c41016a30914baa0347bc8f5f
4
- data.tar.gz: 62a7dd46434d3136875f8f9e6b0590e09d32b87ec6df47ba3169761d2d59f7df
3
+ metadata.gz: 2d4523d52299280469a80451592c55d5771aeaf8e0f93644291f5e9d7a66237a
4
+ data.tar.gz: 27c144da73fcbd992b4fefdddb9dc1b5be1e58b5abff3fd4078c67f8ec561d43
5
5
  SHA512:
6
- metadata.gz: 48f9fb3cdeea538a03d383670b42cc6b5b8fed50018561a4738c08ad57dc93e3558436b3bf42a7d7b318f2b101d24e257dbf7f3397bb74fcfdad4f5481560f66
7
- data.tar.gz: 416a72a4d12e69e22456b5b0dd5a3eeb0911e18f305ab42c2308b7b6b2b7c2d0c39992b3d32e07db88cfb26547940f41bd88d421a2bb489b03000bc769ca79c1
6
+ metadata.gz: e0e48686597a78927e05bff5da29e0ba0db65f8a03796b36046bb6f84cf35bf964662a87a73bad88bca47096b2b51e737bee0b0545f7341cbbd3579c4e74d4bf
7
+ data.tar.gz: ebf2deed3ccf571a88ffd151d544254d483f65f26c5bf027c78cbe31220b22afc6b0c9f5b7a6223dd685c553b41fb80c2fe4a7b2a3629d4ab1cdfc5f9293e038
data/CHANGELOG.md CHANGED
@@ -1,41 +1,22 @@
1
1
  # Hanami::Utils
2
2
  Ruby core extentions and class utilities for Hanami
3
3
 
4
- ## v1.3.8 - 2021-05-03
5
- ### Fixed
6
- - [Hiếu Nguyễn] Ensure `Hanami::Interactor#initialize` to accept keyword arguments while working with Ruby 3
7
-
8
- ## v1.3.7 - 2021-01-04
9
- ### Added
10
- - [Luca Guidi] Official support for Ruby: MRI 3.0
11
- - [Khai Le] Allow `Hanami::Logger` to filter sensitive data for an array of hashes
12
-
13
- ### Fixed
14
- - [Hiếu Nguyễn] Ensure `Hanami::Logger` to not mutate `Hash` input when filtering sensitive data
15
-
16
- ## v1.3.6 - 2020-01-07
17
- ### Added
18
- - [Luca Guidi] Official support for Ruby: MRI 2.7
19
-
20
- ### Fixed
21
- - [ippachi] `Utils::Files.append`: don't check breakline if file is empty
22
-
23
- ## v1.3.5 - 2019-10-25
24
- ### Fixed
25
- - [Ivan Kabluchkov] Ensure `Hanami::Logger` filters to not crash when logger stream is a closed tempfile
26
- - [Luca Guidi] Ensure `Utils::Files.append` to append contents properly when existing file doesn't end with a newline
27
-
28
- ## v1.3.4 - 2019-09-27
4
+ ## v2.0.0.alpha1 - 2019-01-30
29
5
  ### Added
30
- - [Luca Guidi] Let `Utils::BasicObject` to lookup constants at the top-level namespace
6
+ - [Gustavo Caso] Introduce `Hanami::Middleware` namespace
7
+ - [Luca Guidi] Introduce `Callbacks::Chain#dup`
31
8
 
32
- ## v1.3.3 - 2019-09-13
33
- ### Fixed
34
- - [Mauro Morales] Ensure `Utils::Inflector.pluralize` and `.singularize` to work with words that contain an underscore (`_`)
35
-
36
- ## v1.3.2 - 2019-06-21
37
- ### Added
38
- - [Vladislav Yashin & Luca Guidi] Added `Utils::BasicObject#instance_of?`, `#is_a?`, and `#kind_of`
9
+ ### Changed
10
+ - [Luca Guidi] Drop support for Ruby: MRI 2.3, and 2.4.
11
+ - [Luca Guidi] Remove `Utils::Duplicable`
12
+ - [Luca Guidi] Remove `Utils::Inflector`
13
+ - [Luca Guidi] Remove `Utils::String.singularize`, and `.pluralize`
14
+ - [Luca Guidi] Remove `Utils::String#singularize`, and `#pluralize`
15
+ - [Luca Guidi] Remove instance level interface for `Utils::Hash`
16
+ - [Luca Guidi] Transform `Utils::Hash` from class to module
17
+ - [Luca Guidi] Remove `Utils.reload!`
18
+ - [Gustavo Caso] Remove `Utils::File.rewrite`
19
+ - [Vladimir Suvorov] Remove `Utils::Class.load_from_pattern!`
39
20
 
40
21
  ## v1.3.1 - 2019-01-18
41
22
  ### Added
data/README.md CHANGED
@@ -5,7 +5,8 @@ Ruby core extensions and class utilities for [Hanami](http://hanamirb.org)
5
5
  ## Status
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/hanami-utils.svg)](https://badge.fury.io/rb/hanami-utils)
8
- [![CI](https://github.com/hanami/utils/workflows/ci/badge.svg?branch=master)](https://github.com/hanami/utils/actions?query=workflow%3Aci+branch%3Amaster)
8
+ [![TravisCI](https://travis-ci.org/hanami/utils.svg?branch=master)](https://travis-ci.org/hanami/utils)
9
+ [![CircleCI](https://circleci.com/gh/hanami/utils/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/utils/tree/master)
9
10
  [![Test Coverage](https://codecov.io/gh/hanami/utils/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/utils)
10
11
  [![Depfu](https://badges.depfu.com/badges/a8545fb67cf32a2c75b6227bc0821027/overview.svg)](https://depfu.com/github/hanami/utils?project=Bundler)
11
12
  [![Inline Docs](http://inch-ci.org/github/hanami/utils.svg)](http://inch-ci.org/github/hanami/utils)
@@ -21,7 +22,7 @@ Ruby core extensions and class utilities for [Hanami](http://hanamirb.org)
21
22
 
22
23
  ## Rubies
23
24
 
24
- __Hanami::Utils__ supports Ruby (MRI) 2.3+, JRuby 9.1.5.0+
25
+ __Hanami::Utils__ supports Ruby (MRI) 2.5+
25
26
 
26
27
  ## Installation
27
28
 
@@ -78,11 +79,6 @@ Inheritable class attributes. [[API doc](http://www.rubydoc.info/gems/hanami-uti
78
79
 
79
80
  Deprecate Hanami features. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Deprecation)]
80
81
 
81
- ### Hanami::Utils::Duplicable
82
-
83
- Safe `#dup` logic for Ruby objects. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Duplicable)]
84
-
85
-
86
82
  ### Hanami::Utils::Escape
87
83
 
88
84
  Safe and fast escape for URLs, HTML content and attributes. Based on OWASP/ESAPI code. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Escape)]
@@ -97,16 +93,12 @@ File utilities to manipulate files and directories. [[API doc](http://www.rubydo
97
93
 
98
94
  ### Hanami::Utils::Hash
99
95
 
100
- Enhanced version of Ruby's `Hash`. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Hash)]
96
+ `Hash` transformations. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Hash)]
101
97
 
102
98
  ### Hanami::Utils::IO
103
99
 
104
100
  Silence Ruby warnings. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/IO)]
105
101
 
106
- ### Hanami::Utils::Inflector
107
-
108
- Complete and customizable english inflections (pluralization and singularization). [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Inflector)]
109
-
110
102
  ### Hanami::Utils::Json
111
103
 
112
104
  JSON engine with swappable backends (via optional `multi_json` gem) or powered by Ruby's `json` (default). [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Json)]
@@ -149,6 +141,6 @@ __Hanami::Utils__ uses [Semantic Versioning 2.0.0](http://semver.org)
149
141
 
150
142
  ## Copyright
151
143
 
152
- Copyright © 2014-2021 Luca Guidi – Released under MIT License
144
+ Copyright © 2014-2019 Luca Guidi – Released under MIT License
153
145
 
154
146
  This project was formerly known as Lotus (`lotus-utils`).
data/hanami-utils.gemspec CHANGED
@@ -18,13 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
- spec.required_ruby_version = ">= 2.3.0"
21
+ spec.required_ruby_version = ">= 2.5.0"
22
22
 
23
23
  spec.add_dependency "transproc", "~> 1.0"
24
24
  spec.add_dependency "concurrent-ruby", "~> 1.0"
25
25
 
26
26
  spec.add_development_dependency "bundler", ">= 1.6", "< 3"
27
- spec.add_development_dependency "rake", "~> 13"
28
- spec.add_development_dependency "rspec", "~> 3.9"
29
- spec.add_development_dependency "rubocop", "0.81" # rubocop 0.81+ removed support for Ruby 2.3
27
+ spec.add_development_dependency "rake", "~> 12"
28
+ spec.add_development_dependency "rspec", "~> 3.7"
30
29
  end
@@ -19,14 +19,14 @@ module Hanami
19
19
  # @api private
20
20
  #
21
21
  # @see Hanami::Interactor::Result#respond_to_missing?
22
- METHODS = ::Hash[initialize: true,
23
- success?: true,
22
+ METHODS = ::Hash[initialize: true,
23
+ success?: true,
24
24
  successful?: true,
25
- failure?: true,
26
- fail!: true,
27
- prepare!: true,
28
- errors: true,
29
- error: true].freeze
25
+ failure?: true,
26
+ fail!: true,
27
+ prepare!: true,
28
+ errors: true,
29
+ error: true].freeze
30
30
 
31
31
  # Initialize a new result
32
32
  #
@@ -42,7 +42,7 @@ module Hanami
42
42
  @success = true
43
43
  end
44
44
 
45
- # Checks if the current status is successful
45
+ # Check if the current status is successful
46
46
  #
47
47
  # @return [TrueClass,FalseClass] the result of the check
48
48
  #
@@ -52,9 +52,9 @@ module Hanami
52
52
  end
53
53
 
54
54
  # @since 0.3.5
55
- alias_method :success?, :successful?
55
+ alias success? successful?
56
56
 
57
- # Checks if the current status is not successful
57
+ # Check if the current status is not successful
58
58
  #
59
59
  # @return [TrueClass,FalseClass] the result of the check
60
60
  #
@@ -63,7 +63,7 @@ module Hanami
63
63
  !successful?
64
64
  end
65
65
 
66
- # Forces the status to be a failure
66
+ # Force the status to be a failure
67
67
  #
68
68
  # @since 0.3.5
69
69
  def fail!
@@ -106,7 +106,7 @@ module Hanami
106
106
  errors.first
107
107
  end
108
108
 
109
- # Prepares the result before to be returned
109
+ # Prepare the result before to be returned
110
110
  #
111
111
  # @param payload [Hash] an updated payload
112
112
  #
@@ -181,18 +181,10 @@ module Hanami
181
181
  # # ...
182
182
  # end
183
183
  # end
184
- if RUBY_VERSION >= "3.0"
185
- def initialize(*args, **kwargs)
186
- super
187
- ensure
188
- @__result = ::Hanami::Interactor::Result.new
189
- end
190
- else
191
- def initialize(*args)
192
- super
193
- ensure
194
- @__result = ::Hanami::Interactor::Result.new
195
- end
184
+ def initialize(*args)
185
+ super
186
+ ensure
187
+ @__result = ::Hanami::Interactor::Result.new
196
188
  end
197
189
 
198
190
  # Triggers the operation and return a result.
@@ -361,57 +353,33 @@ module Hanami
361
353
  # end
362
354
  #
363
355
  # Signup.new.call # => NoMethodError
364
- if RUBY_VERSION >= "3.0"
365
- def call(*args, **kwargs)
366
- @__result = ::Hanami::Interactor::Result.new
367
- _call(*args, **kwargs) { super }
368
- end
369
- else
370
- def call(*args)
371
- @__result = ::Hanami::Interactor::Result.new
372
- _call(*args) { super }
373
- end
356
+ def call(*args)
357
+ @__result = ::Hanami::Interactor::Result.new
358
+ _call(*args) { super }
374
359
  end
375
360
 
376
361
  private
377
362
 
378
363
  # @api private
379
364
  # @since 1.1.0
380
- if RUBY_VERSION >= "3.0"
381
- def _call(*args, **kwargs)
382
- catch :fail do
383
- validate!(*args, **kwargs)
384
- yield
385
- end
386
-
387
- _prepare!
365
+ def _call(*args)
366
+ catch :fail do
367
+ validate!(*args)
368
+ yield
388
369
  end
389
- else
390
- def _call(*args)
391
- catch :fail do
392
- validate!(*args)
393
- yield
394
- end
395
370
 
396
- _prepare!
397
- end
371
+ _prepare!
398
372
  end
399
373
 
400
374
  # @since 1.1.0
401
- if RUBY_VERSION >= "3.0"
402
- def validate!(*args, **kwargs)
403
- fail! unless valid?(*args, **kwargs)
404
- end
405
- else
406
- def validate!(*args)
407
- fail! unless valid?(*args)
408
- end
375
+ def validate!(*args)
376
+ fail! unless valid?(*args)
409
377
  end
410
378
  end
411
379
 
412
380
  private
413
381
 
414
- # Checks if proceed with <tt>#call</tt> invocation.
382
+ # Check if proceed with <tt>#call</tt> invokation.
415
383
  # By default it returns <tt>true</tt>.
416
384
  #
417
385
  # Developers can override it.
@@ -423,7 +391,7 @@ module Hanami
423
391
  true
424
392
  end
425
393
 
426
- # Fails and interrupts the current flow.
394
+ # Fail and interrupt the current flow.
427
395
  #
428
396
  # @since 0.3.5
429
397
  #
@@ -462,7 +430,7 @@ module Hanami
462
430
  throw :fail
463
431
  end
464
432
 
465
- # Logs an error without interrupting the flow.
433
+ # Log an error without interrupting the flow.
466
434
  #
467
435
  # When used, the returned result won't be successful.
468
436
  #
@@ -517,7 +485,7 @@ module Hanami
517
485
  false
518
486
  end
519
487
 
520
- # Logs an error and interrupts the flow.
488
+ # Log an error AND interrupting the flow.
521
489
  #
522
490
  # When used, the returned result won't be successful.
523
491
  #
@@ -580,7 +548,7 @@ module Hanami
580
548
  # @since 0.5.0
581
549
  # @api private
582
550
  def _exposures
583
- Hash[].tap do |result|
551
+ ::Hash[].tap do |result|
584
552
  self.class.exposures.each do |name, ivar|
585
553
  result[name] = instance_variable_defined?(ivar) ? instance_variable_get(ivar) : nil
586
554
  end
@@ -613,7 +581,7 @@ module Hanami
613
581
  end
614
582
  end
615
583
 
616
- # Exposes local instance variables into the returning value of <tt>#call</tt>
584
+ # Expose local instance variables into the returning value of <tt>#call</tt>
617
585
  #
618
586
  # @param instance_variable_names [Symbol,Array<Symbol>] one or more instance
619
587
  # variable names
@@ -622,7 +590,7 @@ module Hanami
622
590
  #
623
591
  # @see Hanami::Interactor::Result
624
592
  #
625
- # @example Exposes instance variable
593
+ # @example Expose instance variable
626
594
  #
627
595
  # class Signup
628
596
  # include Hanami::Interactor
data/lib/hanami/logger.rb CHANGED
@@ -7,7 +7,7 @@ require "hanami/utils/files"
7
7
  module Hanami
8
8
  # Hanami logger
9
9
  #
10
- # Implementation with the same interface of Ruby std lib `Logger`.
10
+ # Implement with the same interface of Ruby std lib `Logger`.
11
11
  # It uses `STDOUT`, `STDERR`, file name or open file as output stream.
12
12
  #
13
13
  #
@@ -16,7 +16,7 @@ module Hanami
16
16
  #
17
17
  # This is useful for auto-tagging the output. Eg (`app=Booshelf`).
18
18
  #
19
- # When used standalone (eg. `Hanami::Logger.info`), it tags lines with `app=Shared`.
19
+ # When used stand alone (eg. `Hanami::Logger.info`), it tags lines with `app=Shared`.
20
20
  #
21
21
  #
22
22
  # The available severity levels are the same of `Logger`:
@@ -30,7 +30,7 @@ module Hanami
30
30
  #
31
31
  # Those levels are available both as class and instance methods.
32
32
  #
33
- # Also Hanami::Logger supports different formatters. Now available only two:
33
+ # Also Hanami::Logger support different formatters. Now available only two:
34
34
  #
35
35
  # * Formatter (default)
36
36
  # * JSONFormatter
@@ -132,11 +132,11 @@ module Hanami
132
132
  # @since 0.8.0
133
133
  # @api private
134
134
  LEVELS = ::Hash[
135
- "debug" => DEBUG,
136
- "info" => INFO,
137
- "warn" => WARN,
138
- "error" => ERROR,
139
- "fatal" => FATAL,
135
+ "debug" => DEBUG,
136
+ "info" => INFO,
137
+ "warn" => WARN,
138
+ "error" => ERROR,
139
+ "fatal" => FATAL,
140
140
  "unknown" => UNKNOWN
141
141
  ].freeze
142
142
 
@@ -279,9 +279,9 @@ module Hanami
279
279
  # logger.info "Hello World"
280
280
  #
281
281
  # # => {"app":"Hanami","severity":"DEBUG","time":"2017-03-30T13:57:59Z","message":"Hello World"}
282
- # rubocop:disable Lint/SuppressedException
282
+ # rubocop:disable Lint/HandleExceptions
283
283
  # rubocop:disable Metrics/ParameterLists
284
- def initialize(application_name = nil, *args, stream: $stdout, level: DEBUG, formatter: nil, filter: [], colorizer: nil) # rubocop:disable Layout/LineLength
284
+ def initialize(application_name = nil, *args, stream: $stdout, level: DEBUG, formatter: nil, filter: [], colorizer: nil)
285
285
  begin
286
286
  Utils::Files.mkdir_p(stream)
287
287
  rescue TypeError
@@ -296,7 +296,7 @@ module Hanami
296
296
  end
297
297
 
298
298
  # rubocop:enable Metrics/ParameterLists
299
- # rubocop:enable Lint/SuppressedException
299
+ # rubocop:enable Lint/HandleExceptions
300
300
 
301
301
  # Returns the current application name, this is used for tagging purposes
302
302
  #
@@ -313,7 +313,7 @@ module Hanami
313
313
  super _level(value)
314
314
  end
315
315
 
316
- # Closes the logging stream if this stream isn't an STDOUT
316
+ # Close the logging stream if this stream isn't an STDOUT
317
317
  #
318
318
  # @since 0.8.0
319
319
  def close
@@ -14,9 +14,9 @@ module Hanami
14
14
  # @api private
15
15
  def call(app, severity, datetime, _progname)
16
16
  ::Hash[
17
- app: app,
17
+ app: app,
18
18
  severity: severity,
19
- time: datetime,
19
+ time: datetime,
20
20
  ]
21
21
  end
22
22
  end
@@ -44,9 +44,9 @@ module Hanami
44
44
  # @return [::Hash] an Hash containing the keys `:app`, `:severity`, and `:time`
45
45
  def call(app, severity, datetime, _progname)
46
46
  ::Hash[
47
- app: app(app),
47
+ app: app(app),
48
48
  severity: severity(severity),
49
- time: datetime(datetime),
49
+ time: datetime(datetime),
50
50
  ]
51
51
  end
52
52
 
@@ -57,18 +57,18 @@ module Hanami
57
57
  # @since 1.2.0
58
58
  # @api private
59
59
  COLORS = ::Hash[
60
- app: :blue,
60
+ app: :blue,
61
61
  datetime: :cyan,
62
62
  ].freeze
63
63
 
64
64
  # @since 1.2.0
65
65
  # @api private
66
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,
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
72
  Hanami::Logger::UNKNOWN => :blue,
73
73
  ].freeze
74
74