bake 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/bake/input.rb +5 -30
  4. data/bake/output.rb +4 -11
  5. data/bin/bake +3 -2
  6. data/lib/bake/arguments.rb +4 -4
  7. data/lib/bake/base.rb +3 -3
  8. data/lib/bake/command/call.rb +3 -3
  9. data/lib/bake/command/list.rb +2 -2
  10. data/lib/bake/command/top.rb +10 -10
  11. data/lib/bake/command.rb +1 -1
  12. data/lib/bake/context.rb +2 -2
  13. data/lib/bake/documentation.rb +1 -1
  14. data/lib/bake/format/json.rb +25 -0
  15. data/lib/bake/format/ndjson.rb +35 -0
  16. data/lib/bake/format/raw.rb +22 -0
  17. data/lib/bake/format/yaml.rb +22 -0
  18. data/lib/bake/format.rb +24 -0
  19. data/lib/bake/recipe.rb +23 -19
  20. data/lib/bake/registry/aggregate.rb +3 -3
  21. data/lib/bake/registry/bakefile_loader.rb +3 -3
  22. data/lib/bake/registry/directory_loader.rb +3 -3
  23. data/lib/bake/registry.rb +2 -2
  24. data/lib/bake/scope.rb +1 -1
  25. data/lib/bake/{types → type}/any.rb +3 -3
  26. data/lib/bake/{types → type}/array.rb +3 -3
  27. data/lib/bake/{types → type}/boolean.rb +2 -2
  28. data/lib/bake/{types → type}/decimal.rb +3 -3
  29. data/lib/bake/{types → type}/float.rb +2 -2
  30. data/lib/bake/{types → type}/hash.rb +4 -4
  31. data/lib/bake/{types → type}/input.rb +3 -3
  32. data/lib/bake/{types → type}/integer.rb +2 -2
  33. data/lib/bake/{types → type}/nil.rb +2 -2
  34. data/lib/bake/{types → type}/output.rb +3 -3
  35. data/lib/bake/{types → type}/string.rb +2 -2
  36. data/lib/bake/{types → type}/symbol.rb +2 -2
  37. data/lib/bake/{types → type}/tuple.rb +3 -3
  38. data/lib/bake/type.rb +26 -0
  39. data/lib/bake/version.rb +2 -2
  40. data/lib/bake.rb +5 -4
  41. data/license.md +1 -1
  42. data/readme.md +13 -3
  43. data/releases.md +7 -0
  44. data.tar.gz.sig +0 -0
  45. metadata +22 -16
  46. metadata.gz.sig +0 -0
  47. data/lib/bake/types.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4376cc74741d1bd58cb18e02c7d249f01cf0db254ab1476f95a1001e37a3872a
4
- data.tar.gz: 45accbd429c7f9ab27f53d5565b8c7ec0f2c2a13ccf47db67d21c1936673b4d6
3
+ metadata.gz: 6ab7880c750129da00fedd038a2a9686a2c8bce081766b18a250a90f030a216b
4
+ data.tar.gz: f958a6e911baf91f66cf647d0d915ef44a77d093e936ec56c68936267fe3a76c
5
5
  SHA512:
6
- metadata.gz: fc7a172d7df26ce899a22ed14119f290ded9b9d85c7dc55ff4114ea7f942a1affe47cee8c21a5d85ab0d3baf31f71b799c9f506a5ebc405b310d19250b6d9d43
7
- data.tar.gz: 186aedc6fa76d2d194b3f37686980daf7a8c389247f899dc8aaf6d1a0db98eeccb9b003c1cda04c3f596a04cb8c8a42aa21b3fad40e9fad5fa39bd6f84865a10
6
+ metadata.gz: a0fc582b55405b75c1c8f6e47f8b441b724d12f868158e9b48ab3a0e8d541b8d4a54cf81cba935638af6fd76b41c219f273724662b87ba119250abd3350a1ff3
7
+ data.tar.gz: 7b9f2d475de5475db4d3e880d90aac948016e5e22c138d38cb76dbe7398a6444a6438b5dfce03fc8514149693e7215952c69c21b7bc366f5969cbdefef5e8633
checksums.yaml.gz.sig CHANGED
Binary file
data/bake/input.rb CHANGED
@@ -1,39 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
5
-
6
- class NDJSON
7
- def self.parse(file)
8
- new(file)
9
- end
10
-
11
- def initialize(file)
12
- @file = file
13
- end
14
-
15
- def each
16
- return to_enum unless block_given?
17
-
18
- @file.each_line do |line|
19
- yield JSON.parse(line)
20
- end
21
- end
22
- end
23
-
24
- # Parse input files in various formats.
25
- FORMATS = {
26
- json: ->(file){require 'json'; JSON.parse(file.read)},
27
- ndjson: ->(file){require 'json'; NDJSON.parse(file)},
28
- yaml: ->(file){require 'yaml'; YAML.load(file.read)},
29
- }
4
+ # Copyright, 2022-2025, by Samuel Williams.
30
5
 
