bake 0.23.1 → 0.24.1
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
- checksums.yaml.gz.sig +0 -0
- data/bake/output.rb +11 -0
- data/context/command-line-interface.md +55 -0
- data/context/gem-integration.md +69 -0
- data/context/getting-started.md +153 -0
- data/context/index.yaml +29 -0
- data/context/input-and-output.md +34 -0
- data/context/project-integration.md +64 -0
- data/lib/bake/arguments.rb +1 -1
- data/lib/bake/base.rb +9 -2
- data/lib/bake/command/call.rb +6 -2
- data/lib/bake/command/list.rb +2 -2
- data/lib/bake/command/top.rb +1 -1
- data/lib/bake/command.rb +1 -1
- data/lib/bake/context.rb +13 -2
- data/lib/bake/documentation.rb +1 -1
- data/lib/bake/format/ndjson.rb +3 -0
- data/lib/bake/recipe.rb +7 -1
- data/lib/bake/registry/aggregate.rb +3 -3
- data/lib/bake/registry/bakefile_loader.rb +1 -1
- data/lib/bake/registry/directory_loader.rb +1 -1
- data/lib/bake/registry.rb +1 -1
- data/lib/bake/scope.rb +1 -1
- data/lib/bake/type/any.rb +1 -1
- data/lib/bake/type/array.rb +1 -1
- data/lib/bake/type/boolean.rb +1 -1
- data/lib/bake/type/decimal.rb +1 -1
- data/lib/bake/type/float.rb +1 -1
- data/lib/bake/type/hash.rb +2 -2
- data/lib/bake/type/input.rb +1 -1
- data/lib/bake/type/integer.rb +1 -1
- data/lib/bake/type/nil.rb +1 -1
- data/lib/bake/type/output.rb +1 -1
- data/lib/bake/type/string.rb +1 -1
- data/lib/bake/type/symbol.rb +1 -1
- data/lib/bake/type/tuple.rb +1 -1
- data/lib/bake/type.rb +1 -1
- data/lib/bake/version.rb +1 -1
- data/readme.md +8 -0
- data/releases.md +8 -0
- data.tar.gz.sig +0 -0
- metadata +10 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a0b7eec81f6d689857dc2b652d8cabcb1f35ed73eaec9f0cbb3aa43b268b7b3
|
4
|
+
data.tar.gz: 0c07c5778454e1797eddc1b0d5e6e70174a41da5281b04ffcb8af774142335fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dafb2ca73a16b74b16cc745750086069fe967be75dd465de60f0d6a1de49c837971389687a314a13c4866289db858dea40d8176337129764b2e77896a90b6921
|
7
|
+
data.tar.gz: 2d7e5b903233db1b99ed9bd6c81162dc759397d181f887f0e8448608a27eb52ee8f868c55193a741e313f7428f629eaaa3f373640d61e42f3558282df0dafd27
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bake/output.rb
CHANGED
@@ -23,6 +23,17 @@ def output(input:, file: $stdout, format: nil)
|
|
23
23
|
return input
|
24
24
|
end
|
25
25
|
|
26
|
+
# Do not produce any output.
|
27
|
+
def null(input:)
|
28
|
+
# This is a no-op, used to indicate that no output should be produced.
|
29
|
+
return input
|
30
|
+
end
|
31
|
+
|
32
|
+
# This command produces output, and therefore doesn't need default output handling.
|
33
|
+
def output?(recipe)
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
26
37
|
private
|
27
38
|
|
28
39
|
def format_for(file, name)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Command Line Interface
|
2
|
+
|
3
|
+
The `bake` command is broken up into two main functions: `list` and `call`.
|
4
|
+
|
5
|
+
<pre>% bake --help
|
6
|
+
<b>bake [-h/--help] [-b/--bakefile <path>] <command></b>
|
7
|
+
<font color="#638FFF">Execute tasks using Ruby.</font>
|
8
|
+
|
9
|
+
[-h/--help] Show help.
|
10
|
+
[-b/--bakefile <path>] Override the path to the bakefile to use.
|
11
|
+
<command> One of: call, list. (default: call)
|
12
|
+
|
13
|
+
<b>call <commands...></b>
|
14
|
+
<font color="#638FFF">Execute one or more commands.</font>
|
15
|
+
|
16
|
+
<commands...> The commands & arguments to invoke. (default: ["default"])
|
17
|
+
|
18
|
+
<b>list <pattern></b>
|
19
|
+
<pattern> The pattern to filter tasks by.
|
20
|
+
</pre>
|
21
|
+
|
22
|
+
## List
|
23
|
+
|
24
|
+
The `bake list` command allows you to list all available recipes. By proving a pattern you will only see recipes that have a matching command name.
|
25
|
+
|
26
|
+
<pre>$ bake list console
|
27
|
+
<b>Bake::Loader console-1.8.2</b>
|
28
|
+
|
29
|
+
<b>console:info</b>
|
30
|
+
<font color="#638FFF">Increase the verbosity of the logger to info.</font>
|
31
|
+
|
32
|
+
<b>console:debug</b>
|
33
|
+
<font color="#638FFF">Increase the verbosity of the logger to debug.</font>
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
The listing documents positional and optional arguments. The documentation is generated from the comments in the bakefiles.
|
37
|
+
|
38
|
+
## Call
|
39
|
+
|
40
|
+
The `bake call` (the default, so `call` can be omitted) allows you to execute one or more recipes. You must provide the name of the command, followed by any arguments.
|
41
|
+
|
42
|
+
<pre>$ bake async:http:head https://www.codeotaku.com/index
|
43
|
+
<font color="#638FFF"><b> HEAD</b></font>: https://www.codeotaku.com/index
|
44
|
+
<font color="#00AA00"><b> version</b></font>: h2
|
45
|
+
<font color="#00AA00"><b> status</b></font>: 200
|
46
|
+
<font color="#00AA00"><b> body</b></font>: body with length <b>7879B</b>
|
47
|
+
<b> content-type</b>: "text/html; charset=utf-8"
|
48
|
+
<b> cache-control</b>: "public, max-age=3600"
|
49
|
+
<b> expires</b>: "Mon, 04 May 2020 13:23:47 GMT"
|
50
|
+
<b> server</b>: "falcon/0.36.4"
|
51
|
+
<b> date</b>: "Mon, 04 May 2020 12:23:47 GMT"
|
52
|
+
<b> vary</b>: "accept-encoding"
|
53
|
+
</pre>
|
54
|
+
|
55
|
+
You can specify multiple commands and they will be executed sequentially.
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Gem Integration
|
2
|
+
|
3
|
+
This guide explains how to add `bake` to a Ruby gem and export standardised tasks for use by other gems and projects.
|
4
|
+
|
5
|
+
## Exporting Tasks
|
6
|
+
|
7
|
+
Adding a `bake/` directory to your gem will allow other gems and projects to consume those recipes. In order to prevent collisions, you *should* prefix your commands with the name of the gem, e.g. in `mygem/bake/mygem.rb`:
|
8
|
+
|
9
|
+
~~~ ruby
|
10
|
+
def setup
|
11
|
+
# ...
|
12
|
+
end
|
13
|
+
~~~
|
14
|
+
|
15
|
+
Then, in a different project which depends on `mygem`, you can run tasks from `mygem` by invoking them using `bake`:
|
16
|
+
|
17
|
+
~~~ bash
|
18
|
+
$ bake mygem:setup
|
19
|
+
~~~
|
20
|
+
|
21
|
+
## Examples
|
22
|
+
|
23
|
+
There are many gems which export tasks in this way. Here are some notable examples:
|
24
|
+
|
25
|
+
### Variant
|
26
|
+
|
27
|
+
The [variant gem](https://github.com/socketry/variant) exposes bake tasks for setting the environment e.g. `development`, `testing`, or `production`.
|
28
|
+
|
29
|
+
<pre class="terminal">$ bake list variant
|
30
|
+
<b>Bake::Loader variant-0.1.1</b>
|
31
|
+
|
32
|
+
<b>variant:production</b> <font color="#00AA00">**overrides</font>
|
33
|
+
<font color="#638FFF">Select the production variant.</font>
|
34
|
+
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
35
|
+
|
36
|
+
<b>variant:staging</b> <font color="#00AA00">**overrides</font>
|
37
|
+
<font color="#638FFF">Select the staging variant.</font>
|
38
|
+
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
39
|
+
|
40
|
+
<b>variant:development</b> <font color="#00AA00">**overrides</font>
|
41
|
+
<font color="#638FFF">Select the development variant.</font>
|
42
|
+
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
43
|
+
|
44
|
+
<b>variant:testing</b> <font color="#00AA00">**overrides</font>
|
45
|
+
<font color="#638FFF">Select the testing variant.</font>
|
46
|
+
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
47
|
+
|
48
|
+
<b>variant:force</b> <font color="#AA0000">name</font> <font color="#00AA00">**overrides</font>
|
49
|
+
<font color="#638FFF">Force a specific variant.</font>
|
50
|
+
<font color="#00AA00">name</font> [Symbol] <font color="#638FFF">the default variant.</font>
|
51
|
+
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
52
|
+
|
53
|
+
<b>variant:show</b>
|
54
|
+
<font color="#638FFF">Show variant-related environment variables.</font>
|
55
|
+
</pre>
|
56
|
+
|
57
|
+
### Console
|
58
|
+
|
59
|
+
The [console gem](https://github.com/socketry/console) exposes bake tasks to change the log level.
|
60
|
+
|
61
|
+
<pre class="terminal">$ bake list console
|
62
|
+
<b>Bake::Loader console-1.8.2</b>
|
63
|
+
|
64
|
+
<b>console:info</b>
|
65
|
+
<font color="#638FFF">Increase the verbosity of the logger to info.</font>
|
66
|
+
|
67
|
+
<b>console:debug</b>
|
68
|
+
<font color="#638FFF">Increase the verbosity of the logger to debug.</font>
|
69
|
+
</pre>
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# Getting Started
|
2
|
+
|
3
|
+
This guide gives a general overview of `bake` and how to use it.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the gem to your project:
|
8
|
+
|
9
|
+
~~~ bash
|
10
|
+
$ bundle add bake
|
11
|
+
~~~
|
12
|
+
|
13
|
+
## Core Concepts
|
14
|
+
|
15
|
+
`bake` has several core concepts:
|
16
|
+
|
17
|
+
- A `bake` executable used for invoking one or more tasks.
|
18
|
+
- A {ruby Bake::Context} instance which is bound to a project or gem and exposes a hierarchy of runnable tasks.
|
19
|
+
- A {ruby Bake::Loader::Aggregate} instance which is used for on-demand loading of bake files from the current project and all available gems.
|
20
|
+
|
21
|
+
## Executing Tasks
|
22
|
+
|
23
|
+
The `bake` executable can be used to execute tasks in a `bake.rb` file in the same directory.
|
24
|
+
|
25
|
+
``` ruby
|
26
|
+
# bake.rb
|
27
|
+
|
28
|
+
def add(x, y)
|
29
|
+
puts Integer(x) + Integer(y)
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
You can execute this task from the command line:
|
34
|
+
|
35
|
+
``` shell
|
36
|
+
% bake add 10 20
|
37
|
+
30
|
38
|
+
```
|
39
|
+
|
40
|
+
### Executing Multiple Tasks
|
41
|
+
|
42
|
+
The `bake` executable can execute multiple tasks in one invocation and even pass the output of one task into a subsequent task.
|
43
|
+
|
44
|
+
``` ruby
|
45
|
+
# bake.rb
|
46
|
+
|
47
|
+
attr_accessor :value
|
48
|
+
```
|
49
|
+
|
50
|
+
You can set and print the value:
|
51
|
+
|
52
|
+
``` shell
|
53
|
+
% bake value= 10 value output
|
54
|
+
```
|
55
|
+
|
56
|
+
This is essentially broken down into three operations: `value = 10`, `value` & `output`. The `value` method returns the current value and the `output` task prints the result of the previous task.
|
57
|
+
|
58
|
+
## Optional Arguments
|
59
|
+
|
60
|
+
You can provide optional arguments:
|
61
|
+
|
62
|
+
``` ruby
|
63
|
+
# bake.rb
|
64
|
+
|
65
|
+
def add(x: 10, y: 20)
|
66
|
+
puts Integer(x) + Integer(y)
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
You can execute this task from the command line:
|
71
|
+
|
72
|
+
``` shell
|
73
|
+
% bake add --x 10 --y 20
|
74
|
+
30
|
75
|
+
```
|
76
|
+
|
77
|
+
Or alternatively:
|
78
|
+
|
79
|
+
``` shell
|
80
|
+
% bake add x=10 y=20
|
81
|
+
30
|
82
|
+
```
|
83
|
+
|
84
|
+
### Using Types
|
85
|
+
|
86
|
+
You can annotate your task with a type signature and `bake` will coerce your arguments to these types:
|
87
|
+
|
88
|
+
``` ruby
|
89
|
+
# bake.rb
|
90
|
+
|
91
|
+
# @parameter x [Integer]
|
92
|
+
# @parameter y [Integer]
|
93
|
+
def add(x, y)
|
94
|
+
puts x + y
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
You can execute this task from the command line:
|
99
|
+
|
100
|
+
``` shell
|
101
|
+
% bake add 10 20
|
102
|
+
30
|
103
|
+
```
|
104
|
+
|
105
|
+
The values are automatically coerced to `Integer`.
|
106
|
+
|
107
|
+
### Extending With Documentation
|
108
|
+
|
109
|
+
You can add documentation to your tasks and parameters (using Markdown formatting).
|
110
|
+
|
111
|
+
``` ruby
|
112
|
+
# bake.rb
|
113
|
+
|
114
|
+
# Add the x and y coordinate together and print the result.
|
115
|
+
# @parameter x [Integer] The x offset.
|
116
|
+
# @parameter y [Integer] The y offset.
|
117
|
+
def add(x, y)
|
118
|
+
puts x + y
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
You can see this documentation in the task listing:
|
123
|
+
|
124
|
+
``` shell
|
125
|
+
% bake list add
|
126
|
+
Bake::Context getting-started
|
127
|
+
|
128
|
+
add x y
|
129
|
+
Add the x and y coordinate together and print the result.
|
130
|
+
x [Integer] The x offset.
|
131
|
+
y [Integer] The y offset.
|
132
|
+
```
|
133
|
+
|
134
|
+
### Private Methods
|
135
|
+
|
136
|
+
If you want to add helper methods which don't show up as tasks, define them as `protected` or `private`.
|
137
|
+
|
138
|
+
``` ruby
|
139
|
+
# bake.rb
|
140
|
+
|
141
|
+
# Add the x and y coordinate together and print the result.
|
142
|
+
# @parameter x [Integer] The x offset.
|
143
|
+
# @parameter y [Integer] The y offset.
|
144
|
+
def add(x, y)
|
145
|
+
puts x + y
|
146
|
+
end
|
147
|
+
|
148
|
+
private
|
149
|
+
|
150
|
+
def puts(*arguments)
|
151
|
+
$stdout.puts arguments.inspect
|
152
|
+
end
|
153
|
+
```
|
data/context/index.yaml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Automatically generated context index for Utopia::Project guides.
|
2
|
+
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
|
3
|
+
---
|
4
|
+
description: A replacement for rake with a simpler syntax.
|
5
|
+
metadata:
|
6
|
+
documentation_uri: https://ioquatix.github.io/bake/
|
7
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
8
|
+
source_code_uri: https://github.com/ioquatix/bake.git
|
9
|
+
files:
|
10
|
+
- path: getting-started.md
|
11
|
+
title: Getting Started
|
12
|
+
description: This guide gives a general overview of `bake` and how to use it.
|
13
|
+
- path: command-line-interface.md
|
14
|
+
title: Command Line Interface
|
15
|
+
description: 'The `bake` command is broken up into two main functions: `list` and
|
16
|
+
`call`.'
|
17
|
+
- path: project-integration.md
|
18
|
+
title: Project Integration
|
19
|
+
description: This guide explains how to add `bake` to a Ruby project.
|
20
|
+
- path: gem-integration.md
|
21
|
+
title: Gem Integration
|
22
|
+
description: This guide explains how to add `bake` to a Ruby gem and export standardised
|
23
|
+
tasks for use by other gems and projects.
|
24
|
+
- path: input-and-output.md
|
25
|
+
title: Input and Output
|
26
|
+
description: "`bake` has built in tasks for reading input and writing output in
|
27
|
+
different formats. While this can be useful for general processing, there are
|
28
|
+
some limitations, notably that rich object representations like `json` and `yaml`
|
29
|
+
often don't support stream processing."
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Input and Output
|
2
|
+
|
3
|
+
`bake` has built in tasks for reading input and writing output in different formats. While this can be useful for general processing, there are some limitations, notably that rich object representations like `json` and `yaml` often don't support stream processing.
|
4
|
+
|
5
|
+
## Input
|
6
|
+
|
7
|
+
The `input` task reads from `stdin` or a specified `--file` path. It handles a number of different `--format` arguments including `json` and `yaml`.
|
8
|
+
|
9
|
+
``` shell
|
10
|
+
> bake input --file data.json --format json output
|
11
|
+
[{"name"=>"Alice", "age"=>30}, {"name"=>"Bob", "age"=>40}]
|
12
|
+
```
|
13
|
+
|
14
|
+
### Text
|
15
|
+
|
16
|
+
Instead of using a file, you can parse a string argument.
|
17
|
+
|
18
|
+
``` shell
|
19
|
+
> bin/bake input:parse "[1,2,3]" output
|
20
|
+
[1, 2, 3]
|
21
|
+
```
|
22
|
+
|
23
|
+
## Output
|
24
|
+
|
25
|
+
The `output` task takes the return value from the previous command and outputs it to `stdout` or the specified `--file` path. It also handles a number of differnt `--format` arguments including `json`, `yaml`, `raw` and the default `pp`.
|
26
|
+
|
27
|
+
``` shell
|
28
|
+
> bin/bake input --file data.json output --format yaml
|
29
|
+
---
|
30
|
+
- name: Alice
|
31
|
+
age: 30
|
32
|
+
- name: Bob
|
33
|
+
age: 40
|
34
|
+
```
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Project Integration
|
2
|
+
|
3
|
+
This guide explains how to add `bake` to a Ruby project.
|
4
|
+
|
5
|
+
## Bakefile
|
6
|
+
|
7
|
+
At the top level of your project, you can create a `bake.rb` file, which contains top level tasks which are private to your project.
|
8
|
+
|
9
|
+
~~~ ruby
|
10
|
+
def cake
|
11
|
+
ingredients = call 'supermarket:shop', 'flour,sugar,cocoa'
|
12
|
+
lookup('mixer:add').call(ingredients)
|
13
|
+
end
|
14
|
+
~~~
|
15
|
+
|
16
|
+
This file is project specific and is the only file which can expose top level tasks (i.e. without a defined namespace). When used in a gem, these tasks are not exposed to other gems/projects.
|
17
|
+
|
18
|
+
## Recipes
|
19
|
+
|
20
|
+
Alongside the `bake.rb`, there is a `bake/` directory which contains files like `supermarket.rb`. These files contain recipes, e.g.:
|
21
|
+
|
22
|
+
~~~ ruby
|
23
|
+
# @parameter ingredients [Array(Any)] the ingredients to purchase.
|
24
|
+
def shop(ingredients)
|
25
|
+
supermarket = Supermarket.best
|
26
|
+
|
27
|
+
return supermarket.purchase(ingredients)
|
28
|
+
end
|
29
|
+
~~~
|
30
|
+
|
31
|
+
These methods are automatically scoped according to the file name, e.g. `bake/supermarket.rb` will define `supermarket:shop`.
|
32
|
+
|
33
|
+
|
34
|
+
## Arguments
|
35
|
+
|
36
|
+
Arguments work as normal. Documented types are used to parse strings from the command line. Both positional and optional parameters are supported.
|
37
|
+
|
38
|
+
### Positional Parameters
|
39
|
+
|
40
|
+
Positional parameters are non-keyword parameters which may have a default value. However, because of the limits of the command line, all positional arguments must be specified.
|
41
|
+
|
42
|
+
~~~ ruby
|
43
|
+
# @parameter x [Integer]
|
44
|
+
# @parameter y [Integer]
|
45
|
+
def add(x, y)
|
46
|
+
puts x + y
|
47
|
+
end
|
48
|
+
~~~
|
49
|
+
|
50
|
+
Which is invoked by `bake add 1 2`.
|
51
|
+
|
52
|
+
### Optional Parameters
|
53
|
+
|
54
|
+
Optional parameters are keyword parameters which may have a default value. The parameter is set on the command line using the name of the parameter followed by an equals sign, followed by the value.
|
55
|
+
|
56
|
+
~~~ ruby
|
57
|
+
# @parameter x [Integer]
|
58
|
+
# @parameter y [Integer]
|
59
|
+
def add(x:, y: 2)
|
60
|
+
puts x + y
|
61
|
+
end
|
62
|
+
~~~
|
63
|
+
|
64
|
+
Which is invoked by `bake add x=1`. Because `y` is not specified, it will default to `2` as per the method definition.
|
data/lib/bake/arguments.rb
CHANGED
data/lib/bake/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "recipe"
|
7
7
|
require_relative "scope"
|
@@ -31,7 +31,7 @@ module Bake
|
|
31
31
|
|
32
32
|
def self.inspect
|
33
33
|
if path = self.path
|
34
|
-
"Bake::Base
|
34
|
+
"Bake::Base[#{path.join(':')}]"
|
35
35
|
else
|
36
36
|
super
|
37
37
|
end
|
@@ -45,6 +45,13 @@ module Bake
|
|
45
45
|
nil
|
46
46
|
end
|
47
47
|
|
48
|
+
# If an instance generates output, it should override this method to return `true`, otherwise default output handling will be used (essentially the return value of the last recipe).
|
49
|
+
#
|
50
|
+
# @returns [Boolean] Whether this instance handles its own output.
|
51
|
+
def output?(recipe)
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
48
55
|
# The path for this derived base class.
|
49
56
|
# @returns [Array(String)]
|
50
57
|
def path
|
data/lib/bake/command/call.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require "samovar"
|
7
7
|
|
@@ -29,7 +29,11 @@ module Bake
|
|
29
29
|
def call
|
30
30
|
context = @parent.context
|
31
31
|
|
32
|
-
context.call(*@commands)
|
32
|
+
context.call(*@commands) do |recipe, last_result|
|
33
|
+
if last_result and !recipe.output?
|
34
|
+
context.lookup("output").call(input: last_result)
|
35
|
+
end
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
data/lib/bake/command/list.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require "samovar"
|
7
7
|
require "set"
|
@@ -50,7 +50,7 @@ module Bake
|
|
50
50
|
|
51
51
|
unless printed
|
52
52
|
yield
|
53
|
-
|
53
|
+
|
54
54
|
printed = true
|
55
55
|
end
|
56
56
|
|
data/lib/bake/command/top.rb
CHANGED
data/lib/bake/command.rb
CHANGED
data/lib/bake/context.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
# Copyright, 2020, by Olle Jonsson.
|
6
6
|
|
7
7
|
require_relative "base"
|
@@ -90,9 +90,15 @@ module Bake
|
|
90
90
|
# e.g. `context.call("gem:release:version:increment", "0,0,1")`
|
91
91
|
#
|
92
92
|
# @parameter commands [Array(String)]
|
93
|
-
|
93
|
+
# @yield {|recipe, result| If a block is given, it will be called with the last recipe and its result.
|
94
|
+
# @parameter recipe [Recipe] The last recipe that was called.
|
95
|
+
# @parameter result [Object | Nil] The result of the last recipe.
|
96
|
+
# @returns [Object] The result of the last recipe.
|
97
|
+
def call(*commands, &block)
|
98
|
+
recipe = nil
|
94
99
|
last_result = nil
|
95
100
|
|
101
|
+
# Invoke the recipes in the order they were specified:
|
96
102
|
while command = commands.shift
|
97
103
|
if recipe = @recipes[command]
|
98
104
|
arguments, options = recipe.prepare(commands, last_result)
|
@@ -102,6 +108,11 @@ module Bake
|
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
111
|
+
# If a block is given, we yield the last recipe and its result:
|
112
|
+
if block_given?
|
113
|
+
yield recipe, last_result
|
114
|
+
end
|
115
|
+
|
105
116
|
return last_result
|
106
117
|
end
|
107
118
|
|
data/lib/bake/documentation.rb
CHANGED
data/lib/bake/format/ndjson.rb
CHANGED
data/lib/bake/recipe.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "type"
|
7
7
|
require_relative "arguments"
|
@@ -68,6 +68,12 @@ module Bake
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
# If a recipe produces output, we do not need to invoke the default output command.
|
72
|
+
# @returns [Boolean] Whether this recipe produces output.
|
73
|
+
def output?
|
74
|
+
@instance.output?(self)
|
75
|
+
end
|
76
|
+
|
71
77
|
def required_options
|
72
78
|
if parameters = self.parameters
|
73
79
|
parameters.map do |(type, name)|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require "console"
|
7
7
|
|
@@ -97,11 +97,11 @@ module Bake
|
|
97
97
|
def insert(directory, **options)
|
98
98
|
unless @roots.key?(directory)
|
99
99
|
Console.debug(self) {"Adding #{directory.inspect}"}
|
100
|
-
|
100
|
+
|
101
101
|
loader = DirectoryLoader.new(directory, **options)
|
102
102
|
@roots[directory] = loader
|
103
103
|
@ordered << loader
|
104
|
-
|
104
|
+
|
105
105
|
return true
|
106
106
|
end
|
107
107
|
|
data/lib/bake/registry.rb
CHANGED
data/lib/bake/scope.rb
CHANGED
data/lib/bake/type/any.rb
CHANGED
data/lib/bake/type/array.rb
CHANGED
data/lib/bake/type/boolean.rb
CHANGED
data/lib/bake/type/decimal.rb
CHANGED
data/lib/bake/type/float.rb
CHANGED
data/lib/bake/type/hash.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "any"
|
7
7
|
|
@@ -27,7 +27,7 @@ module Bake
|
|
27
27
|
|
28
28
|
key = @key_type.parse(key)
|
29
29
|
value = @value_type.parse(value)
|
30
|
-
|
30
|
+
|
31
31
|
hash[key] = value
|
32
32
|
end
|
33
33
|
|
data/lib/bake/type/input.rb
CHANGED
data/lib/bake/type/integer.rb
CHANGED
data/lib/bake/type/nil.rb
CHANGED
data/lib/bake/type/output.rb
CHANGED
data/lib/bake/type/string.rb
CHANGED
data/lib/bake/type/symbol.rb
CHANGED
data/lib/bake/type/tuple.rb
CHANGED
data/lib/bake/type.rb
CHANGED
data/lib/bake/version.rb
CHANGED
data/readme.md
CHANGED
@@ -33,6 +33,14 @@ Please see the [project documentation](https://ioquatix.github.io/bake/) for mor
|
|
33
33
|
|
34
34
|
Please see the [project releases](https://ioquatix.github.io/bake/releases/index) for all releases.
|
35
35
|
|
36
|
+
### v0.24.1
|
37
|
+
|
38
|
+
- Add agent context.
|
39
|
+
|
40
|
+
### v0.24.0
|
41
|
+
|
42
|
+
- If the final result of a recipe is not an `output?`, it will now be passed to the default output recipe.
|
43
|
+
|
36
44
|
### v0.23.0
|
37
45
|
|
38
46
|
- Add support for `ndjson`.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date:
|
40
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bigdecimal
|
@@ -75,6 +75,12 @@ files:
|
|
75
75
|
- bake/input.rb
|
76
76
|
- bake/output.rb
|
77
77
|
- bin/bake
|
78
|
+
- context/command-line-interface.md
|
79
|
+
- context/gem-integration.md
|
80
|
+
- context/getting-started.md
|
81
|
+
- context/index.yaml
|
82
|
+
- context/input-and-output.md
|
83
|
+
- context/project-integration.md
|
78
84
|
- lib/bake.rb
|
79
85
|
- lib/bake/arguments.rb
|
80
86
|
- lib/bake/base.rb
|
@@ -127,14 +133,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
133
|
requirements:
|
128
134
|
- - ">="
|
129
135
|
- !ruby/object:Gem::Version
|
130
|
-
version: '3.
|
136
|
+
version: '3.2'
|
131
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
138
|
requirements:
|
133
139
|
- - ">="
|
134
140
|
- !ruby/object:Gem::Version
|
135
141
|
version: '0'
|
136
142
|
requirements: []
|
137
|
-
rubygems_version: 3.6.
|
143
|
+
rubygems_version: 3.6.9
|
138
144
|
specification_version: 4
|
139
145
|
summary: A replacement for rake with a simpler syntax.
|
140
146
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|