@@ -35,6 +35,12 @@ def self.options
3535 on : [ "--strict" ] ,
3636 description : "Make strict vocabulary"
3737 ) { true } ,
38+ RDF ::CLI ::Option . new (
39+ symbol : :extra ,
40+ datatype : String ,
41+ on : [ "--extra URIEncodedJSON" ] ,
42+ description : "URI Encoded JSON representation of extra data"
43+ ) { |arg | ::JSON . parse ( ::URI . decode ( arg ) ) } ,
3844 ]
3945 end
4046
@@ -142,10 +148,10 @@ def from_node(name, attributes, term_type)
142148 op = term_type == :property ? "property" : "term"
143149
144150 components = [ " #{ op } #{ name . to_sym . inspect } " ]
145- attributes . keys . sort_by ( &:to_s ) . each do |key |
151+ attributes . keys . sort_by ( &:to_s ) . map ( & :to_sym ) . each do |key |
146152 next if key == :vocab
147153 value = Array ( attributes [ key ] )
148- component = key . is_a? ( Symbol ) ? "#{ key } : " : ": #{ key . inspect } => "
154+ component = key . inspect . start_with? ( ':"' ) ? "#{ key . inspect } => " : "#{ key . to_s } : "
149155 value = value . first if value . length == 1
150156 component << if value . is_a? ( Array )
151157 '[' + value . map { |v | serialize_value ( v , key ) } . sort . join ( ", " ) + "]"
@@ -158,8 +164,8 @@ def from_node(name, attributes, term_type)
158164 end
159165
160166 def serialize_value ( value , key )
161- case key
162- when : comment, String
167+ case key . to_s
168+ when " comment" , /:/
163169 "%(#{ value . gsub ( '(' , '\(' ) . gsub ( ')' , '\)' ) } ).freeze"
164170 else
165171 "#{ value . inspect } .freeze"
0 commit comments