bake 0.5.1 → 0.6.0

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: a7693473d81becf64ea8f5013fe414eb85ecbe82c7924b6aae745c8453eef648
4
- data.tar.gz: 9f0df220a0530195b8729b2338860dae28ee3b6d1fbddb004659584d4e7dc603
3
+ metadata.gz: 9cb4cc20cba975f1a38dc28b9943bdde9316c5c0f39f930666c6f88551852e47
4
+ data.tar.gz: dd2771c79e248dfac2d1815b6bcbe7b3d23f5c90d7f9fb4da14bdc6feb7e9ca2
5
5
  SHA512:
6
- metadata.gz: 7b946cde875cd3d8a74fed3d25f9cd5a80ea0ecc7d48868d3f329f1b69ca6184f07f9b0f9df57b529f7b046c96a524321ac9ed02c087bb77c87088d0be620dee
7
- data.tar.gz: fd987404064a8fd051c671380dbf3f7c24cf7ef8dc83b0bd9664adc3b32ac89a03ab507960dba2a3bcf291f53680a7e0b58c03426be2496093ef8d536ab0f005
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` which contains project-specific configuration and recipes, e.g.:
30
+ There is a root level `bake.rb` e.g.:
31
31
 
32
32
  ```ruby
33
- recipe :cake do
34
- call 'supermarket:shop', 'flour,sugar,cocoa'
35
- call 'mixer:add', 'everything'
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 `recipes/` directory which contains files like `supermarket.rb`. These files contain recipes, e.g.:
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
- recipe :shop do |ingredients|
46
+ # @param ingredients [Array(Any)] the ingredients to purchase.
47
+ def shop(ingredients)
47
48
  supermarket = Supermarket.best
48
- supermarket.shop(ingredients.split(","))
49
+
50
+ return supermarket.purchase(ingredients)
49
51
  end
50
52
  ```
51
53
 
52
- These recipes are automatically scoped according to the file name, e.g. `recipes/supermarket.rb` with `recipe :shop` will define `supermarket:shop`.
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 `recipes/` 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/recipes/mygem.rb`:
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
- recipe :setup do
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, e.g.:
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
- recipe :add do |x, y|
78
- puts Integer(x) + Integer(y)
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
- recipe :add do |x:, y:|
88
- puts Integer(x) + Integer(y)
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(scope, name, method = nil)
28
- @scope = scope
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 :scope
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 ||= @scope.method(@name)
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
- @scope.send(@name, *arguments, **options)
124
+ @instance.send(@name, *arguments, **options)
125
125
  else
126
126
  # Ignore options...
127
- @scope.send(@name, *arguments)
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 = @scope.path
150
+ path = @instance.path
151
151
 
152
152
  if path.empty?
153
153
  @name.to_s
data/lib/bake/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Bake
22
- VERSION = "0.5.1"
22
+ VERSION = "0.6.0"
23
23
  end
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.5.1
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.1.2
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.