hanami-utils 1.3.6 → 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: 0e6573938b28f1b4f3b8f46aebec53e487d0af4e85087a65d5e081c4fdc2f030
4
- data.tar.gz: e2d13a7d2a675633a7b984882d7c01c5963b3933f1d9339b871ed20838b630c9
3
+ metadata.gz: 2d4523d52299280469a80451592c55d5771aeaf8e0f93644291f5e9d7a66237a
4
+ data.tar.gz: 27c144da73fcbd992b4fefdddb9dc1b5be1e58b5abff3fd4078c67f8ec561d43
5
5
  SHA512:
6
- metadata.gz: f8255168597fd310d075400c0a926b28f7bea6dd2025b1572d065e8df7e7ecfa76f991dc88afa1be37b3dfa57b06e70332015018e724ad7731184329a1cab559
7
- data.tar.gz: 4ff3e862379db3b02d1fecace8336ed0f44df2b98c9588f807f46883b3b0e7a862beac8119da7428b07484802842b09aca509e1d01ee9dc25360438847d94f63
6
+ metadata.gz: e0e48686597a78927e05bff5da29e0ba0db65f8a03796b36046bb6f84cf35bf964662a87a73bad88bca47096b2b51e737bee0b0545f7341cbbd3579c4e74d4bf
7
+ data.tar.gz: ebf2deed3ccf571a88ffd151d544254d483f65f26c5bf027c78cbe31220b22afc6b0c9f5b7a6223dd685c553b41fb80c2fe4a7b2a3629d4ab1cdfc5f9293e038
@@ -1,29 +1,22 @@
1
1
  # Hanami::Utils
2
2
  Ruby core extentions and class utilities for Hanami
3
3
 
4
- ## v1.3.6 - 2020-01-07
4
+ ## v2.0.0.alpha1 - 2019-01-30
5
5
  ### Added
6
- - [Luca Guidi] Official support for Ruby: MRI 2.7
6
+ - [Gustavo Caso] Introduce `Hanami::Middleware` namespace
7
+ - [Luca Guidi] Introduce `Callbacks::Chain#dup`
7
8
 
8
- ### Fixed
9
- - [ippachi] `Utils::Files.append`: don't check breakline if file is empty
10
-
11
- ## v1.3.5 - 2019-10-25
12
- ### Fixed
13
- - [Ivan Kabluchkov] Ensure `Hanami::Logger` filters to not crash when logger stream is a closed tempfile
14
- - [Luca Guidi] Ensure `Utils::Files.append` to append contents properly when existing file doesn't end with a newline
15
-
16
- ## v1.3.4 - 2019-09-27
17
- ### Added
18
- - [Luca Guidi] Let `Utils::BasicObject` to lookup constants at the top-level namespace
19
-
20
- ## v1.3.3 - 2019-09-13
21
- ### Fixed
22
- - [Mauro Morales] Ensure `Utils::Inflector.pluralize` and `.singularize` to work with words that contain an underscore (`_`)
23
-
24
- ## v1.3.2 - 2019-06-21
25
- ### Added
26
- - [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!`
27
20
 
28
21
  ## v1.3.1 - 2019-01-18
29
22
  ### Added
data/README.md CHANGED
@@ -5,7 +5,7 @@ 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
- [![Build Status](https://ci.hanamirb.org/api/badges/hanami/utils/status.svg)](https://ci.hanamirb.org/hanami/utils)
8
+ [![TravisCI](https://travis-ci.org/hanami/utils.svg?branch=master)](https://travis-ci.org/hanami/utils)
9
9
  [![CircleCI](https://circleci.com/gh/hanami/utils/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/utils/tree/master)
10
10
  [![Test Coverage](https://codecov.io/gh/hanami/utils/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/utils)
11
11
  [![Depfu](https://badges.depfu.com/badges/a8545fb67cf32a2c75b6227bc0821027/overview.svg)](https://depfu.com/github/hanami/utils?project=Bundler)
@@ -22,7 +22,7 @@ Ruby core extensions and class utilities for [Hanami](http://hanamirb.org)
22
22
 
23
23
  ## Rubies
24
24
 
25
- __Hanami::Utils__ supports Ruby (MRI) 2.3+, JRuby 9.1.5.0+
25
+ __Hanami::Utils__ supports Ruby (MRI) 2.5+
26
26
 
27
27
  ## Installation
28
28
 
@@ -79,11 +79,6 @@ Inheritable class attributes. [[API doc](http://www.rubydoc.info/gems/hanami-uti
79
79
 
80
80
  Deprecate Hanami features. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Deprecation)]
81
81
 
82
- ### Hanami::Utils::Duplicable
83
-
84
- Safe `#dup` logic for Ruby objects. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Duplicable)]
85
-
86
-
87
82
  ### Hanami::Utils::Escape
88
83
 
89
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)]
@@ -98,16 +93,12 @@ File utilities to manipulate files and directories. [[API doc](http://www.rubydo
98
93
 
99
94
  ### Hanami::Utils::Hash
100
95
 
101
- 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)]
102
97
 
