bake 0.4.4 → 0.5.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.
- checksums.yaml +4 -4
- data/lib/bake/context.rb +5 -1
- data/lib/bake/recipe.rb +36 -2
- data/lib/bake/types.rb +37 -0
- data/lib/bake/types/any.rb +53 -0
- data/lib/bake/types/array.rb +47 -0
- data/lib/bake/types/decimal.rb +35 -0
- data/lib/bake/types/float.rb +33 -0
- data/lib/bake/types/hash.rb +53 -0
- data/lib/bake/types/integer.rb +33 -0
- data/lib/bake/types/string.rb +33 -0
- data/lib/bake/types/symbol.rb +33 -0
- data/lib/bake/types/tuple.rb +45 -0
- data/lib/bake/version.rb +1 -1
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc8a46a50ac43cd0fb5db9d9898327b4c999f3fbe7991b549b7710340268c5a8
|
4
|
+
data.tar.gz: a299278a280a3613490b0acc96dc826f498d7950abe38289fb56dcd22165f049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b4ff92cffbb0653dfdb7cd8cbddf8d4d117563f3f934d65c12eacdcb2a1da34646706c845565a32b23854335008a6a6b332ec9901a7c43a49b4b3dfa4428435
|
7
|
+
data.tar.gz: 22d5cd4677921eb326ae85998b365b7ee151abf53a3752acab4d883b048140cf685f4c34037a052ca8e08406dff1636177e2bc99b7c3a95fa7c1700d37de1e28
|
data/lib/bake/context.rb
CHANGED
@@ -97,14 +97,18 @@ module Bake
|
|
97
97
|
attr :loaders
|
98
98
|
|
99
99
|
def call(*commands)
|
100
|
+
last_result = nil
|
101
|
+
|
100
102
|
while command = commands.shift
|
101
103
|
if recipe = @recipes[command]
|
102
104
|
arguments, options = recipe.prepare(commands)
|
103
|
-
recipe.call(*arguments, **options)
|
105
|
+
last_result = recipe.call(*arguments, **options)
|
104
106
|
else
|
105
107
|
raise ArgumentError, "Could not find recipe for #{command}!"
|
106
108
|
end
|
107
109
|
end
|
110
|
+
|
111
|
+
return last_result
|
108
112
|
end
|
109
113
|
|
110
114
|
def lookup(command)
|
data/lib/bake/recipe.rb
CHANGED
@@ -18,13 +18,18 @@
|
|
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 'types'
|
22
|
+
|
21
23
|
module Bake
|
24
|
+
PARAMETER = /@param\s+(?<name>.*?)\s+\[(?<type>.*?)\]\s+(?<details>.*?)\Z/
|
25
|
+
|
22
26
|
class Recipe
|
23
27
|
def initialize(scope, name, method = nil)
|
24
28
|
@scope = scope
|
25
29
|
@name = name
|
26
30
|
@command = nil
|
27
31
|
@description = nil
|
32
|
+
@types = nil
|
28
33
|
|
29
34
|
@method = method
|
30
35
|
@arity = nil
|
@@ -55,7 +60,7 @@ module Bake
|
|
55
60
|
|
56
61
|
def options?
|
57
62
|
if parameters = self.parameters
|
58
|
-
type, name =
|
63
|
+
type, name = parameters.last
|
59
64
|
|
60
65
|
return type == :keyrest || type == :keyreq || type == :key
|
61
66
|
end
|
@@ -81,6 +86,8 @@ module Bake
|
|
81
86
|
offset = 0
|
82
87
|
ordered = []
|
83
88
|
options = {}
|
89
|
+
parameters = method.parameters.dup
|
90
|
+
types = self.types
|
84
91
|
|
85
92
|
while argument = arguments.first
|
86
93
|
name, value = argument.split('=', 2)
|
@@ -89,10 +96,21 @@ module Bake
|
|
89
96
|
# Consume it:
|
90
97
|
arguments.shift
|
91
98
|
|
99
|
+
if type = types[name]
|
100
|
+
value = types.parse(value)
|
101
|
+
end
|
102
|
+
|
92
103
|
options[name.to_sym] = value
|
93
104
|
elsif ordered.size < self.arity
|
105
|
+
_, name = parameters.shift
|
106
|
+
value = arguments.shift
|
107
|
+
|
108
|
+
if type = types[name]
|
109
|
+
value = type.parse(value)
|
110
|
+
end
|
111
|
+
|
94
112
|
# Consume it:
|
95
|
-
ordered <<
|
113
|
+
ordered << value
|
96
114
|
else
|
97
115
|
break
|
98
116
|
end
|
@@ -122,6 +140,10 @@ module Bake
|
|
122
140
|
@description ||= read_description
|
123
141
|
end
|
124
142
|
|
143
|
+
def types
|
144
|
+
@types ||= read_types
|
145
|
+
end
|
146
|
+
|
125
147
|
private
|
126
148
|
|
127
149
|
def compute_command
|
@@ -163,5 +185,17 @@ module Bake
|
|
163
185
|
|
164
186
|
return description
|
165
187
|
end
|
188
|
+
|
189
|
+
def read_types
|
190
|
+
types = {}
|
191
|
+
|
192
|
+
description.each do |description|
|
193
|
+
if fields = PARAMETER.match(description)
|
194
|
+
types[fields[:name].to_sym] = Types.parse(fields[:type])
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
return types
|
199
|
+
end
|
166
200
|
end
|
167
201
|
end
|
data/lib/bake/types.rb
ADDED
@@ -0,0 +1,37 @@
|
|
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 'types/any'
|
22
|
+
require_relative 'types/array'
|
23
|
+
require_relative 'types/decimal'
|
24
|
+
require_relative 'types/float'
|
25
|
+
require_relative 'types/hash'
|
26
|
+
require_relative 'types/integer'
|
27
|
+
require_relative 'types/string'
|
28
|
+
require_relative 'types/symbol'
|
29
|
+
require_relative 'types/tuple'
|
30
|
+
|
31
|
+
module Bake
|
32
|
+
module Types
|
33
|
+
def self.parse(signature)
|
34
|
+
eval(signature, binding)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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
|
+
module Bake
|
22
|
+
module Types
|
23
|
+
class Any
|
24
|
+
def initialize(types)
|
25
|
+
@types = types
|
26
|
+
end
|
27
|
+
|
28
|
+
def composite?
|
29
|
+
@types.any?{|type| type.composite?}
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse(input)
|
33
|
+
@types.each do |type|
|
34
|
+
return type.parse(input)
|
35
|
+
rescue
|
36
|
+
# Ignore
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.parse(value)
|
41
|
+
value
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
"any of #{@types.join(', ')}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.Any(types)
|
50
|
+
Any.new(types)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
+
class Array
|
26
|
+
def initialize(item_type)
|
27
|
+
@item_type = item_type
|
28
|
+
end
|
29
|
+
|
30
|
+
def composite?
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse(input)
|
35
|
+
input.split(',').map{|value| @item_type.parse(value)}
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
"an Array of #{@item_type}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.Array(item_type = Any)
|
44
|
+
Array.new(item_type)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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 'bigdecimal'
|
22
|
+
|
23
|
+
module Bake
|
24
|
+
module Types
|
25
|
+
module Decimal
|
26
|
+
def self.composite?
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.parse(value)
|
31
|
+
value.to_d
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
module Bake
|
22
|
+
module Types
|
23
|
+
module Integer
|
24
|
+
def self.composite?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse(value)
|
29
|
+
value.to_f
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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
|
+
module Bake
|
22
|
+
module Types
|
23
|
+
class Hash
|
24
|
+
def initialize(key_type, value_type)
|
25
|
+
@key_type = key_type
|
26
|
+
@value_type = value_type
|
27
|
+
end
|
28
|
+
|
29
|
+
def composite?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse(input)
|
34
|
+
hash = {}
|
35
|
+
|
36
|
+
input.split(',').each do |pair|
|
37
|
+
key, value = pair.split(':', 2)
|
38
|
+
|
39
|
+
key = @key_type.parse(key)
|
40
|
+
value = @value_type.parse(value)
|
41
|
+
|
42
|
+
hash[key] = value
|
43
|
+
end
|
44
|
+
|
45
|
+
return hash
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.Hash(key_type, value_type)
|
50
|
+
Hash.new(key_type, value_type)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
module Bake
|
22
|
+
module Types
|
23
|
+
module Integer
|
24
|
+
def self.composite?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse(value)
|
29
|
+
value.to_i
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
module Bake
|
22
|
+
module Types
|
23
|
+
module String
|
24
|
+
def self.composite?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse(value)
|
29
|
+
value.to_s
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
module Bake
|
22
|
+
module Types
|
23
|
+
module Symbol
|
24
|
+
def self.composite?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse(input)
|
29
|
+
input.to_sym
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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
|
+
module Bake
|
22
|
+
module Types
|
23
|
+
class Tuple
|
24
|
+
def initialize(item_types)
|
25
|
+
@item_types = item_types
|
26
|
+
end
|
27
|
+
|
28
|
+
def composite?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse(input)
|
33
|
+
input.split(',').map{|value| @item_type.parse(value)}
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
"a Tuple of (#{@item_types.join(', ')})"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.Tuple(*item_types)
|
42
|
+
Tuple.new(item_types)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
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.5.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-
|
11
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: samovar
|
@@ -109,6 +109,16 @@ files:
|
|
109
109
|
- lib/bake/loaders.rb
|
110
110
|
- lib/bake/recipe.rb
|
111
111
|
- lib/bake/scope.rb
|
112
|
+
- lib/bake/types.rb
|
113
|
+
- lib/bake/types/any.rb
|
114
|
+
- lib/bake/types/array.rb
|
115
|
+
- lib/bake/types/decimal.rb
|
116
|
+
- lib/bake/types/float.rb
|
117
|
+
- lib/bake/types/hash.rb
|
118
|
+
- lib/bake/types/integer.rb
|
119
|
+
- lib/bake/types/string.rb
|
120
|
+
- lib/bake/types/symbol.rb
|
121
|
+
- lib/bake/types/tuple.rb
|
112
122
|
- lib/bake/version.rb
|
113
123
|
homepage: https://github.com/ioquatix/bake
|
114
124
|
licenses:
|
@@ -130,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
140
|
- !ruby/object:Gem::Version
|
131
141
|
version: '0'
|
132
142
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.2
|
134
144
|
signing_key:
|
135
145
|
specification_version: 4
|
136
146
|
summary: A replacement for rake with a simpler syntax.
|