bake 0.16.0 → 0.18.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: 492a3039647b5dfb430f1d22b0c2bc691531e3bd06fa8adbb87f04cf53f06e49
4
- data.tar.gz: f9c4aa8b76fc5dec8dd23ca65fa62123e24b37edc5bac909f7e4f3021f4a174f
3
+ metadata.gz: f661b25836e9a41dd7e626297a8102f5096ba16fc56819f0c1a5ae9ce9e42ed4
4
+ data.tar.gz: 521eba8cc86affdbdda37a1a8753107e04fb0903a481b0aed031e18c3699e229
5
5
  SHA512:
6
- metadata.gz: 91146cbe9150339a51041896ac55b27c0d0791b0a1ebb20b6c3b0220c69f651f359d9e0f2f09c04db870f1e2501c773f7a6e25155550e0b3957eea3e8cd54825
7
- data.tar.gz: 5df776825366bd19352085a97b5eba5eba6e5c18da9aa24bbe15dc5387789f20cf40836e4f3664c76e0911c458f274c5eccb02502ebb23650b9b97771f1a0e46
6
+ metadata.gz: 7b7138456ea6b2753a9c78d9f0df5ea3a7b789b6f1d6c75946ee2c896139c87627ad6c0429fc612fb30fd6958c475d670b9b9044dbf72d35a51223598d2c4775
7
+ data.tar.gz: 593d60a3b0c6cae127a71e8af68c4b4c16088d82b033b307c509f500e219a3716f804dc7df01ed93a762dea54c849b5a0b6206cf009d491c29fbe8bd524d8b4f
checksums.yaml.gz.sig ADDED
Binary file
@@ -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
- self.new(recipe).extract(arguments)
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/base.rb CHANGED
@@ -95,5 +95,9 @@ module Bake
95
95
  def recipe_for(name)
96
96
  Recipe.new(self, name)
97
97
  end
98
+
99
+ def to_s
100
+ "\#<#{self.class}>"
101
+ end
98
102
  end
99
103
  end
@@ -38,6 +38,12 @@ module Bake
38
38
 
39
39
  many :commands, "The commands & arguments to invoke.", default: ["default"], stop: false
40
40
 
41
+ def format(output, value)
42
+ if formatter = OUTPUT[output]
43
+ formatter.call(value)
44
+ end
45
+ end
46
+
41
47
  def call
42
48
  context = @parent.context
43
49
 
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}!"
@@ -170,7 +170,7 @@ module Bake
170
170
  end
171
171
  end
172
172
 
173
- # @parameter path [Array<String>] the path for the scope.
173
+ # @parameter path [Array(String)] the path for the scope.
174
174
  def base_for(path)
175
175
  base = nil
176
176
 
data/lib/bake/loaders.rb CHANGED
@@ -97,7 +97,9 @@ module Bake
97
97
 
98
98
  # Enumerate all loaded gems and add them.
99
99
  def append_from_gems
100
- Gem.loaded_specs.each do |name, spec|
100
+ Console.logger.debug(self) {::Gem.loaded_specs.keys.grep(/bake/)}
101
+
102
+ ::Gem.loaded_specs.each do |name, spec|
101
103
  Console.logger.debug(self) {"Checking gem #{name}: #{spec.full_gem_path}..."}
102
104
 
103
105
  if path = spec.full_gem_path and File.directory?(path)
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.
@@ -33,8 +33,8 @@ module Bake
33
33
  false
34
34
  end
35
35
 
36
- def self.parse(value)
37
- BigDecimal(value)
36
+ def self.parse(input)
37
+ BigDecimal(input)
38
38
  end
39
39
  end
40
40
  end
@@ -31,8 +31,8 @@ module Bake
31
31
  false
32
32
  end
33
33
 
34
- def self.parse(value)
35
- value.to_f
34
+ def self.parse(input)
35
+ input.to_f
36
36
  end
37
37
  end
38
38
  end
@@ -31,8 +31,8 @@ module Bake
31
31
  false
32
32
  end
33
33
 
34
- def self.parse(value)
35
- Integer(value)
34
+ def self.parse(input)
35
+ Integer(input)
36
36
  end
37
37
  end
38
38
  end
@@ -31,8 +31,8 @@ module Bake
31
31
  false
32
32
  end
33
33
 
34
- def self.parse(value)
35
- value.to_s
34
+ def self.parse(input)
35
+ input.to_s
36
36
  end
37
37
  end
38
38
  end
data/lib/bake/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Bake
24
- VERSION = "0.16.0"
24
+ VERSION = "0.18.0"
25
25
  end
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Olle Jonsson
8
9
  autorequire:
9
10
  bindir: bin
10
- cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
15
+ ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
16
+ MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
17
+ aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
18
+ AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
19
+ xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
20
+ eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
21
+ L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
22
+ 9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
23
+ E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0+tpJrfsYiAmXMJNi4XAYJH7uL
24
+ rgJuJwSaa/dMz+VmUoo7VKtSfCoOI+6v5/z0sK3oT6sG6ZwyI47DBq2XqNC6tnAj
25
+ w+XmCywiTQrFzMMAvcA7rPI4F0nU1rZId51rOvvfxaONp+wgTi4P8owZLw0/j0m4
26
+ 8C20DYi6EYx4AHDXiLpElWh3AgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8E
27
+ BAMCBLAwHQYDVR0OBBYEFB6ZaeWKxQjGTI+pmz7cKRmMIywwMC4GA1UdEQQnMCWB
28
+ I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWB
29
+ I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEB
30
+ CwUAA4IBgQBVoM+pu3dpdUhZM1w051iw5GfiqclAr1Psypf16Tiod/ho//4oAu6T
31
+ 9fj3DPX/acWV9P/FScvqo4Qgv6g4VWO5ZU7z2JmPoTXZtYMunRAmQPFL/gSUc6aK
32
+ vszMHIyhtyzRc6DnfW2AiVOjMBjaYv8xXZc9bduniRVPrLR4J7ozmGLh4o4uJp7w
33
+ x9KCFaR8Lvn/r0oJWJOqb/DMAYI83YeN2Dlt3jpwrsmsONrtC5S3gOUle5afSGos
34
+ bYt5ocnEpKSomR9ZtnCGljds/aeO1Xgpn2r9HHcjwnH346iNrnHmMlC7BtHUFPDg
35
+ Ts92S47PTOXzwPBDsrFiq3VLbRjHSwf8rpqybQBH9MfzxGGxTaETQYOd6b4e4Ag6
36
+ y92abGna0bmIEb4+Tx9rQ10Uijh1POzvr/VTH4bbIPy9FbKrRsIQ24qDbNJRtOpE
37
+ RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
38
+ HiLJ8VOFx6w=
39
+ -----END CERTIFICATE-----
40
+ date: 2022-05-22 00:00:00.000000000 Z
12
41
  dependencies:
13
42
  - !ruby/object:Gem::Dependency
14
43
  name: samovar
@@ -122,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
151
  - !ruby/object:Gem::Version
123
152
  version: '0'
124
153
  requirements: []
125
- rubygems_version: 3.2.15
154
+ rubygems_version: 3.3.8
126
155
  signing_key:
127
156
  specification_version: 4
128
157
  summary: A replacement for rake with a simpler syntax.
metadata.gz.sig ADDED
Binary file