1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
|
use strict;
use lib -e 't' ? 't' : 'test';
# This tests the slides I used for YAPC 2002
use TestYAML tests => 28;
run_load_passes();
__DATA__
===
+++ yaml
YAML design goals:
- YAML documents are very readable by humans.
- YAML interacts well with scripting languages.
- YAML uses host languages native data structures.
- YAML has a consistent information model.
- YAML enables stream-based processing.
- YAML is expressive and extensible.
- YAML is easy to implement.
===
+++ yaml
---
scripting languages:
- Perl
- Python
- C
- Java
standards:
- RFC0822 (MAIL)
- RFC1866 (HTML)
- RFC2045 (MIME)
- RFC2396 (URI)
others:
- SOAP
- XML
- SAX
===
+++ yaml
---
name: Benjamin
rank: Private
serial number: 1234567890
12:34 PM: My favorite time
===
+++ yaml
---
- red
- white
- blue
- pinko
===
+++ yaml
---
Fruits:
- Apples
- Tomatoes
Veggies:
- Spinach
- Broccoli
Meats:
- Burgers
- Shrimp
Household:
- Candles
- Incense
- Toilet Duck
===
+++ yaml
---
-
- 3
- 5
- 7
-
- 0
- 0
- 7
-
- 9
- 1
- 1
===
+++ yaml
- Intro
-
Part 1:
- Up
- Down
- Side to Side
- Part 2:
- Here
- There
- Underwear
- Part 3:
- The Good
- The Bad
- The Ingy
===
+++ yaml
## comment before document
#--- #DIRECTIVE # comment
#foo: bar # inline comment
#
#phone: number #555-1234
# ### Comment
#fact: fiction
#---
#blue: bird
## Comment
===
+++ yaml
---
simple: look ma, no quotes
quoted:
- 'Single quoted. Like Perl, no escapes'
- "Double quotes.\nLike Perl, has escapes"
- |
A YAML block scalar.
Much like Perl's
here-document.
===
+++ yaml
#---
#simple key: simple value
#this value: can span multiple lines
# but the key cannot. it would need quotes
#stuff:
# - foo
# - 42
# - 3.14
# - 192.168.2.98
# - m/^(.*)\//
===
+++ yaml
#---
#'contains: colon': '$19.99'
#or: ' value has leading/trailing whitespace '
#'key spans
#lines': 'double ticks \ for ''escaping'''
===
+++ yaml
#---
#The spec says: "The double quoted style variant adds escaping to the 'single quoted' style variant."
#
#like this: "null->\z newline->\n bell->\a
#smiley->\u263a"
#
#self escape: "Brian \"Ingy\" Ingerson"
===
+++ yaml
---
what is this: |
is it: a YAML mapping
or just: a string
chomp me: |-
sub foo {
print "Love me do!";
}
===
+++ yaml
--- #YAML:1.0
old doc: |
--- #YAML:1.0
tools:
- XML
- XSLT
new doc: |
--- #YAML:1.0
tools:
- YAML
- cYATL
===
+++ yaml
---
- >
Copyright © 2001 Brian Ingerson, Clark
Evans & Oren Ben-Kiki, all rights
reserved. This document may be freely
copied provided that it is not modified.
Next paragraph.
- foo
===
+++ yaml
---
The YAML Specification starts out by saying: >
YAML(tm) (rhymes with "camel") is a straightforward
machine parsable data serialization format designed
for human readability and interaction with
scripting languages such as Perl and Python.
YAML documents are very readable by humans.
YAML interacts well with scripting languages.
YAML uses host languages' native data structures.
Please join us, the mailing list is at SourceForge.
===
+++ yaml
---
? >+
Even a key can:
1) Be Folded
2) Have Wiki
: cool, eh?
===
+++ yaml
---
Hey Jude: &chorus
- na, na, na,
- &4 na, na, na, na,
- *4
- Hey Jude.
- *chorus
===
+++ yaml
headerless: first document
--- #YAML:1.0 #TAB:NONE
--- >
folded top level scalar
--- &1
recurse: *1
---
- simple header
===
+++ yaml
#---
#seq: [ 14, 34, 55 ]
#map: {purple: rain, blue: skies}
#mixed: {sizes: [9, 11], shapes: [round]}
#span: {players: [who, what, I don't know],
# positions: [first, second, third]}
===
+++ yaml
## Inline sequences make data more compact
#---
#- [3, 5, 7]
#- [0, 0, 7]
#- [9, 1, 1]
#
## Above is equal to below
#--- [[3, 5, 7], [0, 0, 7], [9, 1, 1]]
#
## A 3D Matrix
#---
#- [[3, 5, 7], [0, 0, 7], [9, 1, 1]]
#- [[0, 0, 7], [9, 1, 1], [3, 5, 7]]
#- [[9, 1, 1], [3, 5, 7], [0, 0, 7]]
===
+++ yaml
---
?
- Kane
- Kudra
: engaged
[Damian, Dominus]: engaging
===
+++ yaml
#same:
# - 42
# - !int 42
# - !yaml.org/int 42
# - !http://yaml.org/int 42
#perl:
# - !perl/Foo::Bar {}
# - !perl.yaml.org/Foo::Bar {}
# - !http://perl.yaml.org/Foo::Bar {}
===
+++ yaml
#---
#- 42 # integer
#- -3.14 # floating point
#- 6.02e+23 # scientific notation
#- 0xCAFEBABE # hexadecimal int
#- 2001-09-11 # ISO8601 time
#- '2001-09-11' # string
#- + # boolean true
#- (false) # alternate boolean
#- ~ # null (undef in Perl)
#- 123 Main St # string
===
+++ yaml
#---
#- !str YAML, YAML, YAML!
#- !int 42
#- !float 0.707
#- !time 2001-12-14T21:59:43.10-05:00
#- !bool 1
#- !null 0
#- !binary MWYNG84BwwEeECcgggoBADs=
===
+++ yaml
#---
#- !perl/Foo::Bar {} # hash-based class
#- !perl/@Foo::Bar [] # array-based class
#- !perl/$Foo::Bar '' # scalar-based class
#- !perl/glob: # typeglob
#- !perl/code: # code reference
#- !perl/ref: # hard reference
#- !perl/regexp: # regular expression
#- !perl/regexp:Foo::Bar # blessed regexp
===
+++ yaml
--- #YAML:1.0
NAME: AddressEntry
HASH:
- NAME: Name
HASH:
- NAME: First
- NAME: Last
OPTIONAL: yes
- NAME: EmailAddresses
ARRAY: yes
- NAME: Phone
ARRAY: yes
HASH:
- NAME: Type
OPTIONAL: yes
- NAME: Number
===
+++ yaml
--- #YAML:1.0
AddressEntry:
Name:
First: Brian
EmailAddresses:
- ingy@CPAN.org
- ingy@ttul.org
Phone:
- Type: Work
Number: 604-333-4567
- Number: 843-444-5678
|