sinclair 2.1.1 → 3.0.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -3
  3. data/.rubocop.yml +33 -1
  4. data/.rubocop_todo.yml +13 -1
  5. data/Dockerfile +2 -3
  6. data/Gemfile +17 -0
  7. data/Makefile +6 -0
  8. data/README.md +3 -3
  9. data/lib/sinclair/caster/class_methods.rb +6 -6
  10. data/lib/sinclair/chain_settable.rb +1 -1
  11. data/lib/sinclair/class_methods.rb +3 -3
  12. data/lib/sinclair/config_builder.rb +4 -4
  13. data/lib/sinclair/config_class.rb +3 -3
  14. data/lib/sinclair/config_factory.rb +7 -6
  15. data/lib/sinclair/configurable.rb +5 -5
  16. data/lib/sinclair/env_settable.rb +1 -1
  17. data/lib/sinclair/equals_checker.rb +1 -3
  18. data/lib/sinclair/exception.rb +1 -0
  19. data/lib/sinclair/input_hash.rb +3 -2
  20. data/lib/sinclair/matchers/add_class_method_to.rb +1 -1
  21. data/lib/sinclair/matchers/add_instance_method_to.rb +1 -1
  22. data/lib/sinclair/matchers/base.rb +2 -1
  23. data/lib/sinclair/matchers/change_class_method_on.rb +1 -1
  24. data/lib/sinclair/matchers/change_instance_method_on.rb +1 -1
  25. data/lib/sinclair/method_builder/base.rb +2 -1
  26. data/lib/sinclair/method_definition/block_helper.rb +4 -4
  27. data/lib/sinclair/method_definition/parameter_builder.rb +2 -2
  28. data/lib/sinclair/method_definition/parameter_helper.rb +2 -2
  29. data/lib/sinclair/method_definition.rb +8 -8
  30. data/lib/sinclair/method_definitions.rb +2 -2
  31. data/lib/sinclair/model/builder.rb +2 -2
  32. data/lib/sinclair/model.rb +4 -4
  33. data/lib/sinclair/options/class_methods.rb +0 -2
  34. data/lib/sinclair/options.rb +0 -2
  35. data/lib/sinclair/settable/builder.rb +1 -0
  36. data/lib/sinclair/settable.rb +1 -1
  37. data/lib/sinclair/version.rb +1 -1
  38. data/lib/sinclair.rb +6 -6
  39. data/sinclair.gemspec +3 -20
  40. data/spec/integration/readme/my_class_spec.rb +2 -2
  41. data/spec/integration/readme/sinclair/model_spec.rb +2 -2
  42. data/spec/integration/readme/sinclair/options_spec.rb +1 -1
  43. data/spec/integration/yard/sinclair/add_class_method_spec.rb +2 -2
  44. data/spec/integration/yard/sinclair/caster/cast_spec.rb +2 -2
  45. data/spec/integration/yard/sinclair/caster/cast_with_spec.rb +1 -1
  46. data/spec/integration/yard/sinclair/config_factory_spec.rb +4 -4
  47. data/spec/integration/yard/sinclair/core_ext/object_spec.rb +2 -2
  48. data/spec/lib/sinclair/chain_settable_spec.rb +1 -1
  49. data/spec/lib/sinclair/config_factory_spec.rb +1 -1
  50. data/spec/lib/sinclair/equals_checker/reader_spec.rb +1 -1
  51. data/spec/lib/sinclair/matchers/add_class_method_spec.rb +1 -1
  52. data/spec/lib/sinclair/matchers/add_class_method_to_spec.rb +1 -1
  53. data/spec/lib/sinclair/matchers/add_instance_method_spec.rb +1 -1
  54. data/spec/lib/sinclair/matchers/add_instance_method_to_spec.rb +1 -1
  55. data/spec/lib/sinclair/matchers/change_class_method_on_spec.rb +1 -1
  56. data/spec/lib/sinclair/matchers/change_class_method_spec.rb +1 -1
  57. data/spec/lib/sinclair/matchers/change_instance_method_on_spec.rb +1 -1
  58. data/spec/lib/sinclair/matchers/change_instance_method_spec.rb +1 -1
  59. data/spec/lib/sinclair/method_builder/base_spec.rb +1 -1
  60. data/spec/lib/sinclair/method_builder/block_method_builder_spec.rb +1 -1
  61. data/spec/lib/sinclair/method_builder/call_method_builder_spec.rb +1 -1
  62. data/spec/lib/sinclair/method_builder/string_method_builder_spec.rb +1 -1
  63. data/spec/lib/sinclair/method_definition_spec.rb +1 -0
  64. data/spec/lib/sinclair/method_definitions_spec.rb +9 -9
  65. data/spec/lib/sinclair/model_spec.rb +3 -3
  66. data/spec/lib/sinclair/options/class_methods_spec.rb +1 -1
  67. data/spec/lib/sinclair/options_spec.rb +3 -3
  68. data/spec/lib/sinclair/settable/builder_spec.rb +1 -1
  69. data/spec/spec_helper.rb +1 -1
  70. data/spec/support/models/default_valueable.rb +1 -1
  71. data/spec/support/models/env_settings.rb +1 -1
  72. data/spec/support/models/random_generator.rb +1 -1
  73. data/spec/support/shared_examples/model.rb +2 -2
  74. data/spec/support/shared_examples/settable.rb +2 -2
  75. metadata +11 -233
  76. /data/spec/integration/readme/{sinclair/types_of_definition_spec.rb → sinclair_types_of_definition_spec.rb} +0 -0
  77. /data/spec/integration/yard/sinclair/{class_methods/build_spec.rb → class_methods_build_spec.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d76ebc93311a132641b78144b2b81a05c84fade374cc0d149ff0164b9a5e07ff
4
- data.tar.gz: 90bac707ca24a39baed7352cffa1ffcba9f3f7082077caf1d0cd20e9eb1021fb
3
+ metadata.gz: 7d9505060c3b7a018a408ea37b59af41203747d280336fd5f1f6bb148f329af6
4
+ data.tar.gz: 9967733ebc9f4ba73d553816a20530ff9399d3045cf0485f7412b0116924a2c8
5
5
  SHA512:
6
- metadata.gz: 6c0e1ee48effffc16883f6d1b514089e0673d073970131ea9e1ba480fbfb4dbc4d4bc871d3dcd92d21aebb3e78b36cb7e775493bfb8f490ad6cedebe0a8e1e1a
7
- data.tar.gz: f48a3a61574f6b9d66122a0a23b1f709ac29f36b5dbd41bd246908280779fafc9bc42ad494d4da21b70772323bd43bfff5848ed8941229f01a8d4da8b8180e7c
6
+ metadata.gz: 66bf1c943c5b9c9e6facfb8c5eecd92b86de5385f0fbb701715e62329ad5e82912272182baf4dce83f7517c8aae7b340aed8ce12e0315e0aefb805db3cfc90c7
7
+ data.tar.gz: e1166a305873c0e5184a9d8043166f27e1f2ecae5be57d031fea48f5d7ec0f2c79c0d8f1acefdf1db30d54ad8579ea220d6cd64be160ae5d0f6505379291d96a
data/.circleci/config.yml CHANGED
@@ -22,7 +22,7 @@ workflows:
22
22
  jobs:
23
23
  test:
24
24
  docker:
25
- - image: darthjee/circleci_ruby_270:1.2.0
25
+ - image: darthjee/circleci_ruby_331:1.0.1
26
26
  environment:
27
27
  PROJECT: sinclair
28
28
  steps:
@@ -41,7 +41,7 @@ jobs:
41
41
  command: cc-test-reporter after-build --exit-code $?
42
42
  checks:
43
43
  docker:
44
- - image: darthjee/circleci_ruby_270:1.2.0
44
+ - image: darthjee/circleci_ruby_331:1.0.1
45
45
  environment:
46
46
  PROJECT: sinclair
47
47
  steps:
@@ -66,7 +66,7 @@ jobs:
66
66
  command: check_specs
67
67
  build-and-release:
68
68
  docker:
69
- - image: darthjee/circleci_ruby_270:1.2.0
69
+ - image: darthjee/circleci_ruby_331:1.0.1
70
70
  environment:
71
71
  PROJECT: sinclair
72
72
  steps:
data/.rubocop.yml CHANGED
@@ -2,7 +2,8 @@ require: rubocop-rspec
2
2
  inherit_from: .rubocop_todo.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 3.3
6
+ NewCops: enable
6
7
 
7
8
  RSpec/DescribeClass:
8
9
  Exclude:
@@ -58,3 +59,34 @@ Style/HashTransformKeys:
58
59
 
59
60
  Style/HashTransformValues:
60
61
  Enabled: true
62
+
63
+ RSpec/MultipleMemoizedHelpers:
64
+ Enabled: false
65
+
66
+ Naming/VariableNumber:
67
+ Enabled: false
68
+
69
+ RSpec/IndexedLet:
70
+ Enabled: false
71
+
72
+ RSpec/IdenticalEqualityAssertion:
73
+ Enabled: false
74
+
75
+ RSpec/VerifiedDoubleReference:
76
+ Enabled: false
77
+
78
+ RSpec/RedundantPredicateMatcher:
79
+ Exclude:
80
+ - 'spec/integration/yard/sinclair/config_factory_spec.rb'
81
+ - 'spec/lib/sinclair/equals_checker_spec.rb'
82
+
83
+ Gemspec/RequireMFA:
84
+ Enabled: false
85
+
86
+ Lint/EmptyBlock:
87
+ Exclude:
88
+ - 'spec/**/*_spec.rb'
89
+
90
+ Lint/EmptyClass:
91
+ Exclude:
92
+ - 'spec/**/*.rb'
data/.rubocop_todo.yml CHANGED
@@ -1,7 +1,19 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-04-27 21:26:53 +0000 using RuboCop version 0.80.1.
3
+ # on 2025-05-09 01:27:02 UTC using RuboCop version 1.59.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports unsafe autocorrection (--autocorrect-all).
11
+ # Configuration parameters: AllowSplatArgument.
12
+ Style/HashConversion:
13
+ Exclude:
14
+ - 'lib/sinclair/input_hash.rb'
15
+
16
+ # Offense count: 1
17
+ Style/OpenStructUse:
18
+ Exclude:
19
+ - 'lib/sinclair/options_parser.rb'
data/Dockerfile CHANGED
@@ -1,6 +1,5 @@
1
- FROM darthjee/scripts:0.3.1 as scripts
2
-
3
- FROM darthjee/ruby_270:1.2.0 as base
1
+ FROM darthjee/scripts:0.4.3 as scripts
2
+ FROM darthjee/ruby_331:1.0.1 as base
4
3
 
5
4
  COPY --chown=app:app ./ /home/app/app/
6
5
 
data/Gemfile CHANGED
@@ -3,3 +3,20 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
7
+ gem 'bundler', '>= 2.5.13'
8
+ gem 'pry', '0.14.2'
9
+ gem 'pry-nav', '1.0.0'
10
+ gem 'rake', '13.1.0'
11
+ gem 'reek', '6.1.4'
12
+ gem 'rspec', '3.12.0'
13
+ gem 'rspec-core', '3.12.2'
14
+ gem 'rspec-expectations', '3.12.3'
15
+ gem 'rspec-mocks', '3.12.5'
16
+ gem 'rspec-support', '3.12.0'
17
+ gem 'rubocop', '1.59.0'
18
+ gem 'rubocop-rspec', '3.0.0'
19
+ gem 'rubycritic', '4.9.1'
20
+ gem 'simplecov', '0.22.0'
21
+ gem 'yard', '0.9.36'
22
+ gem 'yardstick', '0.9.9'
data/Makefile ADDED
@@ -0,0 +1,6 @@
1
+ .PHONY: dev
2
+
3
+ PROJECT?=sinclair
4
+
5
+ dev:
6
+ docker-compose run $(PROJECT) /bin/bash
data/README.md CHANGED
@@ -15,13 +15,13 @@ create custom comparators, configure your application, create powerfull options,
15
15
 
16
16
  Employing Sinclair in your applications helps you streamline your development workflow and enhance your development process through more efficient, cleaner code
17
17
 
18
- Current Release: [2.1.1](https://github.com/darthjee/sinclair/tree/2.1.1)
18
+ Current Release: [3.0.0](https://github.com/darthjee/sinclair/tree/3.0.0)
19
19
 
20
- [Next release](https://github.com/darthjee/sinclair/compare/2.1.1...master)
20
+ [Next release](https://github.com/darthjee/sinclair/compare/3.0.0...master)
21
21
 
22
22
  Yard Documentation
23
23
  -------------------
24
- [https://www.rubydoc.info/gems/sinclair/2.1.1](https://www.rubydoc.info/gems/sinclair/2.1.1)
24
+ [https://www.rubydoc.info/gems/sinclair/3.0.0](https://www.rubydoc.info/gems/sinclair/3.0.0)
25
25
 
26
26
  Installation
27
27
  ---------------
@@ -13,8 +13,8 @@ class Sinclair
13
13
  end
14
14
 
15
15
  # (see Caster.cast_with)
16
- def cast_with(key, method_name = nil, &block)
17
- caster = instance_for(method_name, &block)
16
+ def cast_with(key, method_name = nil, &)
17
+ caster = instance_for(method_name, &)
18
18
 
19
19
  return class_casters[key] = caster if key.is_a?(Class)
20
20
 
@@ -22,8 +22,8 @@ class Sinclair
22
22
  end
23
23
 
24
24
  # (see Caster.cast)
25
- def cast(value, key, **opts)
26
- caster_for(key).cast(value, **opts)
25
+ def cast(value, key, **)
26
+ caster_for(key).cast(value, **)
27
27
  end
28
28
 
29
29
  # (see Caster.caster_for)
@@ -93,8 +93,8 @@ class Sinclair
93
93
  # @param caster [Caster] instance of caster to be returned
94
94
  #
95
95
  # @return [Caster]
96
- def instance_for(method_name, &block)
97
- return new(&block) unless method_name
96
+ def instance_for(method_name, &)
97
+ return new(&) unless method_name
98
98
  return method_name if method_name.is_a?(Caster)
99
99
 
100
100
  new(&method_name)
@@ -76,7 +76,7 @@ class Sinclair
76
76
  def default_options
77
77
  {
78
78
  sources: sources_order,
79
- sources_map: sources_map
79
+ sources_map:
80
80
  }
81
81
  end
82
82
  end
@@ -32,9 +32,9 @@ class Sinclair
32
32
  # model = MyPerson.new
33
33
  #
34
34
  # model.random_name # returns 'John 803 Doe'
35
- def build(*args, **opts, &block)
36
- new(*args, **opts).tap do |builder|
37
- builder.instance_eval(&block) if block_given?
35
+ def build(*, **, &)
36
+ new(*, **).tap do |builder|
37
+ builder.instance_eval(&) if block_given?
38
38
  end.build
39
39
  end
40
40
  end
@@ -49,10 +49,10 @@ class Sinclair
49
49
  # @param args [Array<Object>] arguments of the call
50
50
  #
51
51
  # @return [Object]
52
- def method_missing(method_name, *args)
52
+ def method_missing(method_name, *)
53
53
  return super unless method_included?(method_name)
54
54
 
55
- @config.instance_variable_set("@#{method_name}", *args)
55
+ @config.instance_variable_set("@#{method_name}", *)
56
56
  end
57
57
 
58
58
  # @private
@@ -78,8 +78,8 @@ class Sinclair
78
78
  klass = @config.class
79
79
 
80
80
  @config_attributes.include?(method_name) ||
81
- klass.is_a?(Sinclair::ConfigClass) &&
82
- klass.config_attributes.include?(method_name)
81
+ (klass.is_a?(Sinclair::ConfigClass) &&
82
+ klass.config_attributes.include?(method_name))
83
83
  end
84
84
  end
85
85
  end
@@ -79,11 +79,11 @@ class Sinclair
79
79
  #
80
80
  # config.secret # return '123abc'
81
81
  # config.app_name # return 'MySuperApp'
82
- def add_configs(*args)
83
- Config::MethodsBuilder.new(self, *args).tap do |builder|
82
+ def add_configs(*)
83
+ Config::MethodsBuilder.new(self, *).tap do |builder|
84
84
  builder.build
85
85
 
86
- Sinclair::InputHash.input_hash(*args).each do |name, value|
86
+ Sinclair::InputHash.input_hash(*).each do |name, value|
87
87
  options_class.with_options(name => value)
88
88
  end
89
89
 
@@ -21,8 +21,8 @@ class Sinclair
21
21
  # Deprecation warning message
22
22
  # @see https://github.com/darthjee/sinclair/blob/master/WARNINGS.md#usage-of-custom-config-classes
23
23
  CONFIG_CLASS_WARNING = 'Config class is expected to be ConfigClass. ' \
24
- "In future releases this will be enforced.\n" \
25
- 'see more on https://github.com/darthjee/sinclair/blob/master/WARNINGS.md#usage-of-custom-config-classes'
24
+ "In future releases this will be enforced.\n" \
25
+ 'see more on https://github.com/darthjee/sinclair/blob/master/WARNINGS.md#usage-of-custom-config-classes'
26
26
 
27
27
  # @param config_class [Class] configuration class to be used
28
28
  # @param config_attributes [Array<Symbol,String>] list of possible configurations
@@ -56,11 +56,11 @@ class Sinclair
56
56
  #
57
57
  # config.respond_to? :active
58
58
  # # returns true
59
- def add_configs(*args)
59
+ def add_configs(*)
60
60
  builder = if config_class.is_a?(Sinclair::ConfigClass)
61
- config_class.add_configs(*args)
61
+ config_class.add_configs(*)
62
62
  else
63
- Config::MethodsBuilder.build(config_class, *args)
63
+ Config::MethodsBuilder.build(config_class, *)
64
64
  end
65
65
 
66
66
  config_attributes.concat(builder.config_names.map(&:to_sym))
@@ -138,13 +138,14 @@ class Sinclair
138
138
  def child
139
139
  self.class.new(
140
140
  config_class: Class.new(config_class),
141
- config_attributes: config_attributes
141
+ config_attributes:
142
142
  )
143
143
  end
144
144
 
145
145
  private
146
146
 
147
147
  attr_reader :config_class, :config_attributes
148
+
148
149
  # @method config_class
149
150
  # @private
150
151
  # @api private
@@ -22,10 +22,10 @@ class Sinclair
22
22
  # Deprecation warning message
23
23
  # @see https://github.com/darthjee/sinclair/blob/master/WARNINGS.md#usage-of-custom-config-classes
24
24
  CONFIG_CLASS_WARNING = 'Config classes attributes should ' \
25
- 'be defined inside the class or through the usage of ' \
26
- "configurable_with.\n" \
27
- "In future releases this will be enforced.\n" \
28
- 'see more on https://github.com/darthjee/sinclair/blob/master/WARNINGS.md#usage-of-custom-config-classes'
25
+ 'be defined inside the class or through the usage of ' \
26
+ "configurable_with.\n" \
27
+ "In future releases this will be enforced.\n" \
28
+ 'see more on https://github.com/darthjee/sinclair/blob/master/WARNINGS.md#usage-of-custom-config-classes'
29
29
 
30
30
  # @method config
31
31
  #
@@ -202,7 +202,7 @@ class Sinclair
202
202
  warn CONFIG_CLASS_WARNING if with.present?
203
203
 
204
204
  @config_factory = ConfigFactory.new(
205
- config_class: config_class,
205
+ config_class:,
206
206
  config_attributes: with.map(&:to_sym)
207
207
  )
208
208
  end
@@ -30,7 +30,7 @@ class Sinclair
30
30
  read_with do |key, prefix: nil|
31
31
  env_key = [prefix, key].compact.join('_').to_s.upcase
32
32
 
33
- ENV[env_key]
33
+ ENV.fetch(env_key, nil)
34
34
  end
35
35
 
36
36
  private
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  class Sinclair
6
4
  # @api public
7
5
  # @author darthjee
@@ -90,7 +88,7 @@ class Sinclair
90
88
  #
91
89
  # @return [TrueClass,FalseClass]
92
90
  def match?(model, other)
93
- return false unless model.class == other.class
91
+ return false unless model.instance_of?(other.class)
94
92
 
95
93
  attributes.all? do |attr|
96
94
  Reader.attributes_match?(attr, model, other)
@@ -18,6 +18,7 @@ class Sinclair
18
18
  class InvalidOptions < Sinclair::Exception
19
19
  # @param invalid_keys [Array<Symbol>] list of invalid keys
20
20
  def initialize(invalid_keys = [])
21
+ super
21
22
  @invalid_keys = invalid_keys
22
23
  end
23
24
 
@@ -34,8 +34,8 @@ class Sinclair
34
34
  # # key3: 10,
35
35
  # # 'key4' => 20
36
36
  # # }
37
- def self.input_hash(*args)
38
- new(*args).to_h
37
+ def self.input_hash(*)
38
+ new(*).to_h
39
39
  end
40
40
 
41
41
  # @api private
@@ -51,6 +51,7 @@ class Sinclair
51
51
  private
52
52
 
53
53
  attr_reader :attributes, :hash
54
+
54
55
  # @method attributes
55
56
  # @api private
56
57
  # @private
@@ -78,7 +78,7 @@ class Sinclair
78
78
  # @raise SyntaxError
79
79
  def raise_block_syntax_error
80
80
  raise SyntaxError, 'Block not received by the `add_class_method_to` matcher. ' \
81
- 'Perhaps you want to use `{ ... }` instead of do/end?'
81
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
82
82
  end
83
83
  end
84
84
  end
@@ -108,7 +108,7 @@ class Sinclair
108
108
  # @raise SyntaxError
109
109
  def raise_block_syntax_error
110
110
  raise SyntaxError, 'Block not received by the `add_instance_method_to` matcher. ' \
111
- 'Perhaps you want to use `{ ... }` instead of do/end?'
111
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
112
112
  end
113
113
  end
114
114
  end
@@ -9,6 +9,7 @@ class Sinclair
9
9
  class Base < RSpec::Matchers::BuiltIn::BaseMatcher
10
10
  # @param method_name [String,Symbol] the method, to be checked, name
11
11
  def initialize(method_name)
12
+ super
12
13
  @method_name = method_name.to_sym
13
14
  end
14
15
 
@@ -23,7 +24,7 @@ class Sinclair
23
24
  #
24
25
  # @return [Boolean]
25
26
  def equal?(other)
26
- return unless other.class == self.class
27
+ return false unless other.class == self.class
27
28
 
28
29
  other.method_name == method_name &&
29
30
  other.try(:klass) == try(:klass)
@@ -57,7 +57,7 @@ class Sinclair
57
57
  # @raise SyntaxError
58
58
  def raise_block_syntax_error
59
59
  raise SyntaxError, 'Block not received by the `change_class_method_on` matcher. ' \
60
- 'Perhaps you want to use `{ ... }` instead of do/end?'
60
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
61
61
  end
62
62
  end
63
63
  end
@@ -91,7 +91,7 @@ class Sinclair
91
91
  # @raise SyntaxError
92
92
  def raise_block_syntax_error
93
93
  raise SyntaxError, 'Block not received by the `change_instance_method_on` matcher. ' \
94
- 'Perhaps you want to use `{ ... }` instead of do/end?'
94
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
95
95
  end
96
96
  end
97
97
  end
@@ -19,7 +19,7 @@ class Sinclair
19
19
  #
20
20
  # @return [Symbol] name of the method built
21
21
  def self.build(klass, definition, type:)
22
- new(klass, definition, type: type).build
22
+ new(klass, definition, type:).build
23
23
  end
24
24
 
25
25
  # @param klass [Class] class to receive the method
@@ -45,6 +45,7 @@ class Sinclair
45
45
  private
46
46
 
47
47
  attr_reader :klass, :definition, :type
48
+
48
49
  # @method klass
49
50
  # @private
50
51
  # @api private
@@ -14,12 +14,12 @@ class Sinclair
14
14
  # Returns proc block when {#cached?} as simple
15
15
  #
16
16
  # @return [Proc]
17
- def cached_method_proc(method_name, &inner_block)
17
+ def cached_method_proc(method_name, &)
18
18
  proc do
19
19
  instance_variable_get("@#{method_name}") ||
20
20
  instance_variable_set(
21
21
  "@#{method_name}",
22
- instance_eval(&inner_block)
22
+ instance_eval(&)
23
23
  )
24
24
  end
25
25
  end
@@ -29,14 +29,14 @@ class Sinclair
29
29
  # Returns proc block when {#cached?} as full
30
30
  #
31
31
  # @return [Proc]
32
- def full_cached_method_proc(method_name, &inner_block)
32
+ def full_cached_method_proc(method_name, &)
33
33
  proc do
34
34
  if instance_variable_defined?("@#{method_name}")
35
35
  instance_variable_get("@#{method_name}")
36
36
  else
37
37
  instance_variable_set(
38
38
  "@#{method_name}",
39
- instance_eval(&inner_block)
39
+ instance_eval(&)
40
40
  )
41
41
  end
42
42
  end
@@ -23,8 +23,8 @@ class Sinclair
23
23
  # and +Hash+ representing parameters with default values
24
24
  #
25
25
  # @return [String]
26
- def self.from(*args)
27
- new(*args).to_s
26
+ def self.from(*)
27
+ new(*).to_s
28
28
  end
29
29
 
30
30
  private_class_method :new
@@ -17,8 +17,8 @@ class Sinclair
17
17
  # named parameters
18
18
  #
19
19
  # @return [String]
20
- def self.parameters_from(*args, **opts)
21
- new(*args, **opts).strings
20
+ def self.parameters_from(*, **)
21
+ new(*, **).strings
22
22
  end
23
23
 
24
24
  private_class_method :new
@@ -49,11 +49,11 @@ class Sinclair
49
49
  # returns a {StringDefinition} otherwise
50
50
  #
51
51
  # @return [Base]
52
- def from(name, code = nil, **options, &block)
52
+ def from(name, code = nil, **, &block)
53
53
  if block
54
- BlockDefinition.new(name, **options, &block)
54
+ BlockDefinition.new(name, **, &block)
55
55
  else
56
- StringDefinition.new(name, code, **options)
56
+ StringDefinition.new(name, code, **)
57
57
  end
58
58
  end
59
59
 
@@ -68,11 +68,11 @@ class Sinclair
68
68
  # @param type [Symbol] the method definition type
69
69
  #
70
70
  # @return [Sinclair::MethodDefinition] an instance of a subclass
71
- def for(type, *args, **options, &block)
72
- return from(*args, **options, &block) unless type
71
+ def for(type, ...)
72
+ return from(...) unless type
73
73
 
74
74
  klass = const_get("#{type}_definition".camelize)
75
- klass.new(*args, **options, &block)
75
+ klass.new(...)
76
76
  end
77
77
 
78
78
  # Defines builder for a definition class
@@ -100,7 +100,7 @@ class Sinclair
100
100
  # @return [Symbol] the name of the method built
101
101
  def build_with(builder_class)
102
102
  define_method(:build) do |klass, type|
103
- builder_class.build(klass, self, type: type)
103
+ builder_class.build(klass, self, type:)
104
104
  end
105
105
  end
106
106
  end
@@ -131,7 +131,7 @@ class Sinclair
131
131
  # @raise NotImplementedError
132
132
  def build(_klass, _type)
133
133
  raise NotImplementedError, 'Build is implemented in subclasses. ' \
134
- "Use #{self.class}.from to initialize a proper object"
134
+ "Use #{self.class}.from to initialize a proper object"
135
135
  end
136
136
 
137
137
  delegate :cached, to: :options_object
@@ -40,8 +40,8 @@ class Sinclair
40
40
  # @see MethodDefinition.from
41
41
  #
42
42
  # @return [Array<MethodDefinition>]
43
- def add(*args, type: nil, **options, &block)
44
- definitions << MethodDefinition.for(type, *args, **options, &block)
43
+ def add(*, type: nil, **, &)
44
+ definitions << MethodDefinition.for(type, *, **, &)
45
45
  end
46
46
 
47
47
  private
@@ -26,10 +26,10 @@ class Sinclair
26
26
  # method should be added
27
27
  # @param comparable [TrueClass,FalseClass] flag to make the class {Comparable}
28
28
  # by the fields
29
- def initialize(klass, *attributes, **options)
29
+ def initialize(klass, *attributes, **)
30
30
  super(klass)
31
31
  @attributes = attributes.flatten
32
- @options = BuilderOptions.new(**options)
32
+ @options = BuilderOptions.new(**)
33
33
 
34
34
  add_methods
35
35
  change_equals
@@ -51,9 +51,9 @@ class Sinclair
51
51
  # job.state # returns :done
52
52
  #
53
53
  # @return [Class<Model>] a new class with the chosen attributes
54
- def for(*attributes, **options)
54
+ def for(*attributes, **)
55
55
  Class.new(self) do |klass|
56
- Builder.new(klass, *attributes, **options).build
56
+ Builder.new(klass, *attributes, **).build
57
57
  end
58
58
  end
59
59
 
@@ -100,8 +100,8 @@ class Sinclair
100
100
  # job.state # returns :done
101
101
  #
102
102
  # @return [Array<MethodDefinition>]
103
- def initialize_with(*attributes, **options)
104
- Builder.new(self, *attributes, **options).build
103
+ def initialize_with(*attributes, **)
104
+ Builder.new(self, *attributes, **).build
105
105
  end
106
106
  end
107
107
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  class Sinclair
6
4
  class Options
7
5
  # Class Methods for {Sinclair::Options}
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  class Sinclair
6
4
  # @api public
7
5
  # @author Darthjee
@@ -62,6 +62,7 @@ class Sinclair
62
62
  alias read_block read_with
63
63
 
64
64
  attr_reader :settings
65
+
65
66
  # @method settings
66
67
  # @private
67
68
  # @api private
@@ -78,7 +78,7 @@ class Sinclair
78
78
  setting_with_options(*settings_name)
79
79
 
80
80
  defaults.each do |key, default|
81
- setting_with_options(key, default: default)
81
+ setting_with_options(key, default:)
82
82
  end
83
83
  end
84
84