bake 0.11.0 → 0.14.1

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: 8f99be0a2f861aa6bbfad669012adabb50a63b50284cfbd08184c51aa1ccd833
4
- data.tar.gz: d2ed3be69422c1b17e127cc6b3d31097f7203e4ab5fa1260076309659f7a31f8
3
+ metadata.gz: e5791d094c972d0cec6fa96e65bb0727703a08cde7cf669e82391d5e5783b5dd
4
+ data.tar.gz: 3f096c089469cb615756a3748f8150e504a39f7910eca170de5d2f39323af796
5
5
  SHA512:
6
- metadata.gz: 865d204e2390a3ac306c8c9c4e84c779b5070b9356030395ce02b08a0f4a8bb8343912354f47bf7f7f72203be5b8b4a20975e7df549564fc1c3deead1bbcc489
7
- data.tar.gz: 7eba460839a07814c3ee432d775789b65a810c876b20e1bb201d2092cdf80c7388a4397613cdd06e608f730ce8613644b99749964fbc7944dbf74d9ed06cd7b6
6
+ metadata.gz: 8bfa10d9641df00861b68593c4e65731e9e5083550fce23e4e4f3996161ff563fafd9d5de6b19be69a64b33dab986afcd0e89caad07edfe9a3006bfb63a41df8
7
+ data.tar.gz: e4e3b5fb27bb7bccc0b4f0c2aa3fa4befdedb76a177a2350cf192c77d82b46e192eec9ee62829f01775acfde392ba43bbca6a00d4b01ac83172687595b459a81
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Bake is a task execution tool, inspired by Rake, but codifying many of the use cases which are typically implemented in an ad-hoc manner.
4
4
 