31
6
  # Parse an input file (defaulting to stdin) in the specified format. The format can be extracted from the file extension if left unspecified.
32
7
  # @parameter file [Input] The input file.
33
8
  # @parameter format [Symbol] The input format, e.g. json, yaml.
34
9
  def input(file: $stdin, format: nil)
35
10
  if format = format_for(file, format)
36
- format.call(file)
11
+ format.input(file)
37
12
  else
38
13
  raise "Unable to determine input format of #{file}!"
39
14
  end
@@ -46,7 +21,7 @@ def parse(text, format: :json)
46
21
  file = StringIO.new(text)
47
22
 
48
23
  if format = format_for(nil, format)
49
- format.call(file)
24
+ format.input(file)
50
25
  else
51
26
  raise "Unable to determine input format!"
52
27
  end
@@ -59,12 +34,12 @@ def format_for(file, name)
59
34
  name ||= file_type(path)
60
35
  end
61
36
 
62
- FORMATS[name]
37
+ Bake::Format[name]
63
38
  end
64
39
 
65
40
  def file_type(path)
66
41
  if extension = File.extname(path)
67
- extension.sub!(/\A\./, '')
42
+ extension.sub!(/\A\./, "")
68
43
  return if extension.empty?
69
44
  return extension.to_sym
70
45
  end
data/bake/output.rb CHANGED
@@ -1,21 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2024, by Samuel Williams.
5
-
6
- FORMATS = {
7
- json: ->(file, value){require 'json'; file.puts(JSON.pretty_generate(value))},
8
- pp: ->(file, value){require 'pp'; PP.pp(value, file)},
9
- raw: ->(file, value){file.puts(value)},
10
- yaml: ->(file, value){require 'yaml'; file.puts(YAML.dump(value))},
11
- }
4
+ # Copyright, 2022-2025, by Samuel Williams.
12
5
 
13
6
  # Dump the last result to the specified file (defaulting to stdout) in the specified format (defaulting to Ruby's pretty print).
14
7
  # @parameter file [Output] The input file.
15
8
  # @parameter format [Symbol] The output format.
16
9
  def output(input:, file: $stdout, format: nil)
17
10
  if format = format_for(file, format)
18
- format.call(file, input)
11
+ format.output(file, input)
19
12
  else
20
13
  raise "Unable to determine output format!"
21
14
  end
@@ -34,12 +27,12 @@ def format_for(file, name)
34
27
  # Default to pretty print:
35
28
  name ||= :pp
36
29
 
37
- FORMATS[name]
30
+ Bake::Format[name]
38
31
  end
39
32
 
40
33
  def file_type(path)
41
34
  if extension = File.extname(path)
42
- extension.sub!(/\A\./, '')
35
+ extension.sub!(/\A\./, "")
43
36
  return if extension.empty?
44
37
  return extension.to_sym
45
38
  end
data/bin/bake CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
5
  #
@@ -21,9 +22,9 @@
21
22
  # THE SOFTWARE.
22
23
 
23
24
  # This avoids the need to use `bundle exec bake`:
24
- require 'bundler/setup'
25
+ require "bundler/setup"
25
26
 
26
- require_relative '../lib/bake/command'
27
+ require_relative "../lib/bake/command"
27
28
 
28
29
  begin
