sinclair 1.15.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/sinclair/caster/class_methods.rb +2 -0
- data/lib/sinclair/caster.rb +5 -5
- data/lib/sinclair/version.rb +1 -1
- data/spec/integration/yard/sinclair/caster/class_methods_spec.rb +7 -1
- data/spec/lib/sinclair/caster/class_methods_spec.rb +23 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54cfb901ecd8185d00862d7c0b5a99e9cb626d2bbadf45db59553ae980ef9dc1
|
4
|
+
data.tar.gz: 7f0f0a291a659fbc5eaa0d6b56a8bc0f2dfe08b3c0a0d290dad2a6136c7ccc53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d788efed427695e2b001e7b38cc7fa4ef41fb8f6e6b855d321e88f24cb7c97b71b7f4d2622041a5f36ed9921b88513bb26beb4d3b0f11c37a19425a2d1698d9b
|
7
|
+
data.tar.gz: 66f7170ee3a639fa43219f10f3c984369d72ac3e58f182ac00bf0fecf947efa0e5f25107cffa45db30048366085c7c329cd214b5ed5659d854af93f0588b264b
|
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: [1.
|
18
|
+
Current Release: [1.16.0](https://github.com/darthjee/sinclair/tree/1.16.0)
|
19
19
|
|
20
|
-
[Next release](https://github.com/darthjee/sinclair/compare/1.
|
20
|
+
[Next release](https://github.com/darthjee/sinclair/compare/1.16.0...master)
|
21
21
|
|
22
22
|
Yard Documentation
|
23
23
|
-------------------
|
24
|
-
[https://www.rubydoc.info/gems/sinclair/1.
|
24
|
+
[https://www.rubydoc.info/gems/sinclair/1.16.0](https://www.rubydoc.info/gems/sinclair/1.16.0)
|
25
25
|
|
26
26
|
Installation
|
27
27
|
---------------
|
data/lib/sinclair/caster.rb
CHANGED
@@ -24,7 +24,11 @@ class Sinclair
|
|
24
24
|
# The master caster never checks with its an
|
25
25
|
#
|
26
26
|
# @example
|
27
|
-
# class
|
27
|
+
# class BaseCaster < Sinclair::Caster
|
28
|
+
# cast_with(:string, :to_s)
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# class MyCaster < BaseCaster
|
28
32
|
# end
|
29
33
|
#
|
30
34
|
# MyCaster.cast(10, :string) # returns '10'
|
@@ -373,9 +377,5 @@ class Sinclair
|
|
373
377
|
#
|
374
378
|
# @return [Proc]
|
375
379
|
attr_reader :block
|
376
|
-
|
377
|
-
cast_with(:string, :to_s)
|
378
|
-
cast_with(:integer, :to_i)
|
379
|
-
cast_with(:float, :to_f)
|
380
380
|
end
|
381
381
|
end
|
data/lib/sinclair/version.rb
CHANGED
@@ -3,7 +3,13 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe 'yard Sinclair::Caster::ClassMethods' do
|
6
|
-
let(:my_caster) { Class.new(
|
6
|
+
let(:my_caster) { Class.new(superclass) }
|
7
|
+
|
8
|
+
let(:superclass) do
|
9
|
+
Class.new(Sinclair::Caster) do
|
10
|
+
cast_with(:string, :to_s)
|
11
|
+
end
|
12
|
+
end
|
7
13
|
|
8
14
|
describe '.master_caster!' do
|
9
15
|
it 'Making a class to be a master caster' do
|
@@ -3,7 +3,16 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Sinclair::Caster::ClassMethods do
|
6
|
-
subject(:caster) { Class.new(
|
6
|
+
subject(:caster) { Class.new(superclass) }
|
7
|
+
|
8
|
+
let(:superclass) do
|
9
|
+
Class.new(Sinclair::Caster) do
|
10
|
+
cast_with(:string, :to_s)
|
11
|
+
cast_with(:integer, :to_i)
|
12
|
+
cast_with(:float, :to_f)
|
13
|
+
cast_with(String, :to_s)
|
14
|
+
end
|
15
|
+
end
|
7
16
|
|
8
17
|
describe '.cast_with' do
|
9
18
|
let(:value) { instance_double('value', to_p: final_value) }
|
@@ -120,6 +129,19 @@ describe Sinclair::Caster::ClassMethods do
|
|
120
129
|
end
|
121
130
|
|
122
131
|
describe '.caster_for' do
|
132
|
+
context 'when nil key is given' do
|
133
|
+
let(:value) { values.sample }
|
134
|
+
let(:values) do
|
135
|
+
[Random.rand, 'some string', { key: 10 }, Object.new, Class.new, [2, 3]]
|
136
|
+
end
|
137
|
+
|
138
|
+
it { expect(caster.caster_for(nil)).to be_a(Sinclair::Caster) }
|
139
|
+
|
140
|
+
it 'returns the default caster' do
|
141
|
+
expect(caster.caster_for(nil).cast(value)).to eq(value)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
123
145
|
context 'when the key has been defined with a symbol key' do
|
124
146
|
before { caster.cast_with(:problem, :to_p) }
|
125
147
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinclair
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarthJee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|