[英]Inconsistent wrapping of quotes in to_yaml
在下面的示例中,您可以看到 header 和第 1 节和第 11 节已作为普通值放入 yaml 中,但第 2 节和第 8 节已用单引号括起来。 这似乎发生在to_yaml
阶段,因为在 hash 中一切看起来都不错。 (我不是简单地加载 yaml 并将其转换回来,这只是为了简化示例)
我试过看看是否有任何特殊字符会引起混淆,但没有任何运气。 例如,在单词vehicle's
有一个卷曲撇号而不是一个直撇号'
,但在所有部分都可以找到。 isn't
in section 2 有直撇号。 我尝试在不同的部分系统地添加/删除每种类型的撇号,看看这是否会产生任何影响,但它没有
en:
contract:
terms_and_conditions:
FF:
company: Foo Foo SA
spain_checkin_company: Foo Foo Spain SLR
title: Rental Agreement
header: "This Rental Agreement regulates the rental conditions between Foo Foo, hereinafter referred to as the Rental
Firm, and the client, identified by a valid driving license, hereinafter referred to as the Hirer, and it is ruled by all the
general and special conditions described in this agreement, unless there is any written derogation or alteration."
column_1:
section_1:
title: 1. Vehicle conditions
text: "1) The customer acknowledges having received the Vehicle and rented extras in a clean condition and with all the features working. 2) The customer will return the vehicle in a clean condition, with the same amount of fuel at the pick-up, and with all the vehicle’s features operating in a normal way, on the return date, time and location established in the Rental Agreement. Failure to meet these criteria will result in additional charges to the Hirer according to the rental firm price table. Any loss or damage in rented extras, equipment or spare parts, will be fully charged to the Hirer according to the Rental Firm price table."
section_2:
title: 2. Documents
text: "A valid vehicle driver’s license, ID or Passport and credit card (Visa or Mastercard) are required and must be presented upon the vehicle’s collection and signing of the rental agreement. If the Hirer does not bring the necessary documents, the vehicle cannot be rented and regular no show fee will apply. 2) To hold a valid license to drive in Europe is the responsibility of the Hirer 3) The Hirer should be older than 18 years old. 4) If the Hirer is under 25 years of age, purchasing the Standard Insurance plan is mandatory, and he/she isn't allowed to purchase the Basic or Full Insurance plan when renting a vehicle.
5) The credit card owner must be present at the vehicle´s collection.
"
column_2:
section_8:
title: 8. Accident / Vehicle Damage
text: "In the event of an accident or vehicle damage, the Hirer agrees to the following procedures: 1) Immediately notify the Rental Firm and police authorities of any accident, theft, robbery or other misfortune. 2) Take pictures and obtain names and addresses of all persons involved as well as witnesses, that can document what happened 3) Fill the accident report, together with other vehicles that may be involved. 4) Shall not leave the vehicle without taking all measures regarding its protection and . 5) Shall not take any responsibility or pled guilty, in the event of an accident that might hold the Rental Firm liable 6) Collect the accident report signed by all parties involved and the documents prepared by the police authorities, along with the vehicle keys, if retained (in case of vehicle theft) and send it immediately to the Rental firm. Otherwise, all insurances and coverage’s will expire, and the Hirer is liable for all expenses."
section_11:
title: 11. Liability / Security Deposit and After Rental Payments
text: "1) The security deposit can only be paid by credit card (Visa or Mastercard), and the credit card owner must be present at the pick-up. At the vehicle delivery, the Hirer is required to pay the security deposit according to the chosen Insurance option. This amount will be held in the Hirer’s credit card to ensure the excess payment in the event of robbery or accident and any other vehicle damage during the rental period. 2) If the security deposit amount is not authorized by the bank or by the credit card owner, the contract cannot be executed and the vehicle cannot be delivered. In this case, the regular cancelation policy will apply and the full booking amount will be charged to the Hirer. The security deposit will be returned to the Hirer at the end of the rental period, after an inspection by a Rental Firm member staff, who shall state the vehicle is in similar conditions compared to when it was collected. 3) Vehicle damage and equipment/extras damage costs will be charged according to the Rental Firm price table. The Hirer will also be liable for the days not rented during the vehicle reasonable repair time, according to the damages at issue. 4) In case of an accident where the Hirer does not consider himself responsible, the Rental Firm will hold the full amount of the security deposit until the insurance company states the responsibility. 5) If the damage repair costs cannot be determined immediately, the Rental Firm will hold the full amount of the security deposit. A portion of the excess can be refunded in case the final damage repair costs are lower than the amount paid. 6) The Hirer agrees that the Rental Firm is authorized to charge the credit card on file for any further amounts that may arise such as wild camping, parking tickets, fines, traffic offence penalties, tolls, damages to the van (interior or exterior) and overdue amounts. Rental Firm is entitled to verify any of the damages to the van for 30 days after the last day of the rental agreement. In the event of a fine, the Rental Firm will always attempt to forward the fine to the Hirer. On these cases, a 25€ administrative fee will be charged by the Rental Firm. In the event that it is not possible to forward the fine to the Hirer, the Rental Firm will process the fine and charge to the Hirer the total cost of the fine plus VAT and an added administrative fee of 50€. 7) Hirer must provide the Rental Firm with an alternative credit card that can be used to meet Hirer’s obligations under the Rental Firm Terms and Conditions, in case of insufficient funds, declined transactions for any reason, and cancelled or suspended credit card. 8) All unpaid invoices will be added interest, which is the highest legal rate plus a flat fee, corresponding to 20% of the unpaid amount and any compensation for occurred damages / lost profits due by law. In the event of a legal dispute somehow related with this contract, the parties agree that the jurisdiction of the pick-up location will be applied."
foo = YAML.load(File.read("#{@PATH}foo.yml"))
=> {"en"=>
{"contract"=>
{"terms_and_conditions"=>
{"FF"=>
{"company"=>"Foo Foo SA",
"spain_checkin_company"=>"Foo Foo Spain SLR",
"title"=>"Rental Agreement",
"header"=>
"This Rental Agreement regulates the rental conditions between Foo Foo, hereinafter referred to as the Rental Firm, and the client, identified by a valid driving license, hereinafter referred to as the Hirer, and it is ruled by all the general and special conditions described in this agreement, unless there is any written derogation or alteration.",
"column_1"=>
{"section_1"=>
{"title"=>"1. Vehicle conditions",
"text"=>
"1) The customer acknowledges having received the Vehicle and rented extras in a clean condition and with all the features working. 2) The customer will return the vehicle in a clean condition, with the same amount of fuel at the pick-up, and with all the vehicle’s features operating in a normal way, on the return date, time and location established in the Rental Agreement. Failure to meet these criteria will result in additional charges to the Hirer according to the rental firm price table. Any loss or damage in rented extras, equipment or spare parts, will be fully charged to the Hirer according to the Rental Firm price table."},
"section_2"=>
{"title"=>"2. Documents",
"text"=>
"A valid vehicle driver’s license, ID or Passport and credit card (Visa or Mastercard) are required and must be presented upon the vehicle’s collection and signing of the rental agreement. If the Hirer does not bring the necessary documents, the vehicle cannot be rented and regular no show fee will apply. 2) To hold a valid license to drive in Europe is the responsibility of the Hirer 3) The Hirer should be older than 18 years old. 4) If the Hirer is under 25 years of age, purchasing the Standard Insurance plan is mandatory, and he/she isn't allowed to purchase the Basic or Full Insurance plan when renting a vehicle. 5) The credit card owner must be present at the vehicle´s collection. "}},
"column_2"=>
{"section_8"=>
{"title"=>"8. Accident / Vehicle Damage",
"text"=>
"In the event of an accident or vehicle damage, the Hirer agrees to the following procedures: 1) Immediately notify the Rental Firm and police authorities of any accident, theft, robbery or other misfortune. 2) Take pictures and obtain names and addresses of all persons involved as well as witnesses, that can document what happened 3) Fill the accident report, together with other vehicles that may be involved. 4) Shall not leave the vehicle without taking all measures regarding its protection and . 5) Shall not take any responsibility or pled guilty, in the event of an accident that might hold the Rental Firm liable 6) Collect the accident report signed by all parties involved and the documents prepared by the police authorities, along with the vehicle keys, if retained (in case of vehicle theft) and send it immediately to the Rental firm. Otherwise, all insurances and coverage’s will expire, and the Hirer is liable for all expenses."},
"section_11"=>
{"title"=>"11. Liability / Security Deposit and After Rental Payments",
"text"=>
"1) The security deposit can only be paid by credit card (Visa or Mastercard), and the credit card owner must be present at the pick-up. At the vehicle delivery, the Hirer is required to pay the security deposit according to the chosen Insurance option. This amount will be held in the Hirer’s credit card to ensure the excess payment in the event of robbery or accident and any other vehicle damage during the rental period. 2) If the security deposit amount is not authorized by the bank or by the credit card owner, the contract cannot be executed and the vehicle cannot be delivered. In this case, the regular cancelation policy will apply and the full booking amount will be charged to the Hirer. The security deposit will be returned to the Hirer at the end of the rental period, after an inspection by a Rental Firm member staff, who shall state the vehicle is in similar conditions compared to when it was collected. 3) Vehicle damage and equipment/extras damage costs will be charged according to the Rental Firm price table. The Hirer will also be liable for the days not rented during the vehicle reasonable repair time, according to the damages at issue. 4) In case of an accident where the Hirer does not consider himself responsible, the Rental Firm will hold the full amount of the security deposit until the insurance company states the responsibility. 5) If the damage repair costs cannot be determined immediately, the Rental Firm will hold the full amount of the security deposit. A portion of the excess can be refunded in case the final damage repair costs are lower than the amount paid. 6) The Hirer agrees that the Rental Firm is authorized to charge the credit card on file for any further amounts that may arise such as wild camping, parking tickets, fines, traffic offence penalties, tolls, damages to the van (interior or exterior) and overdue amounts. Rental Firm is entitled to verify any of the damages to the van for 30 days after the last day of the rental agreement. In the event of a fine, the Rental Firm will always attempt to forward the fine to the Hirer. On these cases, a 25€ administrative fee will be charged by the Rental Firm. In the event that it is not possible to forward the fine to the Hirer, the Rental Firm will process the fine and charge to the Hirer the total cost of the fine plus VAT and an added administrative fee of 50€. 7) Hirer must provide the Rental Firm with an alternative credit card that can be used to meet Hirer’s obligations under the Rental Firm Terms and Conditions, in case of insufficient funds, declined transactions for any reason, and cancelled or suspended credit card. 8) All unpaid invoices will be added interest, which is the highest legal rate plus a flat fee, corresponding to 20% of the unpaid amount and any compensation for occurred damages / lost profits due by law. In the event of a legal dispute somehow related with this contract, the parties agree that the jurisdiction of the pick-up location will be applied."}}}}}}}
File.open("#{@PATH}foo.yml", "w") do |f|
YAML.dump(foo,f)
end
(也使用f.puts foo.to_yaml
)具有相同的结果
en:
contract:
terms_and_conditions:
FF:
company: Foo Foo SA
spain_checkin_company: Foo Foo Spain SLR
title: Rental Agreement
header: This Rental Agreement regulates the rental conditions between Foo
Foo, hereinafter referred to as the Rental Firm, and the client, identified
by a valid driving license, hereinafter referred to as the Hirer, and it
is ruled by all the general and special conditions described in this agreement,
unless there is any written derogation or alteration.
column_1:
section_1:
title: 1. Vehicle conditions
text: 1) The customer acknowledges having received the Vehicle and rented
extras in a clean condition and with all the features working. 2) The
customer will return the vehicle in a clean condition, with the same
amount of fuel at the pick-up, and with all the vehicle’s features operating
in a normal way, on the return date, time and location established in
the Rental Agreement. Failure to meet these criteria will result in
additional charges to the Hirer according to the rental firm price table.
Any loss or damage in rented extras, equipment or spare parts, will
be fully charged to the Hirer according to the Rental Firm price table.
section_2:
title: 2. Documents
text: 'A valid vehicle driver’s license, ID or Passport and credit card
(Visa or Mastercard) are required and must be presented upon the vehicle’s
collection and signing of the rental agreement. If the Hirer does not
bring the necessary documents, the vehicle cannot be rented and regular
no show fee will apply. 2) To hold a valid license to drive in Europe
is the responsibility of the Hirer 3) The Hirer should be older than
18 years old. 4) If the Hirer is under 25 years of age, purchasing the
Standard Insurance plan is mandatory, and he/she isn''t allowed to purchase
the Basic or Full Insurance plan when renting a vehicle. 5) The credit
card owner must be present at the vehicle´s collection. '
column_2:
section_8:
title: 8. Accident / Vehicle Damage
text: 'In the event of an accident or vehicle damage, the Hirer agrees
to the following procedures: 1) Immediately notify the Rental Firm and
police authorities of any accident, theft, robbery or other misfortune.
2) Take pictures and obtain names and addresses of all persons involved
as well as witnesses, that can document what happened 3) Fill the accident
report, together with other vehicles that may be involved. 4) Shall
not leave the vehicle without taking all measures regarding its protection
and . 5) Shall not take any responsibility or pled guilty, in the event
of an accident that might hold the Rental Firm liable 6) Collect the
accident report signed by all parties involved and the documents prepared
by the police authorities, along with the vehicle keys, if retained
(in case of vehicle theft) and send it immediately to the Rental firm.
Otherwise, all insurances and coverage’s will expire, and the Hirer
is liable for all expenses.'
section_11:
title: 11. Liability / Security Deposit and After Rental Payments
text: 1) The security deposit can only be paid by credit card (Visa or
Mastercard), and the credit card owner must be present at the pick-up.
At the vehicle delivery, the Hirer is required to pay the security deposit
according to the chosen Insurance option. This amount will be held in
the Hirer’s credit card to ensure the excess payment in the event of
robbery or accident and any other vehicle damage during the rental period.
2) If the security deposit amount is not authorized by the bank or by
the credit card owner, the contract cannot be executed and the vehicle
cannot be delivered. In this case, the regular cancelation policy will
apply and the full booking amount will be charged to the Hirer. The
security deposit will be returned to the Hirer at the end of the rental
period, after an inspection by a Rental Firm member staff, who shall
state the vehicle is in similar conditions compared to when it was collected.
3) Vehicle damage and equipment/extras damage costs will be charged
according to the Rental Firm price table. The Hirer will also be liable
for the days not rented during the vehicle reasonable repair time, according
to the damages at issue. 4) In case of an accident where the Hirer does
not consider himself responsible, the Rental Firm will hold the full
amount of the security deposit until the insurance company states the
responsibility. 5) If the damage repair costs cannot be determined immediately,
the Rental Firm will hold the full amount of the security deposit. A
portion of the excess can be refunded in case the final damage repair
costs are lower than the amount paid. 6) The Hirer agrees that the Rental
Firm is authorized to charge the credit card on file for any further
amounts that may arise such as wild camping, parking tickets, fines,
traffic offence penalties, tolls, damages to the van (interior or exterior)
and overdue amounts. Rental Firm is entitled to verify any of the damages
to the van for 30 days after the last day of the rental agreement. In
the event of a fine, the Rental Firm will always attempt to forward
the fine to the Hirer. On these cases, a 25€ administrative fee will
be charged by the Rental Firm. In the event that it is not possible
to forward the fine to the Hirer, the Rental Firm will process the fine
and charge to the Hirer the total cost of the fine plus VAT and an added
administrative fee of 50€. 7) Hirer must provide the Rental Firm with
an alternative credit card that can be used to meet Hirer’s obligations
under the Rental Firm Terms and Conditions, in case of insufficient
funds, declined transactions for any reason, and cancelled or suspended
credit card. 8) All unpaid invoices will be added interest, which is
the highest legal rate plus a flat fee, corresponding to 20% of the
unpaid amount and any compensation for occurred damages / lost profits
due by law. In the event of a legal dispute somehow related with this
contract, the parties agree that the jurisdiction of the pick-up location
will be applied.
:
字符,后跟一个空格。规范说:
普通(未加引号)样式没有识别指示符,也没有提供 escaping 的形式。 因此,它是最易读、最有限和最上下文敏感的风格。 除了受限字符集之外,纯标量不得为空,也不得包含前导或尾随空白字符。 只能在空格字符被非空格包围的地方打断一条长的平线。
...
纯标量绝不能包含“:”和“#”字符组合。 这样的组合会导致映射键的歧义:值对和注释。 此外,在流 collections 内部,或用作隐式键时,纯标量不得包含“[”、“]”、“{”、“}”和“,”字符。 这些字符会导致流集合结构的歧义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.