103
98
  ### Hanami::Utils::IO
104
99
 
105
100
  Silence Ruby warnings. [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/IO)]
106
101
 
107
- ### Hanami::Utils::Inflector
108
-
109
- Complete and customizable english inflections (pluralization and singularization). [[API doc](http://www.rubydoc.info/gems/hanami-utils/Hanami/Utils/Inflector)]
110
-
111
102
  ### Hanami::Utils::Json
112
103
 
113
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)]
@@ -150,6 +141,6 @@ __Hanami::Utils__ uses [Semantic Versioning 2.0.0](http://semver.org)
150
141
 
151
142
  ## Copyright
152
143
 
153
- Copyright © 2014-2017 Luca Guidi – Released under MIT License
144
+ Copyright © 2014-2019 Luca Guidi – Released under MIT License
154
145
 
155
146
  This project was formerly known as Lotus (`lotus-utils`).
@@ -1,27 +1,29 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'hanami/utils/version'
5
+ require "hanami/utils/version"
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = 'hanami-utils'
8
+ spec.name = "hanami-utils"
7
9
  spec.version = Hanami::Utils::VERSION
8
- spec.authors = ['Luca Guidi']
9
- spec.email = ['me@lucaguidi.com']
10
- spec.description = 'Hanami utilities'
11
- spec.summary = 'Ruby core extentions and Hanami utilities'
12
- spec.homepage = 'http://hanamirb.org'
13
- spec.license = 'MIT'
10
+ spec.authors = ["Luca Guidi"]
11
+ spec.email = ["me@lucaguidi.com"]
12
+ spec.description = "Hanami utilities"
13
+ spec.summary = "Ruby core extentions and Hanami utilities"
14
+ spec.homepage = "http://hanamirb.org"
15
+ spec.license = "MIT"
14
16
 
15
17
  spec.files = `git ls-files -- lib/* CHANGELOG.md LICENSE.md README.md hanami-utils.gemspec`.split($/)
16
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ['lib']
19
- spec.required_ruby_version = '>= 2.3.0'
20
+ spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = ">= 2.5.0"
20
22
 
21
- spec.add_dependency 'transproc', '~> 1.0'
22
- spec.add_dependency 'concurrent-ruby', '~> 1.0'
23
+ spec.add_dependency "transproc", "~> 1.0"
24
+ spec.add_dependency "concurrent-ruby", "~> 1.0"
23
25
 
24
- spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
25
- spec.add_development_dependency 'rake', '~> 13'
26
- spec.add_development_dependency 'rspec', '~> 3.7'
26
+ spec.add_development_dependency "bundler", ">= 1.6", "< 3"
27
+ spec.add_development_dependency "rake", "~> 12"
28
+ spec.add_development_dependency "rspec", "~> 3.7"
27
29
  end
@@ -1 +1,3 @@
1
- require 'hanami/utils'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils"
@@ -1,6 +1,8 @@
1
- require 'hanami/utils/basic_object'
2
- require 'hanami/utils/class_attribute'
3
- require 'hanami/utils/hash'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils/basic_object"
4
+ require "hanami/utils/class_attribute"
5
+ require "hanami/utils/hash"
4
6
 
5
7
  module Hanami
6
8
  # Hanami Interactor
@@ -40,7 +42,7 @@ module Hanami
40
42
  @success = true
41
43
  end
42
44
 
43
- # Checks if the current status is successful
45
+ # Check if the current status is successful
44
46
  #
45
47
  # @return [TrueClass,FalseClass] the result of the check
46
48
  #
@@ -52,7 +54,7 @@ module Hanami
52
54
  # @since 0.3.5
53
55
  alias success? successful?
54
56
 
55
- # Checks if the current status is not successful
57
+ # Check if the current status is not successful
56
58
  #
57
59
  # @return [TrueClass,FalseClass] the result of the check
58
60
  #
@@ -61,7 +63,7 @@ module Hanami
61
63
  !successful?
62
64
  end
63
65
 
64
- # Forces the status to be a failure
66
+ # Force the status to be a failure
65
67
  #
66
68
  # @since 0.3.5
67
69
  def fail!
@@ -104,7 +106,7 @@ module Hanami
104
106
  errors.first
105
107
  end
106
108
 
107
- # Prepares the result before to be returned
109
+ # Prepare the result before to be returned
108
110
  #
109
111
  # @param payload [Hash] an updated payload
110
112
  #
@@ -377,7 +379,7 @@ module Hanami
377
379
 
378
380
  private
379
381
 
380
- # Checks if proceed with <tt>#call</tt> invocation.
382
+ # Check if proceed with <tt>#call</tt> invokation.
381
383
  # By default it returns <tt>true</tt>.
382
384
  #
383
385
  # Developers can override it.
@@ -389,7 +391,7 @@ module Hanami
389
391
  true
390
392
  end
391
393
 
392
- # Fails and interrupts the current flow.
394
+ # Fail and interrupt the current flow.
393
395
  #
394
396
  # @since 0.3.5
395
397
  #
@@ -428,7 +430,7 @@ module Hanami
428
430
  throw :fail
429
431
  end
430
432
 
431
- # Logs an error without interrupting the flow.
433
+ # Log an error without interrupting the flow.
432
434
  #
433
435
  # When used, the returned result won't be successful.
434
436
  #
@@ -483,7 +485,7 @@ module Hanami
483
485
  false
484
486
  end
485
487
 
486
- # Logs an error and interrupts the flow.
488
+ # Log an error AND interrupting the flow.
487
489
  #
488
490
  # When used, the returned result won't be successful.
489
491
  #
@@ -546,7 +548,7 @@ module Hanami
546
548
  # @since 0.5.0
547
549
  # @api private
548
550
  def _exposures
549
- Hash[].tap do |result|
551
+ ::Hash[].tap do |result|
550
552
  self.class.exposures.each do |name, ivar|
551
553
  result[name] = instance_variable_defined?(ivar) ? instance_variable_get(ivar) : nil
552
554
  end
@@ -579,7 +581,7 @@ module Hanami
579
581
  end
580
582
  end
581
583
 
582
- # 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>
583
585
  #
584
586
  # @param instance_variable_names [Symbol,Array<Symbol>] one or more instance
585
587
  # variable names
@@ -588,7 +590,7 @@ module Hanami
588
590
  #
589
591
  # @see Hanami::Interactor::Result
590
592
  #
591
- # @example Exposes instance variable
593
+ # @example Expose instance variable
592
594
  #
593
595
  # class Signup
594
596
  # include Hanami::Interactor
@@ -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
@@ -279,7 +279,7 @@ 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
284
  def initialize(application_name = nil, *args, stream: $stdout, level: DEBUG, formatter: nil, filter: [], colorizer: nil)
285
285
  begin
@@ -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
@@ -42,7 +42,7 @@ module Hanami
42
42
  # @api private
43
43
  def _key_paths(hash, base = nil)
44
44
  hash.inject([]) do |results, (k, v)|
45
- results + (_key_paths?(v) ? _key_paths(v, _build_path(base, k)) : [_build_path(base, k)])
45
+ results + (v.respond_to?(:each) ? _key_paths(v, _build_path(base, k)) : [_build_path(base, k)])
46
46
  end
47
47
  end
48
48
 
@@ -63,17 +63,6 @@ module Hanami
63
63
  res + [correct_key]
64
64
  end
65
65
  end
66
-
67
- # Check if the given value can be iterated (`Enumerable`) and that isn't a `File`.
68
- # This is useful to detect closed `Tempfiles`.
69
- #
70
- # @since 1.3.5
71
- # @api private
72
- #
73
- # @see https://github.com/hanami/utils/pull/342
74
- def _key_paths?(value)
75
- value.is_a?(Enumerable) && !value.is_a?(File)
76
- end
77
66
  end
78
67
  end
79
68
  end
@@ -105,16 +105,16 @@ module Hanami
105
105
  # @api private
106
106
  def _message_hash(message) # rubocop:disable Metrics/MethodLength
107
107
  case message
108
- when Hash
108
+ when ::Hash
109
109
  @filter.call(message)
110
110
  when Exception
111
- Hash[
111
+ ::Hash[
112
112
  message: message.message,
113
113
  backtrace: message.backtrace || [],
114
114
  error: message.class
115
115
  ]
116
116
  else
117
- Hash[message: message]
117
+ ::Hash[message: message]
118
118
  end
119
119
  end
120
120
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module Middleware
5
+ # Hanami middleware utils
6
+
7
+ # @since 2.0.0
8
+ class Error < ::StandardError
9
+ end
10
+ end
11
+ end
@@ -1,11 +1,13 @@
1
- require 'pathname'
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
2
4
 
3
5
  # Hanami - The web, with simplicity
4
6
  #
5
7
  # @since 0.1.0
6
8
  module Hanami
7
- require 'hanami/utils/version'
8
- require 'hanami/utils/file_list'
9
+ require "hanami/utils/version"
10
+ require "hanami/utils/file_list"
9
11
 
10
12
  # Ruby core extentions and Hanami utilities
11
13
  #
@@ -13,15 +15,15 @@ module Hanami
13
15
  module Utils
14
16
  # @since 0.3.1
15
17
  # @api private
16
- HANAMI_JRUBY = 'java'.freeze
18
+ HANAMI_JRUBY = "java"
17
19
 
18
20
  # @since 0.3.1
19
21
  # @api private
20
- HANAMI_RUBINIUS = 'rbx'.freeze
22
+ HANAMI_RUBINIUS = "rbx"
21
23
 
22
24
  # Checks if the current VM is JRuby
23
25
  #
24
- # @return [TrueClass,FalseClass] info whether the VM is JRuby or not
26
+ # @return [TrueClass,FalseClass] return if the VM is JRuby or not
25
27
  #
26
28
  # @since 0.3.1
27
29
  # @api private
@@ -31,7 +33,7 @@ module Hanami
31
33
 
32
34
  # Checks if the current VM is Rubinius
33
35
  #
34
- # @return [TrueClass,FalseClass] info whether the VM is Rubinius or not
36
+ # @return [TrueClass,FalseClass] return if the VM is Rubinius or not
35
37
  #
36
38
  # @since 0.3.1
37
39
  # @api private
@@ -39,7 +41,7 @@ module Hanami
39
41
  RUBY_ENGINE == HANAMI_RUBINIUS
40
42
  end
41
43
 
42
- # Recursively requires Ruby files under the given directory.
44
+ # Recursively require Ruby files under the given directory.
43
45
  #
44
46
  # If the directory is relative, it implies it's the path from current directory.
45
47
  # If the directory is absolute, it uses as it is.
@@ -54,22 +56,6 @@ module Hanami
54
56
  for_each_file_in(directory) { |file| require_relative(file) }
55
57
  end
56
58
 
57
- # Recursively reloads Ruby files under the given directory.
58
- #
59
- # If the directory is relative, it implies it's the path from current directory.
60
- # If the directory is absolute, it uses as it is.
61
- #
62
- # It respects file separator of the current operating system.
63
- # A pattern like <tt>"path/to/files"</tt> will work both on *NIX and Windows machines.
64
- #
65
- # @param directory [String, Pathname] the directory
66
- #
67
- # @since 1.0.0
68
- # @api private
69
- def self.reload!(directory)
70
- for_each_file_in(directory) { |file| load(file) }
71
- end
72
-
73
59
  # Recursively scans through the given directory and yields the given block
74
60
  # for each Ruby source file.
75
61
  #
@@ -87,7 +73,7 @@ module Hanami
87
73
  def self.for_each_file_in(directory, &blk)
88
74
  directory = directory.to_s.gsub(%r{(\/|\\)}, File::SEPARATOR)
89
75
  directory = Pathname.new(Dir.pwd).join(directory).to_s
90
- directory = File.join(directory, '**', '*.rb') unless directory =~ /(\*\*)/
76
+ directory = File.join(directory, "**", "*.rb") unless directory =~ /(\*\*)/
91
77
 
92
78
  FileList[directory].each(&blk)
93
79
  end