public
Description: The Curies library implements the CURIE syntax for expressing Compact URIs. See http://www.w3.org/TR/curie/ for more information on the CURIE specification.
Homepage:
Clone URL: git://github.com/pius/curies.git
pius (author)
Fri Jan 09 02:26:36 -0800 2009
commit  608baabaf65a166e2e9402ab0a868198376b514d
tree    44e50785e6941642ab56023244ea6671b19f4b93
parent  a148e2a50add900596d595e3c8a78e07ce5b32f2
curies / .yardoc
100644 55 lines (55 sloc) 5.474 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
[IC:SymbolHash{:Curie#initializeo:$YARD::CodeObjects::MethodObject:@namespaceo:#YARD::CodeObjects::ClassObject;o:"YARD::CodeObjects::RootObject ;0:@docstring":@childrenIC:&YARD::CodeObjects::CodeObjectList[ o; ;@ ; "; IC; [o;;@ ; ":@signature"def could_be_a_safe_curie?:
@tags[:
@name:could_be_a_safe_curie?: @scope: instance:@explicitT:
@linei:@visibility: public: @source"Zdef could_be_a_safe_curie?
  self[0,1] == "[" and self[length - 1, length] == "]"
end:
@file"lib/curies/curie.rb: @owner@ ;[: @aliases{;: String:@superclasso:YARD::CodeObjects::Proxy;@ ;: Object: @obj0;i:@attributesIC;{;IC;{:@symbolize_valueT:
classIC;{;"T;"T;@: @mixinsIC; [;@ @o; ;@ ; "; IC; [o;;@; ";"def stringify_keys ;[;:stringify_keys;;;T;iL;;;"tdef stringify_keys
  inject({}) do |options, (key, value)|
      options[key.to_s] = value
  options
  end
end;@;@;[;{;: Hash;o;;@ ;;; 0;iK;!IC;{;IC;{;"T;#IC;{;"T;"T;@;$IC; [;@o:$YARD::CodeObjects::ModuleObject;@ ; "; IC; [o;';@+; "; IC; [ o:&YARD::CodeObjects::ConstantObject ;@.; ";"MAJOR = 0;[;:
MAJOR;i;"MAJOR = 0;"lib/curies/version.rbo;( ;@.; ";"MINOR = 0;[;:
MINOR;i ;"MINOR = 0;@6o;( ;@.; ";"TINY = 1;[;: TINY;i
;"TINY = 1;@6o;( ;@.; ";",STRING = [MAJOR, MINOR, TINY].join('.');[;: STRING;i ;",STRING = [MAJOR, MINOR, TINY].join('.');@6;@.;[;{;: VERSION;i;!IC;{;IC;{;"T;#IC;{;"T;"T;@6;$IC; [;@.;@+;[;{;: Curies;i;!IC;{;IC;{;"T;#IC;{;"T;"T;@6;$IC; [;@+;@ ;[;{;: root;!IC;{;IC;{;"T;#IC;{;"T;"T;$IC; [;@ ; "; IC; [ o;( ;@; ";"LDEFAULT_MAPPINGS = {"cal" => "http://www.w3.org/2002/12/cal/ical#", "cc" => "http://creativecommons.org/ns#", "contact" => "http://www.w3.org/2001/vcard-rdf/3.0#", "dc" => "http://purl.org/dc/elements/1.1/", "foaf" => "http://xmlns.com/foaf/0.1/", "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs" => "http://www.w3.org/2000/01/rdf-schema#", "xsd" => "http://www.w3.org/2001/XMLSchema#", "http" => "http" };[;:DEFAULT_MAPPINGS;i ;"LDEFAULT_MAPPINGS = {"cal" => "http://www.w3.org/2002/12/cal/ical#", "cc" => "http://creativecommons.org/ns#", "contact" => "http://www.w3.org/2001/vcard-rdf/3.0#", "dc" => "http://purl.org/dc/elements/1.1/", "foaf" => "http://xmlns.com/foaf/0.1/", "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs" => "http://www.w3.org/2000/01/rdf-schema#", "xsd" => "http://www.w3.org/2001/XMLSchema#", "http" => "http" };@o:+YARD::CodeObjects::ClassVariableObject ;@; ";"@@mappings = {};[;:@@mappings;i;"@@mappings = {};@@o;;@; ";",def self.parse(curie_string, opts = {});[;:
parse;;#: @dynamicT;T;i;;;"wdef self.parse(curie_string, opts = {})
  if opts[:treat_unsafe_as_normal_strings] and not curie_string.could_be_a_safe_curie?
    a = [curie_string, :string]
    return a
  end
  if not(curie_string.index(':')) #just some random string that doesn't even have a colon!
    #strip off brackets if they exist
    curie_string = curie_string[1,curie_string.length-2] if curie_string.could_be_a_safe_curie?
    return curie_string
  elsif curie_string.could_be_a_safe_curie?
    pivot = curie_string.index(':')
    prefix = curie_string[1,pivot-1]
    reference = curie_string[pivot+1, curie_string.length].chop
  else
    pivot = curie_string.index(':')
    prefix = curie_string[0,pivot]
    reference = curie_string[pivot+1, curie_string.length]
  end
  if opts[:in_parts]
    return [qualified_uri_for(prefix), reference]
  else
    return qualified_uri_for(prefix) + reference
  end
end;@o;;@; ";"'def self.qualified_uri_for(prefix);[;:qualified_uri_for;;#;4T;T;i6;;;"°def self.qualified_uri_for(prefix)
  return @@mappings[prefix] if @@mappings[prefix]
  raise "Sorry, no namespace or prefix registered for curies with the prefix #{prefix}"
end;@o;;@; ";"%def self.add_prefixes!(mappings);[;:add_prefixes!;;#;4T;T;i;;;;"Udef self.add_prefixes!(mappings)
  @@mappings.merge! mappings.stringify_keys
end;@o;;@; ";"(def self.remove_prefixes!(prefixes);[;:remove_prefixes!;;#;4T;T;i?;;;"¢def self.remove_prefixes!(prefixes)
  prefixes = [prefixes] unless prefixes.respond_to? :each
  for prefix in prefixes
    @@mappings.delete prefix.to_s
  end
end;@o;;@; ";" def to_s;[;: to_s;;;4T;T;iF;;;"0def to_s
  "[#{@prefix}:#{@reference}]"
end;@;@;[;{;:
Curie;o;;@ ;;; 0;i ;!IC;{;IC;{;"T;#IC;{;"T;"T;@;$IC; [;@; ";"&def initialize(prefix, reference);[;:initialize;;;T;i;;;"Tdef initialize(prefix, reference)
  @prefix, @reference = prefix, reference
end;@:Curies::VERSION::TINY@<:Curie::remove_prefixes!@s:Curies::VERSION@.:Curie::parse@d:Curie::DEFAULT_MAPPINGS@Z:Curies::VERSION::MAJOR@1:Curie::qualified_uri_for@i:Curies::VERSION::STRING@A;.@+:Curie#to_s@x;9@:Hash#stringify_keys@:Curie::@@mappings@_:Curies::VERSION::MINOR@7:Curie::add_prefixes!@n:"String#could_be_a_safe_curie?@;&@;@ ;/@ ;"T{" Object;#