bake 0.16.1 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/input.rb +26 -0
- data/bake/output.rb +24 -0
- data/lib/bake/arguments.rb +7 -4
- data/lib/bake/command/call.rb +6 -0
- data/lib/bake/context.rb +2 -2
- data/lib/bake/documentation.rb +1 -1
- data/lib/bake/loaders.rb +2 -0
- data/lib/bake/recipe.rb +12 -2
- data/lib/bake/types/decimal.rb +2 -2
- data/lib/bake/types/float.rb +2 -2
- data/lib/bake/types/integer.rb +2 -2
- data/lib/bake/types/string.rb +2 -2
- data/lib/bake/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +35 -4
- metadata.gz.sig +2 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45dc14db128a03b0d45937817bbbf8b2d74d1762c5eb09706334113b1bcf2102
|
4
|
+
data.tar.gz: 6ecb1fe731b1440fc73a831d182b00d134d5b8572ac8d37a2f4b7ec188b5af46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75621544ab473d069454794226b840adfb5e670eb3c7ccecd0cc197122b9a3d06e6541d16ab4819ee4037c284eac91da8defd2a45ef747ccfac2e285368f5681
|
7
|
+
data.tar.gz: '068df1863a48a29cacc02d5ad64b98b8f5af0d6c03b82334699894932fa8aee26e258e8bcf27aab3929680b6c46aa01ba24a5512fe161d226eede9d87c73350f'
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/bake/input.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
FORMATS = {
|
3
|
+
json: ->(file){require 'json'; JSON.parse(file.read)},
|
4
|
+
yaml: ->(file){require 'yaml'; YAML.load(file.read)},
|
5
|
+
}
|
6
|
+
|
7
|
+
# Parse an input file (defaulting to stdin) in the specified format (defaulting to JSON).
|
8
|
+
# @parameter file [Input] The input file.
|
9
|
+
# @parameter format [Symbol] The input format, e.g. json, yaml.
|
10
|
+
def input(file: $stdin, format: :json)
|
11
|
+
format_for(format).call(file)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Parse some input text in the specified format (defaulting to JSON).
|
15
|
+
# @parameter text [String] The input text.
|
16
|
+
# @parameter format [Symbol] The input format, e.g. json, yaml.
|
17
|
+
def parse(text, format: :json)
|
18
|
+
file = StringIO.new(text)
|
19
|
+
format_for(format).call(file)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def format_for(name)
|
25
|
+
FORMATS[name]
|
26
|
+
end
|
data/bake/output.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
FORMATS = {
|
3
|
+
json: ->(file, value){require 'json'; file.puts(JSON.pretty_generate(value))},
|
4
|
+
pp: ->(file, value){require 'pp'; PP.pp(value, file)},
|
5
|
+
raw: ->(file, value){file.puts(value)},
|
6
|
+
yaml: ->(file, value){require 'yaml'; file.puts(YAML.dump(value))},
|
7
|
+
}
|
8
|
+
|
9
|
+
# Dump the last result to the specified file (defaulting to stdout) in the specified format (defaulting to Ruby's pretty print).
|
10
|
+
# @parameter input [Array(Integer)]
|
11
|
+
# @parameter file [Output] The input file.
|
12
|
+
# @parameter format [Symbol] The output format.
|
13
|
+
def output(input:, file: $stdout, format: :pp)
|
14
|
+
format_for(format).call(file, input)
|
15
|
+
|
16
|
+
# Allow chaining of output processing:
|
17
|
+
return input
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def format_for(name)
|
23
|
+
FORMATS[name]
|
24
|
+
end
|
data/lib/bake/arguments.rb
CHANGED
@@ -26,11 +26,14 @@ require_relative 'documentation'
|
|
26
26
|
module Bake
|
27
27
|
# Structured access to arguments.
|
28
28
|
class Arguments
|
29
|
-
def self.extract(recipe, arguments)
|
30
|
-
|
29
|
+
def self.extract(recipe, arguments, **defaults)
|
30
|
+
# Only supply defaults that match the recipe option names:
|
31
|
+
defaults = defaults.slice(*recipe.required_options)
|
32
|
+
|
33
|
+
self.new(recipe, defaults).extract(arguments)
|
31
34
|
end
|
32
35
|
|
33
|
-
def initialize(recipe)
|
36
|
+
def initialize(recipe, defaults)
|
34
37
|
@recipe = recipe
|
35
38
|
|
36
39
|
@types = recipe.types
|
@@ -38,7 +41,7 @@ module Bake
|
|
38
41
|
@arity = recipe.arity
|
39
42
|
|
40
43
|
@ordered = []
|
41
|
-
@options =
|
44
|
+
@options = defaults
|
42
45
|
end
|
43
46
|
|
44
47
|
attr :ordered
|
data/lib/bake/command/call.rb
CHANGED
@@ -38,6 +38,12 @@ module Bake
|
|
38
38
|
|
39
39
|
many :commands, "The commands & arguments to invoke.", default: ["default"], stop: false
|
40
40
|
|
41
|
+
def format(output, value)
|
42
|
+
if formatter = OUTPUT[output]
|
43
|
+
formatter.call(value)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
41
47
|
def call
|
42
48
|
context = @parent.context
|
43
49
|
|
data/lib/bake/context.rb
CHANGED
@@ -118,7 +118,7 @@ module Bake
|
|
118
118
|
|
119
119
|
while command = commands.shift
|
120
120
|
if recipe = @recipes[command]
|
121
|
-
arguments, options = recipe.prepare(commands)
|
121
|
+
arguments, options = recipe.prepare(commands, last_result)
|
122
122
|
last_result = recipe.call(*arguments, **options)
|
123
123
|
else
|
124
124
|
raise ArgumentError, "Could not find recipe for #{command}!"
|
@@ -170,7 +170,7 @@ module Bake
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
-
# @parameter path [Array
|
173
|
+
# @parameter path [Array(String)] the path for the scope.
|
174
174
|
def base_for(path)
|
175
175
|
base = nil
|
176
176
|
|
data/lib/bake/documentation.rb
CHANGED
@@ -81,7 +81,7 @@ module Bake
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
PARAMETER = /\A
|
84
|
+
PARAMETER = /\A@param(eter)?\s+(?<name>.*?)\s+\[(?<type>.*?)\](\s+(?<details>.*?))?\z/
|
85
85
|
|
86
86
|
# The parameter lines of the comment block.
|
87
87
|
# e.g. `@parameter value [String] The value.`
|
data/lib/bake/loaders.rb
CHANGED
@@ -83,6 +83,8 @@ module Bake
|
|
83
83
|
# @parameter current [String] The path to start searching from.
|
84
84
|
def append_from_root(current = Dir.pwd, **options)
|
85
85
|
while current
|
86
|
+
Console.logger.debug(self) {"Checking current #{current}..."}
|
87
|
+
|
86
88
|
append_path(current, **options)
|
87
89
|
|
88
90
|
parent = File.dirname(current)
|
data/lib/bake/recipe.rb
CHANGED
@@ -85,6 +85,16 @@ module Bake
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def required_options
|
89
|
+
if parameters = self.parameters
|
90
|
+
parameters.map do |(type, name)|
|
91
|
+
if type == :keyreq
|
92
|
+
name
|
93
|
+
end
|
94
|
+
end.compact
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
88
98
|
# The command name for this recipe.
|
89
99
|
def command
|
90
100
|
@command ||= compute_command
|
@@ -107,8 +117,8 @@ module Bake
|
|
107
117
|
# @parameter arguments [Array(String)] The command line arguments
|
108
118
|
# @returns ordered [Array]
|
109
119
|
# @returns options [Hash]
|
110
|
-
def prepare(arguments)
|
111
|
-
Arguments.extract(self, arguments)
|
120
|
+
def prepare(arguments, last_result = nil)
|
121
|
+
Arguments.extract(self, arguments, input: last_result)
|
112
122
|
end
|
113
123
|
|
114
124
|
# Call the recipe with the specified arguments and options.
|
data/lib/bake/types/decimal.rb
CHANGED
data/lib/bake/types/float.rb
CHANGED
data/lib/bake/types/integer.rb
CHANGED
data/lib/bake/types/string.rb
CHANGED
data/lib/bake/version.rb
CHANGED
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- Olle Jonsson
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
|
15
|
+
ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
|
16
|
+
MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
|
17
|
+
aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
|
18
|
+
AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
|
19
|
+
xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
|
20
|
+
eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
|
21
|
+
L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
|
22
|
+
9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
|
23
|
+
E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0+tpJrfsYiAmXMJNi4XAYJH7uL
|
24
|
+
rgJuJwSaa/dMz+VmUoo7VKtSfCoOI+6v5/z0sK3oT6sG6ZwyI47DBq2XqNC6tnAj
|
25
|
+
w+XmCywiTQrFzMMAvcA7rPI4F0nU1rZId51rOvvfxaONp+wgTi4P8owZLw0/j0m4
|
26
|
+
8C20DYi6EYx4AHDXiLpElWh3AgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8E
|
27
|
+
BAMCBLAwHQYDVR0OBBYEFB6ZaeWKxQjGTI+pmz7cKRmMIywwMC4GA1UdEQQnMCWB
|
28
|
+
I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWB
|
29
|
+
I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEB
|
30
|
+
CwUAA4IBgQBVoM+pu3dpdUhZM1w051iw5GfiqclAr1Psypf16Tiod/ho//4oAu6T
|
31
|
+
9fj3DPX/acWV9P/FScvqo4Qgv6g4VWO5ZU7z2JmPoTXZtYMunRAmQPFL/gSUc6aK
|
32
|
+
vszMHIyhtyzRc6DnfW2AiVOjMBjaYv8xXZc9bduniRVPrLR4J7ozmGLh4o4uJp7w
|
33
|
+
x9KCFaR8Lvn/r0oJWJOqb/DMAYI83YeN2Dlt3jpwrsmsONrtC5S3gOUle5afSGos
|
34
|
+
bYt5ocnEpKSomR9ZtnCGljds/aeO1Xgpn2r9HHcjwnH346iNrnHmMlC7BtHUFPDg
|
35
|
+
Ts92S47PTOXzwPBDsrFiq3VLbRjHSwf8rpqybQBH9MfzxGGxTaETQYOd6b4e4Ag6
|
36
|
+
y92abGna0bmIEb4+Tx9rQ10Uijh1POzvr/VTH4bbIPy9FbKrRsIQ24qDbNJRtOpE
|
37
|
+
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
38
|
+
HiLJ8VOFx6w=
|
39
|
+
-----END CERTIFICATE-----
|
40
|
+
date: 2022-05-22 00:00:00.000000000 Z
|
12
41
|
dependencies:
|
13
42
|
- !ruby/object:Gem::Dependency
|
14
43
|
name: samovar
|
@@ -73,6 +102,8 @@ executables:
|
|
73
102
|
extensions: []
|
74
103
|
extra_rdoc_files: []
|
75
104
|
files:
|
105
|
+
- bake/input.rb
|
106
|
+
- bake/output.rb
|
76
107
|
- bin/bake
|
77
108
|
- lib/bake.rb
|
78
109
|
- lib/bake/arguments.rb
|
@@ -122,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
153
|
- !ruby/object:Gem::Version
|
123
154
|
version: '0'
|
124
155
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.3.7
|
126
157
|
signing_key:
|
127
158
|
specification_version: 4
|
128
159
|
summary: A replacement for rake with a simpler syntax.
|
metadata.gz.sig
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
F⏧�Z�
|
2
|
+
�wS���pl���Jt g���{,l]������R�%ahy�����]�Aa � m���y���U�U]W���װĔP5�co{��&k!e�cո��s#���4k[7����H0�&�s#?7��dz%����kSSzy�6�G�H^աn���(!���)��dW�Z� �+�6�ƛ=Vn,�M�QLϮ�A�����=LYN(������c=F־��ⲫo$�}�:�P�|p�@����8A��dQ�D�wO[��� �_�wπ�1rOG��IQl������T�Ƿ����7UI���3�A���=ww����l�+!�U��W�KJ�+�y����()5}��=�wG����Ia�.
|