klenod-build 0.0.28 → 0.0.30
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13ffde9084826c2af713cef2b267b547b57ec88b1f23dd7e32bb5da3681d929e
|
|
4
|
+
data.tar.gz: 46585426c377c8368573a901f7062fc7f862e8fed2dbf4b0b96b1032fd0e36dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4abd68c6f308b9fbadd8e099a034e741220a22d72f93207880d97400a7f2987a27dbcb3fd9aaaae2a833dfd4586cc7c23703ba6a5fe0f0691226ad378f4febf
|
|
7
|
+
data.tar.gz: f8c131821ecdbe4ed750418c0262be97602116f64f6b8a05cce9b099c3072a7bc73e5323c00ac9348cc1a68ce2256a1ad9a80611dea5805ee7f559aa650ee918
|
data/lib/klenod/build/context.rb
CHANGED
|
@@ -88,6 +88,10 @@ module Klenod
|
|
|
88
88
|
|
|
89
89
|
DEFAULT_PLUGINS = DefaultPlugins.new.freeze
|
|
90
90
|
|
|
91
|
+
# `:development` collects, evaluates, and reloads on demand. `:build`
|
|
92
|
+
# only collects, for writing a bundle; `klenod build` always uses it.
|
|
93
|
+
MODES = %i[development build].freeze
|
|
94
|
+
|
|
91
95
|
def self.default_plugins
|
|
92
96
|
[
|
|
93
97
|
Plugins::RubyPlugin.new,
|
|
@@ -116,6 +120,12 @@ module Klenod
|
|
|
116
120
|
namespace: Module.new,
|
|
117
121
|
analysis: false
|
|
118
122
|
)
|
|
123
|
+
# Plugins compare the mode with `==`, so an unknown one would quietly
|
|
124
|
+
# behave like neither, e.g. CSS that is not minified.
|
|
125
|
+
unless MODES.include?(mode)
|
|
126
|
+
raise ArgumentError, "Unknown mode #{mode.inspect}; expected one of #{MODES.map(&:inspect).join(", ")}"
|
|
127
|
+
end
|
|
128
|
+
|
|
119
129
|
@source_dir = source_dir
|
|
120
130
|
plugins = plugins.to_a if plugins.equal?(DEFAULT_PLUGINS)
|
|
121
131
|
@plugins = plugins
|
|
@@ -223,7 +223,11 @@ module Klenod
|
|
|
223
223
|
:failed
|
|
224
224
|
)
|
|
225
225
|
)
|
|
226
|
-
|
|
226
|
+
# Only an evaluated module needs the placeholder, so demand raises the
|
|
227
|
+
# error instead of serving stale exports. The failed record already
|
|
228
|
+
# covers a collected-only module, and a placeholder would make the
|
|
229
|
+
# next update treat it as evaluated and run its code.
|
|
230
|
+
mods[module_id] = FailedModule.new(error) if mods.key?(module_id)
|
|
227
231
|
end
|
|
228
232
|
|
|
229
233
|
def diff_assets(previous_assets, current_assets)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "date"
|
|
3
4
|
require "json"
|
|
4
5
|
require "toml-rb"
|
|
5
6
|
require "yaml"
|
|
@@ -63,9 +64,42 @@ module Klenod
|
|
|
63
64
|
|
|
64
65
|
def module_source(data)
|
|
65
66
|
<<~RUBY
|
|
66
|
-
Default = #{data
|
|
67
|
+
Default = #{ruby_literal(data)}
|
|
67
68
|
RUBY
|
|
68
69
|
end
|
|
70
|
+
|
|
71
|
+
# `inspect` is not Ruby source for every parsed value: dates, times,
|
|
72
|
+
# and non-finite floats need constructor calls instead.
|
|
73
|
+
def ruby_literal(value)
|
|
74
|
+
case value
|
|
75
|
+
when Hash
|
|
76
|
+
entries = value.map { |key, entry| "#{ruby_literal(key)} => #{ruby_literal(entry)}" }
|
|
77
|
+
"{#{entries.join(", ")}}"
|
|
78
|
+
when Array
|
|
79
|
+
"[#{value.map { ruby_literal(it) }.join(", ")}]"
|
|
80
|
+
when Float
|
|
81
|
+
float_literal(value)
|
|
82
|
+
when Time
|
|
83
|
+
zone = value.utc? ? "UTC" : value.utc_offset
|
|
84
|
+
"::Time.at(#{value.to_i}, #{value.nsec}, :nsec, in: #{zone.inspect})"
|
|
85
|
+
when Date
|
|
86
|
+
"::Date.new(#{value.year}, #{value.month}, #{value.day})"
|
|
87
|
+
when nil, true, false, String, Symbol, Integer
|
|
88
|
+
value.inspect
|
|
89
|
+
else
|
|
90
|
+
raise TypeError, "Cannot write #{value.class} as data module source"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def float_literal(value)
|
|
95
|
+
if value.nan?
|
|
96
|
+
"::Float::NAN"
|
|
97
|
+
elsif value.infinite?
|
|
98
|
+
value.positive? ? "::Float::INFINITY" : "-::Float::INFINITY"
|
|
99
|
+
else
|
|
100
|
+
value.inspect
|
|
101
|
+
end
|
|
102
|
+
end
|
|
69
103
|
end
|
|
70
104
|
end
|
|
71
105
|
|
|
@@ -155,8 +189,8 @@ module Klenod
|
|
|
155
189
|
end
|
|
156
190
|
|
|
157
191
|
class ParseError < Klenod::Build::SourceError
|
|
158
|
-
# "
|
|
159
|
-
LOCATION =
|
|
192
|
+
# "Unexpected \"\\n\" at line 2, column 10: expected a value"
|
|
193
|
+
LOCATION = / at line (?<line>\d+), column (?<column>\d+)/
|
|
160
194
|
|
|
161
195
|
def kind
|
|
162
196
|
"TOML parse error"
|
|
@@ -165,16 +199,16 @@ module Klenod
|
|
|
165
199
|
private
|
|
166
200
|
|
|
167
201
|
def location(error)
|
|
202
|
+
# Invalid values such as "Invalid date: 1979-13-01" carry no location.
|
|
168
203
|
found = LOCATION.match(error.message)
|
|
169
204
|
return nil unless found
|
|
170
205
|
|
|
171
|
-
#
|
|
172
|
-
#
|
|
206
|
+
# One-based. The location is rendered as the title and the caret, so
|
|
207
|
+
# drop the copy the parser puts in its message.
|
|
173
208
|
Location.new(
|
|
174
209
|
line: found[:line].to_i,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
detail: "Could not parse TOML"
|
|
210
|
+
column: found[:column].to_i,
|
|
211
|
+
detail: error.message.sub(LOCATION, "")
|
|
178
212
|
)
|
|
179
213
|
end
|
|
180
214
|
end
|
|
@@ -186,7 +220,26 @@ module Klenod
|
|
|
186
220
|
private
|
|
187
221
|
|
|
188
222
|
def parse(code)
|
|
189
|
-
TomlRB.parse(code)
|
|
223
|
+
plain_values(TomlRB.parse(code))
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# toml-rb returns its own Time subclasses for local values. Exports
|
|
227
|
+
# and bundles should not depend on toml-rb, so a local date becomes a
|
|
228
|
+
# Date, as in YAML, and a local datetime or time becomes a UTC Time
|
|
229
|
+
# with the same clock time. A local time falls on 1970-01-01.
|
|
230
|
+
def plain_values(value)
|
|
231
|
+
case value
|
|
232
|
+
when Hash
|
|
233
|
+
value.transform_values { plain_values(it) }
|
|
234
|
+
when Array
|
|
235
|
+
value.map { plain_values(it) }
|
|
236
|
+
when TomlRB::LocalDate
|
|
237
|
+
Date.new(value.year, value.month, value.day)
|
|
238
|
+
when TomlRB::LocalDateTime, TomlRB::LocalTime
|
|
239
|
+
Time.at(value, in: "UTC")
|
|
240
|
+
else
|
|
241
|
+
value
|
|
242
|
+
end
|
|
190
243
|
end
|
|
191
244
|
end
|
|
192
245
|
end
|
|
@@ -494,6 +494,9 @@ module Klenod
|
|
|
494
494
|
kind, prefix, pattern = VARIABLE_TOKEN_KINDS[type]
|
|
495
495
|
receiver = @variables[kind]
|
|
496
496
|
next unless receiver
|
|
497
|
+
# `:@name` names the variable rather than reading it, as in
|
|
498
|
+
# `instance_variable_get(:@name)`.
|
|
499
|
+
next if tokens[index - 1]&.fetch(1) == :on_symbeg
|
|
497
500
|
|
|
498
501
|
# Parenthesize the receiver so a low-precedence expression
|
|
499
502
|
# such as `a || b` stays one operand, e.g. in `$*.fetch(:x)`.
|
data/lib/klenod/build/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: klenod-build
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.30
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrés Alin
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.0.
|
|
18
|
+
version: 0.0.30
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.0.
|
|
25
|
+
version: 0.0.30
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: async
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -217,14 +217,14 @@ dependencies:
|
|
|
217
217
|
requirements:
|
|
218
218
|
- - "~>"
|
|
219
219
|
- !ruby/object:Gem::Version
|
|
220
|
-
version: '
|
|
220
|
+
version: '6.0'
|
|
221
221
|
type: :runtime
|
|
222
222
|
prerelease: false
|
|
223
223
|
version_requirements: !ruby/object:Gem::Requirement
|
|
224
224
|
requirements:
|
|
225
225
|
- - "~>"
|
|
226
226
|
- !ruby/object:Gem::Version
|
|
227
|
-
version: '
|
|
227
|
+
version: '6.0'
|
|
228
228
|
- !ruby/object:Gem::Dependency
|
|
229
229
|
name: tsort
|
|
230
230
|
requirement: !ruby/object:Gem::Requirement
|