bake 0.24.0 → 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/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/version.rb +1 -1
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +8 -2
- 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
|
@@ -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/version.rb
CHANGED
data/readme.md
CHANGED
@@ -33,6 +33,10 @@ 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
|
+
|
36
40
|
### v0.24.0
|
37
41
|
|
38
42
|
- If the final result of a recipe is not an `output?`, it will now be passed to the default output recipe.
|
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.24.
|
4
|
+
version: 0.24.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -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
|
@@ -134,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
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
|