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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35b512d522643dc5fdc38c36a5343160c900137b6db86f008f383cd86b0072a6
4
- data.tar.gz: cfef9377af4254ba2eb09e5048702ba2b65e267e717692c241a0e21deb25983c
3
+ metadata.gz: 24da40cece4d7deba62b4e2da664a28b672bc9aacb9c257d8e2a5e6c509f6fa2
4
+ data.tar.gz: 374c18c8e2cc439b03db3af40cc1f72d66e55404d8420b88651b1b5d70394026
5
5
  SHA512:
6
- metadata.gz: 0b681ce2b0ab886ceb2cecb71d197a6302952f40d0cd5e33aa1ac5f1535bd7c3214a1b9c9a8d4c2fc306a3fc1cd1b1baee0f43b8735252095340b0b8ba74388e
7
- data.tar.gz: e306ce859c781f2a900e67814e235adcfe94165ef8852c713bc630b21e4ff552e03a03841f9a6a5c85fe29a108a36e8506f35a451dc6446b08085622a590e05f
6
+ metadata.gz: c2f2d82f245533bdfd80841427996770ec9b94c423b1e1a11d168293b0b8c98d2435ed35d7593fcadf9da848c9a269302e325df79da602529ac07b78ca309c2f
7
+ data.tar.gz: cec40b1184938a6a0d1543400853f76ca49bb4f1616032b0922e1499628d5a24103ce20fbf3336a21824652ddb68445c6584212dae93ea72c917002093809a02
@@ -147,7 +147,7 @@ module Bake
147
147
  end
148
148
  end
149
149
 
150
- # @param scope [Array<String>] the path for the scope.
150
+ # @param path [Array<String>] the path for the scope.
151
151
  def base_for(path)
152
152
  base = nil
153
153
 
@@ -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'
@@ -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
@@ -23,6 +23,8 @@ require_relative 'any'
23
23
  module Bake
24
24
  module Types
25
25
  class Array
26
+ extend Type
27
+
26
28
  def initialize(item_type)
27
29
  @item_type = item_type
28
30
  end
@@ -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
  module Boolean
26
+ extend Type
27
+
24
28
  def self.composite?
25
29
  false
26
30
  end
@@ -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.to_d
35
+ BigDecimal(value)
32
36
  end
33
37
  end
34
38
  end
@@ -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
  module Float
26
+ extend Type
27
+
24
28
  def self.composite?
25
29
  false
26
30
  end
@@ -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
@@ -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.to_i
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
@@ -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
  module String
26
+ extend Type
27
+
24
28
  def self.composite?
25
29
  false
26
30
  end
@@ -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
  module Symbol
26
+ extend Type
27
+
24
28
  def self.composite?
25
29
  false
26
30
  end
@@ -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
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Bake
22
- VERSION = "0.7.0"
22
+ VERSION = "0.8.0"
23
23
  end
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.7.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-25 00:00:00.000000000 Z
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