29
30
  Bake::Command.call
@@ -3,8 +3,8 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'types'
7
- require_relative 'documentation'
6
+ require_relative "type"
7
+ require_relative "documentation"
8
8
 
9
9
  module Bake
10
10
  # Structured access to arguments.
@@ -69,7 +69,7 @@ module Bake
69
69
  private
70
70
 
71
71
  def normalize(name)
72
- name.tr('-', '_').to_sym
72
+ name.tr("-", "_").to_sym
73
73
  end
74
74
 
75
75
  def delimiter_index(arguments)
@@ -84,7 +84,7 @@ module Bake
84
84
  if type&.composite?
85
85
  if count = delimiter_index(arguments)
86
86
  value = arguments.shift(count)
87
- arguments.shift if arguments.first == ';'
87
+ arguments.shift if arguments.first == ";"
88
88
  else
89
89
  value = arguments.dup
90
90
  arguments.clear
data/lib/bake/base.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'recipe'
7
- require_relative 'scope'
6
+ require_relative "recipe"
7
+ require_relative "scope"
8
8
 
9
9
  module Bake
10
10
  # The base class for including {Scope} instances which define {Recipe} instances.
@@ -23,7 +23,7 @@ module Bake
23
23
  # @returns [String]
24
24
  def self.to_s
25
25
  if path = self.path
26
- path.join(':')
26
+ path.join(":")
27
27
  else
28
28
  super
29
29
  end
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require 'samovar'
6
+ require "samovar"
7
7
 
8
- require_relative '../registry'
9
- require_relative '../context'
8
+ require_relative "../registry"
9
+ require_relative "../context"
10
10
 
11
11
  module Bake
12
12
  module Command
@@ -3,8 +3,8 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require 'samovar'
7
- require 'set'
6
+ require "samovar"
7
+ require "set"
8
8
 
9
9
  module Bake
10
10
  module Command
@@ -3,11 +3,11 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require 'samovar'
7
- require 'console/terminal'
6
+ require "samovar"
7
+ require "console/terminal"
8
8
 
9
- require_relative 'call'
10
- require_relative 'list'
9
+ require_relative "call"
10
+ require_relative "list"
11
11
 
12
12
  module Bake
13
13
  module Command
@@ -16,18 +16,18 @@ module Bake
16
16
  self.description = "Execute tasks using Ruby."
17
17
 
18
18
  options do
19
- option '-h/--help', 'Show help.'
20
- option '-b/--bakefile <path>', 'Override the path to the bakefile to use.'
19
+ option "-h/--help", "Show help."
20
+ option "-b/--bakefile <path>", "Override the path to the bakefile to use."
21
21
 
22
- option '-g/--gem <name>', 'Load the specified gem, e.g. "bake ~> 1.0".' do |value|
22
+ option "-g/--gem <name>", 'Load the specified gem, e.g. "bake ~> 1.0".' do |value|
23
23
  gem(*value.split(/\s+/))
24
24
  end
25
25
  end
26
26
 
27
27
  nested :command, {
28
- 'call' => Call,
29
- 'list' => List,
30
- }, default: 'call'
28
+ "call" => Call,
29
+ "list" => List,
30
+ }, default: "call"
31
31
 
32
32
  def terminal(output = self.output)
33
33
  terminal = Console::Terminal.for(output)
data/lib/bake/command.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'command/top'
6
+ require_relative "command/top"
7
7
 
8
8
  module Bake
9
9
  # The command line interface.
data/lib/bake/context.rb CHANGED
@@ -4,8 +4,8 @@
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
  # Copyright, 2020, by Olle Jonsson.
6
6
 
7
- require_relative 'base'
8
- require_relative 'registry'
7
+ require_relative "base"
8
+ require_relative "registry"
9
9
 
10
10
  module Bake
11
11
  # The default file name for the top level bakefile.
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'scope'
6
+ require_relative "scope"
7
7
 
8
8
  module Bake
