bake 0.23.1 → 0.24.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91718ab61f79e1538c5687ee4749766f630d997eb1a2f4141b6f8f5236796995
4
- data.tar.gz: 8728f1f95746b022f912f70aff45a4b31e539ce3e7e7c3e4ec4b056a918b0645
3
+ metadata.gz: d61fa19d40c8b9ff3933b58687c514217485705753527a87c7e67843d87124c8
4
+ data.tar.gz: f752fa8a4f2a61b6e238d1f9639198b758526668df8e7ff9d908b1039e5d8183
5
5
  SHA512:
6
- metadata.gz: 4ab027ad33f0aa03ea7f06b1c45aab20f09ee89a1be46687d9cba518da0f62bc30b2dbf3b0038a369fdaaa8163d07ead6df4738a89627dc4598645800c364f57
7
- data.tar.gz: c78c3e33a4b1d8543bb9a5f8157df81a9af2dec880245736a02dc31a3a27fc23d40f21746ac3e559db9b7dd6f4d5069f0ca48a311251c59062b8c962cdd997a5
6
+ metadata.gz: 223664fa23c0ffa472145331a0fe0b0e9626045bc865002e4febf2dff21ac712a0b738a4d4ca3b53e9e620d4548ef075d84ac1e9d4a94bf153d5b88bcba17ed7
7
+ data.tar.gz: 48d325fad183eb7aed796faa2c8b896334bc944414d53e72821fd17636cc7c7fbddf98ba0e680f6c72a33df0824fcd8c58ff480ff9cf32113fdeea35adb8f1e4
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)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "type"
7
7
  require_relative "documentation"
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-2024, by Samuel Williams.
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<#{path.join(':')}>"
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
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
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require "samovar"
7
7
  require "console/terminal"
data/lib/bake/command.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "command/top"
7
7
 
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-2024, by Samuel Williams.
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
- def call(*commands)
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
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "scope"
7
7
 
@@ -13,6 +13,9 @@ module Bake
13
13
  end
14
14
 
15
15
  def self.output(file, value)
16
+ value.each do |item|
17
+ file.puts(JSON.generate(item))
18
+ end
16
19
  end
17
20
 
18
21
  def initialize(file)
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-2024, by Samuel Williams.
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-2024, by Samuel Williams.
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
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "../scope"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "../scope"
7
7
 
data/lib/bake/registry.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "registry/aggregate"
7
7
 
data/lib/bake/scope.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "recipe"
7
7
 
data/lib/bake/type/any.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  module Bake
7
7
  module Type
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
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
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
data/lib/bake/type/nil.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "any"
7
7
 
data/lib/bake/type.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "type/any"
7
7
  require_relative "type/array"
data/lib/bake/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  module Bake
7
- VERSION = "0.23.1"
7
+ VERSION = "0.24.0"
8
8
  end
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.0
37
+
38
+ - If the final result of a recipe is not an `output?`, it will now be passed to the default output recipe.
39
+
36
40
  ### v0.23.0
37
41
 
38
42
  - Add support for `ndjson`.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.24.0
4
+
5
+ - If the final result of a recipe is not an `output?`, it will now be passed to the default output recipe.
6
+
3
7
  ## v0.23.0
4
8
 
5
9
  - Add support for `ndjson`.
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.23.1
4
+ version: 0.24.0
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: 2025-02-21 00:00:00.000000000 Z
40
+ date: 1980-01-02 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bigdecimal
@@ -127,14 +127,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: '3.1'
130
+ version: '3.2'
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  requirements:
133
133
  - - ">="
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
- rubygems_version: 3.6.2
137
+ rubygems_version: 3.6.7
138
138
  specification_version: 4
139
139
  summary: A replacement for rake with a simpler syntax.
140
140
  test_files: []
metadata.gz.sig CHANGED
Binary file