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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1ea8ab091d44b17e56c05e69de9d056f7c020a3d4a6826a7d2430d933008ba3
4
- data.tar.gz: f7675a5ea7f37f921a3c6f9010131b1bed23a82b19acb4d969dded12ef800887
3
+ metadata.gz: ea4db07fefad5477d0a6471ba407dc0d3b6e2cdfd779d5268baa47ca2202797a
4
+ data.tar.gz: 6d9c89041ab2029259642e4d4624ecb8f6cc838d210fecb8b8f6de87ae038621
5
5
  SHA512:
6
- metadata.gz: 8c19fb049fb52a56755e7efec3b91cbc26c81c40f652d5f9344a6d4df348a0670e479290a858bb03e4d0180df414a1374e48cd6747644e3a8ccacda20184f5ce
7
- data.tar.gz: 2d90dbb3de96af4bfcad0db286929584e1dfbfc01ef1369ecb153d3f82da057a13b52ea5b297fd8bd9ec3029c4abf69cddf9b0dfacab5a0d8ffda23ea44cc2de
6
+ metadata.gz: 6f89b82226c6233228aa6682952934c0009c3295534629899a20c03863053685a99538b6aec74d5d1dc067b7abc9e421c382d9abdc1ef9995996d8a942249efc
7
+ data.tar.gz: bf230e8600265df219ce6c6e1ebb02a8a1ccbb9188fe8f2020fb081220aeb883c8032a4003cd43974fcd11ae844990f55d4659d4d03e683ef38e3106e15f59c6
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format documentation
2
1
  --color
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in koine-attributes.gemspec
@@ -1,6 +1,6 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
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 'coveralls'
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
@@ -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
@@ -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(collectionOfValues)
23
+ def coerce_not_nil(collection_of_values)
22
24
  secure do
23
- collectionOfValues.map { |value| @adapter.coerce(value) }
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 => error
69
- raise_error(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
@@ -9,6 +11,7 @@ module Koine
9
11
  secure do
10
12
  next date if date.is_a?(::Date)
11
13
  next date.to_date if date.is_a?(::Time)
14
+
12
15
  ::Date.parse(date)
13
16
  end
14
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
5
  module Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
5
  module Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
5
  module Adapter
@@ -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
  module Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'time'
2
4
 
3
5
  module Koine
@@ -10,6 +12,7 @@ module Koine
10
12
  wrap_errors do
11
13
  secure do
12
14
  next value if value.is_a?(::Time)
15
+
13
16
  ::Time.parse(value)
14
17
  end
15
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
5
  class Attributes
@@ -18,6 +20,7 @@ module Koine
18
20
  end
19
21
 
20
22
  return unless @initializer[:initialize]
23
+
21
24
  set_values(values) && @initializer[:freeze] && freeze
22
25
  end
23
26
 
@@ -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
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
5
  class HashHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
5
  class InvalidAttributeError < ::ArgumentError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
5
  class InvalidAttributesError < ::ArgumentError
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Koine
2
4
  module Attributes
3
- VERSION = '1.2.3'.freeze
5
+ VERSION = '1.2.4'
4
6
  end
5
7
  end
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.3
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: coveralls
84
+ name: rubocop
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - ">="
87
+ - - '='
60
88
  - !ruby/object:Gem::Version
61
- version: '0'
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: '0'
96
+ version: 0.79.0
69
97
  - !ruby/object:Gem::Dependency
70
- name: simplecov
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: reek
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