bake 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/bake/arguments.rb +7 -4
- data/lib/bake/command/call.rb +1 -16
- data/lib/bake/context.rb +1 -1
- data/lib/bake/loaders.rb +2 -0
- data/lib/bake/recipe.rb +12 -2
- data/lib/bake/types/decimal.rb +2 -2
- data/lib/bake/types/float.rb +2 -2
- data/lib/bake/types/integer.rb +2 -2
- data/lib/bake/types/string.rb +2 -2
- data/lib/bake/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f661b25836e9a41dd7e626297a8102f5096ba16fc56819f0c1a5ae9ce9e42ed4
|
4
|
+
data.tar.gz: 521eba8cc86affdbdda37a1a8753107e04fb0903a481b0aed031e18c3699e229
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b7138456ea6b2753a9c78d9f0df5ea3a7b789b6f1d6c75946ee2c896139c87627ad6c0429fc612fb30fd6958c475d670b9b9044dbf72d35a51223598d2c4775
|
7
|
+
data.tar.gz: 593d60a3b0c6cae127a71e8af68c4b4c16088d82b033b307c509f500e219a3716f804dc7df01ed93a762dea54c849b5a0b6206cf009d491c29fbe8bd524d8b4f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/bake/arguments.rb
CHANGED
@@ -26,11 +26,14 @@ require_relative 'documentation'
|
|
26
26
|
module Bake
|
27
27
|
# Structured access to arguments.
|
28
28
|
class Arguments
|
29
|
-
def self.extract(recipe, arguments)
|
30
|
-
|
29
|
+
def self.extract(recipe, arguments, **defaults)
|
30
|
+
# Only supply defaults that match the recipe option names:
|
31
|
+
defaults = defaults.slice(*recipe.required_options)
|
32
|
+
|
33
|
+
self.new(recipe, defaults).extract(arguments)
|
31
34
|
end
|
32
35
|
|
33
|
-
def initialize(recipe)
|
36
|
+
def initialize(recipe, defaults)
|
34
37
|
@recipe = recipe
|
35
38
|
|
36
39
|
@types = recipe.types
|
@@ -38,7 +41,7 @@ module Bake
|
|
38
41
|
@arity = recipe.arity
|
39
42
|
|
40
43
|
@ordered = []
|
41
|
-
@options =
|
44
|
+
@options = defaults
|
42
45
|
end
|
43
46
|
|
44
47
|
attr :ordered
|
data/lib/bake/command/call.rb
CHANGED
@@ -32,17 +32,6 @@ module Bake
|
|
32
32
|
class Call < Samovar::Command
|
33
33
|
self.description = "Execute one or more commands."
|
34
34
|
|
35
|
-
OUTPUT = {
|
36
|
-
json: ->(value){require 'json'; $stdout.puts(JSON.pretty_generate(value))},
|
37
|
-
pp: ->(value){require 'pp'; PP.pp(value, $stdout)},
|
38
|
-
raw: ->(value){$stdout.puts(value)},
|
39
|
-
yaml: ->(value){require 'yaml'; $stdout.puts(YAML.dump(value))},
|
40
|
-
}
|
41
|
-
|
42
|
-
options do
|
43
|
-
option "-o/--output <format>", "Output the result of the last task in the given format: #{OUTPUT.keys.join(", ")}.", type: Symbol
|
44
|
-
end
|
45
|
-
|
46
35
|
def bakefile
|
47
36
|
@parent.bakefile
|
48
37
|
end
|
@@ -58,11 +47,7 @@ module Bake
|
|
58
47
|
def call
|
59
48
|
context = @parent.context
|
60
49
|
|
61
|
-
|
62
|
-
|
63
|
-
if output = @options[:output]
|
64
|
-
format(output, last_result)
|
65
|
-
end
|
50
|
+
context.call(*@commands)
|
66
51
|
end
|
67
52
|
end
|
68
53
|
end
|
data/lib/bake/context.rb
CHANGED
@@ -118,7 +118,7 @@ module Bake
|
|
118
118
|
|
119
119
|
while command = commands.shift
|
120
120
|
if recipe = @recipes[command]
|
121
|
-
arguments, options = recipe.prepare(commands)
|
121
|
+
arguments, options = recipe.prepare(commands, last_result)
|
122
122
|
last_result = recipe.call(*arguments, **options)
|
123
123
|
else
|
124
124
|
raise ArgumentError, "Could not find recipe for #{command}!"
|
data/lib/bake/loaders.rb
CHANGED
@@ -97,6 +97,8 @@ module Bake
|
|
97
97
|
|
98
98
|
# Enumerate all loaded gems and add them.
|
99
99
|
def append_from_gems
|
100
|
+
Console.logger.debug(self) {::Gem.loaded_specs.keys.grep(/bake/)}
|
101
|
+
|
100
102
|
::Gem.loaded_specs.each do |name, spec|
|
101
103
|
Console.logger.debug(self) {"Checking gem #{name}: #{spec.full_gem_path}..."}
|
102
104
|
|
data/lib/bake/recipe.rb
CHANGED
@@ -85,6 +85,16 @@ module Bake
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def required_options
|
89
|
+
if parameters = self.parameters
|
90
|
+
parameters.map do |(type, name)|
|
91
|
+
if type == :keyreq
|
92
|
+
name
|
93
|
+
end
|
94
|
+
end.compact
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
88
98
|
# The command name for this recipe.
|
89
99
|
def command
|
90
100
|
@command ||= compute_command
|
@@ -107,8 +117,8 @@ module Bake
|
|
107
117
|
# @parameter arguments [Array(String)] The command line arguments
|
108
118
|
# @returns ordered [Array]
|
109
119
|
# @returns options [Hash]
|
110
|
-
def prepare(arguments)
|
111
|
-
Arguments.extract(self, arguments)
|
120
|
+
def prepare(arguments, last_result = nil)
|
121
|
+
Arguments.extract(self, arguments, input: last_result)
|
112
122
|
end
|
113
123
|
|
114
124
|
# Call the recipe with the specified arguments and options.
|
data/lib/bake/types/decimal.rb
CHANGED
data/lib/bake/types/float.rb
CHANGED
data/lib/bake/types/integer.rb
CHANGED
data/lib/bake/types/string.rb
CHANGED
data/lib/bake/version.rb
CHANGED
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.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
38
38
|
HiLJ8VOFx6w=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2022-05-
|
40
|
+
date: 2022-05-22 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: samovar
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
154
|
+
rubygems_version: 3.3.8
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: A replacement for rake with a simpler syntax.
|
metadata.gz.sig
CHANGED
Binary file
|