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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6664c0bc3baf20513dd6d0ed532aa5c76ea4abcb9b9bfede49339ba39d640229
4
- data.tar.gz: abd4ef6d17e0156aee54f49c7a238ac8c1086f75eabbb3e555b47482e6f38461
3
+ metadata.gz: f5a138b2fbec6a865ad645184fc2955f9caea83a9133c9e6142c438c7bf2337b
4
+ data.tar.gz: 07ceebe0608ecabecaae9b3c8967dbe5e99db8221445a4eae7da5194682b6e32
5
5
  SHA512:
6
- metadata.gz: b409889a4046742e044c659be7706b938f22f3e346f4ff26d046d0e01511f576889c90868936465ad66fca974b33e120745f5954b95dbed9559dcd4f0bca9034
7
- data.tar.gz: 5025f7dfc9334411badfa20a81f74e4db920e85f9ea95d30acabf2e9e14b9a2fb2278bdae46567a623158390252d2891c08da5b190e7905cd2beccad341eb3b7
6
+ metadata.gz: 7714362e5f36f7cc6f891be9cf343ac48a7cdf74043a2a9615b87e62526c84ec00e1150e61989e14d63eadba687a36acb1668efa02a8686ca4123ad09a4ec303
7
+ data.tar.gz: 38ee653f878f77821a2b8ff9cd3c0cd2856c70b60c7564248b2ab4f4026eed8b94cf27598d129febd6ac0cb9711d6615c018c7f8ee6fad97e6ff742a191e511b
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.1.5
4
+
5
+ The guard asks whether date, stringio and strscan are linked, not how the
6
+ encoding table looks; 0.1.4 refuses on builder 0.13.0's `minimal`. Refuses on
7
+ `full` with the fix.
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.** Each file shadows a real library by its
24
- name, and `date.rb` is a stub. So every file refuses to load anywhere but a
25
- `minimal` canister, raising `LoadError`. A `minimal` canister is one where the
26
- builder's wrapper gem has defined `IC::DATA_DIR` and the core registered no
27
- alias for any encoding (`Encoding.name_list.size == Encoding.list.size`).
28
- Observed on PocketIC with the 0.6.0 Base Module (28 October 2026): twelve
29
- encodings, the core's built-in table, and no alias, which is why
30
- `# encoding: binary` traps there. MRI and the `full` Build register aliases,
31
- so it refuses there too: carry none of it on `full`.
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
- This repository is the gem's source. The
59
- [ruby_wasm_builder](https://gitlab.com/phrug/ruby_wasm_builder) suite tests the
60
- published gem (its `spec/gems/`): the guard on MRI, the stand-ins traced
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. A stand-in shadows a real library by its name (`date`, `stringio`,
3
- # `strscan`), and `date.rb` here is a stub, so loading one anywhere but a
4
- # `minimal` canister would quietly take the real library away. The guard
5
- # refuses that instead, with LoadError. Since 0.1.3 the stand-ins also sit
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
- # A `minimal` canister is one where the wrapper gem has defined IC::DATA_DIR
10
- # (every canister packed by ruby_wasm_builder) and the core registered no
11
- # alias for any encoding: `Encoding.name_list` is exactly `Encoding.list`'s
12
- # names. Observed on PocketIC 16.0.0 with the 0.6.0 Base Module (28 October
13
- # 2026): twelve encodings, the core's built-in table, and twelve names, no
14
- # alias among them, which is why `# encoding: binary` traps there. MRI, and a
15
- # Build that links the encoding database (`full`), register aliases (BINARY,
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
- # It counts names rather than looking for Encoding::UTF_8, which this gem's
22
- # own encoding_constants.rb defines, and defining a constant adds no name.
23
- # Decided once, at the first stand-in loaded, and kept in
24
- # RubyWasmIcMinimal::ON_MINIMAL; a test harness may set that constant first
25
- # (ruby_wasm_builder's MRI player does, for `minimal: true`).
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
- ON_MINIMAL = !defined?(IC::DATA_DIR).nil? && Encoding.name_list.size == Encoding.list.size
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
- # Only these three: there is no transcoding to any other (ADR-0053).
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyWasmIcMinimal
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
@@ -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 `minimal`
10
- # canister this file, and each stand-in, raises LoadError (see
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 "encoding_constants"
21
- require "stringio"
22
- require "strscan"
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.3
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: 2026-10-28 00:00:00.000000000 Z
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: 3.5.11
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