bake 0.14.0 → 0.15.2

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: c21d6d91f4610a4abdca6e513279db3532f535b879fd284efd0d93f39915bb1c
4
- data.tar.gz: 52648fc8729a487d1873eca3c90a5222a0837a5b66934810e197ee75d7740cc6
3
+ metadata.gz: 47bcbd5bbd0350ae6032bbf639684489b8a28ce5e41956a8a4f2f979c7ac4f3b
4
+ data.tar.gz: afe8e3084738e450520d2bc82c2ae122be8503b14014f0ad6ed94f72ee70f88f
5
5
  SHA512:
6
- metadata.gz: 6642cfd94507b0654e3cfef28a9c89440bae8f2c28b219d3e742c7eb089f3230596c23e0a7c278cd956dcfa3d664ca90d3becb9ebb041539171d3e093f3885da
7
- data.tar.gz: f13b33176b5be8a0bc5083e2832022fbb5e8f11c6242d20679f768a35e03e6e92e0db3fe25ead0da5fe7eb5c5b1f8678debfca8913e0725d8878eeb329eb5fdd
6
+ metadata.gz: 5ed9a70c290a1757433b1d8db2cb78103d7790192b2149a4ce89948c66123d9ae35726b3f05665968c71434ab879c15eafd29eb3e77559b4b444a768a586d64b
7
+ data.tar.gz: fbf2ad74fa227ce1c5be308f0f7c35f8198cae0414f8ca3092eb813de129a31c7c613297af50a65a7676af0d66cefd483249b032bcc6086cf71589301e063694
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
- require "bake/version"
23
+ require_relative 'bake/version'
24
+ require_relative 'bake/loaders'
25
+ require_relative 'bake/loader'
26
+ require_relative 'bake/context'
@@ -0,0 +1,122 @@
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 = name.to_sym
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 delimiter_index(arguments)
86
+ arguments.index{|argument| argument =~ /\A(--|;\z)/}
87
+ end
88
+
89
+ def extract_arguments(name, arguments)
90
+ value = nil
91
+ type = @types[name]
92
+
93
+ # Can this named parameter accept more than one input argument?
94
+ if type&.composite?
95
+ if count = delimiter_index(arguments)
96
+ value = arguments.shift(count)
97
+ arguments.shift if arguments.first == ';'
98
+ else
99
+ value = arguments.dup
100
+ arguments.clear
101
+ end
102
+ else
103
+ # Otherwise we just take one item:
104
+ value = arguments.shift
105
+ end
106
+
107
+ if type
108
+ value = type.parse(value)
109
+ end
110
+
111
+ return value
112
+ end
113
+
114
+ def extract_argument(name, value)
115
+ if type = @types[name]
116
+ value = type.parse(value)
117
+ end
118
+
119
+ return value
120
+ end
121
+ end
122
+ end
data/lib/bake/base.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
data/lib/bake/command.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
@@ -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
@@ -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
@@ -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
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)
@@ -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
data/lib/bake/loader.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
data/lib/bake/loaders.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
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
- offset = 0
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
@@ -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
data/lib/bake/types.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
@@ -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
@@ -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.split(',').map{|value| @item_type.parse(value)}
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
@@ -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
@@ -32,6 +34,10 @@ module Bake
32
34
  def self.parse(input)
33
35
  if input =~ /t(rue)?|y(es)?/i
34
36
  return true
37
+ elsif input =~ /f(alse)?|n(o)?/i
38
+ return false
39
+ else
40
+ raise ArgumentError, "Cannot coerce #{input.inspect} into boolean!"
35
41
  end
36
42
  end
37
43
  end
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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,7 +35,7 @@ module Bake
33
35
  if input =~ /nil|null/i
34
36
  return nil
35
37
  else
36
- raise ArgumentError, "Cannot coerce #{input} into nil!"
38
+ raise ArgumentError, "Cannot coerce #{input.inspect} into nil!"
37
39
  end
38
40
  end
39
41
  end
@@ -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
@@ -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
@@ -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
@@ -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.split(',').map{|value| @item_type.parse(value)}
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.14.0"
24
+ VERSION = "0.15.2"
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.14.0
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-16 00:00:00.000000000 Z
11
+ date: 2021-06-04 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: covered
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: bundler
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
- donation_uri: https://github.com/sponsors/ioquatix
109
+ funding_uri: https://github.com/sponsors/ioquatix/
122
110
  post_install_message:
123
111
  rdoc_options: []
124
112
  require_paths:
@@ -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
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- gems.locked
11
-
12
- # rspec failure tracking
13
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
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,11 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in bake.gemspec
4
- gemspec
5
-
6
- group :maintenance, optional: true do
7
- gem 'bake-modernize'
8
- gem 'bake-bundler'
9
-
10
- gem 'utopia-project'
11
- end
@@ -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 &lt;path&gt;] &lt;command&gt;</b>
7
- <font color="#638FFF">Execute tasks using Ruby.</font>
8
-
9
- [-h/--help] Show help.
10
- [-b/--bakefile &lt;path&gt;] Override the path to the bakefile to use.
11
- &lt;command&gt; One of: call, list. (default: call)
12
-
13
- <b>call &lt;commands...&gt;</b>
14
- <font color="#638FFF">Execute one or more commands.</font>
15
-
16
- &lt;commands...&gt; The commands &amp; arguments to invoke. (default: [&quot;default&quot;])
17
-
18
- <b>list &lt;pattern&gt;</b>
19
- &lt;pattern&gt; 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>: &quot;text/html; charset=utf-8&quot;
48
- <b> cache-control</b>: &quot;public, max-age=3600&quot;
49
- <b> expires</b>: &quot;Mon, 04 May 2020 13:23:47 GMT&quot;
50
- <b> server</b>: &quot;falcon/0.36.4&quot;
51
- <b> date</b>: &quot;Mon, 04 May 2020 12:23:47 GMT&quot;
52
- <b> vary</b>: &quot;accept-encoding&quot;
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,8 +0,0 @@
1
- getting-started:
2
- order: 1
3
- command-line-interface:
4
- order: 2
5
- project-integration:
6
- order: 3
7
- gem-integration:
8
- order: 4
@@ -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.