9
9
  # Structured access to a set of comment lines.
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "json"
7
+
8
+ module Bake
9
+ module Format
10
+ module JSON
11
+ def self.input(file)
12
+ ::JSON.load(file)
13
+ end
14
+
15
+ OPTIONS = {indent: " ", space: " ", space_before: "", object_nl: "\n", array_nl: "\n"}
16
+
17
+ def self.output(file, value)
18
+ ::JSON::State.generate(value, OPTIONS, file)
19
+ file.puts
20
+ end
21
+ end
22
+
23
+ REGISTRY[:json] = JSON
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "json"
7
+
8
+ module Bake
9
+ module Format
10
+ class NDJSON
11
+ def self.input(file)
12
+ new(file)
13
+ end
14
+
15
+ def self.output(file, value)
16
+ end
17
+
18
+ def initialize(file)
19
+ @file = file
20
+ end
21
+
22
+ attr :file
23
+
24
+ def each
25
+ return to_enum unless block_given?
26
+
27
+ @file.each_line do |line|
28
+ yield JSON.parse(line)
29
+ end
30
+ end
31
+ end
32
+
33
+ REGISTRY[:ndjson] = NDJSON
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "pp"
7
+
8
+ module Bake
9
+ module Format
10
+ module Raw
11
+ def self.input(file)
12
+ file
13
+ end
14
+
15
+ def self.output(file, value)
16
+ PP.pp(value, file)
17
+ end
18
+ end
19
+
20
+ REGISTRY[:raw] = Raw
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "yaml"
7
+
8
+ module Bake
9
+ module Format
10
+ module YAML
11
+ def self.input(file)
12
+ ::YAML.load(file)
13
+ end
14
+
15
+ def self.output(file, value)
16
+ ::YAML.dump(value, file)
17
+ end
18
+ end
19
+
20
+ REGISTRY[:yaml] = YAML
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ module Bake
7
+ module Format
8
+ REGISTRY = {}
9
+
10
+ def self.[](name)
11
+ unless name =~ /\A[a-z_]+\z/
12
+ raise ArgumentError.new("Invalid format name: #{name}")
13
+ end
14
+
15
+ begin
16
+ require_relative "format/#{name}"
17
+ rescue LoadError
18
+ raise ArgumentError.new("Unknown format: #{name}")
19
+ end
20
+
21
+ return REGISTRY[name.to_sym]
22
+ end
23
+ end
24
+ end
data/lib/bake/recipe.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'types'
7
- require_relative 'arguments'
8
- require_relative 'documentation'
6
+ require_relative "type"
7
+ require_relative "arguments"
8
+ require_relative "documentation"
9
9
 
10
10
  module Bake
11
11
  # Structured access to an instance method in a bakefile.
@@ -20,7 +20,7 @@ module Bake
20
20
  @name = name
21
21
  @command = nil
22
22
  @comments = nil
23
- @types = nil
23
+ @signature = nil
24
24
  @documentation = nil
25
25
 
26
26
  @method = method
@@ -62,9 +62,9 @@ module Bake
62
62
  # @returns [Boolean]
63
63
  def options?
64
64
  if parameters = self.parameters
65
- type, name = parameters.last
66
-
67
- return type == :keyrest || type == :keyreq || type == :key
65
+ parameters.any? do |type, name|
66
+ type == :keyrest || type == :keyreq || type == :key
67
+ end
68
68
  end
69
69
  end
70
70
 
@@ -105,12 +105,13 @@ module Bake
105
105
  end
106
106
 
107
107
  # Call the recipe with the specified arguments and options.
108
- def call(*arguments, **options)
109
- if options?
110
- @instance.send(@name, *arguments, **options)
108
+ # If the recipe does not accept options, they will be ignored.
109
+ def call(*arguments, **options, &block)
110
+ if options.any? and self.options?
111
+ @instance.send(@name, *arguments, **options, &block)
111
112
  else
112
113
  # Ignore options...
113
- @instance.send(@name, *arguments)
114
+ @instance.send(@name, *arguments, &block)
114
115
  end
115
116
  end
116
117
 
@@ -127,15 +128,18 @@ module Bake
127
128
  end
128
129
 
129
130
  # The documented type signature of the recipe.
130
- # @returns [Array] An array of {Types} instances.
131
- def types
132
- @types ||= read_types
131
+ # @returns [Array] An array of {Type} instances.
132
+ def signature
133
+ @signature ||= read_signature
133
134
  end
