bake 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bake/context.rb +1 -1
- data/lib/bake/types.rb +1 -0
- data/lib/bake/types/any.rb +10 -0
- data/lib/bake/types/array.rb +2 -0
- data/lib/bake/types/boolean.rb +4 -0
- data/lib/bake/types/decimal.rb +5 -1
- data/lib/bake/types/float.rb +4 -0
- data/lib/bake/types/hash.rb +4 -0
- data/lib/bake/types/integer.rb +5 -1
- data/lib/bake/types/nil.rb +41 -0
- data/lib/bake/types/string.rb +4 -0
- data/lib/bake/types/symbol.rb +4 -0
- data/lib/bake/types/tuple.rb +4 -0
- data/lib/bake/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24da40cece4d7deba62b4e2da664a28b672bc9aacb9c257d8e2a5e6c509f6fa2
|
4
|
+
data.tar.gz: 374c18c8e2cc439b03db3af40cc1f72d66e55404d8420b88651b1b5d70394026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f2d82f245533bdfd80841427996770ec9b94c423b1e1a11d168293b0b8c98d2435ed35d7593fcadf9da848c9a269302e325df79da602529ac07b78ca309c2f
|
7
|
+
data.tar.gz: cec40b1184938a6a0d1543400853f76ca49bb4f1616032b0922e1499628d5a24103ce20fbf3336a21824652ddb68445c6584212dae93ea72c917002093809a02
|
data/lib/bake/context.rb
CHANGED
data/lib/bake/types.rb
CHANGED
@@ -25,6 +25,7 @@ require_relative 'types/decimal'
|
|
25
25
|
require_relative 'types/float'
|
26
26
|
require_relative 'types/hash'
|
27
27
|
require_relative 'types/integer'
|
28
|
+
require_relative 'types/nil'
|
28
29
|
require_relative 'types/string'
|
29
30
|
require_relative 'types/symbol'
|
30
31
|
require_relative 'types/tuple'
|
data/lib/bake/types/any.rb
CHANGED
@@ -20,11 +20,21 @@
|
|
20
20
|
|
21
21
|
module Bake
|
22
22
|
module Types
|
23
|
+
module Type
|
24
|
+
def | other
|
25
|
+
Any.new([self, other])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
23
29
|
class Any
|
24
30
|
def initialize(types)
|
25
31
|
@types = types
|
26
32
|
end
|
27
33
|
|
34
|
+
def | other
|
35
|
+
self.class.new([*@types, other])
|
36
|
+
end
|
37
|
+
|
28
38
|
def composite?
|
29
39
|
@types.any?{|type| type.composite?}
|
30
40
|
end
|
data/lib/bake/types/array.rb
CHANGED
data/lib/bake/types/boolean.rb
CHANGED
data/lib/bake/types/decimal.rb
CHANGED
@@ -18,17 +18,21 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require_relative 'any'
|
22
|
+
|
21
23
|
require 'bigdecimal'
|
22
24
|
|
23
25
|
module Bake
|
24
26
|
module Types
|
25
27
|
module Decimal
|
28
|
+
extend Type
|
29
|
+
|
26
30
|
def self.composite?
|
27
31
|
false
|
28
32
|
end
|
29
33
|
|
30
34
|
def self.parse(value)
|
31
|
-
value
|
35
|
+
BigDecimal(value)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
data/lib/bake/types/float.rb
CHANGED
data/lib/bake/types/hash.rb
CHANGED
@@ -18,9 +18,13 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require_relative 'any'
|
22
|
+
|
21
23
|
module Bake
|
22
24
|
module Types
|
23
25
|
class Hash
|
26
|
+
extend Type
|
27
|
+
|
24
28
|
def initialize(key_type, value_type)
|
25
29
|
@key_type = key_type
|
26
30
|
@value_type = value_type
|
data/lib/bake/types/integer.rb
CHANGED
@@ -18,15 +18,19 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require_relative 'any'
|
22
|
+
|
21
23
|
module Bake
|
22
24
|
module Types
|
23
25
|
module Integer
|
26
|
+
extend Type
|
27
|
+
|
24
28
|
def self.composite?
|
25
29
|
false
|
26
30
|
end
|
27
31
|
|
28
32
|
def self.parse(value)
|
29
|
-
value
|
33
|
+
Integer(value)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require_relative 'any'
|
22
|
+
|
23
|
+
module Bake
|
24
|
+
module Types
|
25
|
+
module Nil
|
26
|
+
extend Type
|
27
|
+
|
28
|
+
def self.composite?
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.parse(input)
|
33
|
+
if input =~ /nil|null/i
|
34
|
+
return nil
|
35
|
+
else
|
36
|
+
raise ArgumentError, "Cannot coerce #{input} into nil!"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/bake/types/string.rb
CHANGED
data/lib/bake/types/symbol.rb
CHANGED
data/lib/bake/types/tuple.rb
CHANGED
@@ -18,9 +18,13 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require_relative 'any'
|
22
|
+
|
21
23
|
module Bake
|
22
24
|
module Types
|
23
25
|
class Tuple
|
26
|
+
extend Type
|
27
|
+
|
24
28
|
def initialize(item_types)
|
25
29
|
@item_types = item_types
|
26
30
|
end
|
data/lib/bake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: samovar
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/bake/types/float.rb
|
131
131
|
- lib/bake/types/hash.rb
|
132
132
|
- lib/bake/types/integer.rb
|
133
|
+
- lib/bake/types/nil.rb
|
133
134
|
- lib/bake/types/string.rb
|
134
135
|
- lib/bake/types/symbol.rb
|
135
136
|
- lib/bake/types/tuple.rb
|