Skip to content

Commit

Permalink
Finish 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 31, 2016
2 parents 60feb34 + 02a1691 commit 4e3e9e6
Show file tree
Hide file tree
Showing 12 changed files with 248,928 additions and 44 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.1.2
63 changes: 46 additions & 17 deletions bin/jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def run(input, options)
reader_class.new(input, options[:parser_options])
end

prefixes = {}
start = Time.new
if options[:expand]
options = options.merge(expandContext: options.delete(:context)) if options.has_key?(:context)
Expand Down Expand Up @@ -87,17 +86,27 @@ input = nil
OPT_ARGS = [
["--dbg", GetoptLong::NO_ARGUMENT, "Turn on verbose debugging"],
["--compact", GetoptLong::NO_ARGUMENT, "Compact document, using --context"],
["--compactArrays", GetoptLong::OPTIONAL_ARGUMENT, "Set compactArrays option"],
["--context", GetoptLong::REQUIRED_ARGUMENT,"Context to apply for expand, compact and converting from RDF"],
["--embed", GetoptLong::REQUIRED_ARGUMENT,"a flag specifying that objects should be directly embedded in the output, instead of being referred to by their IRI"],
["--evaluate","-e", GetoptLong::REQUIRED_ARGUMENT,"Evaluate argument as a JSON-LD document"],
["--expand", GetoptLong::NO_ARGUMENT, "Expand document, using an optional --context"],
["--expanded", GetoptLong::OPTIONAL_ARGUMENT, "Input is already expanded"],
["--explicit", GetoptLong::OPTIONAL_ARGUMENT, "a flag specifying that for properties to be included in the output, they must be explicitly declared in the framing context"],
["--flatten", GetoptLong::NO_ARGUMENT, "Flatten document, using an optional --context"],
["--format", GetoptLong::REQUIRED_ARGUMENT,"Specify output format when converting to RDF"],
["--frame", GetoptLong::REQUIRED_ARGUMENT,"Frame document, using the file or URL as a frame specification"],
["--input-format", GetoptLong::REQUIRED_ARGUMENT,"Format of the input document, when converting from RDF."],
["--omitDefault", GetoptLong::OPTIONAL_ARGUMENT,"a flag specifying that properties that are missing from the JSON-LD input should be omitted from the output"],
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT,"Output to the specified file path"],
["--parse-only", GetoptLong::NO_ARGUMENT, "Parse the document for well-formedness only"],
["--processingMode",GetoptLong::REQUIRED_ARGUMENT,"Set processing mode, defaults to json-ld-1.1"],
["--quiet", GetoptLong::NO_ARGUMENT, "Supress most output other than progress indicators"],
["--rename_bnodes", GetoptLong::OPTIONAL_ARGUMENT,"Rename bnodes as part of expansion, or keep them the same"],
["--requireAll", GetoptLong::OPTIONAL_ARGUMENT,"Rename bnodes as part of expansion, or keep them the same"],
["--simple_compact_iris",GetoptLong::OPTIONAL_ARGUMENT,"When compacting IRIs, do not use terms with expanded term definitions"],
["--stream", GetoptLong::NO_ARGUMENT, "Use Streaming reader/writer"],
["--unique_bnodes", GetoptLong::OPTIONAL_ARGUMENT,"Use unique bnode identifiers"],
["--uri", GetoptLong::REQUIRED_ARGUMENT,"URI to be used as the document base"],
["--validate", GetoptLong::NO_ARGUMENT, "Validate while processing"],
["--help", "-?", GetoptLong::NO_ARGUMENT, "This message"]
Expand All @@ -121,22 +130,42 @@ opts = GetoptLong.new(*OPT_ARGS.map {|o| o[0..-2]})