134
135
 
136
+ # @deprecated Use {signature} instead.
137
+ alias types signature
138
+
135
139
  private
136
140
 
137
141
  def parse(name, value, arguments, types)
138
- if count = arguments.index(';')
142
+ if count = arguments.index(";")
139
143
  value = arguments.shift(count)
140
144
  arguments.shift
141
145
  end
@@ -153,9 +157,9 @@ module Bake
153
157
  if path.empty?
154
158
  @name.to_s
155
159
  elsif path.last.to_sym == @name
156
- path.join(':')
160
+ path.join(":")
157
161
  else
158
- (path + [@name]).join(':')
162
+ (path + [@name]).join(":")
159
163
  end
160
164
  end
161
165
 
@@ -190,11 +194,11 @@ module Bake
190
194
  return description
191
195
  end
192
196
 
193
- def read_types
197
+ def read_signature
194
198
  types = {}
195
199
 
196
200
  self.documentation.parameters do |parameter|
197
- types[parameter[:name].to_sym] = Types.parse(parameter[:type])
201
+ types[parameter[:name].to_sym] = Type.parse(parameter[:type])
198
202
  end
199
203
 
200
204
  return types
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require 'console'
6
+ require "console"
7
7
 
8
- require_relative 'directory_loader'
9
- require_relative 'bakefile_loader'
8
+ require_relative "directory_loader"
9
+ require_relative "bakefile_loader"
10
10
 
11
11
  module Bake
12
12
  # Structured access to the working directory and loaded gems for loading bakefiles.
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require_relative '../scope'
6
+ require_relative "../scope"
7
7
 
8
8
  module Bake
9
9
  module Registry
@@ -29,4 +29,4 @@ module Bake
29
29
  end
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative '../scope'
6
+ require_relative "../scope"
7
7
 
8
8
  module Bake
9
9
  module Registry
@@ -33,7 +33,7 @@ module Bake
33
33
  return to_enum unless block_given?
34
34
 
35
35
  Dir.glob("**/*.rb", base: @root) do |file_path|
36
- yield file_path.sub(/\.rb$/, '').split(File::SEPARATOR)
36
+ yield file_path.sub(/\.rb$/, "").split(File::SEPARATOR)
37
37
  end
38
38
  end
39
39
 
@@ -74,4 +74,4 @@ module Bake
74
74
  end
75
75
  end
76
76
  end
77
- end
77
+ end
data/lib/bake/registry.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require_relative 'registry/aggregate'
6
+ require_relative "registry/aggregate"
7
7
 
8
8
  module Bake
9
9
  # Structured access to the working directory and loaded gems for loading bakefiles.
data/lib/bake/scope.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'recipe'
6
+ require_relative "recipe"
7
7
 
8
8
  module Bake
9
9
  # Used for containing all methods defined in a bakefile.
@@ -4,11 +4,11 @@
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
6
  module Bake
7
- module Types
7
+ module Type
8
8
  # An ordered list of types. The first type to match the input is used.
9
9
  #
10
10
  # ```ruby
11
- # type = Bake::Types::Any(Bake::Types::String, Bake::Types::Integer)
11
+ # type = Bake::Type::Any(Bake::Type::String, Bake::Type::Integer)
12
12
  # ```
13
13
  #
14
14
  class Any
@@ -66,7 +66,7 @@ module Bake
66
66
  # Any(Integer, String)
67
67
  # ```
68
68
  #
69
- # See [Any.initialize](#Bake::Types::Any::initialize).
69
+ # See [Any.initialize](#Bake::Type::Any::initialize).
70
70
  #
71
71
  def self.Any(*types)
72
72
  Any.new(types)
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  class Array
11
11
  include Type
12
12
 
@@ -25,7 +25,7 @@ module Bake
25
25
  def parse(input)
26
26
  case input
27
27
  when ::String
28
- return input.split(',').map{|value| @item_type.parse(value)}
28
+ return input.split(",").map{|value| @item_type.parse(value)}
29
29
  when ::Array
