rdfa_parser 0.1.0
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.
- data/.gitignore +7 -0
- data/History.txt +47 -0
- data/README.rdoc +61 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/bin/rdfa_parser +55 -0
- data/lib/rdfa_parser.rb +35 -0
- data/lib/rdfa_parser/bnode.rb +92 -0
- data/lib/rdfa_parser/exceptions.rb +11 -0
- data/lib/rdfa_parser/graph.rb +222 -0
- data/lib/rdfa_parser/literal.rb +375 -0
- data/lib/rdfa_parser/namespace.rb +91 -0
- data/lib/rdfa_parser/rdfa_parser.rb +415 -0
- data/lib/rdfa_parser/triple.rb +100 -0
- data/lib/rdfa_parser/uriref.rb +94 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/bnode_spec.rb +51 -0
- data/spec/graph_spec.rb +230 -0
- data/spec/literal_spec.rb +282 -0
- data/spec/matchers.rb +134 -0
- data/spec/namespace_spec.rb +61 -0
- data/spec/rdfa_helper.rb +127 -0
- data/spec/rdfa_parser_spec.rb +119 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/triple_spec.rb +145 -0
- data/spec/uriref_spec.rb +117 -0
- data/spec/xhtml1-testcases/.sparql +13 -0
- data/spec/xhtml1-testcases/0001.nt +1 -0
- data/spec/xhtml1-testcases/0001.sparql +3 -0
- data/spec/xhtml1-testcases/0001.xhtml +11 -0
- data/spec/xhtml1-testcases/0002.sparql +3 -0
- data/spec/xhtml1-testcases/0003.sparql +3 -0
- data/spec/xhtml1-testcases/0006.nt +2 -0
- data/spec/xhtml1-testcases/0006.sparql +8 -0
- data/spec/xhtml1-testcases/0006.xhtml +16 -0
- data/spec/xhtml1-testcases/0007.nt +3 -0
- data/spec/xhtml1-testcases/0007.sparql +5 -0
- data/spec/xhtml1-testcases/0007.xhtml +16 -0
- data/spec/xhtml1-testcases/0008.nt +1 -0
- data/spec/xhtml1-testcases/0008.sparql +3 -0
- data/spec/xhtml1-testcases/0008.xhtml +16 -0
- data/spec/xhtml1-testcases/0009.nt +1 -0
- data/spec/xhtml1-testcases/0009.sparql +3 -0
- data/spec/xhtml1-testcases/0009.xhtml +14 -0
- data/spec/xhtml1-testcases/0010.nt +2 -0
- data/spec/xhtml1-testcases/0010.sparql +4 -0
- data/spec/xhtml1-testcases/0010.xhtml +13 -0
- data/spec/xhtml1-testcases/0011.nt +3 -0
- data/spec/xhtml1-testcases/0011.sparql +17 -0
- data/spec/xhtml1-testcases/0011.xhtml +14 -0
- data/spec/xhtml1-testcases/0012.nt +1 -0
- data/spec/xhtml1-testcases/0012.sparql +3 -0
- data/spec/xhtml1-testcases/0012.xhtml +12 -0
- data/spec/xhtml1-testcases/0013.nt +1 -0
- data/spec/xhtml1-testcases/0013.sparql +3 -0
- data/spec/xhtml1-testcases/0013.xhtml +12 -0
- data/spec/xhtml1-testcases/0014.nt +1 -0
- data/spec/xhtml1-testcases/0014.sparql +3 -0
- data/spec/xhtml1-testcases/0014.xhtml +15 -0
- data/spec/xhtml1-testcases/0015.nt +2 -0
- data/spec/xhtml1-testcases/0015.sparql +4 -0
- data/spec/xhtml1-testcases/0015.xhtml +13 -0
- data/spec/xhtml1-testcases/0017.nt +3 -0
- data/spec/xhtml1-testcases/0017.sparql +6 -0
- data/spec/xhtml1-testcases/0017.xhtml +16 -0
- data/spec/xhtml1-testcases/0018.nt +1 -0
- data/spec/xhtml1-testcases/0018.sparql +3 -0
- data/spec/xhtml1-testcases/0018.xhtml +17 -0
- data/spec/xhtml1-testcases/0019.nt +1 -0
- data/spec/xhtml1-testcases/0019.sparql +3 -0
- data/spec/xhtml1-testcases/0019.xhtml +14 -0
- data/spec/xhtml1-testcases/0020.nt +1 -0
- data/spec/xhtml1-testcases/0020.sparql +3 -0
- data/spec/xhtml1-testcases/0020.xhtml +17 -0
- data/spec/xhtml1-testcases/0021.nt +1 -0
- data/spec/xhtml1-testcases/0021.sparql +3 -0
- data/spec/xhtml1-testcases/0021.xhtml +17 -0
- data/spec/xhtml1-testcases/0023.nt +1 -0
- data/spec/xhtml1-testcases/0023.sparql +3 -0
- data/spec/xhtml1-testcases/0023.xhtml +16 -0
- data/spec/xhtml1-testcases/0025.nt +2 -0
- data/spec/xhtml1-testcases/0025.sparql +4 -0
- data/spec/xhtml1-testcases/0025.xhtml +19 -0
- data/spec/xhtml1-testcases/0026.nt +1 -0
- data/spec/xhtml1-testcases/0026.sparql +3 -0
- data/spec/xhtml1-testcases/0026.xhtml +16 -0
- data/spec/xhtml1-testcases/0027.nt +1 -0
- data/spec/xhtml1-testcases/0027.sparql +3 -0
- data/spec/xhtml1-testcases/0027.xhtml +17 -0
- data/spec/xhtml1-testcases/0029.nt +1 -0
- data/spec/xhtml1-testcases/0029.sparql +3 -0
- data/spec/xhtml1-testcases/0029.xhtml +17 -0
- data/spec/xhtml1-testcases/0030.nt +1 -0
- data/spec/xhtml1-testcases/0030.sparql +3 -0
- data/spec/xhtml1-testcases/0030.xhtml +16 -0
- data/spec/xhtml1-testcases/0031.nt +1 -0
- data/spec/xhtml1-testcases/0031.sparql +3 -0
- data/spec/xhtml1-testcases/0031.xhtml +14 -0
- data/spec/xhtml1-testcases/0032.nt +1 -0
- data/spec/xhtml1-testcases/0032.sparql +3 -0
- data/spec/xhtml1-testcases/0032.xhtml +15 -0
- data/spec/xhtml1-testcases/0033.nt +2 -0
- data/spec/xhtml1-testcases/0033.sparql +5 -0
- data/spec/xhtml1-testcases/0033.xhtml +19 -0
- data/spec/xhtml1-testcases/0034.nt +1 -0
- data/spec/xhtml1-testcases/0034.sparql +3 -0
- data/spec/xhtml1-testcases/0034.xhtml +14 -0
- data/spec/xhtml1-testcases/0035.nt +1 -0
- data/spec/xhtml1-testcases/0035.sparql +3 -0
- data/spec/xhtml1-testcases/0035.xhtml +17 -0
- data/spec/xhtml1-testcases/0036.nt +1 -0
- data/spec/xhtml1-testcases/0036.sparql +3 -0
- data/spec/xhtml1-testcases/0036.xhtml +17 -0
- data/spec/xhtml1-testcases/0037.nt +1 -0
- data/spec/xhtml1-testcases/0037.sparql +3 -0
- data/spec/xhtml1-testcases/0037.xhtml +18 -0
- data/spec/xhtml1-testcases/0038.nt +1 -0
- data/spec/xhtml1-testcases/0038.sparql +3 -0
- data/spec/xhtml1-testcases/0038.xhtml +14 -0
- data/spec/xhtml1-testcases/0039.nt +1 -0
- data/spec/xhtml1-testcases/0039.sparql +3 -0
- data/spec/xhtml1-testcases/0039.xhtml +17 -0
- data/spec/xhtml1-testcases/0040.nt +1 -0
- data/spec/xhtml1-testcases/0040.sparql +3 -0
- data/spec/xhtml1-testcases/0040.xhtml +16 -0
- data/spec/xhtml1-testcases/0041.nt +1 -0
- data/spec/xhtml1-testcases/0041.sparql +3 -0
- data/spec/xhtml1-testcases/0041.xhtml +18 -0
- data/spec/xhtml1-testcases/0042.nt +0 -0
- data/spec/xhtml1-testcases/0042.sparql +4 -0
- data/spec/xhtml1-testcases/0042.xhtml +15 -0
- data/spec/xhtml1-testcases/0046.nt +3 -0
- data/spec/xhtml1-testcases/0046.sparql +6 -0
- data/spec/xhtml1-testcases/0046.xhtml +13 -0
- data/spec/xhtml1-testcases/0047.nt +3 -0
- data/spec/xhtml1-testcases/0047.sparql +6 -0
- data/spec/xhtml1-testcases/0047.xhtml +13 -0
- data/spec/xhtml1-testcases/0048.nt +3 -0
- data/spec/xhtml1-testcases/0048.sparql +6 -0
- data/spec/xhtml1-testcases/0048.xhtml +14 -0
- data/spec/xhtml1-testcases/0049.nt +2 -0
- data/spec/xhtml1-testcases/0049.sparql +4 -0
- data/spec/xhtml1-testcases/0049.xhtml +14 -0
- data/spec/xhtml1-testcases/0050.nt +2 -0
- data/spec/xhtml1-testcases/0050.sparql +5 -0
- data/spec/xhtml1-testcases/0050.xhtml +14 -0
- data/spec/xhtml1-testcases/0051.nt +2 -0
- data/spec/xhtml1-testcases/0051.sparql +4 -0
- data/spec/xhtml1-testcases/0051.xhtml +12 -0
- data/spec/xhtml1-testcases/0052.nt +1 -0
- data/spec/xhtml1-testcases/0052.sparql +3 -0
- data/spec/xhtml1-testcases/0052.xhtml +13 -0
- data/spec/xhtml1-testcases/0053.nt +2 -0
- data/spec/xhtml1-testcases/0053.sparql +4 -0
- data/spec/xhtml1-testcases/0053.xhtml +13 -0
- data/spec/xhtml1-testcases/0054.nt +2 -0
- data/spec/xhtml1-testcases/0054.sparql +4 -0
- data/spec/xhtml1-testcases/0054.xhtml +14 -0
- data/spec/xhtml1-testcases/0055.nt +2 -0
- data/spec/xhtml1-testcases/0055.sparql +4 -0
- data/spec/xhtml1-testcases/0055.xhtml +16 -0
- data/spec/xhtml1-testcases/0056.nt +3 -0
- data/spec/xhtml1-testcases/0056.sparql +5 -0
- data/spec/xhtml1-testcases/0056.xhtml +13 -0
- data/spec/xhtml1-testcases/0057.nt +4 -0
- data/spec/xhtml1-testcases/0057.sparql +6 -0
- data/spec/xhtml1-testcases/0057.xhtml +14 -0
- data/spec/xhtml1-testcases/0058.nt +6 -0
- data/spec/xhtml1-testcases/0058.sparql +9 -0
- data/spec/xhtml1-testcases/0058.xhtml +14 -0
- data/spec/xhtml1-testcases/0059.nt +6 -0
- data/spec/xhtml1-testcases/0059.sparql +8 -0
- data/spec/xhtml1-testcases/0059.xhtml +16 -0
- data/spec/xhtml1-testcases/0060.nt +2 -0
- data/spec/xhtml1-testcases/0060.sparql +4 -0
- data/spec/xhtml1-testcases/0060.xhtml +14 -0
- data/spec/xhtml1-testcases/0061.nt +1 -0
- data/spec/xhtml1-testcases/0061.sparql +3 -0
- data/spec/xhtml1-testcases/0061.xhtml +11 -0
- data/spec/xhtml1-testcases/0062.nt +1 -0
- data/spec/xhtml1-testcases/0062.sparql +3 -0
- data/spec/xhtml1-testcases/0062.xhtml +12 -0
- data/spec/xhtml1-testcases/0063.nt +1 -0
- data/spec/xhtml1-testcases/0063.sparql +3 -0
- data/spec/xhtml1-testcases/0063.xhtml +11 -0
- data/spec/xhtml1-testcases/0064.nt +1 -0
- data/spec/xhtml1-testcases/0064.sparql +4 -0
- data/spec/xhtml1-testcases/0064.xhtml +13 -0
- data/spec/xhtml1-testcases/0065.nt +3 -0
- data/spec/xhtml1-testcases/0065.sparql +6 -0
- data/spec/xhtml1-testcases/0065.xhtml +22 -0
- data/spec/xhtml1-testcases/0066.nt +1 -0
- data/spec/xhtml1-testcases/0066.sparql +3 -0
- data/spec/xhtml1-testcases/0066.xhtml +11 -0
- data/spec/xhtml1-testcases/0067.nt +1 -0
- data/spec/xhtml1-testcases/0067.sparql +3 -0
- data/spec/xhtml1-testcases/0067.xhtml +11 -0
- data/spec/xhtml1-testcases/0068.nt +1 -0
- data/spec/xhtml1-testcases/0068.sparql +3 -0
- data/spec/xhtml1-testcases/0068.xhtml +14 -0
- data/spec/xhtml1-testcases/0069.nt +1 -0
- data/spec/xhtml1-testcases/0069.sparql +3 -0
- data/spec/xhtml1-testcases/0069.xhtml +14 -0
- data/spec/xhtml1-testcases/0070.nt +1 -0
- data/spec/xhtml1-testcases/0070.sparql +3 -0
- data/spec/xhtml1-testcases/0070.xhtml +13 -0
- data/spec/xhtml1-testcases/0071.nt +1 -0
- data/spec/xhtml1-testcases/0071.sparql +3 -0
- data/spec/xhtml1-testcases/0071.xhtml +16 -0
- data/spec/xhtml1-testcases/0072.nt +1 -0
- data/spec/xhtml1-testcases/0072.sparql +3 -0
- data/spec/xhtml1-testcases/0072.xhtml +16 -0
- data/spec/xhtml1-testcases/0073.nt +1 -0
- data/spec/xhtml1-testcases/0073.sparql +3 -0
- data/spec/xhtml1-testcases/0073.xhtml +16 -0
- data/spec/xhtml1-testcases/0074.nt +1 -0
- data/spec/xhtml1-testcases/0074.sparql +3 -0
- data/spec/xhtml1-testcases/0074.xhtml +16 -0
- data/spec/xhtml1-testcases/0075.nt +1 -0
- data/spec/xhtml1-testcases/0075.sparql +3 -0
- data/spec/xhtml1-testcases/0075.xhtml +16 -0
- data/spec/xhtml1-testcases/0076.nt +23 -0
- data/spec/xhtml1-testcases/0076.sparql +70 -0
- data/spec/xhtml1-testcases/0076.xhtml +35 -0
- data/spec/xhtml1-testcases/0077.nt +23 -0
- data/spec/xhtml1-testcases/0077.sparql +70 -0
- data/spec/xhtml1-testcases/0077.xhtml +58 -0
- data/spec/xhtml1-testcases/0078.nt +6 -0
- data/spec/xhtml1-testcases/0078.sparql +7 -0
- data/spec/xhtml1-testcases/0078.xhtml +15 -0
- data/spec/xhtml1-testcases/0079.nt +3 -0
- data/spec/xhtml1-testcases/0079.sparql +6 -0
- data/spec/xhtml1-testcases/0079.xhtml +15 -0
- data/spec/xhtml1-testcases/0080.nt +1 -0
- data/spec/xhtml1-testcases/0080.sparql +3 -0
- data/spec/xhtml1-testcases/0080.xhtml +13 -0
- data/spec/xhtml1-testcases/0081.nt +6 -0
- data/spec/xhtml1-testcases/0081.sparql +9 -0
- data/spec/xhtml1-testcases/0081.xhtml +15 -0
- data/spec/xhtml1-testcases/0082.nt +8 -0
- data/spec/xhtml1-testcases/0082.sparql +11 -0
- data/spec/xhtml1-testcases/0082.xhtml +15 -0
- data/spec/xhtml1-testcases/0083.nt +6 -0
- data/spec/xhtml1-testcases/0083.sparql +9 -0
- data/spec/xhtml1-testcases/0083.xhtml +15 -0
- data/spec/xhtml1-testcases/0084.nt +8 -0
- data/spec/xhtml1-testcases/0084.sparql +11 -0
- data/spec/xhtml1-testcases/0084.xhtml +18 -0
- data/spec/xhtml1-testcases/0085.nt +4 -0
- data/spec/xhtml1-testcases/0085.sparql +6 -0
- data/spec/xhtml1-testcases/0085.xhtml +17 -0
- data/spec/xhtml1-testcases/0086.nt +0 -0
- data/spec/xhtml1-testcases/0086.sparql +4 -0
- data/spec/xhtml1-testcases/0086.xhtml +13 -0
- data/spec/xhtml1-testcases/0087.nt +23 -0
- data/spec/xhtml1-testcases/0087.sparql +70 -0
- data/spec/xhtml1-testcases/0087.xhtml +35 -0
- data/spec/xhtml1-testcases/0088.nt +3 -0
- data/spec/xhtml1-testcases/0088.sparql +6 -0
- data/spec/xhtml1-testcases/0088.xhtml +14 -0
- data/spec/xhtml1-testcases/0089.nt +1 -0
- data/spec/xhtml1-testcases/0089.sparql +3 -0
- data/spec/xhtml1-testcases/0089.xhtml +13 -0
- data/spec/xhtml1-testcases/0090.nt +1 -0
- data/spec/xhtml1-testcases/0090.sparql +3 -0
- data/spec/xhtml1-testcases/0090.xhtml +16 -0
- data/spec/xhtml1-testcases/0091.nt +3 -0
- data/spec/xhtml1-testcases/0091.sparql +6 -0
- data/spec/xhtml1-testcases/0091.xhtml +16 -0
- data/spec/xhtml1-testcases/0092.nt +3 -0
- data/spec/xhtml1-testcases/0092.sparql +16 -0
- data/spec/xhtml1-testcases/0092.xhtml +15 -0
- data/spec/xhtml1-testcases/0093.nt +2 -0
- data/spec/xhtml1-testcases/0093.sparql +4 -0
- data/spec/xhtml1-testcases/0093.xhtml +15 -0
- data/spec/xhtml1-testcases/0094.nt +3 -0
- data/spec/xhtml1-testcases/0094.sparql +16 -0
- data/spec/xhtml1-testcases/0094.xhtml +15 -0
- data/spec/xhtml1-testcases/0099.nt +1 -0
- data/spec/xhtml1-testcases/0099.sparql +3 -0
- data/spec/xhtml1-testcases/0099.xhtml +20 -0
- data/spec/xhtml1-testcases/0100.nt +3 -0
- data/spec/xhtml1-testcases/0100.sparql +15 -0
- data/spec/xhtml1-testcases/0100.xhtml +16 -0
- data/spec/xhtml1-testcases/0101.nt +3 -0
- data/spec/xhtml1-testcases/0101.sparql +15 -0
- data/spec/xhtml1-testcases/0101.xhtml +16 -0
- data/spec/xhtml1-testcases/0102.nt +1 -0
- data/spec/xhtml1-testcases/0102.sparql +15 -0
- data/spec/xhtml1-testcases/0102.xhtml +16 -0
- data/spec/xhtml1-testcases/0103.nt +1 -0
- data/spec/xhtml1-testcases/0103.sparql +15 -0
- data/spec/xhtml1-testcases/0103.xhtml +15 -0
- data/spec/xhtml1-testcases/0104.nt +3 -0
- data/spec/xhtml1-testcases/0104.sparql +5 -0
- data/spec/xhtml1-testcases/0104.xhtml +18 -0
- data/spec/xhtml1-testcases/0105.nt +1 -0
- data/spec/xhtml1-testcases/0105.sparql +7 -0
- data/spec/xhtml1-testcases/0105.xhtml +13 -0
- data/spec/xhtml1-testcases/0106.nt +1 -0
- data/spec/xhtml1-testcases/0106.sparql +7 -0
- data/spec/xhtml1-testcases/0106.xhtml +13 -0
- data/spec/xhtml1-testcases/0107.nt +0 -0
- data/spec/xhtml1-testcases/0107.sparql +4 -0
- data/spec/xhtml1-testcases/0107.xhtml +11 -0
- data/spec/xhtml1-testcases/0108.nt +1 -0
- data/spec/xhtml1-testcases/0108.sparql +3 -0
- data/spec/xhtml1-testcases/0108.xhtml +14 -0
- data/spec/xhtml1-testcases/0109.nt +1 -0
- data/spec/xhtml1-testcases/0109.sparql +3 -0
- data/spec/xhtml1-testcases/0109.xhtml +15 -0
- data/spec/xhtml1-testcases/0110.nt +1 -0
- data/spec/xhtml1-testcases/0110.sparql +4 -0
- data/spec/xhtml1-testcases/0110.xhtml +12 -0
- data/spec/xhtml1-testcases/0111.nt +2 -0
- data/spec/xhtml1-testcases/0111.sparql +5 -0
- data/spec/xhtml1-testcases/0111.xhtml +14 -0
- data/spec/xhtml1-testcases/0112.nt +1 -0
- data/spec/xhtml1-testcases/0112.sparql +3 -0
- data/spec/xhtml1-testcases/0112.xhtml +16 -0
- data/spec/xhtml1-testcases/0113.nt +2 -0
- data/spec/xhtml1-testcases/0113.sparql +4 -0
- data/spec/xhtml1-testcases/0113.xhtml +12 -0
- data/spec/xhtml1-testcases/0114.nt +3 -0
- data/spec/xhtml1-testcases/0114.sparql +5 -0
- data/spec/xhtml1-testcases/0114.xhtml +15 -0
- data/spec/xhtml1-testcases/0115.nt +4 -0
- data/spec/xhtml1-testcases/0115.sparql +14 -0
- data/spec/xhtml1-testcases/0115.xhtml +17 -0
- data/spec/xhtml1-testcases/0116.nt +2 -0
- data/spec/xhtml1-testcases/0116.sparql +6 -0
- data/spec/xhtml1-testcases/0116.xhtml +10 -0
- data/spec/xhtml1-testcases/0117.nt +2 -0
- data/spec/xhtml1-testcases/0117.sparql +4 -0
- data/spec/xhtml1-testcases/0117.xhtml +15 -0
- data/spec/xhtml1-testcases/0118.nt +1 -0
- data/spec/xhtml1-testcases/0118.sparql +5 -0
- data/spec/xhtml1-testcases/0118.xhtml +16 -0
- data/spec/xhtml1-testcases/0119.nt +1 -0
- data/spec/xhtml1-testcases/0119.sparql +5 -0
- data/spec/xhtml1-testcases/0119.xhtml +19 -0
- data/spec/xhtml1-testcases/0120.nt +1 -0
- data/spec/xhtml1-testcases/0120.sparql +5 -0
- data/spec/xhtml1-testcases/0120.xhtml +17 -0
- data/spec/xhtml1-testcases/0121.nt +2 -0
- data/spec/xhtml1-testcases/0121.sparql +4 -0
- data/spec/xhtml1-testcases/0121.xhtml +24 -0
- data/spec/xhtml1-testcases/0122.nt +1 -0
- data/spec/xhtml1-testcases/0122.sparql +4 -0
- data/spec/xhtml1-testcases/0122.xhtml +16 -0
- data/spec/xhtml1-testcases/0123.nt +3 -0
- data/spec/xhtml1-testcases/0123.sparql +5 -0
- data/spec/xhtml1-testcases/0123.xhtml +18 -0
- data/spec/xhtml1-testcases/0124.nt +4 -0
- data/spec/xhtml1-testcases/0124.sparql +6 -0
- data/spec/xhtml1-testcases/0124.xhtml +14 -0
- data/spec/xhtml1-testcases/0125.nt +1 -0
- data/spec/xhtml1-testcases/0125.sparql +5 -0
- data/spec/xhtml1-testcases/0125.xhtml +16 -0
- data/spec/xhtml1-testcases/0126.nt +3 -0
- data/spec/xhtml1-testcases/0126.sparql +5 -0
- data/spec/xhtml1-testcases/0126.xhtml +15 -0
- data/spec/xhtml1-testcases/1001.nt +6 -0
- data/spec/xhtml1-testcases/1001.sparql +8 -0
- data/spec/xhtml1-testcases/1001.xhtml +20 -0
- data/spec/xhtml1-testcases/9999.nt +3 -0
- data/spec/xhtml1-testcases/9999.xhtml +14 -0
- data/spec/xhtml1-testcases/rdfa-xhtml1-test-manifest.rdf +1303 -0
- data/tasks/rspec.rake +21 -0
- metadata +485 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
|
|
3
|
+
module RdfaParser
|
|
4
|
+
class URIRef
|
|
5
|
+
attr_accessor :uri
|
|
6
|
+
|
|
7
|
+
# Create a URIRef from a URI or a fragment and a URI
|
|
8
|
+
#
|
|
9
|
+
# ==== Example
|
|
10
|
+
# u = URIRef.new("http://example.com")
|
|
11
|
+
# u = URIRef.new("foo", u) => "http://example.com/foo"
|
|
12
|
+
#
|
|
13
|
+
def initialize (*args)
|
|
14
|
+
args.each {|s| test_string(s)}
|
|
15
|
+
if args.size == 1
|
|
16
|
+
@uri = Addressable::URI.parse(args[0].to_s)
|
|
17
|
+
else
|
|
18
|
+
@uri = Addressable::URI.join(*args.map{|s| s.to_s}.reverse)
|
|
19
|
+
end
|
|
20
|
+
if @uri.relative?
|
|
21
|
+
raise UriRelativeException, "<" + @uri.to_s + "> is a relative URI"
|
|
22
|
+
end
|
|
23
|
+
if !@uri.to_s.match(/^javascript/).nil?
|
|
24
|
+
raise ParserException, "Javascript pseudo-URIs are not acceptable"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Unique URI through class hash to ensure that URIRefs can be easily compared
|
|
28
|
+
@@uri_hash ||= {}
|
|
29
|
+
@@uri_hash[@uri.to_s] ||= @uri
|
|
30
|
+
@uri = @@uri_hash[@uri.to_s]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def + (input)
|
|
34
|
+
input_uri = Addressable::URI.parse(input.to_s)
|
|
35
|
+
return URIRef.new(input_uri, self.to_s)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def short_name
|
|
39
|
+
if @uri.fragment()
|
|
40
|
+
return @uri.fragment()
|
|
41
|
+
elsif @uri.path.split("/").last.class == String and @uri.path.split("/").last.length > 0
|
|
42
|
+
return @uri.path.split("/").last
|
|
43
|
+
else
|
|
44
|
+
return false
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def eql?(other)
|
|
49
|
+
@uri.to_s == other.to_s
|
|
50
|
+
end
|
|
51
|
+
alias_method :==, :eql?
|
|
52
|
+
|
|
53
|
+
# Needed for uniq
|
|
54
|
+
def hash; to_s.hash; end
|
|
55
|
+
|
|
56
|
+
def to_s
|
|
57
|
+
@uri.to_s
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def to_ntriples
|
|
61
|
+
"<" + @uri.to_s + ">"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Output URI as QName using URI binding
|
|
65
|
+
def to_qname(uri_binding = {})
|
|
66
|
+
uri_base = @uri.to_s
|
|
67
|
+
sn = short_name.to_s
|
|
68
|
+
uri_base = uri_base[0, uri_base.length - sn.length]
|
|
69
|
+
if uri_binding.has_key?(uri_base)
|
|
70
|
+
"#{uri_binding[uri_base]}:#{sn}"
|
|
71
|
+
else
|
|
72
|
+
raise ParserException, "Couldn't find QName for #{@uri}"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Output URI as resource reference for RDF/XML
|
|
77
|
+
def xml_args
|
|
78
|
+
[{"rdf:resource" => @uri.to_s}]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_string (string)
|
|
82
|
+
string.to_s.each_byte do |b|
|
|
83
|
+
if b >= 0 and b <= 31
|
|
84
|
+
raise ParserException, "URI must not contain control characters"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# def load_graph
|
|
90
|
+
# get = Net::HTTP.start(@uri.host, @uri.port) {|http| [:xml, http.get(@uri.path)] }
|
|
91
|
+
# return Reddy::RdfXmlParser.new(get[1].body, @uri.to_s).graph if get[0] == :xml
|
|
92
|
+
# end
|
|
93
|
+
end
|
|
94
|
+
end
|
data/script/console
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# File: script/console
|
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
|
4
|
+
|
|
5
|
+
libs = " -r irb/completion"
|
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/rdfa_parser.rb'}"
|
|
9
|
+
puts "Loading rdfa_parser gem"
|
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/destroy'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/generate'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/bnode_spec.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
|
2
|
+
describe "Blank nodes" do
|
|
3
|
+
describe "which have custom identifiers" do
|
|
4
|
+
subject { BNode.new("foo") }
|
|
5
|
+
|
|
6
|
+
it "should return identifier" do
|
|
7
|
+
subject.identifier.should == "foo"
|
|
8
|
+
subject.to_s.should == "foo"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should be rejected if they are not acceptable" do
|
|
12
|
+
b = BNode.new("4cake")
|
|
13
|
+
b.identifier.should_not == "4cake"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should be expressible in NT syntax" do
|
|
17
|
+
subject.to_ntriples.should == "_:foo"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should be able to determine equality" do
|
|
21
|
+
other = BNode.new(subject.to_s)
|
|
22
|
+
should == other
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should be able to determine inequality" do
|
|
26
|
+
other = URIRef.new('http://somehost.com/wherever.xml')
|
|
27
|
+
should_not == other
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should resource hash for RDF/XML named bnode" do
|
|
31
|
+
subject.xml_args.should == [{"rdf:nodeID" => subject.to_s}]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "which has a blank identifier" do
|
|
36
|
+
subject { BNode.new("") }
|
|
37
|
+
it "should not be the same as an anonymous identifier" do should_not == BNode.new end
|
|
38
|
+
it "should be the same as nother blank identifier" do should == BNode.new("") end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should create a single BNode for a blank identifier" do
|
|
42
|
+
BNode.new("").should_not == BNode
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "which are anonymous" do
|
|
46
|
+
it "should resource hash for RDF/XML anonymous bnode" do
|
|
47
|
+
b = BNode.new
|
|
48
|
+
b.xml_args.should == [{"rdf:nodeID" => b.identifier}]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
data/spec/graph_spec.rb
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Graphs" do
|
|
4
|
+
before(:all) do
|
|
5
|
+
@ex = Namespace.new("http://example.org/", "ex")
|
|
6
|
+
@foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
subject { Graph.new }
|
|
10
|
+
it "should allow you to add one or more triples" do
|
|
11
|
+
lambda do
|
|
12
|
+
subject.add_triple(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new)
|
|
13
|
+
end.should_not raise_error
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should give you a list of resources of a particular type" do
|
|
17
|
+
subject.add_triple(URIRef.new("http://example.org/joe"), URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), URIRef.new("http://xmlns.com/foaf/0.1/Person"))
|
|
18
|
+
subject.add_triple(URIRef.new("http://example.org/jane"), URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), URIRef.new("http://xmlns.com/foaf/0.1/Person"))
|
|
19
|
+
|
|
20
|
+
subject.get_by_type("http://xmlns.com/foaf/0.1/Person").size.should == 2
|
|
21
|
+
subject.get_by_type("http://xmlns.com/foaf/0.1/Person")[0].to_s.should == "http://example.org/joe"
|
|
22
|
+
subject.get_by_type("http://xmlns.com/foaf/0.1/Person")[1].to_s.should == "http://example.org/jane"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should support << as an alias for add_triple" do
|
|
26
|
+
lambda do
|
|
27
|
+
subject << Triple.new(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new)
|
|
28
|
+
end.should_not raise_error
|
|
29
|
+
subject.size.should == 1
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should return bnode subjects" do
|
|
33
|
+
bn = BNode.new
|
|
34
|
+
subject.add_triple bn, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new
|
|
35
|
+
subject.subjects.should == [bn]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should be able to determine whether or not it has existing BNodes" do
|
|
39
|
+
foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf")
|
|
40
|
+
subject << Triple.new(BNode.new('john'), foaf.knows, BNode.new('jane'))
|
|
41
|
+
subject.has_bnode_identifier?('john').should be_true
|
|
42
|
+
subject.has_bnode_identifier?('jane').should be_true
|
|
43
|
+
subject.has_bnode_identifier?('jack').should_not be_true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should be able to return BNodes on demand" do
|
|
47
|
+
john = BNode.new('john')
|
|
48
|
+
jane = BNode.new('jane')
|
|
49
|
+
foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf")
|
|
50
|
+
subject << Triple.new(john, foaf.knows, jane)
|
|
51
|
+
subject.get_bnode_by_identifier('john').should == john
|
|
52
|
+
subject.get_bnode_by_identifier('jane').should == jane
|
|
53
|
+
subject.get_bnode_by_identifier('barny').should == false
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should allow you to create and bind Namespace objects on-the-fly" do
|
|
57
|
+
subject.namespace("http://xmlns.com/foaf/0.1/", "foaf")
|
|
58
|
+
subject.nsbinding["foaf"].uri.should == "http://xmlns.com/foaf/0.1/"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should not allow you to bind things other than namespaces" do
|
|
62
|
+
lambda do
|
|
63
|
+
subject.bind(false)
|
|
64
|
+
end.should raise_error
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should follow the specification as to output identical triples" do
|
|
68
|
+
pending
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "with XML Literal objects" do
|
|
72
|
+
subject {
|
|
73
|
+
dc = Namespace.new("http://purl.org/dc/elements/1.1/", "dc")
|
|
74
|
+
xhtml = Namespace.new("http://www.w3.org/1999/xhtml", "")
|
|
75
|
+
g = Graph.new
|
|
76
|
+
g << Triple.new(
|
|
77
|
+
URIRef.new("http://www.w3.org/2006/07/SWD/RDFa/testsuite/xhtml1-testcases/0011.xhtml"),
|
|
78
|
+
URIRef.new("http://purl.org/dc/elements/1.1/title"),
|
|
79
|
+
Literal.typed("E = mc<sup xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">2</sup>: The Most Urgent Problem of Our Time",
|
|
80
|
+
"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
|
81
|
+
g.nsbinding)
|
|
82
|
+
)
|
|
83
|
+
g.bind(dc)
|
|
84
|
+
g.bind(xhtml)
|
|
85
|
+
g
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
it "should output NTriple" do
|
|
89
|
+
nt = '<http://www.w3.org/2006/07/SWD/RDFa/testsuite/xhtml1-testcases/0011.xhtml> <http://purl.org/dc/elements/1.1/title> "E = mc<sup xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">2</sup>: The Most Urgent Problem of Our Time"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .' + "\n"
|
|
90
|
+
subject.to_ntriples.should == nt
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should output RDF/XML" do
|
|
94
|
+
rdfxml = <<-HERE
|
|
95
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
96
|
+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xhv=\"http://www.w3.org/1999/xhtml/vocab#\">
|
|
97
|
+
<rdf:Description rdf:about="http://www.w3.org/2006/07/SWD/RDFa/testsuite/xhtml1-testcases/0011.xhtml">
|
|
98
|
+
<dc:title rdf:parseType="Literal">E = mc<sup xmlns="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/">2>/sup>: The Most Urgent Problem of Our Time</dc:title>
|
|
99
|
+
</rdf:Description>
|
|
100
|
+
</rdf:RDF>
|
|
101
|
+
HERE
|
|
102
|
+
subject.to_rdfxml.should include("E = mc<sup xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">2</sup>: The Most Urgent Problem of Our Time")
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe "with bnodes" do
|
|
107
|
+
subject {
|
|
108
|
+
a = BNode.new("a")
|
|
109
|
+
b = BNode.new("b")
|
|
110
|
+
|
|
111
|
+
g = Graph.new
|
|
112
|
+
g << Triple.new(a, @foaf.name, Literal.untyped("Manu Sporny"))
|
|
113
|
+
g << Triple.new(a, @foaf.knows, b)
|
|
114
|
+
g << Triple.new(b, @foaf.name, Literal.untyped("Ralph Swick"))
|
|
115
|
+
g.bind(@foaf)
|
|
116
|
+
g
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
it "should output RDF/XML" do
|
|
120
|
+
rdfxml = <<-HERE
|
|
121
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
122
|
+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#">
|
|
123
|
+
<rdf:Description rdf:nodeID="a">
|
|
124
|
+
<foaf:name>Manu Sporny</foaf:name>
|
|
125
|
+
<foaf:knows rdf:nodeID="b"/>
|
|
126
|
+
</rdf:Description>
|
|
127
|
+
<rdf:Description rdf:nodeID="b">
|
|
128
|
+
<foaf:name>Ralph Swick</foaf:name>
|
|
129
|
+
</rdf:Description>
|
|
130
|
+
</rdf:RDF>
|
|
131
|
+
HERE
|
|
132
|
+
xml = subject.to_rdfxml
|
|
133
|
+
xml.should include("Ralph Swick")
|
|
134
|
+
xml.should include("Manu Sporny")
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
describe "with triples" do
|
|
139
|
+
subject {
|
|
140
|
+
g = Graph.new
|
|
141
|
+
g.add_triple(@ex.john, @foaf.knows, @ex.jane)
|
|
142
|
+
g.add_triple(@ex.john, @foaf.knows, @ex.rick)
|
|
143
|
+
g.add_triple(@ex.jane, @foaf.knows, @ex.rick)
|
|
144
|
+
g.bind(@foaf)
|
|
145
|
+
g
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
it "should tell you how large the graph is" do
|
|
149
|
+
subject.size.should == 3
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it "should return unique subjects" do
|
|
153
|
+
subject.subjects.should == [@ex.john.uri.to_s, @ex.jane.uri.to_s]
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it "should allow you to select one resource" do
|
|
157
|
+
subject.get_resource(@ex.john).size.should == 2
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "should allow iteration" do
|
|
161
|
+
count = 0
|
|
162
|
+
subject.each do |t|
|
|
163
|
+
count = count + 1
|
|
164
|
+
t.class.should == Triple
|
|
165
|
+
end
|
|
166
|
+
count.should == 3
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "should allow iteration over a particular subject" do
|
|
170
|
+
count = 0
|
|
171
|
+
subject.each_with_subject(@ex.john) do |t|
|
|
172
|
+
count = count + 1
|
|
173
|
+
t.class.should == Triple
|
|
174
|
+
end
|
|
175
|
+
count.should == 2
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
describe "encodings" do
|
|
179
|
+
it "should output NTriple" do
|
|
180
|
+
nt = "<http://example.org/john> <http://xmlns.com/foaf/0.1/knows> <http://example.org/jane> .\n<http://example.org/john> <http://xmlns.com/foaf/0.1/knows> <http://example.org/rick> .\n<http://example.org/jane> <http://xmlns.com/foaf/0.1/knows> <http://example.org/rick> .\n"
|
|
181
|
+
subject.to_ntriples.should == nt
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it "should output RDF/XML" do
|
|
185
|
+
rdfxml = <<HERE
|
|
186
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
187
|
+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#">
|
|
188
|
+
<rdf:Description rdf:about="http://example.org/john">
|
|
189
|
+
<foaf:knows rdf:resource="http://example.org/jane"/>
|
|
190
|
+
</rdf:Description>
|
|
191
|
+
<rdf:Description rdf:about="http://example.org/john">
|
|
192
|
+
<foaf:knows rdf:resource="http://example.org/rick"/>
|
|
193
|
+
</rdf:Description>
|
|
194
|
+
<rdf:Description rdf:about="http://example.org/jane">
|
|
195
|
+
<foaf:knows rdf:resource="http://example.org/rick"/>
|
|
196
|
+
</rdf:Description>
|
|
197
|
+
</rdf:RDF>
|
|
198
|
+
HERE
|
|
199
|
+
subject.to_rdfxml.should be_equivalent_xml(rdfxml)
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
describe "which are joined" do
|
|
205
|
+
it "should be able to integrate another graph" do
|
|
206
|
+
subject.add_triple(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new)
|
|
207
|
+
g = Graph.new
|
|
208
|
+
g.join(subject)
|
|
209
|
+
g.size.should == 1
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it "should not join with non graph" do
|
|
213
|
+
lambda do
|
|
214
|
+
h.join("")
|
|
215
|
+
end.should raise_error
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
describe "that can be compared" do
|
|
220
|
+
it "should be true for empty graphs" do
|
|
221
|
+
should be_equivalent_graph(Graph.new)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
it "should be false for different graphs" do
|
|
225
|
+
f = Graph.new
|
|
226
|
+
f.add_triple(URIRef.new("http://example.org/joe"), URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), URIRef.new("http://xmlns.com/foaf/0.1/Person"))
|
|
227
|
+
should_not be_equivalent_graph(f)
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
end
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "Literals: " do
|
|
4
|
+
describe "an untyped string" do
|
|
5
|
+
subject {Literal.untyped("tom")}
|
|
6
|
+
it "should be equal if they have the same contents" do should == Literal.untyped("tom") end
|
|
7
|
+
it "should not be equal if they do not have the same contents" do should_not == Literal.untyped("tim") end
|
|
8
|
+
it "should match a string" do should == "tom" end
|
|
9
|
+
it "should return a string using to_s" do subject.to_s.should == "tom" end
|
|
10
|
+
|
|
11
|
+
it "should infer type" do
|
|
12
|
+
other = Literal.build_from("foo")
|
|
13
|
+
other.encoding.should == "http://www.w3.org/2001/XMLSchema#string"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "encodings" do
|
|
17
|
+
it "should return n3" do subject.to_n3.should == "\"tom\"" end
|
|
18
|
+
it "should return ntriples" do subject.to_ntriples.should == "\"tom\"" end
|
|
19
|
+
it "should return xml_args" do subject.xml_args.should == ["tom", {}] end
|
|
20
|
+
it "should return TriX" do subject.to_trix.should == "<plainLiteral>tom</plainLiteral>" end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "with extended characters" do
|
|
24
|
+
subject { Literal.untyped("松本 后子") }
|
|
25
|
+
|
|
26
|
+
describe "encodings" do
|
|
27
|
+
it "should return n3" do subject.to_n3.should == "\"\\\u677E\\\u672C \\\u540E\\\u5B50\"" end
|
|
28
|
+
it "should return ntriples" do subject.to_ntriples.should == "\"\\\u677E\\\u672C \\\u540E\\\u5B50\"" end
|
|
29
|
+
it "should return xml_args" do subject.xml_args.should == ["松本 后子", {}] end
|
|
30
|
+
it "should return TriX" do subject.to_trix.should == "<plainLiteral>" + "松本 后子" + "</plainLiteral>" end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "with a language" do
|
|
35
|
+
subject { Literal.untyped("tom", "en") }
|
|
36
|
+
|
|
37
|
+
it "should accept a language tag" do
|
|
38
|
+
subject.lang.should == "en"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should be equal if they have the same contents and language" do
|
|
42
|
+
should == Literal.untyped("tom", "en")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should not be equal if they do not have the same contents" do
|
|
46
|
+
should_not == Literal.untyped("tim", "en")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should not be equal if they do not have the same language" do
|
|
50
|
+
should_not == Literal.untyped("tom", "fr")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "encodings" do
|
|
54
|
+
it "should return n3" do subject.to_n3.should == "\"tom\"@en" end
|
|
55
|
+
it "should return ntriples" do subject.to_ntriples.should == "\"tom\"@en" end
|
|
56
|
+
it "should return xml_args" do subject.xml_args.should == ["tom", {"xml:lang" => "en"}] end
|
|
57
|
+
it "should return TriX" do subject.to_trix.should == "<plainLiteral xml:lang=\"en\">tom</plainLiteral>" end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should normalize language tags to lower case" do
|
|
61
|
+
f = Literal.untyped("tom", "EN")
|
|
62
|
+
f.lang.should == "en"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "a typed string" do
|
|
68
|
+
subject { Literal.typed("tom", "http://www.w3.org/2001/XMLSchema#string") }
|
|
69
|
+
|
|
70
|
+
it "accepts an encoding" do
|
|
71
|
+
subject.encoding.to_s.should == "http://www.w3.org/2001/XMLSchema#string"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "should be equal if they have the same contents and datatype" do
|
|
75
|
+
should == Literal.typed("tom", "http://www.w3.org/2001/XMLSchema#string")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should not be equal if they do not have the same contents" do
|
|
79
|
+
should_not == Literal.typed("tim", "http://www.w3.org/2001/XMLSchema#string")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should not be equal if they do not have the same datatype" do
|
|
83
|
+
should_not == Literal.typed("tom", "http://www.w3.org/2001/XMLSchema#token")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "encodings" do
|
|
87
|
+
it "should return n3" do subject.to_n3.should == "\"tom\"^^<http://www.w3.org/2001/XMLSchema#string>" end
|
|
88
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
89
|
+
it "should return xml_args" do subject.xml_args.should == ["tom", {"rdf:datatype" => "http://www.w3.org/2001/XMLSchema#string"}] end
|
|
90
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/2001/XMLSchema#string\">tom</typedLiteral>" end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "an integer" do
|
|
95
|
+
describe "encodings" do
|
|
96
|
+
subject { Literal.typed(5, "http://www.w3.org/2001/XMLSchema#int") }
|
|
97
|
+
it "should return n3" do subject.to_n3.should == "\"5\"^^<http://www.w3.org/2001/XMLSchema#int>" end
|
|
98
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
99
|
+
it "should return xml_args" do subject.xml_args.should == ["5", {"rdf:datatype" => "http://www.w3.org/2001/XMLSchema#int"}] end
|
|
100
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/2001/XMLSchema#int\">5</typedLiteral>" end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should infer type" do
|
|
104
|
+
int = Literal.build_from(15)
|
|
105
|
+
int.encoding.should == "http://www.w3.org/2001/XMLSchema#int"
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe "a float" do
|
|
110
|
+
describe "encodings" do
|
|
111
|
+
subject { Literal.typed(15.4, "http://www.w3.org/2001/XMLSchema#float") }
|
|
112
|
+
it "should return n3" do subject.to_n3.should == "\"15.4\"^^<http://www.w3.org/2001/XMLSchema#float>" end
|
|
113
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
114
|
+
it "should return xml_args" do subject.xml_args.should == ["15.4", {"rdf:datatype" => "http://www.w3.org/2001/XMLSchema#float"}] end
|
|
115
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/2001/XMLSchema#float\">15.4</typedLiteral>" end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should infer type" do
|
|
119
|
+
float = Literal.build_from(15.4)
|
|
120
|
+
float.encoding.should == "http://www.w3.org/2001/XMLSchema#float"
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe "XML Literal" do
|
|
125
|
+
describe "with no namespace" do
|
|
126
|
+
subject { Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral") }
|
|
127
|
+
it "should indicate xmlliteral?" do
|
|
128
|
+
subject.xmlliteral?.should == true
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
describe "encodings" do
|
|
132
|
+
it "should return n3" do subject.to_n3.should == "\"foo <sup>bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
|
133
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
134
|
+
it "should return xml_args" do subject.xml_args.should == ["foo <sup>bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
|
135
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup>bar</sup> baz!</typedLiteral>" end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it "should be equal if they have the same contents" do
|
|
139
|
+
should == Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should be a XMLLiteral encoding" do
|
|
143
|
+
subject.encoding.should == "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe "with a namespace" do
|
|
148
|
+
subject {
|
|
149
|
+
Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
|
150
|
+
:namespaces => {"dc" => Namespace.new("http://purl.org/dc/elements/1.1/", "dc")})
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
describe "encodings" do
|
|
154
|
+
it "should return n3" do subject.to_n3.should == "\"foo <sup xmlns:dc=\\\"http://purl.org/dc/elements/1.1/\\\">bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
|
155
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
156
|
+
it "should return xml_args" do subject.xml_args.should == ["foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
|
157
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\">bar</sup> baz!</typedLiteral>" end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
describe "and language" do
|
|
161
|
+
subject {
|
|
162
|
+
Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
|
163
|
+
:namespaces => {"dc" => Namespace.new("http://purl.org/dc/elements/1.1/", "dc")},
|
|
164
|
+
:language => "fr")
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
describe "encodings" do
|
|
168
|
+
it "should return n3" do subject.to_n3.should == "\"foo <sup xmlns:dc=\\\"http://purl.org/dc/elements/1.1/\\\" xml:lang=\\\"fr\\\">bar</sup> baz!\"\^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
|
169
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
170
|
+
it "should return xml_args" do subject.xml_args.should == ["foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xml:lang=\"fr\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
|
171
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xml:lang=\"fr\">bar</sup> baz!</typedLiteral>" end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
describe "and language with an existing language embedded" do
|
|
176
|
+
subject {
|
|
177
|
+
Literal.typed("foo <sup>bar</sup><sub xml:lang=\"en\">baz</sub>",
|
|
178
|
+
"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
|
179
|
+
:language => "fr")
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
describe "encodings" do
|
|
183
|
+
it "should return n3" do subject.to_n3.should == "\"foo <sup xml:lang=\\\"fr\\\">bar</sup><sub xml:lang=\\\"en\\\">baz</sub>\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
|
184
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
185
|
+
it "should return xml_args" do subject.xml_args.should == ["foo <sup xml:lang=\"fr\">bar</sup><sub xml:lang=\"en\">baz</sub>", {"rdf:parseType" => "Literal"}] end
|
|
186
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xml:lang=\"fr\">bar</sup><sub xml:lang=\"en\">baz</sub></typedLiteral>" end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
describe "and namespaced element" do
|
|
191
|
+
subject {
|
|
192
|
+
root = Nokogiri::XML.parse(%(
|
|
193
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
194
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
|
|
195
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
|
196
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
197
|
+
xmlns:ex="http://example.org/rdf/"
|
|
198
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
199
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
|
200
|
+
<head profile="http://www.w3.org/1999/xhtml/vocab http://www.w3.org/2005/10/profile">
|
|
201
|
+
<title>Test 0100</title>
|
|
202
|
+
</head>
|
|
203
|
+
<body>
|
|
204
|
+
<div about="http://www.example.org">
|
|
205
|
+
<h2 property="ex:example" datatype="rdf:XMLLiteral"><svg:svg/></h2>
|
|
206
|
+
</div>
|
|
207
|
+
</body>
|
|
208
|
+
</html>
|
|
209
|
+
), nil, nil, Nokogiri::XML::ParseOptions::DEFAULT_XML).root
|
|
210
|
+
content = root.css("h2").children
|
|
211
|
+
Literal.typed(content,
|
|
212
|
+
"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
|
213
|
+
:namespaces => {"svg" => Namespace.new("http://www.w3.org/2000/svg", "svg")})
|
|
214
|
+
}
|
|
215
|
+
it "should return xml_args" do subject.xml_args.should == ["<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"></svg:svg>", {"rdf:parseType" => "Literal"}] end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
describe "and existing namespace definition" do
|
|
219
|
+
subject {
|
|
220
|
+
Literal.typed("<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"/>",
|
|
221
|
+
"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
|
222
|
+
:namespaces => {"svg" => Namespace.new("http://www.w3.org/2000/svg", "svg")})
|
|
223
|
+
}
|
|
224
|
+
it "should return xml_args" do subject.xml_args.should == ["<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"></svg:svg>", {"rdf:parseType" => "Literal"}] end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
describe "with a default namespace" do
|
|
229
|
+
subject {
|
|
230
|
+
Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
|
231
|
+
:namespaces => {"" => Namespace.new("http://purl.org/dc/elements/1.1/", "")})
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
describe "encodings" do
|
|
235
|
+
it "should return n3" do subject.to_n3.should == "\"foo <sup xmlns=\\\"http://purl.org/dc/elements/1.1/\\\">bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
|
236
|
+
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
|
237
|
+
it "should return xml_args" do subject.xml_args.should == ["foo <sup xmlns=\"http://purl.org/dc/elements/1.1/\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
|
238
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xmlns=\"http://purl.org/dc/elements/1.1/\">bar</sup> baz!</typedLiteral>" end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
describe "with multiple namespaces" do
|
|
243
|
+
subject {
|
|
244
|
+
Literal.typed("foo <sup <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")
|
|
245
|
+
}
|
|
246
|
+
it "should ignore namespace order" do
|
|
247
|
+
g = Literal.typed("foo <sup <sup xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")
|
|
248
|
+
should == g
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
describe "with multiple attributes" do
|
|
253
|
+
it "should ignore attribute order" do
|
|
254
|
+
f = Literal.typed("foo <sup a=\"a\" b=\"b\">bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")
|
|
255
|
+
g = Literal.typed("foo <sup b=\"b\" a=\"a\">bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")
|
|
256
|
+
f.should == g
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# it "build_from_language" do
|
|
262
|
+
# english = Literal.build_from_language("Have a nice day")
|
|
263
|
+
# english.encoding.should == "en"
|
|
264
|
+
#
|
|
265
|
+
# french = Literal.build_from_language("Bonjour, madame. Parlez vous francais?")
|
|
266
|
+
# french.encoding.should == "fr"
|
|
267
|
+
#
|
|
268
|
+
# german = Literal.build_from_language("Achtung")
|
|
269
|
+
# german.encoding.should == "de"
|
|
270
|
+
# end
|
|
271
|
+
|
|
272
|
+
# TODO: refactor based on new interface
|
|
273
|
+
# describe "Languages" do
|
|
274
|
+
# it "should be inspectable" do
|
|
275
|
+
# literal = Reddy::Literal.new("foo", "en")
|
|
276
|
+
# lang = literal.lang
|
|
277
|
+
# lang.to_s == "en"
|
|
278
|
+
# lang.hash.class.should == Fixnum
|
|
279
|
+
# end
|
|
280
|
+
# end
|
|
281
|
+
|
|
282
|
+
end
|