sinclair 1.4.1 → 1.4.2
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 +4 -4
- data/.circleci/config.yml +5 -3
- data/.rubocop.yml +20 -4
- data/Dockerfile +8 -4
- data/README.md +1 -1
- data/config/yardstick.yml +10 -35
- data/lib/sinclair.rb +87 -18
- data/lib/sinclair/config.rb +3 -0
- data/lib/sinclair/config/methods_builder.rb +15 -1
- data/lib/sinclair/config_builder.rb +1 -0
- data/lib/sinclair/config_class.rb +1 -0
- data/lib/sinclair/config_factory.rb +15 -0
- data/lib/sinclair/configurable.rb +1 -0
- data/lib/sinclair/matchers.rb +20 -6
- data/lib/sinclair/matchers/add_class_method.rb +56 -0
- data/lib/sinclair/matchers/add_class_method_to.rb +98 -0
- data/lib/sinclair/matchers/add_instance_method.rb +85 -0
- data/lib/sinclair/matchers/add_instance_method_to.rb +119 -0
- data/lib/sinclair/matchers/add_method.rb +11 -73
- data/lib/sinclair/matchers/add_method_to.rb +13 -111
- data/lib/sinclair/method_definition.rb +18 -58
- data/lib/sinclair/method_definition/block_definition.rb +37 -6
- data/lib/sinclair/method_definition/class_block_definition.rb +22 -0
- data/lib/sinclair/method_definition/class_method_definition.rb +50 -0
- data/lib/sinclair/method_definition/class_string_definition.rb +24 -0
- data/lib/sinclair/method_definition/instance_block_definition.rb +22 -0
- data/lib/sinclair/method_definition/instance_method_definition.rb +48 -0
- data/lib/sinclair/method_definition/instance_string_definition.rb +24 -0
- data/lib/sinclair/method_definition/string_definition.rb +39 -5
- data/lib/sinclair/method_definitions.rb +28 -0
- data/lib/sinclair/options_parser.rb +5 -0
- data/lib/sinclair/version.rb +1 -1
- data/sinclair.gemspec +16 -10
- data/spec/integration/yard/sinclair/matchers/add_class_method_spec.rb +23 -0
- data/spec/integration/yard/sinclair/matchers/add_class_method_to_spec.rb +19 -0
- data/spec/integration/yard/sinclair/matchers/{add_method_spec.rb → add_instance_method_spec.rb} +3 -3
- data/spec/integration/yard/sinclair/matchers/{add_method_to_spec.rb → add_instance_method_to_spec.rb} +1 -1
- data/spec/integration/yard/sinclair/method_definition/class_block_definition_spec.rb +34 -0
- data/spec/integration/yard/sinclair/method_definition/class_method_definition_spec.rb +28 -0
- data/spec/integration/yard/sinclair/method_definition/class_string_definition_spec.rb +23 -0
- data/spec/integration/yard/sinclair/method_definition/{block_definition_spec.rb → instance_block_definition_spec.rb} +2 -2
- data/spec/integration/yard/sinclair/method_definition/instance_method_definition_spec.rb +35 -0
- data/spec/integration/yard/sinclair/method_definition/{string_definition_spec.rb → instance_string_definition_spec.rb} +1 -1
- data/spec/integration/yard/sinclair_spec.rb +32 -5
- data/spec/lib/sinclair/matchers/add_class_method_spec.rb +36 -0
- data/spec/lib/sinclair/matchers/add_class_method_to_spec.rb +77 -0
- data/spec/lib/sinclair/matchers/{add_method_spec.rb → add_instance_method_spec.rb} +11 -4
- data/spec/lib/sinclair/matchers/{add_method_to_spec.rb → add_instance_method_to_spec.rb} +2 -2
- data/spec/lib/sinclair/matchers_spec.rb +17 -2
- data/spec/lib/sinclair/method_definition/class_block_definition_spec.rb +29 -0
- data/spec/lib/sinclair/method_definition/class_string_definition_spec.rb +27 -0
- data/spec/lib/sinclair/method_definition/{block_definition_spec.rb → instance_block_definition_spec.rb} +2 -2
- data/spec/lib/sinclair/method_definition/{string_definition_spec.rb → instance_string_definition_spec.rb} +2 -2
- data/spec/lib/sinclair/method_definition_spec.rb +52 -6
- data/spec/lib/sinclair_spec.rb +83 -0
- data/spec/support/models/dummy_class_builder.rb +11 -0
- data/spec/support/shared_examples/class_method_definition.rb +96 -0
- data/spec/support/shared_examples/{method_definition.rb → instance_method_definition.rb} +0 -0
- metadata +148 -45
- data/scripts/check_readme.sh +0 -6
- data/scripts/rubycritic.sh +0 -10
- data/spec/integration/sinclair/matchers_spec.rb +0 -99
- data/spec/integration/yard/sinclair/method_definition_spec.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c859413d4a0550d19e5578915d18a1a9e2c1fd3759af5445de6599eb604e56ab
|
4
|
+
data.tar.gz: 495fe0c0dc55e043647887fb1637a3149647deef58293ef18d1df30b4fd05196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61712ff93d7157675c92971f88b07ac8e6a19004ee2fa077d7f60ebaf9dd98118f1af2ff7730d983c0c705a7cd5e120f996b9baabf44bbcff0ccba93a9321f6a
|
7
|
+
data.tar.gz: 0d3ec3b940c71b9a02599184e9d2b9f8afc23cea563794bc903940fbf6f0bb84bbf203b87f57c02d6bab7907cc845c6aefd93649be92d99e157e4249427629e6
|
data/.circleci/config.yml
CHANGED
@@ -2,7 +2,9 @@ version: 2
|
|
2
2
|
jobs:
|
3
3
|
build:
|
4
4
|
docker:
|
5
|
-
- image: darthjee/circleci_ruby_gems:0.1
|
5
|
+
- image: darthjee/circleci_ruby_gems:0.2.1
|
6
|
+
environment:
|
7
|
+
PROJECT: sinclair
|
6
8
|
steps:
|
7
9
|
- checkout
|
8
10
|
- run:
|
@@ -25,7 +27,7 @@ jobs:
|
|
25
27
|
command: bundle exec rake verify_measurements
|
26
28
|
- run:
|
27
29
|
name: Check version documentation
|
28
|
-
command:
|
30
|
+
command: check_readme.sh
|
29
31
|
- run:
|
30
32
|
name: Rubycritcs check
|
31
|
-
command:
|
33
|
+
command: rubycritic.sh
|
data/.rubocop.yml
CHANGED
@@ -8,6 +8,7 @@ Metrics/BlockLength:
|
|
8
8
|
Exclude:
|
9
9
|
- 'spec/**/*_spec.rb'
|
10
10
|
- 'spec/support/**/*.rb'
|
11
|
+
- '*.gemspec'
|
11
12
|
|
12
13
|
Metrics/LineLength:
|
13
14
|
Max: 100
|
@@ -22,17 +23,32 @@ RSpec/AlignLeftLetBrace:
|
|
22
23
|
RSpec/InstanceVariable:
|
23
24
|
Exclude:
|
24
25
|
- spec/integration/yard/sinclair/method_definition_spec.rb
|
25
|
-
- spec/integration/yard/sinclair/method_definition/
|
26
|
-
- spec/
|
26
|
+
- spec/integration/yard/sinclair/method_definition/instance_block_definition_spec.rb
|
27
|
+
- spec/integration/yard/sinclair/method_definition/instance_method_definition_spec.rb
|
28
|
+
- spec/integration/yard/sinclair/method_definition/class_block_definition_spec.rb
|
29
|
+
- spec/integration/yard/sinclair/method_definition/class_method_definition_spec.rb
|
30
|
+
- spec/lib/sinclair/method_definition/instance_block_definition_spec.rb
|
31
|
+
- spec/lib/sinclair/method_definition/instance_method_definition_spec.rb
|
32
|
+
- spec/lib/sinclair/method_definition/class_block_definition_spec.rb
|
33
|
+
- spec/lib/sinclair/method_definition/class_method_definition_spec.rb
|
27
34
|
- spec/lib/sinclair/method_definition_spec.rb
|
35
|
+
- spec/lib/sinclair/method_definition/block_definition_spec.rb
|
36
|
+
- spec/integration/yard/sinclair/method_definition/block_definition_spec.rb
|
37
|
+
|
28
38
|
|
29
39
|
RSpec/MultipleExpectations:
|
30
40
|
Exclude:
|
31
41
|
- spec/integration/yard/sinclair/method_definition_spec.rb
|
32
|
-
- spec/integration/yard/sinclair/method_definition/
|
33
|
-
- spec/integration/yard/sinclair/method_definition/
|
42
|
+
- spec/integration/yard/sinclair/method_definition/instance_block_definition_spec.rb
|
43
|
+
- spec/integration/yard/sinclair/method_definition/instance_string_definition_spec.rb
|
44
|
+
- spec/integration/yard/sinclair/method_definition/instance_method_definition_spec.rb
|
45
|
+
- spec/integration/yard/sinclair/method_definition/class_block_definition_spec.rb
|
46
|
+
- spec/integration/yard/sinclair/method_definition/class_string_definition_spec.rb
|
47
|
+
- spec/integration/yard/sinclair/method_definition/class_method_definition_spec.rb
|
34
48
|
- spec/lib/sinclair_spec.rb
|
35
49
|
- spec/integration/readme/my_model_spec.rb
|
50
|
+
- spec/integration/yard/sinclair/method_definition/block_definition_spec.rb
|
51
|
+
- spec/integration/yard/sinclair/method_definition/string_definition_spec.rb
|
36
52
|
|
37
53
|
RSpec/NestedGroups:
|
38
54
|
Max: 4
|
data/Dockerfile
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
FROM darthjee/ruby_gems:0.1
|
2
|
-
FROM darthjee/scripts:0.0
|
1
|
+
FROM darthjee/ruby_gems:0.2.1 as base
|
2
|
+
FROM darthjee/scripts:0.1.0 as scripts
|
3
3
|
|
4
4
|
######################################
|
5
5
|
|
6
6
|
FROM base as builder
|
7
7
|
|
8
8
|
COPY --chown=app ./ /home/app/app/
|
9
|
-
COPY --chown=app:app --from=scripts /home/scripts/
|
9
|
+
COPY --chown=app:app --from=scripts /home/scripts/builder/bundle_builder.sh /usr/local/sbin/
|
10
10
|
|
11
11
|
ENV HOME_DIR /home/app
|
12
|
-
RUN
|
12
|
+
RUN bundle_builder.sh
|
13
13
|
|
14
14
|
#######################
|
15
15
|
#FINAL IMAGE
|
16
16
|
FROM base
|
17
|
+
RUN mkdir lib/sinclair -p
|
17
18
|
|
18
19
|
USER root
|
19
20
|
|
@@ -23,4 +24,7 @@ COPY --chown=app:app --from=builder /home/app/bundle/specifications /usr/local/b
|
|
23
24
|
COPY --chown=app:app --from=builder /home/app/bundle/bin /usr/local/bundle/bin
|
24
25
|
COPY --chown=app:app --from=builder /home/app/bundle/extensions /usr/local/bundle/extensions
|
25
26
|
|
27
|
+
COPY --chown=app ./*.gemspec ./Gemfile* /home/app/app/
|
28
|
+
COPY --chown=app ./lib/sinclair/version.rb /home/app/app/lib/sinclair/
|
26
29
|
USER app
|
30
|
+
RUN bundle install
|
data/README.md
CHANGED
data/config/yardstick.yml
CHANGED
@@ -16,53 +16,28 @@ rules:
|
|
16
16
|
ExampleTag:
|
17
17
|
enabled: true
|
18
18
|
exclude:
|
19
|
-
- Sinclair::OptionsParser#options
|
20
|
-
- Sinclair::OptionsParser#options_object
|
21
19
|
- Sinclair::Configurable#config
|
22
20
|
- Sinclair::Configurable#reset_config
|
23
21
|
- Sinclair::Configurable#configure
|
22
|
+
- Sinclair::OptionsParser#options
|
23
|
+
- Sinclair::OptionsParser#options_object
|
24
24
|
ReturnTag:
|
25
25
|
enabled: true
|
26
26
|
exclude:
|
27
|
-
- Sinclair#
|
28
|
-
- Sinclair::Matchers::
|
29
|
-
- Sinclair::Matchers::AddMethodTo#method
|
30
|
-
- Sinclair::Matchers::AddMethodTo#instance
|
31
|
-
- Sinclair::MethodDefinition#name
|
32
|
-
- Sinclair::MethodDefinition#code
|
33
|
-
- Sinclair::MethodDefinition#block
|
34
|
-
- Sinclair::OptionsParser#options
|
35
|
-
- Sinclair::OptionsParser#options_object
|
36
|
-
- Sinclair::Matchers::AddMethodTo#raise_block_syntax_error
|
37
|
-
- Sinclair::ConfigFactory#initialize
|
38
|
-
- Sinclair::ConfigFactory#config_class
|
39
|
-
- Sinclair::ConfigFactory#config_attributes
|
40
|
-
- Sinclair::Config::MethodsBuilder#names
|
41
|
-
- Sinclair::Config::MethodsBuilder#defaults
|
42
|
-
- Sinclair::Configurable#config
|
43
|
-
- Sinclair::Configurable#reset_config
|
44
|
-
- Sinclair::Configurable#configure
|
27
|
+
- Sinclair::Matchers::AddClassMethodTo#raise_block_syntax_error
|
28
|
+
- Sinclair::Matchers::AddInstanceMethodTo#raise_block_syntax_error
|
45
29
|
Summary::Presence:
|
46
30
|
enabled: true
|
47
31
|
exclude:
|
48
|
-
- Sinclair#
|
49
|
-
- Sinclair::
|
50
|
-
- Sinclair::Matchers::
|
51
|
-
- Sinclair::Matchers::
|
32
|
+
- Sinclair::Config::MethodsBuilder#initialize
|
33
|
+
- Sinclair::ConfigFactory#initialize
|
34
|
+
- Sinclair::Matchers::AddClassMethodTo#initialize
|
35
|
+
- Sinclair::Matchers::AddInstanceMethodTo#instance
|
36
|
+
- Sinclair::Matchers::AddMethod#initialize
|
37
|
+
- Sinclair::Matchers::AddMethodTo#initialize
|
52
38
|
- Sinclair::MethodDefinition#initialize
|
53
|
-
- Sinclair::MethodDefinition#name
|
54
|
-
- Sinclair::MethodDefinition#code
|
55
|
-
- Sinclair::MethodDefinition#block
|
56
39
|
- Sinclair::MethodDefinition::BlockDefinition#initialize
|
57
40
|
- Sinclair::MethodDefinition::StringDefinition#initialize
|
58
|
-
- Sinclair::OptionsParser#options
|
59
|
-
- Sinclair::OptionsParser#options_object
|
60
|
-
- Sinclair::ConfigFactory#initialize
|
61
|
-
- Sinclair::ConfigFactory#config_class
|
62
|
-
- Sinclair::ConfigFactory#config_attributes
|
63
|
-
- Sinclair::Config::MethodsBuilder#initialize
|
64
|
-
- Sinclair::Config::MethodsBuilder#names
|
65
|
-
- Sinclair::Config::MethodsBuilder#defaults
|
66
41
|
Summary::Length:
|
67
42
|
enabled: true
|
68
43
|
exclude: []
|
data/lib/sinclair.rb
CHANGED
@@ -82,19 +82,20 @@ require 'active_support/all'
|
|
82
82
|
class Sinclair
|
83
83
|
require 'sinclair/options_parser'
|
84
84
|
|
85
|
-
autoload :VERSION,
|
86
|
-
autoload :
|
87
|
-
autoload :
|
88
|
-
autoload :
|
89
|
-
autoload :
|
90
|
-
autoload :
|
91
|
-
autoload :
|
85
|
+
autoload :VERSION, 'sinclair/version'
|
86
|
+
autoload :Config, 'sinclair/config'
|
87
|
+
autoload :ConfigBuilder, 'sinclair/config_builder'
|
88
|
+
autoload :ConfigClass, 'sinclair/config_class'
|
89
|
+
autoload :ConfigFactory, 'sinclair/config_factory'
|
90
|
+
autoload :Configurable, 'sinclair/configurable'
|
91
|
+
autoload :MethodDefinition, 'sinclair/method_definition'
|
92
|
+
autoload :MethodDefinitions, 'sinclair/method_definitions'
|
92
93
|
|
93
94
|
include OptionsParser
|
94
95
|
|
95
96
|
# Returns a new instance of Sinclair
|
96
97
|
#
|
97
|
-
# @param klass [Class]
|
98
|
+
# @param klass [Class] Class that will receive the methods
|
98
99
|
# @param options [Hash] open hash options to be used by builders inheriting from Sinclair
|
99
100
|
# through the Sinclair::OptionsParser concern
|
100
101
|
#
|
@@ -171,12 +172,19 @@ class Sinclair
|
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
174
|
-
#
|
175
|
+
# Add a method to the method list to be created on klass instances
|
175
176
|
#
|
176
|
-
# @
|
177
|
-
#
|
177
|
+
# @param name [String,Symbol] name of the method to be added
|
178
|
+
# @param options [Hash] Options of construction
|
179
|
+
# @option options cached [Boolean] Flag telling to create
|
180
|
+
# a method with cache
|
181
|
+
#
|
182
|
+
# @overload add_method(name, code, **options)
|
178
183
|
# @param code [String] code to be evaluated when the method is ran
|
179
184
|
#
|
185
|
+
# @overload add_method(name, **options, &block)
|
186
|
+
# @param block [Proc] block to be ran as method
|
187
|
+
#
|
180
188
|
# @example Using string code
|
181
189
|
# class Person
|
182
190
|
# attr_reader :first_name, :last_name
|
@@ -193,19 +201,75 @@ class Sinclair
|
|
193
201
|
#
|
194
202
|
# Person.new('john', 'wick').full_name # returns 'john wick'
|
195
203
|
#
|
196
|
-
# @overload add_method(name, &block)
|
197
|
-
# @param name [String,Symbol] name of the method to be added
|
198
|
-
# @param block [Proc] block to be ran as method
|
199
|
-
#
|
200
204
|
# @example Using block
|
205
|
+
# class Person
|
206
|
+
# attr_reader :first_name, :last_name
|
207
|
+
#
|
208
|
+
# def initialize(first_name, last_name)
|
209
|
+
# @first_name = first_name
|
210
|
+
# @last_name = last_name
|
211
|
+
# end
|
212
|
+
# end
|
213
|
+
#
|
201
214
|
# builder = Sinclair.new(Person)
|
215
|
+
# builder.add_method(:full_name, '[first_name, last_name].join(" ")')
|
202
216
|
# builder.add_method(:bond_name) { "#{last_name}, #{full_name}" }
|
203
217
|
# builder.build
|
204
218
|
#
|
205
219
|
# Person.new('john', 'wick').bond_name # returns 'wick, john wick'
|
206
220
|
# @return [Array<MethodDefinition>]
|
207
221
|
def add_method(name, code = nil, **options, &block)
|
208
|
-
definitions
|
222
|
+
definitions.add(
|
223
|
+
MethodDefinition::InstanceMethodDefinition,
|
224
|
+
name, code, **options, &block
|
225
|
+
)
|
226
|
+
end
|
227
|
+
|
228
|
+
# Add a method to the method list to be created on klass
|
229
|
+
#
|
230
|
+
# @param name [String,Symbol] name of the method to be added
|
231
|
+
# @param options [Hash] Options of construction
|
232
|
+
# @option options cached [Boolean] Flag telling to create
|
233
|
+
# a method with cache
|
234
|
+
#
|
235
|
+
# @overload add_class_method(name, code, **options)
|
236
|
+
# @param code [String] code to be evaluated when the method is ran
|
237
|
+
#
|
238
|
+
# @overload add_class_method(name, **options, &block)
|
239
|
+
# @param block [Proc] block to be ran as method
|
240
|
+
#
|
241
|
+
# @example
|
242
|
+
# class EnvFetcher
|
243
|
+
# end
|
244
|
+
#
|
245
|
+
# builder = Sinclair.new(EnvFetcher)
|
246
|
+
#
|
247
|
+
# builder.add_class_method(:hostname, 'ENV["HOSTNAME"]')
|
248
|
+
# builder.build
|
249
|
+
#
|
250
|
+
# ENV['HOSTNAME'] = 'myhost'
|
251
|
+
#
|
252
|
+
# env_fetcher.hostname # returns 'myhost'
|
253
|
+
#
|
254
|
+
# @example
|
255
|
+
# class EnvFetcher
|
256
|
+
# end
|
257
|
+
#
|
258
|
+
# builder = Sinclair.new(EnvFetcher)
|
259
|
+
#
|
260
|
+
# builder.add_class_method(:timeout) { ENV['TIMEOUT'] }
|
261
|
+
# builder.build
|
262
|
+
#
|
263
|
+
# ENV['TIMEOUT'] = '300'
|
264
|
+
#
|
265
|
+
# env_fetcher.timeout # returns '300'
|
266
|
+
#
|
267
|
+
# @return [Array<MethodDefinition>]
|
268
|
+
def add_class_method(name, code = nil, **options, &block)
|
269
|
+
definitions.add(
|
270
|
+
MethodDefinition::ClassMethodDefinition,
|
271
|
+
name, code, **options, &block
|
272
|
+
)
|
209
273
|
end
|
210
274
|
|
211
275
|
# Evaluetes a block which will result in a String, the method code
|
@@ -284,8 +348,13 @@ class Sinclair
|
|
284
348
|
|
285
349
|
private
|
286
350
|
|
351
|
+
# @method klass
|
287
352
|
# @api private
|
288
353
|
# @private
|
354
|
+
#
|
355
|
+
# Class that will receive the methods
|
356
|
+
#
|
357
|
+
# @return [Class]
|
289
358
|
attr_reader :klass
|
290
359
|
|
291
360
|
# @private
|
@@ -294,8 +363,8 @@ class Sinclair
|
|
294
363
|
#
|
295
364
|
# List of mthod definitions
|
296
365
|
#
|
297
|
-
# @return [
|
366
|
+
# @return [MethodDefinitions]
|
298
367
|
def definitions
|
299
|
-
@definitions ||=
|
368
|
+
@definitions ||= MethodDefinitions.new
|
300
369
|
end
|
301
370
|
end
|
data/lib/sinclair/config.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
class Sinclair
|
4
4
|
class Config
|
5
5
|
# @api private
|
6
|
+
# @author darthjee
|
6
7
|
#
|
7
8
|
# Class responsible for adding method to configuration
|
8
9
|
# classes
|
@@ -27,7 +28,7 @@ class Sinclair
|
|
27
28
|
# @overload initialize(klass, *names, default)
|
28
29
|
# @param names [Array<Symbol,String>] List of configuration names
|
29
30
|
# to be added
|
30
|
-
# @param default [Hash] Configurations that will receive a default
|
31
|
+
# @param default [Hash] Configurations that will receive a default value
|
31
32
|
# value when not configured
|
32
33
|
def initialize(klass, *names)
|
33
34
|
super(klass)
|
@@ -69,6 +70,19 @@ class Sinclair
|
|
69
70
|
|
70
71
|
private
|
71
72
|
|
73
|
+
# @method names
|
74
|
+
# @private
|
75
|
+
#
|
76
|
+
# List of configuration names
|
77
|
+
#
|
78
|
+
# @return [Array<Symbol,String>]
|
79
|
+
|
80
|
+
# @method defaults
|
81
|
+
# @private
|
82
|
+
#
|
83
|
+
# Configurations that will receive a default value
|
84
|
+
#
|
85
|
+
# @return [Hash]
|
72
86
|
attr_reader :names, :defaults
|
73
87
|
|
74
88
|
# @private
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class Sinclair
|
4
4
|
# @api private
|
5
|
+
# @author darthjee
|
5
6
|
#
|
6
7
|
# Class responsible for configuring the configuration class
|
7
8
|
#
|
@@ -22,6 +23,7 @@ class Sinclair
|
|
22
23
|
CONFIG_CLASS_WARNING = 'Config class is expected to be ConfigClass. ' \
|
23
24
|
"In future releases this will be enforced.\n" \
|
24
25
|
'see more on https://github.com/darthjee/sinclair/blob/master/WARNINGS.md#usage-of-custom-config-classes'
|
26
|
+
|
25
27
|
# @param config_class [Class] configuration class to be used
|
26
28
|
# @param config_attributes [Array<Symbol,String>] list of possible configurations
|
27
29
|
def initialize(config_class: Class.new(Config), config_attributes: [])
|
@@ -29,6 +31,7 @@ class Sinclair
|
|
29
31
|
@config_attributes = config_attributes.dup
|
30
32
|
|
31
33
|
return if config_class.is_a?(ConfigClass)
|
34
|
+
|
32
35
|
warn CONFIG_CLASS_WARNING
|
33
36
|
end
|
34
37
|
|
@@ -141,7 +144,19 @@ class Sinclair
|
|
141
144
|
|
142
145
|
private
|
143
146
|
|
147
|
+
# method config_class
|
148
|
+
# @private
|
149
|
+
#
|
150
|
+
# Configuration class to be used
|
151
|
+
#
|
152
|
+
# @return [Class]
|
153
|
+
|
154
|
+
# @method config_attributes
|
144
155
|
# @private
|
156
|
+
#
|
157
|
+
# List of possible configurations
|
158
|
+
#
|
159
|
+
# @return [Array<Symbol,String>]
|
145
160
|
attr_reader :config_class, :config_attributes
|
146
161
|
|
147
162
|
# @private
|