koine-attributes 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/.rubocop.yml +61 -0
- data/Gemfile +2 -0
- data/koine-attributes.gemspec +7 -5
- data/lib/koine/attributes.rb +15 -16
- data/lib/koine/attributes/adapter/any.rb +2 -0
- data/lib/koine/attributes/adapter/array_of.rb +4 -2
- data/lib/koine/attributes/adapter/base.rb +4 -2
- data/lib/koine/attributes/adapter/boolean.rb +3 -0
- data/lib/koine/attributes/adapter/date.rb +3 -0
- data/lib/koine/attributes/adapter/float.rb +2 -0
- data/lib/koine/attributes/adapter/hash_of.rb +2 -0
- data/lib/koine/attributes/adapter/integer.rb +2 -0
- data/lib/koine/attributes/adapter/string.rb +3 -0
- data/lib/koine/attributes/adapter/symbol.rb +2 -0
- data/lib/koine/attributes/adapter/time.rb +3 -0
- data/lib/koine/attributes/attributes.rb +3 -0
- data/lib/koine/attributes/attributes_factory.rb +3 -0
- data/lib/koine/attributes/hash_helper.rb +2 -0
- data/lib/koine/attributes/invalid_attribute_error.rb +2 -0
- data/lib/koine/attributes/invalid_attributes_error.rb +2 -0
- data/lib/koine/attributes/version.rb +3 -1
- metadata +38 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea4db07fefad5477d0a6471ba407dc0d3b6e2cdfd779d5268baa47ca2202797a
|
4
|
+
data.tar.gz: 6d9c89041ab2029259642e4d4624ecb8f6cc838d210fecb8b8f6de87ae038621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f89b82226c6233228aa6682952934c0009c3295534629899a20c03863053685a99538b6aec74d5d1dc067b7abc9e421c382d9abdc1ef9995996d8a942249efc
|
7
|
+
data.tar.gz: bf230e8600265df219ce6c6e1ebb02a8a1ccbb9188fe8f2020fb081220aeb883c8032a4003cd43974fcd11ae844990f55d4659d4d03e683ef38e3106e15f59c6
|
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
Metrics/BlockLength:
|
6
|
+
Exclude:
|
7
|
+
- 'spec/**/*'
|
8
|
+
|
9
|
+
Layout/LineLength:
|
10
|
+
Max: 100
|
11
|
+
Exclude:
|
12
|
+
- 'db/seeds.rb'
|
13
|
+
|
14
|
+
Style/Documentation:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/GuardClause:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/IfUnlessModifier:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Layout/MultilineMethodCallIndentation:
|
24
|
+
EnforcedStyle: indented
|
25
|
+
|
26
|
+
Layout/MultilineOperationIndentation:
|
27
|
+
Enabled: true
|
28
|
+
EnforcedStyle: indented
|
29
|
+
|
30
|
+
Layout/FirstArrayElementIndentation:
|
31
|
+
EnforcedStyle: consistent
|
32
|
+
|
33
|
+
Naming/RescuedExceptionsVariableName:
|
34
|
+
PreferredName: 'exception'
|
35
|
+
|
36
|
+
Style/FormatStringToken:
|
37
|
+
EnforcedStyle: template
|
38
|
+
|
39
|
+
RSpec/ExampleLength:
|
40
|
+
Max: 10
|
41
|
+
|
42
|
+
RSpec/MultipleExpectations:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
RSpec/NamedSubject:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
AllCops:
|
49
|
+
Exclude:
|
50
|
+
- 'bin/**/*'
|
51
|
+
- 'config/**/*'
|
52
|
+
- 'config.ru'
|
53
|
+
- 'db/schema.rb'
|
54
|
+
- 'doc/**/*'
|
55
|
+
- 'docker/**/*'
|
56
|
+
- 'log/**/*'
|
57
|
+
- 'node_modules/**/*'
|
58
|
+
- 'node_modules/**/*'
|
59
|
+
- 'Rakefile'
|
60
|
+
- 'script/**/*'
|
61
|
+
- 'vendor/**/*'
|
data/Gemfile
CHANGED
data/koine-attributes.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'koine/attributes/version'
|
6
6
|
|
@@ -32,10 +32,12 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ['lib']
|
33
33
|
|
34
34
|
spec.add_development_dependency 'bundler'
|
35
|
+
spec.add_development_dependency 'coveralls'
|
35
36
|
spec.add_development_dependency 'rake'
|
37
|
+
spec.add_development_dependency 'reek'
|
36
38
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
-
spec.add_development_dependency '
|
39
|
+
spec.add_development_dependency 'rubocop', '0.79.0'
|
40
|
+
spec.add_development_dependency 'rubocop-performance'
|
41
|
+
spec.add_development_dependency 'rubocop-rspec'
|
38
42
|
spec.add_development_dependency 'simplecov'
|
39
|
-
spec.add_development_dependency 'rubocop'
|
40
|
-
spec.add_development_dependency 'reek'
|
41
43
|
end
|
data/lib/koine/attributes.rb
CHANGED
@@ -1,7 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
1
4
|
require 'koine/attributes/version'
|
2
5
|
require 'koine/attributes/adapter/base'
|
3
6
|
require 'koine/attributes/invalid_attribute_error'
|
4
7
|
require 'koine/attributes/invalid_attributes_error'
|
8
|
+
require 'koine/attributes/attributes'
|
9
|
+
require 'koine/attributes/attributes_factory'
|
10
|
+
require 'koine/attributes/adapter/any'
|
11
|
+
require 'koine/attributes/adapter/array_of'
|
12
|
+
require 'koine/attributes/adapter/boolean'
|
13
|
+
require 'koine/attributes/adapter/date'
|
14
|
+
require 'koine/attributes/adapter/float'
|
15
|
+
require 'koine/attributes/adapter/hash_of'
|
16
|
+
require 'koine/attributes/adapter/integer'
|
17
|
+
require 'koine/attributes/adapter/string'
|
18
|
+
require 'koine/attributes/adapter/symbol'
|
19
|
+
require 'koine/attributes/adapter/time'
|
5
20
|
|
6
21
|
# provides the following API
|
7
22
|
#
|
@@ -100,22 +115,6 @@ require 'koine/attributes/invalid_attributes_error'
|
|
100
115
|
#
|
101
116
|
module Koine
|
102
117
|
module Attributes
|
103
|
-
autoload :Attributes, 'koine/attributes/attributes'
|
104
|
-
autoload :AttributesFactory, 'koine/attributes/attributes_factory'
|
105
|
-
|
106
|
-
module Adapter
|
107
|
-
autoload :Any, 'koine/attributes/adapter/any'
|
108
|
-
autoload :ArrayOf, 'koine/attributes/adapter/array_of'
|
109
|
-
autoload :Boolean, 'koine/attributes/adapter/boolean'
|
110
|
-
autoload :Date, 'koine/attributes/adapter/date'
|
111
|
-
autoload :Float, 'koine/attributes/adapter/float'
|
112
|
-
autoload :HashOf, 'koine/attributes/adapter/hash_of'
|
113
|
-
autoload :Integer, 'koine/attributes/adapter/integer'
|
114
|
-
autoload :String, 'koine/attributes/adapter/string'
|
115
|
-
autoload :Symbol, 'koine/attributes/adapter/symbol'
|
116
|
-
autoload :Time, 'koine/attributes/adapter/time'
|
117
|
-
end
|
118
|
-
|
119
118
|
Error = Class.new(StandardError)
|
120
119
|
|
121
120
|
def self.included(base)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Koine
|
2
4
|
module Attributes
|
3
5
|
module Adapter
|
@@ -18,9 +20,9 @@ module Koine
|
|
18
20
|
|
19
21
|
private
|
20
22
|
|
21
|
-
def coerce_not_nil(
|
23
|
+
def coerce_not_nil(collection_of_values)
|
22
24
|
secure do
|
23
|
-
|
25
|
+
collection_of_values.map { |value| @adapter.coerce(value) }
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Koine
|
2
4
|
module Attributes
|
3
5
|
module Adapter
|
@@ -65,8 +67,8 @@ module Koine
|
|
65
67
|
|
66
68
|
def wrap_errors
|
67
69
|
yield
|
68
|
-
rescue StandardError =>
|
69
|
-
raise_error(
|
70
|
+
rescue StandardError => exception
|
71
|
+
raise_error(exception)
|
70
72
|
end
|
71
73
|
|
72
74
|
def raise_error(message)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Koine
|
2
4
|
module Attributes
|
3
5
|
module Adapter
|
@@ -31,6 +33,7 @@ module Koine
|
|
31
33
|
def coerce_not_nil(value)
|
32
34
|
return true if true_values.include?(value)
|
33
35
|
return false if false_values.include?(value)
|
36
|
+
|
34
37
|
raise InvalidAttributeError.new("Invalid argument '#{value}'", attribute_name)
|
35
38
|
end
|
36
39
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Koine
|
2
4
|
module Attributes
|
3
5
|
module Adapter
|
@@ -20,6 +22,7 @@ module Koine
|
|
20
22
|
value = String(value)
|
21
23
|
value = value.strip if @trim_empty_spaces
|
22
24
|
return nil if value.empty? && @empty_to_nil
|
25
|
+
|
23
26
|
value
|
24
27
|
end
|
25
28
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Koine
|
2
4
|
module Attributes
|
3
5
|
class AttributesFactory
|
@@ -19,6 +21,7 @@ module Koine
|
|
19
21
|
|
20
22
|
def coerce_adapter(adapter)
|
21
23
|
return adapter unless adapter.instance_of?(::Symbol)
|
24
|
+
|
22
25
|
Object.const_get("Koine::Attributes::Adapter::#{adapter.to_s.capitalize}").new
|
23
26
|
end
|
24
27
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koine-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coveralls
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: reek
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rspec
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,21 +81,21 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '3.0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: rubocop
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- -
|
87
|
+
- - '='
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
89
|
+
version: 0.79.0
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- -
|
94
|
+
- - '='
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
96
|
+
version: 0.79.0
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
98
|
+
name: rubocop-performance
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - ">="
|
@@ -81,7 +109,7 @@ dependencies:
|
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
112
|
+
name: rubocop-rspec
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - ">="
|
@@ -95,7 +123,7 @@ dependencies:
|
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
126
|
+
name: simplecov
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
129
|
- - ">="
|
@@ -117,6 +145,7 @@ extra_rdoc_files: []
|
|
117
145
|
files:
|
118
146
|
- ".gitignore"
|
119
147
|
- ".rspec"
|
148
|
+
- ".rubocop.yml"
|
120
149
|
- ".travis.yml"
|
121
150
|
- CODE_OF_CONDUCT.md
|
122
151
|
- Gemfile
|