bake 0.14.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bake.rb +6 -1
- data/lib/bake/arguments.rb +126 -0
- data/lib/bake/base.rb +2 -0
- data/lib/bake/command.rb +2 -0
- data/lib/bake/command/call.rb +3 -1
- data/lib/bake/command/list.rb +2 -0
- data/lib/bake/command/top.rb +6 -0
- data/lib/bake/context.rb +6 -0
- data/lib/bake/documentation.rb +2 -0
- data/lib/bake/loader.rb +2 -0
- data/lib/bake/loaders.rb +2 -0
- data/lib/bake/recipe.rb +17 -34
- data/lib/bake/scope.rb +2 -0
- data/lib/bake/types.rb +2 -0
- data/lib/bake/types/any.rb +2 -0
- data/lib/bake/types/array.rb +14 -1
- data/lib/bake/types/boolean.rb +2 -0
- data/lib/bake/types/decimal.rb +2 -0
- data/lib/bake/types/float.rb +2 -0
- data/lib/bake/types/hash.rb +2 -0
- data/lib/bake/types/input.rb +2 -0
- data/lib/bake/types/integer.rb +2 -0
- data/lib/bake/types/nil.rb +2 -0
- data/lib/bake/types/output.rb +2 -0
- data/lib/bake/types/string.rb +2 -0
- data/lib/bake/types/symbol.rb +2 -0
- data/lib/bake/types/tuple.rb +10 -1
- data/lib/bake/version.rb +3 -1
- metadata +7 -19
- data/.github/workflows/development.yml +0 -35
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/README.md +0 -61
- data/bake.gemspec +0 -29
- data/bake.rb +0 -0
- data/gems.rb +0 -11
- data/guides/command-line-interface/README.md +0 -55
- data/guides/gem-integration/README.md +0 -69
- data/guides/getting-started/README.md +0 -109
- data/guides/links.yaml +0 -8
- data/guides/project-integration/README.md +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492a3039647b5dfb430f1d22b0c2bc691531e3bd06fa8adbb87f04cf53f06e49
|
4
|
+
data.tar.gz: f9c4aa8b76fc5dec8dd23ca65fa62123e24b37edc5bac909f7e4f3021f4a174f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91146cbe9150339a51041896ac55b27c0d0791b0a1ebb20b6c3b0220c69f651f359d9e0f2f09c04db870f1e2501c773f7a6e25155550e0b3957eea3e8cd54825
|
7
|
+
data.tar.gz: 5df776825366bd19352085a97b5eba5eba6e5c18da9aa24bbe15dc5387789f20cf40836e4f3664c76e0911c458f274c5eccb02502ebb23650b9b97771f1a0e46
|
data/lib/bake.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -18,4 +20,7 @@
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
21
|
# THE SOFTWARE.
|
20
22
|
|
21
|
-
|
23
|
+
require_relative 'bake/version'
|
24
|
+
require_relative 'bake/loaders'
|
25
|
+
require_relative 'bake/loader'
|
26
|
+
require_relative 'bake/context'
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'types'
|
24
|
+
require_relative 'documentation'
|
25
|
+
|
26
|
+
module Bake
|
27
|
+
# Structured access to arguments.
|
28
|
+
class Arguments
|
29
|
+
def self.extract(recipe, arguments)
|
30
|
+
self.new(recipe).extract(arguments)
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(recipe)
|
34
|
+
@recipe = recipe
|
35
|
+
|
36
|
+
@types = recipe.types
|
37
|
+
@parameters = recipe.parameters
|
38
|
+
@arity = recipe.arity
|
39
|
+
|
40
|
+
@ordered = []
|
41
|
+
@options = {}
|
42
|
+
end
|
43
|
+
|
44
|
+
attr :ordered
|
45
|
+
attr :options
|
46
|
+
|
47
|
+
def extract(arguments)
|
48
|
+
while argument = arguments.first
|
49
|
+
if /^--(?<name>.*)$/ =~ argument
|
50
|
+
# Consume the argument:
|
51
|
+
arguments.shift
|
52
|
+
|
53
|
+
if name.empty?
|
54
|
+
break
|
55
|
+
end
|
56
|
+
|
57
|
+
name = normalize(name)
|
58
|
+
|
59
|
+
# Extract the trailing arguments:
|
60
|
+
@options[name] = extract_arguments(name, arguments)
|
61
|
+
elsif /^(?<name>.*?)=(?<value>.*)$/ =~ argument
|
62
|
+
# Consume the argument:
|
63
|
+
arguments.shift
|
64
|
+
|
65
|
+
name = name.to_sym
|
66
|
+
|
67
|
+
# Extract the single argument:
|
68
|
+
@options[name] = extract_argument(name, value)
|
69
|
+
elsif @ordered.size < @arity
|
70
|
+
_, name = @parameters.shift
|
71
|
+
value = arguments.shift
|
72
|
+
|
73
|
+
# Consume it:
|
74
|
+
@ordered << extract_argument(name, value)
|
75
|
+
else
|
76
|
+
break
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
return @ordered, @options
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def normalize(name)
|
86
|
+
name.tr('-', '_').to_sym
|
87
|
+
end
|
88
|
+
|
89
|
+
def delimiter_index(arguments)
|
90
|
+
arguments.index{|argument| argument =~ /\A(--|;\z)/}
|
91
|
+
end
|
92
|
+
|
93
|
+
def extract_arguments(name, arguments)
|
94
|
+
value = nil
|
95
|
+
type = @types[name]
|
96
|
+
|
97
|
+
# Can this named parameter accept more than one input argument?
|
98
|
+
if type&.composite?
|
99
|
+
if count = delimiter_index(arguments)
|
100
|
+
value = arguments.shift(count)
|
101
|
+
arguments.shift if arguments.first == ';'
|
102
|
+
else
|
103
|
+
value = arguments.dup
|
104
|
+
arguments.clear
|
105
|
+
end
|
106
|
+
else
|
107
|
+
# Otherwise we just take one item:
|
108
|
+
value = arguments.shift
|
109
|
+
end
|
110
|
+
|
111
|
+
if type
|
112
|
+
value = type.parse(value)
|
113
|
+
end
|
114
|
+
|
115
|
+
return value
|
116
|
+
end
|
117
|
+
|
118
|
+
def extract_argument(name, value)
|
119
|
+
if type = @types[name]
|
120
|
+
value = type.parse(value)
|
121
|
+
end
|
122
|
+
|
123
|
+
return value
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
data/lib/bake/base.rb
CHANGED
data/lib/bake/command.rb
CHANGED
data/lib/bake/command/call.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -34,7 +36,7 @@ module Bake
|
|
34
36
|
@parent.bakefile
|
35
37
|
end
|
36
38
|
|
37
|
-
many :commands, "The commands & arguments to invoke.", default: ["default"]
|
39
|
+
many :commands, "The commands & arguments to invoke.", default: ["default"], stop: false
|
38
40
|
|
39
41
|
def call
|
40
42
|
context = @parent.context
|
data/lib/bake/command/list.rb
CHANGED
data/lib/bake/command/top.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -33,6 +35,10 @@ module Bake
|
|
33
35
|
options do
|
34
36
|
option '-h/--help', 'Show help.'
|
35
37
|
option '-b/--bakefile <path>', 'Override the path to the bakefile to use.'
|
38
|
+
|
39
|
+
option '-g/--gem <name>', 'Load the specified gem, e.g. "bake ~> 1.0".' do |value|
|
40
|
+
gem(*value.split(/\s+/))
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
44
|
nested :command, {
|
data/lib/bake/context.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -140,6 +142,10 @@ module Bake
|
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
145
|
+
def inspect
|
146
|
+
"\#<#{self.class} #{@root}>"
|
147
|
+
end
|
148
|
+
|
143
149
|
private
|
144
150
|
|
145
151
|
def recipe_for(command)
|
data/lib/bake/documentation.rb
CHANGED
data/lib/bake/loader.rb
CHANGED
data/lib/bake/loaders.rb
CHANGED
data/lib/bake/recipe.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -19,6 +21,7 @@
|
|
19
21
|
# THE SOFTWARE.
|
20
22
|
|
21
23
|
require_relative 'types'
|
24
|
+
require_relative 'arguments'
|
22
25
|
require_relative 'documentation'
|
23
26
|
|
24
27
|
module Bake
|
@@ -105,40 +108,7 @@ module Bake
|
|
105
108
|
# @returns ordered [Array]
|
106
109
|
# @returns options [Hash]
|
107
110
|
def prepare(arguments)
|
108
|
-
|
109
|
-
ordered = []
|
110
|
-
options = {}
|
111
|
-
parameters = method.parameters.dup
|
112
|
-
types = self.types
|
113
|
-
|
114
|
-
while argument = arguments.first
|
115
|
-
name, value = argument.split('=', 2)
|
116
|
-
|
117
|
-
if name and value
|
118
|
-
# Consume it:
|
119
|
-
arguments.shift
|
120
|
-
|
121
|
-
if type = types[name.to_sym]
|
122
|
-
value = type.parse(value)
|
123
|
-
end
|
124
|
-
|
125
|
-
options[name.to_sym] = value
|
126
|
-
elsif ordered.size < self.arity
|
127
|
-
_, name = parameters.shift
|
128
|
-
value = arguments.shift
|
129
|
-
|
130
|
-
if type = types[name]
|
131
|
-
value = type.parse(value)
|
132
|
-
end
|
133
|
-
|
134
|
-
# Consume it:
|
135
|
-
ordered << value
|
136
|
-
else
|
137
|
-
break
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
return ordered, options
|
111
|
+
Arguments.extract(self, arguments)
|
142
112
|
end
|
143
113
|
|
144
114
|
# Call the recipe with the specified arguments and options.
|
@@ -171,6 +141,19 @@ module Bake
|
|
171
141
|
|
172
142
|
private
|
173
143
|
|
144
|
+
def parse(name, value, arguments, types)
|
145
|
+
if count = arguments.index(';')
|
146
|
+
value = arguments.shift(count)
|
147
|
+
arguments.shift
|
148
|
+
end
|
149
|
+
|
150
|
+
if type = types[name]
|
151
|
+
value = type.parse(value)
|
152
|
+
end
|
153
|
+
|
154
|
+
return value
|
155
|
+
end
|
156
|
+
|
174
157
|
def compute_command
|
175
158
|
path = @instance.path
|
176
159
|
|
data/lib/bake/scope.rb
CHANGED
data/lib/bake/types.rb
CHANGED
data/lib/bake/types/any.rb
CHANGED
data/lib/bake/types/array.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -33,8 +35,19 @@ module Bake
|
|
33
35
|
true
|
34
36
|
end
|
35
37
|
|
38
|
+
def map(values)
|
39
|
+
values.map{|value| @item_type.parse(value)}
|
40
|
+
end
|
41
|
+
|
36
42
|
def parse(input)
|
37
|
-
input
|
43
|
+
case input
|
44
|
+
when ::String
|
45
|
+
return input.split(',').map{|value| @item_type.parse(value)}
|
46
|
+
when ::Array
|
47
|
+
return input.map{|value| @item_type.parse(value)}
|
48
|
+
else
|
49
|
+
raise ArgumentError, "Cannot coerce #{input.inspect} into array!"
|
50
|
+
end
|
38
51
|
end
|
39
52
|
|
40
53
|
def to_s
|
data/lib/bake/types/boolean.rb
CHANGED
data/lib/bake/types/decimal.rb
CHANGED
data/lib/bake/types/float.rb
CHANGED
data/lib/bake/types/hash.rb
CHANGED
data/lib/bake/types/input.rb
CHANGED
data/lib/bake/types/integer.rb
CHANGED
data/lib/bake/types/nil.rb
CHANGED
data/lib/bake/types/output.rb
CHANGED
data/lib/bake/types/string.rb
CHANGED
data/lib/bake/types/symbol.rb
CHANGED
data/lib/bake/types/tuple.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -34,7 +36,14 @@ module Bake
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def parse(input)
|
37
|
-
input
|
39
|
+
case input
|
40
|
+
when ::String
|
41
|
+
return input.split(',').map{|value| @item_type.parse(value)}
|
42
|
+
when ::Array
|
43
|
+
return input.map{|value| @item_type.parse(value)}
|
44
|
+
else
|
45
|
+
raise ArgumentError, "Cannot coerce #{input.inspect} into tuple!"
|
46
|
+
end
|
38
47
|
end
|
39
48
|
|
40
49
|
def to_s
|
data/lib/bake/version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -19,5 +21,5 @@
|
|
19
21
|
# THE SOFTWARE.
|
20
22
|
|
21
23
|
module Bake
|
22
|
-
VERSION = "0.
|
24
|
+
VERSION = "0.16.0"
|
23
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: samovar
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: covered
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -68,26 +68,14 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
description:
|
70
70
|
email:
|
71
|
-
- samuel.williams@oriontransfer.co.nz
|
72
71
|
executables:
|
73
72
|
- bake
|
74
73
|
extensions: []
|
75
74
|
extra_rdoc_files: []
|
76
75
|
files:
|
77
|
-
- ".github/workflows/development.yml"
|
78
|
-
- ".gitignore"
|
79
|
-
- ".rspec"
|
80
|
-
- README.md
|
81
|
-
- bake.gemspec
|
82
|
-
- bake.rb
|
83
76
|
- bin/bake
|
84
|
-
- gems.rb
|
85
|
-
- guides/command-line-interface/README.md
|
86
|
-
- guides/gem-integration/README.md
|
87
|
-
- guides/getting-started/README.md
|
88
|
-
- guides/links.yaml
|
89
|
-
- guides/project-integration/README.md
|
90
77
|
- lib/bake.rb
|
78
|
+
- lib/bake/arguments.rb
|
91
79
|
- lib/bake/base.rb
|
92
80
|
- lib/bake/command.rb
|
93
81
|
- lib/bake/command/call.rb
|
@@ -118,7 +106,7 @@ homepage: https://github.com/ioquatix/bake
|
|
118
106
|
licenses:
|
119
107
|
- MIT
|
120
108
|
metadata:
|
121
|
-
|
109
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
122
110
|
post_install_message:
|
123
111
|
rdoc_options: []
|
124
112
|
require_paths:
|
@@ -134,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
122
|
- !ruby/object:Gem::Version
|
135
123
|
version: '0'
|
136
124
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.2.15
|
138
126
|
signing_key:
|
139
127
|
specification_version: 4
|
140
128
|
summary: A replacement for rake with a simpler syntax.
|
@@ -1,35 +0,0 @@
|
|
1
|
-
name: Development
|
2
|
-
|
3
|
-
on: [push]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
test:
|
7
|
-
strategy:
|
8
|
-
matrix:
|
9
|
-
os:
|
10
|
-
- ubuntu
|
11
|
-
- macos
|
12
|
-
|
13
|
-
ruby:
|
14
|
-
- 2.5
|
15
|
-
- 2.6
|
16
|
-
- 2.7
|
17
|
-
|
18
|
-
include:
|
19
|
-
- os: 'ubuntu'
|
20
|
-
ruby: '2.6'
|
21
|
-
env: COVERAGE=PartialSummary,Coveralls
|
22
|
-
|
23
|
-
runs-on: ${{matrix.os}}-latest
|
24
|
-
|
25
|
-
steps:
|
26
|
-
- uses: actions/checkout@v1
|
27
|
-
- uses: actions/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: ${{matrix.ruby}}
|
30
|
-
- name: Install dependencies
|
31
|
-
run: |
|
32
|
-
command -v bundler || gem install bundler
|
33
|
-
bundle install
|
34
|
-
- name: Run tests
|
35
|
-
run: ${{matrix.env}} bundle exec rspec
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/README.md
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# Bake
|
2
|
-
|
3
|
-
Bake is a task execution tool, inspired by Rake, but codifying many of the use cases which are typically implemented in an ad-hoc manner.
|
4
|
-
|
5
|
-
[![Development](https://github.com/ioquatix/bake/workflows/Development/badge.svg)](https://github.com/ioquatix/bake/actions?workflow=Development)
|
6
|
-
|
7
|
-
## Features
|
8
|
-
|
9
|
-
Rake is an awesome tool and loved by the community. So, why reinvent it? Bake provides the following features that Rake does not:
|
10
|
-
|
11
|
-
- On demand loading of files following a standard convention. This avoid loading all your rake tasks just to execute a single command.
|
12
|
-
- Better argument handling including support for positional and optional arguments.
|
13
|
-
- Focused on task execution not dependency resolution. Implementation is simpler and a bit more predictable.
|
14
|
-
- Canonical structure for integration with gems.
|
15
|
-
|
16
|
-
That being said, Rake and Bake can exist side by side in the same project.
|
17
|
-
|
18
|
-
## Usage
|
19
|
-
|
20
|
-
Please see the [project documentation](https://ioquatix.github.io/bake/).
|
21
|
-
|
22
|
-
## Contributing
|
23
|
-
|
24
|
-
We welcome contributions to this project.
|
25
|
-
|
26
|
-
1. Fork it.
|
27
|
-
2. Create your feature branch (`git checkout -b my-new-feature`).
|
28
|
-
3. Commit your changes (`git commit -am 'Add some feature'`).
|
29
|
-
4. Push to the branch (`git push origin my-new-feature`).
|
30
|
-
5. Create new Pull Request.
|
31
|
-
|
32
|
-
|
33
|
-
## See Also
|
34
|
-
|
35
|
-
- [Console](https://github.com/socketry/console) — A logging framework which integrates with bake.
|
36
|
-
- [Variant](https://github.com/socketry/variant) — A framework for selecting different environments, including bake tasks.
|
37
|
-
- [Utopia](https://github.com/socketry/utopia) — A website framework which uses bake for maintenance tasks.
|
38
|
-
|
39
|
-
## License
|
40
|
-
|
41
|
-
Released under the MIT license.
|
42
|
-
|
43
|
-
Copyright, 2020, by [Samuel G. D. Williams](http://www.codeotaku.com).
|
44
|
-
|
45
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
46
|
-
of this software and associated documentation files (the "Software"), to deal
|
47
|
-
in the Software without restriction, including without limitation the rights
|
48
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
49
|
-
copies of the Software, and to permit persons to whom the Software is
|
50
|
-
furnished to do so, subject to the following conditions:
|
51
|
-
|
52
|
-
The above copyright notice and this permission notice shall be included in
|
53
|
-
all copies or substantial portions of the Software.
|
54
|
-
|
55
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
56
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
57
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
58
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
59
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
60
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
61
|
-
THE SOFTWARE.
|
data/bake.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative 'lib/bake/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "bake"
|
5
|
-
spec.version = Bake::VERSION
|
6
|
-
spec.authors = ["Samuel Williams"]
|
7
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
8
|
-
|
9
|
-
spec.summary = "A replacement for rake with a simpler syntax."
|
10
|
-
spec.homepage = "https://github.com/ioquatix/bake"
|
11
|
-
spec.license = "MIT"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
13
|
-
|
14
|
-
spec.metadata["donation_uri"] = "https://github.com/sponsors/ioquatix"
|
15
|
-
|
16
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(docs|test|spec|features)/}) }
|
18
|
-
end
|
19
|
-
|
20
|
-
spec.bindir = "bin"
|
21
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.add_dependency 'samovar', '~> 2.1'
|
25
|
-
|
26
|
-
spec.add_development_dependency 'covered'
|
27
|
-
spec.add_development_dependency 'bundler'
|
28
|
-
spec.add_development_dependency 'rspec'
|
29
|
-
end
|
data/bake.rb
DELETED
File without changes
|
data/gems.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# Command Line Interface
|
2
|
-
|
3
|
-
The `bake` command is broken up into two main functions: `list` and `call`.
|
4
|
-
|
5
|
-
<pre>% bake --help
|
6
|
-
<b>bake [-h/--help] [-b/--bakefile <path>] <command></b>
|
7
|
-
<font color="#638FFF">Execute tasks using Ruby.</font>
|
8
|
-
|
9
|
-
[-h/--help] Show help.
|
10
|
-
[-b/--bakefile <path>] Override the path to the bakefile to use.
|
11
|
-
<command> One of: call, list. (default: call)
|
12
|
-
|
13
|
-
<b>call <commands...></b>
|
14
|
-
<font color="#638FFF">Execute one or more commands.</font>
|
15
|
-
|
16
|
-
<commands...> The commands & arguments to invoke. (default: ["default"])
|
17
|
-
|
18
|
-
<b>list <pattern></b>
|
19
|
-
<pattern> The pattern to filter tasks by.
|
20
|
-
</pre>
|
21
|
-
|
22
|
-
## List
|
23
|
-
|
24
|
-
The `bake list` command allows you to list all available recipes. By proving a pattern you will only see recipes that have a matching command name.
|
25
|
-
|
26
|
-
<pre>$ bake list console
|
27
|
-
<b>Bake::Loader console-1.8.2</b>
|
28
|
-
|
29
|
-
<b>console:info</b>
|
30
|
-
<font color="#638FFF">Increase the verbosity of the logger to info.</font>
|
31
|
-
|
32
|
-
<b>console:debug</b>
|
33
|
-
<font color="#638FFF">Increase the verbosity of the logger to debug.</font>
|
34
|
-
</pre>
|
35
|
-
|
36
|
-
The listing documents positional and optional arguments. The documentation is generated from the comments in the bakefiles.
|
37
|
-
|
38
|
-
## Call
|
39
|
-
|
40
|
-
The `bake call` (the default, so `call` can be omitted) allows you to execute one or more recipes. You must provide the name of the command, followed by any arguments.
|
41
|
-
|
42
|
-
<pre>$ bake async:http:head https://www.codeotaku.com/index
|
43
|
-
<font color="#638FFF"><b> HEAD</b></font>: https://www.codeotaku.com/index
|
44
|
-
<font color="#00AA00"><b> version</b></font>: h2
|
45
|
-
<font color="#00AA00"><b> status</b></font>: 200
|
46
|
-
<font color="#00AA00"><b> body</b></font>: body with length <b>7879B</b>
|
47
|
-
<b> content-type</b>: "text/html; charset=utf-8"
|
48
|
-
<b> cache-control</b>: "public, max-age=3600"
|
49
|
-
<b> expires</b>: "Mon, 04 May 2020 13:23:47 GMT"
|
50
|
-
<b> server</b>: "falcon/0.36.4"
|
51
|
-
<b> date</b>: "Mon, 04 May 2020 12:23:47 GMT"
|
52
|
-
<b> vary</b>: "accept-encoding"
|
53
|
-
</pre>
|
54
|
-
|
55
|
-
You can specify multiple commands and they will be executed sequentially.
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# Gem Integration
|
2
|
-
|
3
|
-
This guide explains how to add `bake` to a Ruby gem and export standardised tasks for use by other gems and projects.
|
4
|
-
|
5
|
-
## Exporting Tasks
|
6
|
-
|
7
|
-
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`:
|
8
|
-
|
9
|
-
~~~ ruby
|
10
|
-
def setup
|
11
|
-
# ...
|
12
|
-
end
|
13
|
-
~~~
|
14
|
-
|
15
|
-
Then, in a different project which depends on `mygem`, you can run tasks from `mygem` by invoking them using `bake`:
|
16
|
-
|
17
|
-
~~~ bash
|
18
|
-
$ bake mygem:setup
|
19
|
-
~~~
|
20
|
-
|
21
|
-
## Examples
|
22
|
-
|
23
|
-
There are many gems which export tasks in this way. Here are some notable examples:
|
24
|
-
|
25
|
-
### Variant
|
26
|
-
|
27
|
-
The [variant gem](https://github.com/socketry/variant) exposes bake tasks for setting the environment e.g. `development`, `testing`, or `production`.
|
28
|
-
|
29
|
-
<pre class="terminal">$ bake list variant
|
30
|
-
<b>Bake::Loader variant-0.1.1</b>
|
31
|
-
|
32
|
-
<b>variant:production</b> <font color="#00AA00">**overrides</font>
|
33
|
-
<font color="#638FFF">Select the production variant.</font>
|
34
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
35
|
-
|
36
|
-
<b>variant:staging</b> <font color="#00AA00">**overrides</font>
|
37
|
-
<font color="#638FFF">Select the staging variant.</font>
|
38
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
39
|
-
|
40
|
-
<b>variant:development</b> <font color="#00AA00">**overrides</font>
|
41
|
-
<font color="#638FFF">Select the development variant.</font>
|
42
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
43
|
-
|
44
|
-
<b>variant:testing</b> <font color="#00AA00">**overrides</font>
|
45
|
-
<font color="#638FFF">Select the testing variant.</font>
|
46
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
47
|
-
|
48
|
-
<b>variant:force</b> <font color="#AA0000">name</font> <font color="#00AA00">**overrides</font>
|
49
|
-
<font color="#638FFF">Force a specific variant.</font>
|
50
|
-
<font color="#00AA00">name</font> [Symbol] <font color="#638FFF">the default variant.</font>
|
51
|
-
<font color="#00AA00">overrides</font> [Hash] <font color="#638FFF">any specific variant overrides.</font>
|
52
|
-
|
53
|
-
<b>variant:show</b>
|
54
|
-
<font color="#638FFF">Show variant-related environment variables.</font>
|
55
|
-
</pre>
|
56
|
-
|
57
|
-
### Console
|
58
|
-
|
59
|
-
The [console gem](https://github.com/socketry/console) exposes bake tasks to change the log level.
|
60
|
-
|
61
|
-
<pre class="terminal">$ bake list console
|
62
|
-
<b>Bake::Loader console-1.8.2</b>
|
63
|
-
|
64
|
-
<b>console:info</b>
|
65
|
-
<font color="#638FFF">Increase the verbosity of the logger to info.</font>
|
66
|
-
|
67
|
-
<b>console:debug</b>
|
68
|
-
<font color="#638FFF">Increase the verbosity of the logger to debug.</font>
|
69
|
-
</pre>
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# Getting Started
|
2
|
-
|
3
|
-
This guide gives a general overview of `bake` and how to use it.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add the gem to your project:
|
8
|
-
|
9
|
-
~~~ bash
|
10
|
-
$ bundle add bake
|
11
|
-
~~~
|
12
|
-
|
13
|
-
## Core Concepts
|
14
|
-
|
15
|
-
`bake` has several core concepts:
|
16
|
-
|
17
|
-
- A `bake` executable used for invoking one or more tasks.
|
18
|
-
- A {ruby Bake::Context} instance which is bound to a project or gem and exposes a hierarchy of runnable tasks.
|
19
|
-
- A {ruby Bake::Loaders} instance which is used for on-demand loading of bake files from the current project and all available gems.
|
20
|
-
|
21
|
-
## Executing Tasks
|
22
|
-
|
23
|
-
The `bake` executable can be used to execute tasks in a `bake.rb` file in the same directory.
|
24
|
-
|
25
|
-
``` ruby
|
26
|
-
# bake.rb
|
27
|
-
|
28
|
-
def add(x, y)
|
29
|
-
puts Integer(x) + Integer(y)
|
30
|
-
end
|
31
|
-
```
|
32
|
-
|
33
|
-
You can execute this task from the command line:
|
34
|
-
|
35
|
-
``` shell
|
36
|
-
% bake add 10 20
|
37
|
-
30
|
38
|
-
```
|
39
|
-
|
40
|
-
### Using Types
|
41
|
-
|
42
|
-
You can annotate your task with a type signature and `bake` will coerce your arguments to these types:
|
43
|
-
|
44
|
-
``` ruby
|
45
|
-
# bake.rb
|
46
|
-
|
47
|
-
# @parameter x [Integer]
|
48
|
-
# @parameter y [Integer]
|
49
|
-
def add(x, y)
|
50
|
-
puts x + y
|
51
|
-
end
|
52
|
-
```
|
53
|
-
|
54
|
-
You can execute this task from the command line:
|
55
|
-
|
56
|
-
``` shell
|
57
|
-
% bake add 10 20
|
58
|
-
30
|
59
|
-
```
|
60
|
-
|
61
|
-
The values are automatically coerced to `Integer`.
|
62
|
-
|
63
|
-
### Extending With Documentation
|
64
|
-
|
65
|
-
You can add documentation to your tasks and parameters (using Markdown formatting).
|
66
|
-
|
67
|
-
``` ruby
|
68
|
-
# bake.rb
|
69
|
-
|
70
|
-
# Add the x and y coordinate together and print the result.
|
71
|
-
# @parameter x [Integer] The x offset.
|
72
|
-
# @parameter y [Integer] The y offset.
|
73
|
-
def add(x, y)
|
74
|
-
puts x + y
|
75
|
-
end
|
76
|
-
```
|
77
|
-
|
78
|
-
You can see this documentation in the task listing:
|
79
|
-
|
80
|
-
``` shell
|
81
|
-
% bake list add
|
82
|
-
Bake::Context getting-started
|
83
|
-
|
84
|
-
add x y
|
85
|
-
Add the x and y coordinate together and print the result.
|
86
|
-
x [Integer] The x offset.
|
87
|
-
y [Integer] The y offset.
|
88
|
-
```
|
89
|
-
|
90
|
-
### Private Methods
|
91
|
-
|
92
|
-
If you want to add helper methods which don't show up as tasks, define them as `protected` or `private`.
|
93
|
-
|
94
|
-
``` ruby
|
95
|
-
# bake.rb
|
96
|
-
|
97
|
-
# Add the x and y coordinate together and print the result.
|
98
|
-
# @parameter x [Integer] The x offset.
|
99
|
-
# @parameter y [Integer] The y offset.
|
100
|
-
def add(x, y)
|
101
|
-
puts x + y
|
102
|
-
end
|
103
|
-
|
104
|
-
private
|
105
|
-
|
106
|
-
def puts(*arguments)
|
107
|
-
$stdout.puts arguments.inspect
|
108
|
-
end
|
109
|
-
```
|
data/guides/links.yaml
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Project Integration
|
2
|
-
|
3
|
-
This guide explains how to add `bake` to a Ruby project.
|
4
|
-
|
5
|
-
## Bakefile
|
6
|
-
|
7
|
-
At the top level of your project, you can create a `bake.rb` file, which contains top level tasks which are private to your project.
|
8
|
-
|
9
|
-
~~~ ruby
|
10
|
-
def cake
|
11
|
-
ingredients = call 'supermarket:shop', 'flour,sugar,cocoa'
|
12
|
-
lookup('mixer:add').call(ingredients)
|
13
|
-
end
|
14
|
-
~~~
|
15
|
-
|
16
|
-
This file is project specific and is the only file which can expose top level tasks (i.e. without a defined namespace). When used in a gem, these tasks are not exposed to other gems/projects.
|
17
|
-
|
18
|
-
## Recipes
|
19
|
-
|
20
|
-
Alongside the `bake.rb`, there is a `bake/` directory which contains files like `supermarket.rb`. These files contain recipes, e.g.:
|
21
|
-
|
22
|
-
~~~ ruby
|
23
|
-
# @param ingredients [Array(Any)] the ingredients to purchase.
|
24
|
-
def shop(ingredients)
|
25
|
-
supermarket = Supermarket.best
|
26
|
-
|
27
|
-
return supermarket.purchase(ingredients)
|
28
|
-
end
|
29
|
-
~~~
|
30
|
-
|
31
|
-
These methods are automatically scoped according to the file name, e.g. `bake/supermarket.rb` will define `supermarket:shop`.
|
32
|
-
|
33
|
-
|
34
|
-
## Arguments
|
35
|
-
|
36
|
-
Arguments work as normal. Documented types are used to parse strings from the command line. Both positional and optional parameters are supported.
|
37
|
-
|
38
|
-
### Positional Parameters
|
39
|
-
|
40
|
-
Positional parameters are non-keyword parameters which may have a default value. However, because of the limits of the command line, all positional arguments must be specified.
|
41
|
-
|
42
|
-
~~~ ruby
|
43
|
-
# @param x [Integer]
|
44
|
-
# @param y [Integer]
|
45
|
-
def add(x, y)
|
46
|
-
puts x + y
|
47
|
-
end
|
48
|
-
~~~
|
49
|
-
|
50
|
-
Which is invoked by `bake add 1 2`.
|
51
|
-
|
52
|
-
### Optional Parameters
|
53
|
-
|
54
|
-
Optional parameters are keyword parameters which may have a default value. The parameter is set on the command line using the name of the parameter followed by an equals sign, followed by the value.
|
55
|
-
|
56
|
-
~~~ ruby
|
57
|
-
# @param x [Integer]
|
58
|
-
# @param y [Integer]
|
59
|
-
def add(x:, y: 2)
|
60
|
-
puts x + y
|
61
|
-
end
|
62
|
-
~~~
|
63
|
-
|
64
|
-
Which is invoked by `bake add x=1`. Because `y` is not specified, it will default to `2` as per the method definition.
|