eac_ruby_utils 0.51.1 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_ruby_utils/abstract_methods.rb +59 -0
- data/lib/eac_ruby_utils/version.rb +1 -1
- data/lib/eac_ruby_utils/yaml.rb +3 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1cd6f8891c93e7a6a866a11fa705c3ce0609b5b0d6b5e5468d73a46ed135121
|
4
|
+
data.tar.gz: 49a544fac4a944b2c58ad8cbd0f06eeec6a3e9e5e1df4a66872bdd34bf79c1ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/eac_ruby_utils/yaml.rb
CHANGED
@@ -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,
|
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.
|
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-
|
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
|