Can we please get a "raw" loader?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với YAML.load, safe_load và entry point được đề xuất Psych.set_parse_mode, sau đó so sánh hai ví dụ YAML trong issue. Xác định các quy tắc chuyển đổi của raw mode và cách nó phải khác với native-object mode; được xem là hoàn tất khi đầu ra hash-tree được yêu cầu đã được đặc tả và được bao phủ bởi các bài kiểm thử triển khai.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
There are times when we need to load a YAML file but for various reasons, we do not want or care about the serialization/native dataclass conversions. We want to load the data in as a hash-tree object, as if the object classifier were not there.
Now it seems to me based on the long discussion related to the safe_load method, that safe_load does not, in fact, do what is requested here. It seems to me that several sane voices were a bit shuoted down in that discussion. But whatever.
What is needed is essentially to load YAML files as if they were dumb JSON files. As if the following code were implemented before the #load
yamltext = File.read("somefile","r")
yamltext.sub!(/^--- \!.*$/,'---')
purehash = YAML.load(yamltext)
Given the following YAML:
--- !ruby/object:Some::Custom::Type::User::Has::No::Gem::For
node: "string"
array:
- "string"
- unquoted text
- "12.5"
- 12.5
- subarray:
option: true
nottrue: "false"
We get back from #load:
{"node"=>"string", "array"=>["string", "unquoted text", "12.5", 12.5, {"subarray"=>{"option"=>true, "nottrue"=>"false"}}]}
I propose an implementation that is cleaner, that uses YAML.load() but based on the parser-personality. The personalities might be a kind of a "raw" mode and "native-object" mode. Raw mode only sees Hash, Array, String. Native-object mode also sees numeric, boolean (and..?)
Psych.set_parse_mode(:native_object_conversion)
purehash=YAML.load(yamltext)
Produces the inspected output, above. Whereas:
Psych.set_parse_mode(:no_object_conversion)
purehash=YAML.load(yamltext)
produces (subtly different):
{"node"=>"string", "array"=>["string", "unquoted text", "12.5", "12.5", {"subarray"=>{"option"=>"true", "nottrue"=>"false"}}]}
- Ngôn ngữ chính
- Ruby
- Star
- 597
- Fork
- 223
- Merge trung bình
- 14 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ruby/psych
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
-
Psych.dump raises Encoding::CompatibilityError for UTF-16/UTF-32 stringsCó thể đã có người làm @Halvanhelv đã nhận 31 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
scanaislop/aislop#476 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Dependencies view: `getParent` loops forever on untitled documents, extension host runs out of memoryCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/web interface
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
mastodon/mastodon#41000 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
zerocracy/judges-action#2743 ·
Maintainer thường phản hồi trong vòng 8 ngày
-
Deno Runtime is discontinuedĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
endoflife-date/endoflife.date#11314 ·
Maintainer thường phản hồi trong vòng 1 ngày