5
- [![Actions Status](https://github.com/ioquatix/bake/workflows/Development/badge.svg)](https://github.com/ioquatix/bake/actions?workflow=Development)
5
+ [![Development](https://github.com/ioquatix/bake/workflows/Development/badge.svg)](https://github.com/ioquatix/bake/actions?workflow=Development)
6
6
 
7
- ## Motivation
7
+ ## Features
8
8
 
9
9
  Rake is an awesome tool and loved by the community. So, why reinvent it? Bake provides the following features that Rake does not:
10
10
 
@@ -15,97 +15,20 @@ Rake is an awesome tool and loved by the community. So, why reinvent it? Bake pr
15
15
 
16
16
  That being said, Rake and Bake can exist side by side in the same project.
17
17
 
18
- ## Installation
19
-
20
- Execute the following in your project:
21
-
22
- bundle add bake
23
-
24
18
  ## Usage
25
19
 
26
- Bake follows similar patterns to Rake.
27
-
28
- ![Example](example.png)
29
-
30
- ## Bakefile
31
-
32
- There is a root level `bake.rb` e.g.:
33
-
34
- ```ruby
35
- def cake
36
- ingredients = call 'supermarket:shop', 'flour,sugar,cocoa'
37
- lookup('mixer:add').call(ingredients)
38
- end
39
- ```
40
-
41
- 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.
42
-
43
- ## Recipes
44
-
45
- Alongside the `bake.rb`, there is a `bake/` directory which contains files like `supermarket.rb`. These files contain recipes, e.g.:
46
-
47
- ```ruby
48
- # @param ingredients [Array(Any)] the ingredients to purchase.
49
- def shop(ingredients)
50
- supermarket = Supermarket.best
51
-
52
- return supermarket.purchase(ingredients)
53
- end
54
- ```
55
-
56
- These methods are automatically scoped according to the file name, e.g. `bake/supermarket.rb` will define `supermarket:shop`.
57
-
58
- ## Gems
20
+ Please see the [project documentation](https://ioquatix.github.io/bake/).
59
21
 
60
- 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`:
61
-
62
- ```ruby
63
- def setup
64
- # ...
65
- end
66
- ```
67
-
68
- Then, in your project `myproject` which depends on `mygem`:
69
-
70
- ```
71
- bake mygem:setup
72
- ```
73
-
74
- ## Arguments
75
-
76
- Arguments work as normal. Documented types are used to parse strings from the command line. Both positional and optional parameters are supported.
77
-
78
- ### Positional Parameters
79
-
80
- ```ruby
81
- # @param x [Integer]
82
- # @param y [Integer]
83
- def add(x, y)
84
- puts x + y
85
- end
86
- ```
87
-
88
- Which is invoked by `bake add 1 2`.
89
-
90
- ### Optional Parameters
91
-
92
- ```ruby
93
- # @param x [Integer]
94
- # @param y [Integer]
95
- def add(x:, y:)
96
- puts x + y
97
- end
98
- ```
22
+ ## Contributing
99
23
 
100
- Which is invoked by `bake add x=1 y=2`.
24
+ We welcome contributions to this project.
101
25
 
102
- ## Contributing
26
+ 1. Fork it.
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
29
+ 4. Push to the branch (`git push origin my-new-feature`).
30
+ 5. Create new Pull Request.
103
31
 
104
- 1. Fork it
105
- 2. Create your feature branch (`git checkout -b my-new-feature`)
106
- 3. Commit your changes (`git commit -am 'Add some feature'`)
107
- 4. Push to the branch (`git push origin my-new-feature`)
108
- 5. Create new Pull Request
109
32
 
110
33
  ## See Also
111
34
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.metadata["donation_uri"] = "https://github.com/sponsors/ioquatix"
15
15
 
16
16
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(docs|test|spec|features)/}) }
18
18
  end
19
19
 
20
20
  spec.bindir = "bin"
@@ -23,10 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'samovar', '~> 2.1'
25
25
 
26
- spec.add_development_dependency 'bake-bundler'
27
-
28
26
  spec.add_development_dependency 'covered'
29
27
  spec.add_development_dependency 'bundler'
30
28
  spec.add_development_dependency 'rspec'
31
- spec.add_development_dependency 'rake'
32
29
  end
data/bake.rb CHANGED
@@ -1,4 +0,0 @@
1
-
2
- # A test method.
3
- def test
4
- end
data/gems.rb CHANGED
@@ -3,3 +3,9 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in bake.gemspec
4
4
  gemspec
5
5
 
6
+ group :maintenance, optional: true do
7
+ gem 'bake-modernize'
8
+ gem 'bake-bundler'
9
+
10
+ gem 'utopia-project'
11
+ end
@@ -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 &lt;path&gt;] &lt;command&gt;</b>
7
+ <font color="#638FFF">Execute tasks using Ruby.</font>
8
+
9
+ [-h/--help] Show help.
10
+ [-b/--bakefile &lt;path&gt;] Override the path to the bakefile to use.
11
+ &lt;command&gt; One of: call, list. (default: call)
12
+
13
+ <b>call &lt;commands...&gt;</b>
14
+ <font color="#638FFF">Execute one or more commands.</font>
15
+
16
+ &lt;commands...&gt; The commands &amp; arguments to invoke. (default: [&quot;default&quot;])
17
+
18
+ <b>list &lt;pattern&gt;</b>
19
+ &lt;pattern&gt; 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>: &quot;text/html; charset=utf-8&quot;
48
+ <b> cache-control</b>: &quot;public, max-age=3600&quot;
49
+ <b> expires</b>: &quot;Mon, 04 May 2020 13:23:47 GMT&quot;
50
+ <b> server</b>: &quot;falcon/0.36.4&quot;
51
+ <b> date</b>: &quot;Mon, 04 May 2020 12:23:47 GMT&quot;
52
+ <b> vary</b>: &quot;accept-encoding&quot;
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,109 @@
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::Loaders} 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
+ ### Using Types
41
+
42
+ You can annotate your task with a type signature and `bake` will coerce your arguments to these types:
43
+
44
+ ``` ruby
45
+ # bake.rb
46
+
47
+ # @parameter x [Integer]
48
+ # @parameter y [Integer]
49
+ def add(x, y)
50
+ puts x + y
51
+ end
52
+ ```
53
+
54
+ You can execute this task from the command line:
55
+
56
+ ``` shell
57
+ % bake add 10 20
58
+ 30
59
+ ```
60
+
61
+ The values are automatically coerced to `Integer`.
62
+
63
+ ### Extending With Documentation
64
+
65
+ You can add documentation to your tasks and parameters (using Markdown formatting).
66
+
67
+ ``` ruby
68
+ # bake.rb
69
+
70
+ # Add the x and y coordinate together and print the result.
71
+ # @parameter x [Integer] The x offset.
72
+ # @parameter y [Integer] The y offset.
73
+ def add(x, y)
74
+ puts x + y
75
+ end
76
+ ```
77
+
78
+ You can see this documentation in the task listing:
79
+
80
+ ``` shell
81
+ % bake list add
82
+ Bake::Context getting-started
83
+
84
+ add x y
85
+ Add the x and y coordinate together and print the result.
86
+ x [Integer] The x offset.
87
+ y [Integer] The y offset.
88
+ ```
89
+
90
+ ### Private Methods
91
+
92
+ If you want to add helper methods which don't show up as tasks, define them as `protected` or `private`.
93
+
94
+ ``` ruby
95
+ # bake.rb
96
+
97
+ # Add the x and y coordinate together and print the result.
98
+ # @parameter x [Integer] The x offset.
99
+ # @parameter y [Integer] The y offset.
100
+ def add(x, y)
101
+ puts x + y
102
+ end
103
+
104
+ private
105
+
106
+ def puts(*arguments)
107
+ $stdout.puts arguments.inspect
108
+ end
109
+ ```
@@ -0,0 +1,8 @@
1
+ getting-started:
2
+ order: 1
3
+ command-line-interface:
4
+ order: 2
5
+ project-integration:
6
+ order: 3
7
+ gem-integration:
8
+ order: 4
@@ -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
+ # @param 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
+ # @param x [Integer]
44
+ # @param 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
+ # @param x [Integer]
58
+ # @param 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.