30
30
  return input.map{|value| @item_type.parse(value)}
31
31
  else
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module Boolean
11
11
  extend Type
12
12
 
@@ -3,12 +3,12 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
- require 'bigdecimal'
8
+ require "bigdecimal"
9
9
 
10
10
  module Bake
11
- module Types
11
+ module Type
12
12
  module Decimal
13
13
  extend Type
14
14
 
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module Float
11
11
  extend Type
12
12
 
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  class Hash
11
11
  include Type
12
12
 
@@ -22,8 +22,8 @@ module Bake
22
22
  def parse(input)
23
23
  hash = {}
24
24
 
25
- input.split(',').each do |pair|
26
- key, value = pair.split(':', 2)
25
+ input.split(",").each do |pair|
26
+ key, value = pair.split(":", 2)
27
27
 
28
28
  key = @key_type.parse(key)
29
29
  value = @value_type.parse(value)
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module Input
11
11
  extend Type
12
12
 
@@ -16,7 +16,7 @@ module Bake
16
16
 
17
17
  def self.parse(input)
18
18
  case input
19
- when '-'
19
+ when "-"
20
20
  return $stdin
21
21
  when IO, StringIO
22
22
  return input
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module Integer
11
11
  extend Type
12
12
 
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module Nil
11
11
  extend Type
12
12
 
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module Output
11
11
  extend Type
12
12
 
@@ -16,7 +16,7 @@ module Bake
16
16
 
17
17
  def self.parse(input)
18
18
  case input
19
- when '-'
19
+ when "-"
20
20
  return $stdout
21
21
  when IO, StringIO
22
22
  return input
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module String
11
11
  extend Type
12
12
 
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  module Symbol
11
11
  extend Type
12
12
 
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020-2024, by Samuel Williams.
5
5
 
6
- require_relative 'any'
6
+ require_relative "any"
7
7
 
8
8
  module Bake
9
- module Types
9
+ module Type
10
10
  class Tuple
11
11
  include Type
12
12
 
@@ -21,7 +21,7 @@ module Bake
21
21
  def parse(input)
22
22
  case input
23
23
  when ::String
24
- return input.split(',').map{|value| @item_type.parse(value)}
24
+ return input.split(",").map{|value| @item_type.parse(value)}
25
25
  when ::Array
26
26
  return input.map{|value| @item_type.parse(value)}
27
27
  else
data/lib/bake/type.rb ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
5
+
6
+ require_relative "type/any"
7
+ require_relative "type/array"
8
+ require_relative "type/boolean"
9
+ require_relative "type/decimal"
10
+ require_relative "type/float"
11
+ require_relative "type/hash"
12
+ require_relative "type/input"
13
+ require_relative "type/integer"
14
+ require_relative "type/nil"
15
+ require_relative "type/output"
16
+ require_relative "type/string"
17
+ require_relative "type/symbol"
18
+ require_relative "type/tuple"
19
+
20
+ module Bake
21
+ module Type
22
+ def self.parse(signature)
23
+ eval(signature, binding)
24
+ end
25
+ end
26
+ end
data/lib/bake/version.rb CHANGED
@@ -1,8 +1,8 @@
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
- VERSION = "0.22.0"
7
+ VERSION = "0.23.0"
8
8
  end
