CodeSampleX

示例

ostruct 0.6.3: Work out which stdlib libraries Ruby 3.4 actually forces into the Gemfile and fix the LoadError, without OpenStruct silently overwriting a method a data key collides with

已验证示例 — gem ostruct 0.6.3: Work out which stdlib libraries Ruby 3.4 actually forces into the Gemfile and fix the LoadError, without OpenStruct silently…

sha256:7a622d8fbf61d9ccea9796f655d24afc226f861f933bc616c92ec7ee61ee448a

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 ruby 3 linux x64 ruby 3 ruby bundler

验证运行环境

环境 契约 阶段 运行日期
ruby 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · gem@1
2026-08-14

案例

FIX
目标
Work out which stdlib libraries Ruby 3.4 actually forces into the Gemfile and fix the LoadError, without OpenStruct silently overwriting a method a data key collides with
符号
  • Gem::BUNDLED_GEMS::SINCE
  • OpenStruct
  • OpenStruct#[]
  • OpenStruct#to_h
  • Set
  • Set#include?
  • Abbrev.abbrev
环境
ruby 3
创建时间
2026-08-14T20:29:58Z

契约

  1. assert Ruby's own Gem::BUNDLED_GEMS::SINCE table puts abbrev, observer and drb in the 3.4.0 wave, ostruct, benchmark and logger in the 4.0.0 wave, and set on no wave at all
  2. assert a library from the wave that already landed raises LoadError naming it unless the Gemfile declares it, while the declared one loads and lands its Array monkeypatch
  3. assert Ruby emits the add-it-to-your-Gemfile notice through Warning.warn and still raises the LoadError in the same run
  4. assert a library from the next wave loads without a Gemfile entry but warns about 4.0.0, and stays absent from the resolved bundle
  5. assert declaring a default gem is a real version pin, because the interpreter's own copy still exists and the Gemfile decides which one runs
  6. assert Set resolves through the bundle by autoload, with no require anywhere
  7. assert an OpenStruct key overwrites the method it collides with, so class returns the data, method stops taking an argument, and only [] and to_h read safely
  8. assert OpenStruct overwrites __send__ too, warning that this may cause serious problems, and then refuses an argument
  9. assert a missing OpenStruct key reads as nil through both accessors while to_h.fetch raises KeyError
  10. assert Set dedupes by eql? rather than ==, loses a member mutated after insertion, and has no rehash to repair the index

文件

  • Gemfile
  • Gemfile.lock
  • csx.json
  • test/contract.rb

下载源代码构件 (tar.gz)

原始种子者

anonymous