eac_ruby_utils 0.51.1 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 247be76881888a818e9c8d0c5970ee9068b8fe1edade1d73855916581279b5fc
4
- data.tar.gz: ca9aaf7f3c0c82f26a3a44b50844f0326c06855b0163b60c9238aaf450f235b9
3
+ metadata.gz: d1cd6f8891c93e7a6a866a11fa705c3ce0609b5b0d6b5e5468d73a46ed135121
4
+ data.tar.gz: 49a544fac4a944b2c58ad8cbd0f06eeec6a3e9e5e1df4a66872bdd34bf79c1ef
5
5
  SHA512:
6
- metadata.gz: ccb0243f0fa95ae62218ffdb260a78e998d748fd879cf20424465c94389a91038ed704d4073fa9b1875622bd7d38a995de3110209d1c1bba32a58df4cd6ba74a
7
- data.tar.gz: 65d8e17a1e7b2d10ddb49b0404c6e4a9176e227c31d70dd0e3af49254ecc6bc3a39052420e580bc5c70a18ad63e0a0d88c049c69f22bf76898b221efcda14a87
6
+ metadata.gz: 00e8db1cb8da1ed4b54aee6e704820b8962b22e5f9bdb0321354db5ed044cd1799024775c8704765a25d302d2cce776de2511e511665b5d55d00150c3e897271
7
+ data.tar.gz: 8da830a3af85dc78d88b919645522cdec79e52c61086517b35bb9a64a14e5f9d4bc2af067f9cef31153268e1b1522b7adbad3e0507d04a62fcd2255e9f090d2f
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/module/common_concern'
4
+
5
+ module EacRubyUtils
6
+ # Support to abstract methods.
7
+ #
8
+ # Usage:
9
+ #
10
+ # require 'eac_ruby_utils/abstract_methods'
11
+ #
12
+ # class BaseClass
13
+ # include EacRubyUtils::AbstractMethods
14
+ #
15
+ # abstract_methods :mymethod
16
+ # end
17
+ #
18
+ # BaseClass.new.mymethod # raise "Abstract method: mymethod"
19
+ #
20
+ # class SubClass
21
+ # def mymethod
22
+ # "Implemented"
23
+ # end
24
+ # end
25
+ #
26
+ # SubClass.new.mymethod # return "Implemented"
27
+ module AbstractMethods
28
+ common_concern
29
+
30
+ module ClassMethods
31
+ def abstract_methods(*methods_names)
32
+ @abstract_methods ||= Set.new
33
+ @abstract_methods += methods_names.map(&:to_sym)
34
+
35
+ @abstract_methods.to_enum
36
+ end
37
+ end
38
+
39
+ module InstanceMethods
40
+ def respond_to_missing?(method_name, include_private = false)
41
+ super || abstract_method?(method_name)
42
+ end
43
+
44
+ def method_missing(method_name, *arguments, &block)
45
+ raise_abstract_method(method_name) if abstract_method?(method_name)
46
+
47
+ super
48
+ end
49
+
50
+ def abstract_method?(method_name)
51
+ self.class.abstract_methods.include?(method_name.to_sym)
52
+ end
53
+
54
+ def raise_abstract_method(method_name)
55
+ raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\""
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.51.1'
4
+ VERSION = '0.52.0'
5
5
  end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'date'
3
4
  require 'yaml'
4
5
 
5
6
  module EacRubyUtils
6
7
  # A safe YAML loader/dumper with common types included.
7
8
  class Yaml
8
9
  class << self
9
- DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::FalseClass, ::Hash, ::NilClass, ::Numeric,
10
- ::String, ::Symbol, ::Time, ::TrueClass].freeze
10
+ DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::DateTime, ::FalseClass, ::Hash, ::NilClass,
11
+ ::Numeric, ::String, ::Symbol, ::Time, ::TrueClass].freeze
11
12
 
12
13
  def dump(object)
13
14
  ::YAML.dump(sanitize(object))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.51.1
4
+ version: 0.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,7 @@ extra_rdoc_files: []
108
108
  files:
109
109
  - README.rdoc
110
110
  - lib/eac_ruby_utils.rb
111
+ - lib/eac_ruby_utils/abstract_methods.rb
111
112
  - lib/eac_ruby_utils/arguments_consumer.rb
112
113
  - lib/eac_ruby_utils/blank_not_blank.rb
113
114
  - lib/eac_ruby_utils/boolean.rb