data/lib/bake.rb CHANGED
@@ -1,8 +1,9 @@
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
- require_relative 'bake/version'
7
- require_relative 'bake/registry'
8
- require_relative 'bake/context'
6
+ require_relative "bake/version"
7
+ require_relative "bake/registry"
8
+ require_relative "bake/context"
9
+ require_relative "bake/format"
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2020-2024, by Samuel Williams.
3
+ Copyright, 2020-2025, by Samuel Williams.
4
4
  Copyright, 2020-2023, by Olle Jonsson.
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
data/readme.md CHANGED
@@ -29,6 +29,16 @@ Please see the [project documentation](https://ioquatix.github.io/bake/) for mor
29
29
 
30
30
  - [Input and Output](https://ioquatix.github.io/bake/guides/input-and-output/index) - `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.
31
31
 
32
+ ## Releases
33
+
34
+ Please see the [project releases](https://ioquatix.github.io/bake/releases/index) for all releases.
35
+
36
+ ### v0.23.0
37
+
38
+ - Add support for `ndjson`.
39
+ - General improvements to input and output handling.
40
+ - Removed support for `pp` output - use `raw` if required.
41
+
32
42
  ## Contributing
33
43
 
34
44
  We welcome contributions to this project.
@@ -41,11 +51,11 @@ We welcome contributions to this project.
41
51
 
42
52
  ### Developer Certificate of Origin
43
53
 
44
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
54
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
45
55
 
46
- ### Contributor Covenant
56
+ ### Community Guidelines
47
57
 
48
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
58
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
49
59
 
50
60
  ## See Also
51
61
 
data/releases.md ADDED
@@ -0,0 +1,7 @@
1
+ # Releases
2
+
3
+ ## v0.23.0
4
+
5
+ - Add support for `ndjson`.
6
+ - General improvements to input and output handling.
7
+ - Removed support for `pp` output - use `raw` if required.
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.22.0
4
+ version: 0.23.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-14 00:00:00.000000000 Z
40
+ date: 2025-02-15 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bigdecimal
@@ -84,29 +84,35 @@ files:
84
84
  - lib/bake/command/top.rb
85
85
  - lib/bake/context.rb
86
86
  - lib/bake/documentation.rb
87
+ - lib/bake/format.rb
88
+ - lib/bake/format/json.rb
89
+ - lib/bake/format/ndjson.rb
90
+ - lib/bake/format/raw.rb
91
+ - lib/bake/format/yaml.rb
87
92
  - lib/bake/recipe.rb
88
93
  - lib/bake/registry.rb
89
94
  - lib/bake/registry/aggregate.rb
90
95
  - lib/bake/registry/bakefile_loader.rb
91
96
  - lib/bake/registry/directory_loader.rb
92
97
  - lib/bake/scope.rb
93
- - lib/bake/types.rb
94
- - lib/bake/types/any.rb
95
- - lib/bake/types/array.rb
96
- - lib/bake/types/boolean.rb
97
- - lib/bake/types/decimal.rb
98
- - lib/bake/types/float.rb
99
- - lib/bake/types/hash.rb
100
- - lib/bake/types/input.rb
101
- - lib/bake/types/integer.rb
102
- - lib/bake/types/nil.rb
103
- - lib/bake/types/output.rb
104
- - lib/bake/types/string.rb
105
- - lib/bake/types/symbol.rb
106
- - lib/bake/types/tuple.rb
98
+ - lib/bake/type.rb
99
+ - lib/bake/type/any.rb
100
+ - lib/bake/type/array.rb
101
+ - lib/bake/type/boolean.rb
102
+ - lib/bake/type/decimal.rb
103
+ - lib/bake/type/float.rb
104
+ - lib/bake/type/hash.rb
105
+ - lib/bake/type/input.rb
106
+ - lib/bake/type/integer.rb
107
+ - lib/bake/type/nil.rb
108
+ - lib/bake/type/output.rb
109
+ - lib/bake/type/string.rb
110
+ - lib/bake/type/symbol.rb
111
+ - lib/bake/type/tuple.rb
107
112
  - lib/bake/version.rb
108
113
  - license.md
109
114
  - readme.md
115
+ - releases.md
110
116
  homepage: https://github.com/ioquatix/bake
111
117
  licenses:
112
118
  - MIT
metadata.gz.sig CHANGED
Binary file
data/lib/bake/types.rb DELETED
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
5
-
6
- require_relative 'types/any'
7
- require_relative 'types/array'
8
- require_relative 'types/boolean'
9
- require_relative 'types/decimal'
10
- require_relative 'types/float'
11
- require_relative 'types/hash'
12
- require_relative 'types/input'
13
- require_relative 'types/integer'
14
- require_relative 'types/nil'
15
- require_relative 'types/output'
16
- require_relative 'types/string'
17
- require_relative 'types/symbol'
18
- require_relative 'types/tuple'
19
-
20
- module Bake
21
- module Types
22
- def self.parse(signature)
23
- eval(signature, binding)
24
- end
25
- end
26
- end