plover 1.0.0 → 1.1.1
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 +4 -4
- data/README.md +2 -2
- data/lib/plover.rb +92 -15
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e379809ddbf68dfdeea5b28c0f12494b0afc748fdeda52b41c9dbcc132db45d8
|
4
|
+
data.tar.gz: 61134a172618ef8651d10e550d11d4eb09cd132d4a5c1b0e996c38ba485f63b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f5f26be169f24153958ef159e8798e397555fcb75d4f3e5dc4cbec31681e04e2f2b319ca5528aac99c1811881208952edf8f63c816c6eba2bad6ccdd2902960
|
7
|
+
data.tar.gz: 974db73e8b87acb54d8c278fbfe74ac169bfb5dca68296fe7c0fa935616f4e1b615976a58d2a9faf6c5231edb53e9efeb17fdacecee93966feedea7798e1cd20
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ To help you with that, Plover provides a lightweight DSL for defining build phas
|
|
10
10
|
|
11
11
|
#### Tiny & Embeddable
|
12
12
|
|
13
|
-
Plover consists of ~
|
13
|
+
Plover consists of ~300 lines of plain Ruby, with no dependencies outside of the standard library.
|
14
14
|
|
15
15
|
Because Plover is built to be embeddable, you can copy/paste `lib/plover.rb` into your project if you'd rather not use the gem.
|
16
16
|
|
@@ -47,7 +47,7 @@ Or, add it to your project’s Gemfile:
|
|
47
47
|
gem "plover"
|
48
48
|
```
|
49
49
|
|
50
|
-
Because Plover is built to be embeddable, you can also just copy/paste `lib/plover.rb` into your project if you'd rather not use RubyGems (it's ~
|
50
|
+
Because Plover is built to be embeddable, you can also just copy/paste `lib/plover.rb` into your project if you'd rather not use RubyGems (it's ~300 lines of plain Ruby, with no dependencies outside of the standard library).
|
51
51
|
|
52
52
|
## Usage
|
53
53
|
|
data/lib/plover.rb
CHANGED
@@ -4,7 +4,7 @@ module Plover
|
|
4
4
|
require "shellwords"
|
5
5
|
require "fileutils"
|
6
6
|
|
7
|
-
VERSION = "1.
|
7
|
+
VERSION = "1.1.1"
|
8
8
|
|
9
9
|
class PloverError < StandardError; end
|
10
10
|
|
@@ -30,6 +30,46 @@ module Plover
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
module Log
|
34
|
+
require "logger"
|
35
|
+
|
36
|
+
def log(severity, msg)
|
37
|
+
logger.add(log_severity(severity), msg) unless log_config[:level] == :none
|
38
|
+
end
|
39
|
+
|
40
|
+
def log_level(severity)
|
41
|
+
log_config[:level] = severity
|
42
|
+
@logger = nil
|
43
|
+
logger.level = log_severity(log_config[:level])
|
44
|
+
end
|
45
|
+
|
46
|
+
def log_severity(severity = nil)
|
47
|
+
Logger::Severity.coerce(severity)
|
48
|
+
rescue
|
49
|
+
Logger::Severity.coerce(:unknown)
|
50
|
+
end
|
51
|
+
|
52
|
+
def logger
|
53
|
+
sink = case log_config[:sink]
|
54
|
+
when String
|
55
|
+
f = File.open(log_config[:sink], "a")
|
56
|
+
f.sync = true
|
57
|
+
f
|
58
|
+
when ->(s) { s.respond_to?(:write) }
|
59
|
+
log_config[:sink]
|
60
|
+
else $stdout
|
61
|
+
end
|
62
|
+
|
63
|
+
@logger ||= Logger.new(sink,
|
64
|
+
progname: "<Plover/#{is_a?(Class) ? name : self.class.name}>",
|
65
|
+
level: log_severity(log_config[:level]))
|
66
|
+
end
|
67
|
+
|
68
|
+
def log_config
|
69
|
+
is_a?(Class) ? configuration[:options][:log] : @configuration[:options][:log]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
33
73
|
class Builder
|
34
74
|
class FlagError < PloverError; end
|
35
75
|
|
@@ -39,6 +79,8 @@ module Plover
|
|
39
79
|
|
40
80
|
module Common; end
|
41
81
|
|
82
|
+
include Log
|
83
|
+
|
42
84
|
attr_reader :configuration
|
43
85
|
|
44
86
|
@configuration = {
|
@@ -51,9 +93,13 @@ module Plover
|
|
51
93
|
},
|
52
94
|
options: {
|
53
95
|
flags: {},
|
54
|
-
expected_flags: []
|
96
|
+
expected_flags: [],
|
97
|
+
common_include: :none,
|
98
|
+
log: {
|
99
|
+
level: :info,
|
100
|
+
sink: :stdout
|
101
|
+
}
|
55
102
|
},
|
56
|
-
include_common: :none,
|
57
103
|
artifacts: {
|
58
104
|
setup: {},
|
59
105
|
before_build: {},
|
@@ -64,10 +110,12 @@ module Plover
|
|
64
110
|
}
|
65
111
|
|
66
112
|
class << self
|
113
|
+
extend Log
|
114
|
+
|
67
115
|
attr_reader :configuration
|
68
116
|
|
69
117
|
def inherited(subclass)
|
70
|
-
|
118
|
+
subclass.extend(Log)
|
71
119
|
subclass.instance_variable_set(:@configuration, deep_copy(configuration))
|
72
120
|
end
|
73
121
|
|
@@ -87,6 +135,14 @@ module Plover
|
|
87
135
|
configuration[:options][:common_include] = :none
|
88
136
|
end
|
89
137
|
|
138
|
+
def log_level(severity)
|
139
|
+
configuration[:options][:log][:level] = severity.to_sym
|
140
|
+
end
|
141
|
+
|
142
|
+
def log_sink(sink)
|
143
|
+
configuration[:options][:log][:sink] = sink
|
144
|
+
end
|
145
|
+
|
90
146
|
def common_include(*modules)
|
91
147
|
configuration[:options][:common_include] = [] unless configuration[:options][:common_include].is_a?(Array)
|
92
148
|
|
@@ -108,14 +164,17 @@ module Plover
|
|
108
164
|
end
|
109
165
|
|
110
166
|
def auto_include_common
|
111
|
-
return if configuration[:options][:common_include] == :none
|
167
|
+
return if @configuration[:options][:common_include] == :none
|
112
168
|
|
113
169
|
ObjectSpace.each_object(Module).select { |m| m&.name&.start_with?("Plover::Builder::Common::") }.each do |mod|
|
114
170
|
next if mod.name.to_s.end_with?("::ClassMethods")
|
115
171
|
|
116
|
-
next if configuration[:options][:common_include].is_a?(Array) &&
|
172
|
+
next if @configuration[:options][:common_include].is_a?(Array) && !@configuration[:options][:common_include].any? { |m| m == mod.name.split("::").last }
|
117
173
|
|
118
|
-
|
174
|
+
if mod.respond_to?(:apply_concern) && !included_modules.include?(mod)
|
175
|
+
log(:debug, "Loading Common #{mod.name}")
|
176
|
+
mod.apply_concern(self)
|
177
|
+
end
|
119
178
|
end
|
120
179
|
end
|
121
180
|
|
@@ -131,15 +190,22 @@ module Plover
|
|
131
190
|
end
|
132
191
|
end
|
133
192
|
|
134
|
-
def initialize(flags = {})
|
135
|
-
self.class.auto_include_common
|
193
|
+
def initialize(flags = {}, use_env_flags: true)
|
136
194
|
@configuration = self.class.configuration
|
137
|
-
@configuration[:options][:flags] = @configuration[:options][:flags].merge(flags).merge(self.class.env_flags)
|
138
195
|
|
139
|
-
|
196
|
+
@configuration[:options][:log][:level] = flags[:log_level] || ENV["PLOVER_LOG_LEVEL"]&.to_sym || @configuration[:options][:log][:level] || :info
|
197
|
+
@configuration[:options][:log][:sink] = flags[:log_sink] || ENV["PLOVER_LOG_SINK"] || @configuration[:options][:log][:sink] || :stdout
|
140
198
|
|
141
|
-
|
142
|
-
|
199
|
+
@configuration[:options][:flags] = @configuration[:options][:flags].merge(flags).merge(use_env_flags ? self.class.env_flags : {})
|
200
|
+
|
201
|
+
self.class.auto_include_common
|
202
|
+
|
203
|
+
if @configuration[:options][:expected_flags].any?
|
204
|
+
missing_flags = @configuration[:options][:expected_flags].reject { |sym| @configuration[:options][:flags].key?(sym) }
|
205
|
+
fail_build("Missing required flags: #{missing_flags.join(", ")}") if missing_flags.any?
|
206
|
+
end
|
207
|
+
|
208
|
+
log :debug, "Initialized, options=#{@configuration[:options]}"
|
143
209
|
end
|
144
210
|
|
145
211
|
def prepend_phase(phase, &block)
|
@@ -167,11 +233,15 @@ module Plover
|
|
167
233
|
end
|
168
234
|
|
169
235
|
def raise_unless_flag(name, message)
|
170
|
-
|
236
|
+
unless flag(name)
|
237
|
+
log :fatal, "Missing flag '#{name}': #{message}"
|
238
|
+
raise FlagError.new(message)
|
239
|
+
end
|
171
240
|
end
|
172
241
|
|
173
242
|
def push_artifact(name, value)
|
174
243
|
return unless @current_phase
|
244
|
+
log :debug, "Pushed artifact name='#{name}' value='#{value}'"
|
175
245
|
@configuration[:artifacts][@current_phase][name] = value
|
176
246
|
end
|
177
247
|
|
@@ -189,17 +259,23 @@ module Plover
|
|
189
259
|
end
|
190
260
|
|
191
261
|
def raise_unless_artifact(phase, name, message)
|
192
|
-
|
262
|
+
unless artifact(phase, name)
|
263
|
+
log :fatal, "Missing artifact '#{name}': #{message}"
|
264
|
+
raise ArtifactError.new(message)
|
265
|
+
end
|
193
266
|
end
|
194
267
|
|
195
268
|
def fail_build(message)
|
269
|
+
log :fatal, "Build failure: #{message}"
|
196
270
|
raise BuildError.new(message)
|
197
271
|
end
|
198
272
|
|
199
273
|
def run_phase(phase)
|
274
|
+
log :debug, "\\/ #{phase.to_s.capitalize} Phase Starting \\/"
|
200
275
|
@current_phase = phase
|
201
276
|
@configuration[:steps][phase].each { |block| instance_exec(&block) }
|
202
277
|
@current_phase = nil
|
278
|
+
log :debug, "/\\ #{phase.to_s.capitalize} Phase Finished /\\"
|
203
279
|
end
|
204
280
|
|
205
281
|
def run
|
@@ -210,6 +286,7 @@ module Plover
|
|
210
286
|
run_phase(:after_build)
|
211
287
|
end
|
212
288
|
run_phase(:teardown)
|
289
|
+
logger.close
|
213
290
|
end
|
214
291
|
end
|
215
292
|
end
|
metadata
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlton Trezevant
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
11
|
-
dependencies:
|
10
|
+
date: 2025-03-19 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: logger
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
12
26
|
description: Plover is a tiny, embeddable Ruby build system.
|
13
27
|
email:
|
14
28
|
- ct@ctis.me
|