bake 0.5.1 → 0.6.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/README.md +23 -15
- data/lib/bake/recipe.rb +7 -7
- data/lib/bake/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cb4cc20cba975f1a38dc28b9943bdde9316c5c0f39f930666c6f88551852e47
|
4
|
+
data.tar.gz: dd2771c79e248dfac2d1815b6bcbe7b3d23f5c90d7f9fb4da14bdc6feb7e9ca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9803830df096d57ef548305bdf120899db1a8f85961f14272c50eaa4829d1293ed4adabf084a75a68b291d545d8d7892df8aeeedf5f9ebfe1e6190499d50ec
|
7
|
+
data.tar.gz: 56240dbb1d65c116c6bb48afcb51f6338c34cdc1058c3c1aaeba01b774311182fc51bd6cb1484bcdaaaf422f242e650754613df0a3f193f12f8b27657bb7d86f
|
data/README.md
CHANGED
@@ -27,12 +27,12 @@ Bake follows similar patterns to Rake.
|
|
27
27
|
|
28
28
|
## Bakefile
|
29
29
|
|
30
|
-
There is a root level `bake.rb`
|
30
|
+
There is a root level `bake.rb` e.g.:
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
|
34
|
-
call 'supermarket:shop', 'flour,sugar,cocoa'
|
35
|
-
|
33
|
+
def cake
|
34
|
+
ingredients = call 'supermarket:shop', 'flour,sugar,cocoa'
|
35
|
+
lookup('mixer:add').call(ingredients)
|
36
36
|
end
|
37
37
|
```
|
38
38
|
|
@@ -40,23 +40,25 @@ This file is project specific and is the only file which can expose top level ta
|
|
40
40
|
|
41
41
|
## Recipes
|
42
42
|
|
43
|
-
Alongside the `bake.rb`, there is a `
|
43
|
+
Alongside the `bake.rb`, there is a `bake/` directory which contains files like `supermarket.rb`. These files contain recipes, e.g.:
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
|
46
|
+
# @param ingredients [Array(Any)] the ingredients to purchase.
|
47
|
+
def shop(ingredients)
|
47
48
|
supermarket = Supermarket.best
|
48
|
-
|
49
|
+
|
50
|
+
return supermarket.purchase(ingredients)
|
49
51
|
end
|
50
52
|
```
|
51
53
|
|
52
|
-
These
|
54
|
+
These methods are automatically scoped according to the file name, e.g. `bake/supermarket.rb` will define `supermarket:shop`.
|
53
55
|
|
54
56
|
## Gems
|
55
57
|
|
56
|
-
Adding a `
|
58
|
+
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`:
|
57
59
|
|
58
60
|
```ruby
|
59
|
-
|
61
|
+
def setup
|
60
62
|
# ...
|
61
63
|
end
|
62
64
|
```
|
@@ -69,13 +71,15 @@ bake mygem:setup
|
|
69
71
|
|
70
72
|
## Arguments
|
71
73
|
|
72
|
-
Both positional and optional parameters are supported
|
74
|
+
Arguments work as normal. Documented types are used to parse strings from the command line. Both positional and optional parameters are supported.
|
73
75
|
|
74
76
|
### Positional Parameters
|
75
77
|
|
76
78
|
```ruby
|
77
|
-
|
78
|
-
|
79
|
+
# @param x [Integer]
|
80
|
+
# @param y [Integer]
|
81
|
+
def add(x, y)
|
82
|
+
puts x + y
|
79
83
|
end
|
80
84
|
```
|
81
85
|
|
@@ -84,8 +88,10 @@ Which is invoked by `bake add 1 2`.
|
|
84
88
|
### Optional Parameters
|
85
89
|
|
86
90
|
```ruby
|
87
|
-
|
88
|
-
|
91
|
+
# @param x [Integer]
|
92
|
+
# @param y [Integer]
|
93
|
+
def add(x:, y:)
|
94
|
+
puts x + y
|
89
95
|
end
|
90
96
|
```
|
91
97
|
|
@@ -101,6 +107,8 @@ Which is invoked by `bake add x=1 y=2`.
|
|
101
107
|
|
102
108
|
## See Also
|
103
109
|
|
110
|
+
- [Console](https://github.com/socketry/console) — A logging framework which integrates with bake.
|
111
|
+
- [Variant](https://github.com/socketry/variant) — A framework for selecting different environments, including bake tasks.
|
104
112
|
- [Utopia](https://github.com/socketry/utopia) — A website framework which uses bake for maintenance tasks.
|
105
113
|
|
106
114
|
## License
|
data/lib/bake/recipe.rb
CHANGED
@@ -24,8 +24,8 @@ module Bake
|
|
24
24
|
PARAMETER = /@param\s+(?<name>.*?)\s+\[(?<type>.*?)\]\s+(?<details>.*?)\Z/
|
25
25
|
|
26
26
|
class Recipe
|
27
|
-
def initialize(
|
28
|
-
@
|
27
|
+
def initialize(instance, name, method = nil)
|
28
|
+
@instance = instance
|
29
29
|
@name = name
|
30
30
|
@command = nil
|
31
31
|
@description = nil
|
@@ -35,7 +35,7 @@ module Bake
|
|
35
35
|
@arity = nil
|
36
36
|
end
|
37
37
|
|
38
|
-
attr :
|
38
|
+
attr :instance
|
39
39
|
attr :name
|
40
40
|
|
41
41
|
def <=> other
|
@@ -43,7 +43,7 @@ module Bake
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def method
|
46
|
-
@method ||= @
|
46
|
+
@method ||= @instance.method(@name)
|
47
47
|
end
|
48
48
|
|
49
49
|
def source_location
|
@@ -121,10 +121,10 @@ module Bake
|
|
121
121
|
|
122
122
|
def call(*arguments, **options)
|
123
123
|
if options?
|
124
|
-
@
|
124
|
+
@instance.send(@name, *arguments, **options)
|
125
125
|
else
|
126
126
|
# Ignore options...
|
127
|
-
@
|
127
|
+
@instance.send(@name, *arguments)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -147,7 +147,7 @@ module Bake
|
|
147
147
|
private
|
148
148
|
|
149
149
|
def compute_command
|
150
|
-
path = @
|
150
|
+
path = @instance.path
|
151
151
|
|
152
152
|
if path.empty?
|
153
153
|
@name.to_s
|
data/lib/bake/version.rb
CHANGED
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.0.6
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: A replacement for rake with a simpler syntax.
|