tommorris / reddy

Ruby-native RDF library

This URL has Read+Write access

reddy / .yardoc
100644 815 lines (789 sloc) 34.904 kb
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
[IC:SymbolHash{q:RdfaParser#grapho:$YARD::CodeObjects::MethodObject:@signature"def graph:@short_docstring0:
@tags[:
@name:
graph: @scope: instance: @source"def graph
  @graph
end:@visibility: public:
@file"lib/rena/rdfaparser.rb:
@linei :@namespaceo:#YARD::CodeObjects::ClassObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[o;;"def xml=(value); 0;
[o:YARD::Tags::Tag : @types[; "
value:@tag_name"
param:
@text"-the value to set the attribute +xml+ to.; : xml=; ;;"'def xml=(value)
  @xml = value
end;;;@ ;i ;@ :@docstring"Sets the attribute +xml+o;;" def xml; 0;
[; :xml; ;;"def xml
  @xml
end;;;@ ;i ;@ ;")Returns the value of attribute +xml+o;;"def uri=(value); 0;
[o; ;[; "
value;"
param;"-the value to set the attribute +uri+ to.; : uri=; ;;"'def uri=(value)
  @uri = value
end;;;@ ;i ;@ ;"Sets the attribute +uri+o;;" def uri; 0;
[; :uri; ;;"def uri
  @uri
end;;;@ ;i ;@ ;")Returns the value of attribute +uri+o;;"def graph=(value); 0;
[o; ;[; "
value;"
param;"/the value to set the attribute +graph+ to.; : graph=; ;;"+def graph=(value)
  @graph = value
end;;;@ ;i ;@ ;"Sets the attribute +graph+@o;;"def initialize (str, uri);
[; :initialize; ;:@explicitT;"def initialize (str, uri)
  @doc_string = str
  @xml = REXML::Document.new(str)
  @uri = uri
  @graph = Graph.new
  self.iterate(@xml.root.elements[2].elements[1].elements[1])
end;;;@ ;i ;@ ;"o;;"$def parse_ns_curie(el, attname);
[; :parse_ns_curie; ;;#T;")def parse_ns_curie(el, attname)
  attstring = el.attributes[attname]
  prefix = attstring.scan(/(.+):.+/).to_s
  if el.namespaces[prefix]
    namespace = el.namespaces[prefix]
  else
    raise "Namespace used in CURIE but not declared"
  end
  return namespace + attstring.scan(/.+:(.+)/).to_s
end;;: @dynamicT;@ ;i;@ ;"o;;"def iterate (el);
[; : iterate; ;;#T;"gdef iterate (el)
 
  if el.attributes['about']
    if el.attributes['about'] =~ /^http/
      # deal with as absolute
      subject = el.attributes['about'].to_s
    else
      # time to go xml:base sneakin'
      if xml.base?
        subject = Addressable::URI.parse(xml.base)
        subject = subject + el.attributes['about']
      else
        subject = Addressable::URI.parse(@uri)
        subject = subject + el.attributes['about']
      end
    end
  else
    subject = @uri
  end
  
  if el.attributes['property']
    if el.attributes['property'] =~ /^http/
      property = el.attributes['property']
    else
      # curie hunt!
    property = self.parse_ns_curie(el, "property")
    end
  end
  
  if el.attributes['content']
    value = el.attributes['content']
  else
    value = el.text
  end
 
  @graph.add_triple subject.to_s, URIRef.new(property), value
end;;;%T;@ ;i;@ ;": @owner@ ; 0;
[; :RdfaParser: @aliases{:@superclasso:YARD::CodeObjects::Proxy; : Object: @obj0;o:"YARD::CodeObjects::RootObject ;IC;[o;;IC;[ o;;"def identifier=(value); 0;
[o; ;[; "
value;"
param;"4the value to set the attribute +identifier+ to.; :identifier=; ;;"5def identifier=(value)
  @identifier = value
end;;;"lib/rena/bnode.rb;i;@J;"$Sets the attribute +identifier+o;;"def identifier; 0;
[; :identifier; ;;"%def identifier
  @identifier
end;;;@U;i;@J;"0Returns the value of attribute +identifier+o;;"%def initialize(identifier = nil);
[; ;"; ;;#T;"def initialize(identifier = nil)
  if identifier != nil && self.valid_id?(identifier) != false
    @identifier = identifier
  else
    @identifier = "bn" + self.hash.to_s
  end
end;;;@U;i;@J;"o;;"def eql? (eql);
[; : eql?; ;;#T;"^def eql? (eql)
  if self.identifier == eql.identifier
    true
  else
    false
  end
end;;;%T;@U;i;@J;"o;;"def to_n3; 0;
[o; ;[" String; 0;" return;"The BNode in n3.o; ;0; 0;" author;"Tom Morris; :
to_n3; ;;#T;"'def to_n3
  "_:" + @identifier
end;;;%T;@U;i#;@J;"Exports the BNode in N-Triples form.
 
==== Example
  b = BNode.new; b.to_n3 # => returns a string of the BNode in n3 form
 
==== Returnso;;"def to_ntriples; 0;
[o; ;[" String; 0;" return;"The BNode in N-Triples.o; ;0; 0;" author;"Tom Morris; :to_ntriples; ;;#T;"%def to_ntriples
  self.to_n3
end;;;%T;@U;i3;@J;"Exports the BNode in N-Triples form.
 
==== Example
  b = BNode.new; b.to_ntriples # => returns a string of the BNode in N-Triples form
 
==== Returnso;;" def to_s;
[; : to_s; ;;#T;"!def to_s
  @identifier
end ;;;%T;@U;i7;@J;"o;;"def valid_id? name;
[; :valid_id?; ;;#T;"bdef valid_id? name
  if name =~ /^[a-zA-Z_][a-zA-Z0-9]*$/
    true
  else
    false
  end
end;:protected;%T;@U;i=;@J;";'@J;
[; :
BNode;){;*o;+; ;,;-0;@H:@attributesIC;{:
classIC;{:@symbolize_valueT;IC;{;0IC;{:
write@L: read@W;:T;:T;:T;@U: @mixinsIC;[;'@J;i;@H;"o;;IC;[;'@;
[; :AboutEachException;){;*o;+; ;,;-0;@H;8IC;{;9IC;{;:T;IC;{;:T;:T;"0lib/rena/exceptions/about_each_exception.rb;=IC;[;'@;i;@H;"o;;IC;[;'@;
[; :UriRelativeException;){;*o;+; :RuntimeError;-0;@H;8IC;{;9IC;{;:T;IC;{;:T;:T;"2lib/rena/exceptions/uri_relative_exception.rb;=IC;[;'@;i;@H;"o;;IC;[o;;"def triples=(value); 0;
[o; ;[; "
value;"
param;"1the value to set the attribute +triples+ to.; : triples=; ;;"/def triples=(value)
  @triples = value
end;;;"lib/rena/graph.rb;i ;@;"!Sets the attribute +triples+o;;"def triples; 0;
[; : triples; ;;"def triples
  @triples
end;;;@;i ;@;"-Returns the value of attribute +triples+o;;"def nsbinding=(value); 0;
[o; ;[; "
value;"
param;"3the value to set the attribute +nsbinding+ to.; :nsbinding=; ;;"3def nsbinding=(value)
  @nsbinding = value
end;;;@;i ;@;"#Sets the attribute +nsbinding+o;;"def nsbinding; 0;
[; :nsbinding; ;;"#def nsbinding
  @nsbinding
end;;;@;i ;@;"/Returns the value of attribute +nsbinding+o;;"def initialize;
[; ;"; ;;#T;"9def initialize
  @triples = []
  @nsbinding = {}
end;;;@;i;@;"o;;" def size;
[; : size; ;;#T;"!def size
  @triples.size
end;;;%T;@;i;@;"o;;" def each;
[; : each; ;;#T;"9def each
  @triples.each { |value| yield value }
end;;;%T;@;i;@;"o;;"#def each_with_subject(subject);
[; :each_with_subject; ;;#T;"~def each_with_subject(subject)
  @triples.each {|value|
    if value.subject == subject
      yield value
    end
  }
end;;;%T;@;i;@;"o;;"def add_triple(s, p, o); 0;
[ o; ;[" URIRef"
BNode; "s;"
param;"the subject of the tripleo; ;[" URIRef; "p;"
param;" the predicate of the tripleo; ;[ " URIRef"
BNode" Literal"TypedLiteral; "o;"
param;"the object of the tripleo; ;["
Array; 0;" return;"VAn array of the triples (leaky abstraction? consider returning the graph instead)o; ;["
Error; 0;"
raise;"=Checks parameter types and raises if they are incorrect.o; ;0; 0;" author;"Tom Morris; :add_triple; ;;#T;"Fdef add_triple(s, p, o)
  @triples += [ Triple.new(s, p, o) ]
end;;;%T;@;i4;@;"Adds a triple to a graph directly from the intended subject, predicate, and object.
 
==== Example
  g = Graph.new; g.add_triple(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new) # => results in the triple being added to g; returns an array of g's tripleso;;"def << (triple); 0;
[o; ;[" Triple; "t;"
param;"(the triple to be added to the grapho; ;["
Array; 0;" return;"VAn array of the triples (leaky abstraction? consider returning the graph instead)o; ;0; 0;" author;"Tom Morris; :<<; ;;#T;"Odef << (triple)
# self.add_triple(s, p, o)
  @triples += [ triple ]
end;;;%T;@;iF;@;"Adds an extant triple to a graph
 
==== Example
  g = Graph.new; t = Triple.new(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new); g << t) # => results in the triple being added to g; returns an array of g's tripleso;;"def to_ntriples; 0;
[o; ;[" String; 0;" return;"The graph in N-Triples.o; ;0; 0;" author;"Tom Morris; ;3; ;;#T;"mdef to_ntriples
  str = ""
  @triples.each do |t|
    str << t.to_ntriples + "\n"
  end
  return str
end;;;%T;@;iV;@;"Exports the graph to RDF in N-Triples form.
 
==== Example
  g = Graph.new; g.add_triple(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new); g.to_ntriples # => returns a string of the graph in N-Triples form
 
==== Returnso;;"def namespace(uri, short); 0;
[ o; ;[" String; "uri;"
param;"the URI of the namespaceo; ;[" String; "
short;"
param;"$the short name of the namespaceo; ;["Namespace; 0;" return;"!The newly created namespace.o; ;["
Error; 0;"
raise;"LChecks validity of the desired shortname and raises if it is incorrect.o; ;["
Error; 0;"
raise;"`Checks that the newly created Namespace is of type Namespace and raises if it is incorrect.o; ;0; 0;" author;"Tom Morris; :namespace; ;;#T;"Hdef namespace(uri, short)
  self.bind Namespace.new(uri, short)
end;;;%T;@;in;@;"Creates a new namespace given a URI and the short name and binds it to the graph.
 
==== Example
  g = Graph.new; g.namespace("http://xmlns.com/foaf/0.1/", "foaf") # => binds the Foaf namespace to go;;"def bind(namespace);
[; : bind; ;;#T;"def bind(namespace)
  if namespace.class == Namespace
    @nsbinding["#{namespace.short}"] = namespace
  else
    raise
  end
end;;;%T;@;ir;@;"o;;"'def has_bnode_identifier?(bnodeid);
[; :has_bnode_identifier?; ;;#T;"1def has_bnode_identifier?(bnodeid)
  temp_bnode = BNode.new(bnodeid)
  returnval = false
  @triples.each { |triple|
    if triple.subject.eql?(temp_bnode)
      returnval = true
      break
    end
    if triple.object.eql?(temp_bnode)
      returnval = true
      break
    end
  }
  return returnval
end;;;%T;@;iz;@;"o;;")def get_bnode_by_identifier(bnodeid);
[; :get_bnode_by_identifier; ;;#T;"Fdef get_bnode_by_identifier(bnodeid)
  temp_bnode = BNode.new(bnodeid)
  returnval = false
  @triples.each { |triple|
    if triple.subject.eql?(temp_bnode)
      returnval = triple.subject
      break
    end
    if triple.object.eql?(temp_bnode)
      returnval = triple.object
      break
    end
  }
  return returnval
end;;;%T;@;i;@;";'@;
[; :
Graph;){;*o;+; ;,;-0;@H;8IC;{;9IC;{;:T;IC;{;BIC;{;;@;<@;:T;DIC;{;;@;<@;:T;:T;:T;@;=IC;[;'@;i ;@H;"o;;IC;[o;;"def contents=(value); 0;
[o; ;[; "
value;"
param;"2the value to set the attribute +contents+ to.; :contents=; ;;"1def contents=(value)
  @contents = value
end;;;"lib/rena/literal.rb;i;@];""Sets the attribute +contents+o;;"def contents; 0;
[; : contents; ;;"!def contents
  @contents
end;;;@h;i;@];".Returns the value of attribute +contents+o;;"def lang=(value); 0;
[o; ;[; "
value;"
param;".the value to set the attribute +lang+ to.; :
lang=; ;;")def lang=(value)
  @lang = value
end;;;@h;i;@];"Sets the attribute +lang+o;;" def lang; 0;
[; : lang; ;;"def lang
  @lang
end;;;@h;i;@];"*Returns the value of attribute +lang+o;;")def initialize(contents, lang = nil);
[; ;"; ;;#T;"def initialize(contents, lang = nil)
  @contents = contents
  if lang != nil && lang != false
    @lang = lang.downcase
  end
end;;;@h;i;@];"o;;"def == (obj);
[; :==; ;;#T;"def == (obj)
  if obj.class == Literal && obj.contents == @contents && (obj.lang == @lang || (obj.lang == nil && @lang == nil))
    true
  else
    false
  end
end;;;%T;@h;i;@];"o;;"def to_n3;
[; ;2; ;;#T;"def to_n3
  out = "\"" + @contents + "\""
  out += "@" + @lang if @lang != nil
  out += "^^" + @encoding if @encoding != nil
  return out
end;;;%T;@h;i;@];"o;;"def to_ntriples;
[; ;3; ;;#T;",def to_ntriples
  return self.to_n3
end;;;%T;@h;i;@];"o;;"def to_trix;
[; : to_trix; ;;#T;"def to_trix
  if @lang != nil && @lang != false
    out = "<plainLiteral xml:lang=\"" + @lang + "\">"
  else
    out = "<plainLiteral>"
  end
  out += @contents
  out += "</plainLiteral>"
  return out
end;;;%T;@h;i";@];";'@];
[; : Literal;){;*o;+; ;,;-0;@H;8IC;{;9IC;{;:T;IC;{;PIC;{;;@_;<@j;:T;RIC;{;;@o;<@y;:T;:T;:T;@h;=IC;[;'@];i;@H;"o;;IC;[o;;"def contents=(value); 0;
[o; ;[; "
value;"
param;"2the value to set the attribute +contents+ to.; ;O; ;;"1def contents=(value)
  @contents = value
end;;;@h;i0;@;""Sets the attribute +contents+o;;"def contents; 0;
[; ;P; ;;"!def contents
  @contents
end;;;@h;i0;@;".Returns the value of attribute +contents+o;;"def encoding=(value); 0;
[o; ;[; "
value;"
param;"2the value to set the attribute +encoding+ to.; :encoding=; ;;"1def encoding=(value)
  @encoding = value
end;;;@h;i0;@;""Sets the attribute +encoding+o;;"def encoding; 0;
[; : encoding; ;;"!def encoding
  @encoding
end;;;@h;i0;@;".Returns the value of attribute +encoding+o;;"'def initialize(contents, encoding);
[; ;"; ;;#T;"def initialize(contents, encoding)
  @contents = contents
  @encoding = encoding
  if @encoding == "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"
    @xmlliteral = true
  else
    @xmlliteral = false
  end
end;;;@h;i1;@;"o;;"def == (obj);
[; ;S; ;;#T;"def == (obj)
  if obj.class == TypedLiteral && obj.contents == @contents && obj.encoding == @encoding
    return true
  else
    return false
  end
end;;;%T;@h;i;;@;"o;;"def to_n3;
[; ;2; ;;#T;"def to_n3
  if @encoding == "http://www.w3.org/2001/XMLSchema#int"
    out = @contents.to_s
  else
    out = "\"" + @contents.to_s + "\""
  end
  out += "^^<" + @encoding + ">" if @encoding != nil
  return out
end;;;%T;@h;iC;@;"o;;"def to_trix;
[; ;T; ;;#T;"fdef to_trix
  "<typedLiteral datatype=\"" + @encoding + "\">" + @contents + "</typedLiteral>"
end;;;%T;@h;iM;@;"o;;"def xmlliteral?;
[; :xmlliteral?; ;;#T;"&def xmlliteral?
  @xmlliteral
end;;;%T;@h;iQ;@;"o;;"def infer!;
[; : infer!; ;;#T;"def infer!
  if @contents.class == Fixnum
    @encoding = "http://www.w3.org/2001/XMLSchema#int"
  elsif @contents.class == Float
    @encoding = "http://www.w3.org/2001/XMLSchema#float"
  else
    @encoding = "http://www.w3.org/2001/XMLSchema#string"
  end
end;;;%T;@h;iU;@;";'@;
[; :TypedLiteral;){;*o;+; ;U;-@];@H;8IC;{;9IC;{;:T;IC;{;PIC;{;;@;<@;:T;WIC;{;;@;<@;:T;:T;:T;@h;=IC;[;'@;i/;@H;"o;;IC;[o;;"def short=(value); 0;
[o; ;[; "
value;"
param;"/the value to set the attribute +short+ to.; : short=; ;;"+def short=(value)
  @short = value
end;;;"lib/rena/namespace.rb;i
;@;"Sets the attribute +short+o;;"def short; 0;
[; :
short; ;;"def short
  @short
end;;;@;i
;@;"+Returns the value of attribute +short+o;;"def uri=(value); 0;
[o; ;[; "
value;"
param;"-the value to set the attribute +uri+ to.; ;; ;;"'def uri=(value)
  @uri = value
end;;;@;i
;@;"Sets the attribute +uri+o;;" def uri; 0;
[; ; ; ;;"def uri
  @uri
end;;;@;i
;@;")Returns the value of attribute +uri+o;;"def fragment=(value); 0;
[o; ;[; "
value;"
param;"2the value to set the attribute +fragment+ to.; :fragment=; ;;"1def fragment=(value)
  @fragment = value
end;;;@;i
;@;""Sets the attribute +fragment+o;;"def fragment; 0;
[; : fragment; ;;"!def fragment
  @fragment
end;;;@;i
;@;".Returns the value of attribute +fragment+o;;"1def initialize(uri, short, fragment = false); 0;
[ o; ;[" String; "uri;"
param;"the URI of the namespaceo; ;[" String; "
short;"
param;"$the short name of the namespaceo; ;[" Boolean; " fragment;"
param;"^are the identifiers on this resource fragment identifiers? (e.g. '#') Defaults to false.o; ;["Namespace; 0;" return;"!The newly created namespace.o; ;["
Error; 0;"
raise;"LChecks validity of the desired shortname and raises if it is incorrect.o; ;0; 0;" author;"Tom Morris, Pius Uzamere; ;"; ;;#T;"def initialize(uri, short, fragment = false)
  @uri = uri
  @fragment = fragment
  if shortname_valid?(short)
    @short = short
  else
    raise
  end
end;;;@;i;@;"Creates a new namespace given a URI and the short name.
 
==== Example
  Namespace.new("http://xmlns.com/foaf/0.1/", "foaf") # => returns a new Foaf namespaceo;;"*def method_missing(methodname, *args); 0;
[ o; ;[" String; "uri;"
param;"the URI of the namespaceo; ;[" String; "
short;"
param;"$the short name of the namespaceo; ;[" Boolean; " fragment;"
param;"^are the identifiers on this resource fragment identifiers? (e.g. '#') Defaults to false.o; ;[" URIRef; 0;" return;"$The newly created URIRegerence.o; ;["
Error; 0;"
raise;"LChecks validity of the desired shortname and raises if it is incorrect.o; ;0; 0;" author;"Tom Morris, Pius Uzamere; :method_missing; ;;#T;"def method_missing(methodname, *args)
  unless fragment
    URIRef.new(@uri + methodname.to_s)
  else
    URIRef.new(@uri + '#' + methodname.to_s)
  end
end;;;%T;@;i7;@;"lAllows the construction of arbitrary URIs on the namespace.
 
==== Example
  foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf"); foaf.knows # => returns a new URIRef with URI "http://xmlns.com/foaf/0.1/knows"
  foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf", true); foaf.knows # => returns a new URIRef with URI "http://xmlns.com/foaf/0.1/#knows"o;;"def bind(graph);
[; ;K; ;;#T;"^def bind(graph)
  if graph.class == Graph
    graph.bind(self)
  else
    raise
  end
end;;;%T;@;i?;@;"o;;"$def shortname_valid?(shortname);
[; :shortname_valid?; ;;#T;"|def shortname_valid?(shortname)
  if shortname =~ /[a-zA-Z_][a-zA-Z0-9_]+/
    return true
  else
    return false
  end
end;: private;%T;@;iH;@;";'@;
[; :Namespace;){;*o;+; ;,;-0;@H;8IC;{;9IC;{;:T;IC;{; IC;{;;@;<@;:T;\IC;{;;@;<@;:T;^IC;{;;@
;<@;:T;:T;:T;@;=IC;[;'@;i ;@H;"@ o;;IC;[o;;"def xml=(value); 0;
[o; ;[; "
value;"
param;"-the value to set the attribute +xml+ to.; ;; ;;"'def xml=(value)
  @xml = value
end;;;"lib/rena/rdfxmlparser.rb;i;@v;"Sets the attribute +xml+o;;" def xml; 0;
[; ;; ;;"def xml
  @xml
end;;;@;i;@v;")Returns the value of attribute +xml+o;;"def graph=(value); 0;
[o; ;[; "
value;"
param;"/the value to set the attribute +graph+ to.; ;!; ;;"+def graph=(value)
  @graph = value
end;;;@;i;@v;"Sets the attribute +graph+o;;"def graph; 0;
[; ; ; ;;"def graph
  @graph
end;;;@;i;@v;"+Returns the value of attribute +graph+o;;"(def initialize (xml_str, uri = nil);
[; ;"; ;;#T;"def initialize (xml_str, uri = nil)
  @excl = ["http://www.w3.org/1999/02/22-rdf-syntax-ns#resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#nodeID", "http://www.w3.org/1999/02/22-rdf-syntax-ns#about", "http://www.w3.org/1999/02/22-rdf-syntax-ns#ID"]
  if uri != nil
    @uri = Addressable::URI.parse(uri)
  end
  @xml = REXML::Document.new(xml_str)
# self.iterator @xml.root.children
  if self.is_rdf?
    @graph = Graph.new
    @xml.root.each_element { |e|
      self.parse_element e
    }
# puts @graph.size
  end
end;;;@;i;@v;"o;;"def is_rdf?;
[; : is_rdf?; ;;#T;"def is_rdf?
  trigger = false
  @xml.each_element do |e|
    if e.namespaces.has_value? "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      trigger = true
    end
  end
  return trigger
end;;;%T;@;i;@v;"o;;"7def get_uri_from_atts (element, aboutmode = false);
[; :get_uri_from_atts; ;;#T;" def get_uri_from_atts (element, aboutmode = false)
  if aboutmode == false
    resourceuri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#resource"
  else
    resourceuri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#about"
  end
  
  subject = nil
  element.attributes.each_attribute { |att|
    uri = att.namespace + att.name
    value = att.to_s
    if uri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#aboutEach"
      raise AboutEachException, "Failed as per RDFMS-AboutEach-Error001.rdf test from 2004 test suite"
    end
    if uri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#aboutEachPrefix"
      raise AboutEachException, "Failed as per RDFMS-AboutEach-Error002.rdf test from 2004 test suite"
    end
    if uri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#bagID"
      raise
      if name =~ /^[a-zA-Z_][a-zA-Z0-9]*$/
        # TODO: do something intelligent with the bagID
      else
        raise
      end
    end
    
    if uri == resourceuri #specified resource
      begin
        possible_subject = URIRef.new(value)
      rescue UriRelativeException
        if value[0..0].to_s != "#"
          value = "#" + value
        end
        begin
          value = URIRef.new(element.base + value)
        rescue UriRelativeException
          # still not a URI
          raise
        else
          subject = value
        end
      else
        subject = possible_subject
        break
      end
    end
    
    if uri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#nodeID" #BNode with ID
      # we have a BNode with an identifier. First, we need to do syntax checking.
      if value =~ /^[a-zA-Z_][a-zA-Z0-9]*$/
        # now we check to see if the graph has the value
        if @graph.has_bnode_identifier?(value)
          # if so, pull it in - no need to recreate objects.
          subject = @graph.get_bnode_by_identifier(value)
        else
          # if not, create a new one.
          subject = BNode.new(value)
        end
      end
    end
    
    if uri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#ID"
      begin
        # check for base
        if att.element.base?
          subject = att.element.base.to_s + value
        elsif @uri != nil
          compound = @uri.to_s + "#" + value
          subject = compound.to_s
        else
          raise "Needs to have an ID"
        end
# rescue UriRelativeException
      end
    end
 
    # add other subject detection subroutines here
  }
  if subject.class == NilClass
    subject = BNode.new
  end
  return subject
end;;6;%T;@;i*;@v;"o;;"Adef parse_element (element, subject = nil, resource = false);
[; :parse_element; ;;#T;"def parse_element (element, subject = nil, resource = false)
  if subject == nil
    # figure out subject
    subject = self.get_uri_from_atts(element, true)
  end
 
  # type parsing
  if resource == true
    type = URIRef.new(element.namespace + element.name)
    unless type.to_s == "http://www.w3.org/1999/02/22-rdf-syntax-ns#Description"
      @graph.add_triple(subject, URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), type)
    end
  end
  
  # attribute parsing
  element.attributes.each_attribute { |att|
    uri = att.namespace + att.name
    value = att.to_s
    
    unless @excl.member? uri
      @graph.add_triple(subject, URIRef.new(uri), Literal.new(value))
    end
  }
 
  # element parsing
  element.each_element { |e|
    self.parse_resource_element e, subject
  }
end;;6;%T;@;i;@v;"o;;"*def parse_resource_element e, subject;
[; :parse_resource_element; ;;#T;"idef parse_resource_element e, subject
  uri = e.namespace + e.name
  if e.attributes.get_attribute_ns("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "parseType").to_s == "Literal"
    @graph.add_triple(subject, URIRef.new(uri), TypedLiteral.new(e.children.to_s.strip, "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"))
  elsif e.has_elements?
    # subparsing
    e.each_element { |se| #se = 'striped element'
      if e.attributes.get_attribute_ns("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "parseType").to_s == "Resource"
        object = BNode.new
      else
        object = self.get_uri_from_atts(se, true)
      end
      @graph.add_triple(subject, URIRef.new(uri), object)
      self.parse_element(se, object, true)
    }
  elsif e.attributes.get_attribute_ns("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "datatype")
    @graph.add_triple(subject, URIRef.new(uri), TypedLiteral.new(e.text, e.attributes.get_attribute_ns("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "datatype").to_s.strip))
  elsif e.has_attributes?
    # get object out
    object = self.get_uri_from_atts(e)
    @graph.add_triple(subject, URIRef.new(uri), object)
  elsif e.has_text?
    if e.lang?
      @graph.add_triple(subject, URIRef.new(uri), Literal.new(e.text, e.lang))
    else
      @graph.add_triple(subject, URIRef.new(uri), Literal.new(e.text))
    end
  end
end;;6;%T;@;i;@v;";'@v;
[; :RdfXmlParser;){;*o;+; ;,;-0;@H;8IC;{;9IC;{;:T;IC;{; IC;{;;@;<@;:T;IC;{;;@x;<@;:T;:T;:T;@;=IC;[;'@v;i ;@H;"o;;IC;[o;;"def subject=(value); 0;
[o; ;[; "
value;"
param;"1the value to set the attribute +subject+ to.; : subject=; ;;"/def subject=(value)
  @subject = value
end;;;"lib/rena/triple.rb;i;@;"!Sets the attribute +subject+o;;"def subject; 0;
[; : subject; ;;"def subject
  @subject
end;;;@;i;@;"-Returns the value of attribute +subject+o;;"def object=(value); 0;
[o; ;[; "
value;"
param;"0the value to set the attribute +object+ to.; : object=; ;;"-def object=(value)
  @object = value
end;;;@;i;@;" Sets the attribute +object+o;;"def object; 0;
[; : object; ;;"def object
  @object
end;;;@;i;@;",Returns the value of attribute +object+o;;"def predicate=(value); 0;
[o; ;[; "
value;"
param;"3the value to set the attribute +predicate+ to.; :predicate=; ;;"3def predicate=(value)
  @predicate = value
end;;;@;i;@;"#Sets the attribute +predicate+o;;"def predicate; 0;
[; :predicate; ;;"#def predicate
  @predicate
end;;;@;i;@;"/Returns the value of attribute +predicate+o;;"0def initialize (subject, predicate, object); 0;
[ o; ;[" URIRef"
BNode; "s;"
param;"the subject of the tripleo; ;[" URIRef; "p;"
param;" the predicate of the tripleo; ;[ " URIRef"
BNode" Literal"TypedLiteral; "o;"
param;"the object of the tripleo; ;[" Triple; 0;" return;"VAn array of the triples (leaky abstraction? consider returning the graph instead)o; ;["
Error; 0;"
raise;"=Checks parameter types and raises if they are incorrect.o; ;0; 0;" author;"Tom Morris; ;"; ;;#T;"def initialize (subject, predicate, object)
  self.check_subject(subject)
  self.check_predicate(predicate)
  self.check_object(object)
end;;;@;i;@;"Creates a new triple directly from the intended subject, predicate, and object.
 
==== Example
  Triple.new(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new) # => results in the creation of a new triple and returns ito;;"def to_ntriples;
[; ;3; ;;#T;"qdef to_ntriples
  @subject.to_ntriples + " " + @predicate.to_ntriples + " " + @object.to_ntriples + " ."
end;;;%T;@;i;@;"o;;"def check_subject(subject);
[; :check_subject; ;;#T;"Zdef check_subject(subject)
  if subject.class == BNode || subject.class == URIRef
    @subject = subject
  elsif subject.class == String
    if subject =~ /\S+\/\/\S+/ # does it smell like a URI?
      @subject = URIRef.new(subject)
    else
      @subject = BNode.new(subject)
    end
  else
    raise "Subject is not of a known class"
  end
end;;6;%T;@;i$;@;"o;;"#def check_predicate(predicate);
[; :check_predicate; ;;#T;"def check_predicate(predicate)
  if predicate.class == URIRef
    @predicate = predicate
  elsif predicate.class == BNode
    raise "BNode is not allowed as a predicate"
  elsif predicate.class == String
    if predicate =~ /\S+\/\/\S+/ # URI smell check again
      @predicate = URIRef.new(predicate)
    else
      raise "String literals are not acceptable as predicates"
    end
  else
    raise "Predicate should be a uriref"
  end
end;;6;%T;@;i3;@;"o;;"def check_object(object);
[; :check_object; ;;#T;" def check_object(object)
  if [String, Integer, Fixnum, Float].include? object.class
    @object = Literal.new(object.to_s)
  elsif [URIRef, BNode, Literal, TypedLiteral].include? object.class
    @object = object
  else
    raise "Object expects valid class"
  end
end;;6;%T;@;iD;@;";'@;
[; : Triple;){;*o;+; ;,;-0;@H;8IC;{;9IC;{;:T;IC;{;kIC;{;;@;<@;:T;iIC;{;;@;<@;:T;mIC;{;;@;<@;:T;:T;:T;@;=IC;[;'@;i;@H;"o;;IC;[ o;;"def uri=(value); 0;
[o; ;[; "
value;"
param;"-the value to set the attribute +uri+ to.; ;; ;;"'def uri=(value)
  @uri = value
end;;;"lib/rena/uriref.rb;i ;@1;"Sets the attribute +uri+o;;" def uri; 0;
[; ; ; ;;"def uri
  @uri
end;;;@<;i ;@1;")Returns the value of attribute +uri+o;;"def initialize (string);
[; ;"; ;;#T;"def initialize (string)
  self.test_string(string)
  @uri = Addressable::URI.parse(string)
  if @uri.relative?
    raise UriRelativeException, "<" + @uri.to_s + ">"
  end
  if !@uri.to_s.match(/^javascript/).nil?
    raise "Javascript pseudo-URIs are not acceptable"
  end
end;;;@<;i ;@1;"o;;"def == (other);
[; ;S; ;;#T;":def == (other)
  return true if @uri == other.uri
end;;;%T;@<;i;@1;"o;;" def to_s;
[; ;4; ;;#T;"def to_s
  @uri.to_s
end;;;%T;@<;i;@1;"o;;"def to_ntriples;
[; ;3; ;;#T;"0def to_ntriples
  "<" + @uri.to_s + ">"
end;;;%T;@<;i;@1;"o;;"def test_string (string);
[; :test_string; ;;#T;"def test_string (string)
  if string.class != String
    string = string.to_s
  end
  
  string.each_byte do |b|
    if b >= 0 and b <= 31
      raise "URI must not contain control characters"
    end
  end
end;;;%T;@<;i#;@1;";'@1;
[; : URIRef;){;*o;+; ;,;-0;@H;8IC;{;9IC;{;:T;IC;{; IC;{;;@3;<@>;:T;:T;:T;@<;=IC;[;'@1;i
;@H;"o:$YARD::CodeObjects::ModuleObject;IC;[;'@e;
[; : Rena;){;8IC;{;9IC;{;:T;IC;{;:T;:T;"lib/rena.rb;=IC;[;'@e;i ;@H;";'@H;
[; : root;){;8IC;{;9IC;{;:T;IC;{;:T;:T;=IC;[;'@H;0;";8IC;{;9IC;{;:T;IC;{; IC;{;;@,;<@;:T; IC;{;;@;<@';:T;IC;{;;@;<@;:T;:T;:T;@ ;=IC;[;'@ ;i;@H;"require 'lib/rena';"+Returns the value of attribute +graph+:TypedLiteral#to_trix@;b@:RdfaParser#xml=@:REXML::Element#base?o;;"def base?;
[; :
base?; ;;#T;"Hdef base?
  if self.base != nil
    true
  else
    false
  end
end;;;%T;"lib/rena/rexml_hacks.rb;i";o;;IC;[ o;;"def lang?;
[; :
lang?; ;;#T;"Hdef lang?
  if self.lang != nil
    true
  else
    false
  end
end;;;@;i;@;"o;;" def lang;
[; ;R; ;;#T;"def lang
  if self.attributes['xml:lang']
    return self.attributes['xml:lang'].to_s
  elsif self.parent != nil
    return self.parent.lang
  else
    return nil
  end
end;;;%T;@;i;@;"@o;;" def base;
[; : base; ;;#T;"def base
  if self.attributes['xml:base']
    return self.attributes['xml:base'].to_s
  elsif self.parent != nil
    return self.parent.base
  else
    return nil
  end
end;;;%T;@;i*;@;"o;;"def write(excl=[]);
[; ;;; ;;#T;"$def write(excl=[])
  # TODO: add optional list argument of excluded namespaces
  self.prefixes.each { |ns|
    self.add_attribute('xmlns:' + ns, self.namespaces[ns].to_s) unless excl.include? self.namespaces[ns]
  }
  self.support_write_recursive(self.namespaces, self)
  return self.to_s
end;;;%T;@;i4;@;"o;;"+def support_write_recursive(array, el);
[; :support_write_recursive; ;;#T;"Tdef support_write_recursive(array, el)
  el.each_element { |e|
    unless array.has_key?(e.prefix) && array.has_value?(e.namespace)
      if e.prefix != ""
        e.add_attribute('xmlns:' + e.prefix, e.namespace)
      else
        e.add_attribute('xmlns', e.namespace)
      end
    end
    self.support_write_recursive(array, e)
  }
end;;6;%T;@;i>;@;";'@; 0;
[; : Element;){;*o;+; ;,;-0;o;+; :
REXML;-0;@H;8IC;{;9IC;{;:T;IC;{;:T;:T;@;=IC;[;'@;i;@;"def subdocument_writer(el)
  el.prefixes.each { |ns|
    el.add_attribute('xmlns:' + ns, el.namespaces[ns].to_s)
  }
  return el.to_s
end;":Triple#check_subject@:RdfXmlParser#parse_element@:TypedLiteral#encoding@:BNode#identifier=@L: Graph#has_bnode_identifier?@I:Triple#subject@:RdfXmlParser#initialize@:RdfXmlParser#xml=@x:Literal#to_trix@;(@ ;?@:Namespace#initialize@:Namespace#uri=@:URIRef#uri=@3:RdfaParser#iterate@@:Literal#contents=@_:Graph#size@:Graph#nsbinding=@:BNode#initialize@\:Literal#initialize@~:+REXML::Element#support_write_recursive@:Triple#check_object@!:TypedLiteral#to_n3@;7@J:RdfaParser#uri@':REXML::Element#lang@:Triple#to_ntriples@:Triple#predicate=@:TypedLiteral#contents@;U@]:Graph#bind@D:URIRef#test_string@W:RdfXmlParser#graph@:BNode#to_ntriples@s:Literal#to_ntriples@:Graph#add_triple@;>@:Namespace#fragment@:Namespace#short=@:URIRef#initialize@C:Literal#lang@y:Graph#initialize@:TypedLiteral#infer!@:Graph#triples=@:REXML::Element#write@:RdfaParser#xml@:TypedLiteral#==@:Triple#initialize@:Triple#object=@:#RdfXmlParser#get_uri_from_atts@;N@:Namespace#shortname_valid?@f:BNode#identifier@W:Graph#namespace@!:URIRef#to_ntriples@R:RdfXmlParser#xml@:Literal#to_n3@:Namespace#uri@:URIRef#uri@>:REXML::Element@:RdfaParser#parse_ns_curie@;:Literal#contents@j:RdfaParser#graph=@,:Graph#nsbinding@:REXML::Element#base@:Triple#check_predicate@:(RdfXmlParser#parse_resource_element@:"Graph#get_bnode_by_identifier@N:TypedLiteral#encoding=@:REXML::Element#lang?@:Triple#predicate@:Triple#subject=@:Graph#to_ntriples@:Namespace#bind@a:BNode#valid_id?@:URIRef#to_s@M:Graph#each_with_subject@:Namespace#short@;Z@:BNode#to_n3@f:Literal#==@;q@;g@v:RdfaParser#initialize@6:TypedLiteral#xmlliteral?@:RdfaParser#uri=@:Graph#triples@;s@1:TypedLiteral#contents=@:TypedLiteral#initialize@:Triple#object@:RdfXmlParser#is_rdf?@:RdfXmlParser#graph=@: Graph#<<@:Namespace#method_missing@=:Namespace#fragment=@
:BNode#to_s@{;u@e:URIRef#==@H;v@H:Graph#each@:BNode#eql?@a:Literal#lang=@o;:T{"RuntimeError;9" Object;9