ruby_wasm_ic_minimal 0.1.3 → 0.1.5
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/CHANGELOG.md +7 -0
- data/README.md +31 -19
- data/lib/ruby_wasm_ic_minimal/guard.rb +53 -23
- data/lib/ruby_wasm_ic_minimal/standins/encoding_constants.rb +2 -1
- data/lib/ruby_wasm_ic_minimal/version.rb +1 -1
- data/lib/ruby_wasm_ic_minimal.rb +6 -9
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5a138b2fbec6a865ad645184fc2955f9caea83a9133c9e6142c438c7bf2337b
|
|
4
|
+
data.tar.gz: 07ceebe0608ecabecaae9b3c8967dbe5e99db8221445a4eae7da5194682b6e32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7714362e5f36f7cc6f891be9cf343ac48a7cdf74043a2a9615b87e62526c84ec00e1150e61989e14d63eadba687a36acb1668efa02a8686ca4123ad09a4ec303
|
|
7
|
+
data.tar.gz: 38ee653f878f77821a2b8ff9cd3c0cd2856c70b60c7564248b2ab4f4026eed8b94cf27598d129febd6ac0cb9711d6615c018c7f8ee6fad97e6ff742a191e511b
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
|
@@ -20,15 +20,25 @@ formats and reads HTTP dates, which need nothing from `Date`; `Time.parse`,
|
|
|
20
20
|
|
|
21
21
|
## Only in a `minimal` canister
|
|
22
22
|
|
|
23
|
-
**Do not put this gem in a Gemfile
|
|
24
|
-
name, and `date.rb` is a stub. So
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
**Do not put this gem in a Gemfile on `full`.** Each file shadows a real
|
|
24
|
+
library by its name, and `date.rb` is a stub. So the gem refuses to load,
|
|
25
|
+
raising `LoadError`, unless both hold:
|
|
26
|
+
|
|
27
|
+
1. it is a canister: the builder's wrapper gem has defined `IC::DATA_DIR`;
|
|
28
|
+
2. none of `stringio`, `strscan` and `date` is linked. Before defining
|
|
29
|
+
anything the gem tries `require` on each, with its own stand-ins left off
|
|
30
|
+
`$LOAD_PATH`. If any loads, it refuses and names it. One real and two
|
|
31
|
+
missing is a refusal too: a real extension is never mixed with stand-ins
|
|
32
|
+
for its neighbours.
|
|
33
|
+
|
|
34
|
+
**On `full`, remove this gem** (from your Gemfile): all three are real there,
|
|
35
|
+
and the error says so. On `minimal` all three raise `LoadError` and the gem
|
|
36
|
+
loads. Supported: ruby_wasm_builder 0.7.0 through 0.13.0's `minimal`. (0.1.4
|
|
37
|
+
and earlier counted encoding aliases instead, and refuse on 0.13.0's
|
|
38
|
+
`minimal`, which links the encoding database.)
|
|
39
|
+
|
|
40
|
+
The Encoding constants are defined only where missing: before 0.13.0, the
|
|
41
|
+
Encoding constants; from 0.13.0 `minimal` has them and they are untouched.
|
|
32
42
|
|
|
33
43
|
## Carrying it
|
|
34
44
|
|
|
@@ -55,17 +65,21 @@ in a `minimal` canister. After it, Rack's own `require "strscan"` and `time`'s
|
|
|
55
65
|
|
|
56
66
|
## Development
|
|
57
67
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
against CRuby's C extensions, and the 0.7.0 `roda_on_minimal` Script played as
|
|
62
|
-
`minimal` with this gem in place of the Challenge's own `carried/` files. To
|
|
63
|
-
release: bump `lib/ruby_wasm_ic_minimal/version.rb`, then `gem build
|
|
64
|
-
ruby_wasm_ic_minimal.gemspec` and check `gem spec ruby_wasm_ic_minimal-*.gem
|
|
65
|
-
files` lists the lib files before `gem push`.
|
|
68
|
+
`ruby test/guard_test.rb` runs this repository's own tests of the guard, on
|
|
69
|
+
MRI with plain Ruby. More comprehensive testing is done on this gem's primary consumer:
|
|
70
|
+
[ruby_wasm_builder](https://gitlab.com/phrug/ruby_wasm_builder) (in `spec/gems/`): the guard on MRI
|
|
66
71
|
|
|
67
72
|
## Changes
|
|
68
73
|
|
|
74
|
+
- **0.1.5:** the guard asks whether `date`, `stringio` and `strscan` are
|
|
75
|
+
linked, not how the encoding table looks; 0.1.4 refuses on builder
|
|
76
|
+
0.13.0's `minimal`. Refuses on `full` with the fix. **Use 0.1.5 or later.**
|
|
77
|
+
- **0.1.4:** the guard leaves the pseudo-names `locale`, `external`,
|
|
78
|
+
`filesystem` and `internal` out of its count. 0.1.3 counted them, so it
|
|
79
|
+
refused a canister where `Encoding.default_external` had been set before
|
|
80
|
+
the first stand-in loaded (as an Application or Rails may do), and it
|
|
81
|
+
refuses every canister of ruby_wasm_builder's 0.9.0, whose Base Module sets
|
|
82
|
+
it at boot. **Use 0.1.4 or later.**
|
|
69
83
|
- **0.1.3:** the stand-ins moved under `lib/ruby_wasm_ic_minimal/standins/`,
|
|
70
84
|
put on `$LOAD_PATH` by `require "ruby_wasm_ic_minimal"`, so a Gemfile that
|
|
71
85
|
lists the gem shadows nothing; the guard's rule is "no aliases". **Use
|
|
@@ -73,7 +87,5 @@ files` lists the lib files before `gem push`.
|
|
|
73
87
|
`require "stringio"` on MRI finds the stand-in and raises.
|
|
74
88
|
- **0.1.2:** the guard asks for `ISO-8859-1` by name, and loads on a
|
|
75
89
|
`minimal` canister. The stand-ins are still at the top of `lib/`.
|
|
76
|
-
- **0.1.1:** the first release with files.
|
|
77
|
-
- **0.1.0:** published empty (no `spec.files`).
|
|
78
90
|
|
|
79
91
|
MIT licensed.
|
|
@@ -1,31 +1,60 @@
|
|
|
1
1
|
# The guard the entry file and every stand-in in ruby_wasm_ic_minimal require
|
|
2
|
-
# first.
|
|
3
|
-
#
|
|
4
|
-
# `
|
|
5
|
-
#
|
|
6
|
-
# outside lib/ proper (ruby_wasm_ic_minimal/standins/), so they shadow nothing
|
|
7
|
-
# unless that directory is put on $LOAD_PATH; the guard is the second line.
|
|
2
|
+
# first. The stand-ins replace `date`, `stringio` and `strscan`. They are right
|
|
3
|
+
# where those C extensions are not linked, and wrong (they shadow the real
|
|
4
|
+
# ones, and `date.rb` is a stub) where they are. So the guard asks that
|
|
5
|
+
# question, in two steps, and raises LoadError if either answer is no:
|
|
8
6
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
# ASCII, CP65001, ...) and the pseudo-names `locale`, `external` and
|
|
17
|
-
# `filesystem`, so their name list is longer. 0.1.1 counted `Encoding.list`
|
|
18
|
-
# against 3 and refused on every canister; 0.1.2 asked for `ISO-8859-1` by
|
|
19
|
-
# name, which held on a canister too.
|
|
7
|
+
# 1. Is this a canister? The wrapper gem has defined IC::DATA_DIR (every
|
|
8
|
+
# canister packed by ruby_wasm_builder).
|
|
9
|
+
# 2. Is any of the three extensions real? Each is `require`d, with this gem's
|
|
10
|
+
# standins directory taken off $LOAD_PATH for the moment so that the
|
|
11
|
+
# require can only find the real thing. If any loads, the guard refuses,
|
|
12
|
+
# naming it: partial presence is a refusal too, never a real extension
|
|
13
|
+
# beside stand-ins for its neighbours.
|
|
20
14
|
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
15
|
+
# On ruby_wasm_builder 0.13.0, `full` links all three (refused); `minimal`
|
|
16
|
+
# links none (loads). Before 0.1.5 the guard counted encoding aliases, which
|
|
17
|
+
# held on `minimal` until 0.13.0 linked the encoding database into it.
|
|
18
|
+
#
|
|
19
|
+
# Decided once, at the first load, and kept in RubyWasmIcMinimal::ON_MINIMAL;
|
|
20
|
+
# a test harness may set that constant first (ruby_wasm_builder's MRI player
|
|
21
|
+
# does, for `minimal: true`).
|
|
26
22
|
module RubyWasmIcMinimal
|
|
23
|
+
STANDINS = File.join(__dir__, "standins")
|
|
24
|
+
PROBED = %w[stringio strscan date].freeze
|
|
25
|
+
|
|
26
|
+
# The libraries among PROBED that a `require` finds, without this gem's own.
|
|
27
|
+
def self.real_extensions
|
|
28
|
+
saved = $LOAD_PATH.dup
|
|
29
|
+
$LOAD_PATH.delete(STANDINS)
|
|
30
|
+
begin
|
|
31
|
+
PROBED.select do |lib|
|
|
32
|
+
begin
|
|
33
|
+
require lib
|
|
34
|
+
true
|
|
35
|
+
rescue LoadError
|
|
36
|
+
false
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
ensure
|
|
40
|
+
$LOAD_PATH.replace(saved)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# nil when this is a canister without the real extensions, else the reason.
|
|
45
|
+
def self.refusal
|
|
46
|
+
return "ruby_wasm_ic_minimal is only for a minimal canister, and this is not one" if defined?(IC::DATA_DIR).nil?
|
|
47
|
+
|
|
48
|
+
real = real_extensions
|
|
49
|
+
return nil if real.empty?
|
|
50
|
+
|
|
51
|
+
"ruby_wasm_ic_minimal: this Base Module links #{real.join(', ')} (it is `full`, or a later `minimal`); " \
|
|
52
|
+
"the stand-ins would shadow them. Remove ruby_wasm_ic_minimal from your Gemfile."
|
|
53
|
+
end
|
|
54
|
+
|
|
27
55
|
unless const_defined?(:ON_MINIMAL, false)
|
|
28
|
-
|
|
56
|
+
REFUSAL = refusal
|
|
57
|
+
ON_MINIMAL = REFUSAL.nil?
|
|
29
58
|
end
|
|
30
59
|
|
|
31
60
|
# `feature` is the library a stand-in stands in for, or nil for the entry
|
|
@@ -33,6 +62,7 @@ module RubyWasmIcMinimal
|
|
|
33
62
|
def self.guard!(feature = nil)
|
|
34
63
|
return if ON_MINIMAL
|
|
35
64
|
|
|
65
|
+
raise LoadError, REFUSAL if defined?(REFUSAL) && REFUSAL
|
|
36
66
|
raise LoadError, "ruby_wasm_ic_minimal is only for a minimal canister, and this is not one" unless feature
|
|
37
67
|
|
|
38
68
|
raise LoadError, "ruby_wasm_ic_minimal's #{feature}.rb stands in for #{feature} only in a minimal canister, " \
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
# Encoding::UTF_8 to decode every query parameter, and `cgi/util` names it as
|
|
5
5
|
# it loads. Each is found here from a literal, without naming a constant:
|
|
6
6
|
# a "\u" escape is always UTF-8, a Symbol's text US-ASCII, String#b binary.
|
|
7
|
-
#
|
|
7
|
+
# Not needed from builder 0.13.0, whose `minimal` has the constants; each is
|
|
8
|
+
# defined only where missing. Only these three: there is no transcoding to any other (ADR-0053).
|
|
8
9
|
require_relative "../guard"
|
|
9
10
|
RubyWasmIcMinimal.guard!("encoding_constants")
|
|
10
11
|
class Encoding
|
data/lib/ruby_wasm_ic_minimal.rb
CHANGED
|
@@ -6,18 +6,15 @@
|
|
|
6
6
|
# first on $LOAD_PATH and loads all four, so Rack's own `require "strscan"`
|
|
7
7
|
# and `time`'s `require "date"` find them by their libraries' names. They live
|
|
8
8
|
# in a directory of their own, not in lib/, so a Gemfile or `gem install` that
|
|
9
|
-
# puts lib/ on $LOAD_PATH shadows nothing (0.1.3). Anywhere but a
|
|
10
|
-
#
|
|
9
|
+
# puts lib/ on $LOAD_PATH shadows nothing (0.1.3). Anywhere but a canister
|
|
10
|
+
# that links none of date, stringio and strscan, this file, and each stand-in,
|
|
11
|
+
# raises LoadError (see
|
|
11
12
|
# ruby_wasm_ic_minimal/guard.rb).
|
|
12
13
|
require_relative "ruby_wasm_ic_minimal/version"
|
|
13
14
|
require_relative "ruby_wasm_ic_minimal/guard"
|
|
14
15
|
RubyWasmIcMinimal.guard!
|
|
15
16
|
|
|
16
|
-
module RubyWasmIcMinimal
|
|
17
|
-
STANDINS = File.join(__dir__, "ruby_wasm_ic_minimal", "standins")
|
|
18
|
-
end
|
|
19
17
|
$LOAD_PATH.unshift(RubyWasmIcMinimal::STANDINS) unless $LOAD_PATH.include?(RubyWasmIcMinimal::STANDINS)
|
|
20
|
-
require "
|
|
21
|
-
|
|
22
|
-
require
|
|
23
|
-
require "date"
|
|
18
|
+
# Loaded by path, so a later `require "stringio"` finds the loaded file on
|
|
19
|
+
# $LOAD_PATH and is a no-op.
|
|
20
|
+
%w[encoding_constants stringio strscan date].each { |f| require File.join(RubyWasmIcMinimal::STANDINS, f) }
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_wasm_ic_minimal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- graial
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: This gem contains the four carried files required for running rack and
|
|
14
13
|
roda on the minimal ruby.wasm build.
|
|
@@ -18,6 +17,7 @@ executables: []
|
|
|
18
17
|
extensions: []
|
|
19
18
|
extra_rdoc_files: []
|
|
20
19
|
files:
|
|
20
|
+
- CHANGELOG.md
|
|
21
21
|
- LICENSE
|
|
22
22
|
- README.md
|
|
23
23
|
- lib/ruby_wasm_ic_minimal.rb
|
|
@@ -31,7 +31,6 @@ homepage: https://github.com/graial/ruby_wasm_ic_minimal
|
|
|
31
31
|
licenses:
|
|
32
32
|
- MIT
|
|
33
33
|
metadata: {}
|
|
34
|
-
post_install_message:
|
|
35
34
|
rdoc_options: []
|
|
36
35
|
require_paths:
|
|
37
36
|
- lib
|
|
@@ -46,8 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
46
|
version: '0'
|
|
48
47
|
requirements: []
|
|
49
|
-
rubygems_version:
|
|
50
|
-
signing_key:
|
|
48
|
+
rubygems_version: 4.0.23
|
|
51
49
|
specification_version: 4
|
|
52
50
|
summary: Four carried files required for running rack and roda on the minimal ruby.wasm
|
|
53
51
|
build
|