opts.each do |opt, arg|
case opt
when '--dbg' then parser_options[:debug] = ::JSON::LD::debug = true
when '--compact' then options[:compact] = true
when '--context' then options[:context] = arg
when '--evaluate' then input = arg
when '--expand' then options[:expand] = true
when '--format' then options[:output_format] = arg.to_sym
when '--flatten' then options[:flatten] = arg
when '--frame' then options[:frame] = arg
when '--input-format' then options[:input_format] = arg.to_sym
when '--output' then options[:output] = File.open(arg, "w")
when '--parse-only' then options[:parse_only] = true
when '--quiet' then options[:quiet] = true
when '--stream' then parser_options[:stream] = true
when '--uri' then parser_options[:base] = arg
when '--validate' then parser_options[:validate] = true
when '--help' then usage
when '--dbg' then parser_options[:debug] = ::JSON::LD::debug = true
when '--compact' then options[:compact] = true
when "--compactArrays" then options[:compactArrays] = (arg || 'true') == 'true'
when '--context' then options[:context] = arg
when '--evaluate' then input = arg
when '--expand' then options[:expand] = true
when "--expanded" then options[:expanded] = (arg || 'true') == 'true'
when "--explicit" then options[:compactArrays] = (arg || 'true') == 'true'
when '--format' then options[:output_format] = arg.to_sym
when '--flatten' then options[:flatten] = arg
when '--frame' then options[:frame] = arg
when '--input-format' then options[:input_format] = arg.to_sym
when "--omitDefault" then options[:omitDefault] = (arg || 'true') == 'true'
when '--output' then options[:output] = File.open(arg, "w")
when '--parse-only' then options[:parse_only] = true
when '--processingMode' then options[:processingMode] = arg
when '--quiet' then options[:quiet] = true
when "--rename_bnodes" then options[:rename_bnodes] = (arg || 'true') == 'true'
when "--requireAll" then options[:requireAll] = (arg || 'true') == 'true'
when '--stream' then parser_options[:stream] = true
when "--unique_bnodes" then options[:unique_bnodes] = (arg || 'true') == 'true'
when '--uri' then parser_options[:base] = arg
when '--validate' then parser_options[:validate] = true
when '--help' then usage
when '--embed'
case arg
when '@always', '@never', '@link', '@last'
options[:embed] = arg
when 'true'
options[:embed] = true
when 'false'
options[:embed] = false
else
STDERR.puts "--embed option takes one of '@always', '@never', '@link', '@last', true, or false"
exit(1)
end
end
end

Expand Down
155 changes: 155 additions & 0 deletions example-files/earl-frame.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"@context": {
"@vocab": "http://www.w3.org/ns/earl#",
"foaf:homepage": {
"@type": "@id"
},
"dc": "http://purl.org/dc/terms/",
"doap": "http://usefulinc.com/ns/doap#",
"earl": "http://www.w3.org/ns/earl#",
"mf": "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#",
"foaf": "http://xmlns.com/foaf/0.1/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"assertedBy": {
"@type": "@id"
},
"assertions": {
"@type": "@id",
"@container": "@set"
},
"bibRef": {
"@id": "dc:bibliographicCitation"
},
"created": {
"@id": "doap:created",
"@type": "xsd:date"
},
"description": {
"@id": "rdfs:comment",
"@language": "en"
},
"developer": {
"@id": "doap:developer",
"@type": "@id",
"@container": "@set"
},
"doapDesc": {
"@id": "doap:description",
"@language": "en"
},
"generatedBy": {
"@type": "@id"
},
"homepage": {
"@id": "doap:homepage",
"@type": "@id"
},
"language": {
"@id": "doap:programming-language"
},
"license": {
"@id": "doap:license",
"@type": "@id"
},
"mode": {
"@type": "@id"
},
"name": {
"@id": "doap:name"
},
"outcome": {
"@type": "@id"
},
"release": {
"@id": "doap:release",
"@type": "@id"
},
"revision": {
"@id": "doap:revision"
},
"shortdesc": {
"@id": "doap:shortdesc",
"@language": "en"
},
"subject": {
"@type": "@id"
},
"test": {
"@type": "@id"
},
"testAction": {
"@id": "mf:action",
"@type": "@id"
},
"testResult": {
"@id": "mf:result",
"@type": "@id"
},
"title": {
"@id": "mf:name"
},
"entries": {
"@id": "mf:entries",
"@type": "@id",
"@container": "@list"
},
"testSubjects": {
"@type": "@id",
"@container": "@set"
},
"xsd": {
"@id": "http://www.w3.org/2001/XMLSchema#"
}
},
"@requireAll": true,
"@embed": "@always",
"assertions": {
},
"bibRef": {
},
"generatedBy": {
"@embed": "@always",
"developer": {
"@embed": "@always"
},
"release": {
"@embed": "@always"
}
},
"testSubjects": {
"@embed": "@always",
"@type": "earl:TestSubject",
"developer": {
"@embed": "@always"
},
"homepage": {
"@embed": "@never"
}
},
"entries": [
{
"@embed": "@always",
"@type": "mf:Manifest",
"entries": [
{
"@embed": "@always",
"@type": "earl:TestCase",
"assertions": {
"@embed": "@always",
"@type": "earl:Assertion",
"assertedBy": {
"@embed": "@never"
},
"result": {
"@embed": "@always",
"@type": "earl:TestResult"
},
"subject": {
"@embed": "@never"
}
}
}
]
}
]
}

0 comments on commit 4e3e9e6

Please sign in to comment.