Skip to content

Commit 9f0e9d1

Browse files
committed
Make sure context processing mode is captured when serialized to Ruby, and that we can handle it if it's not saved in the cache.
1 parent 5e2f14a commit 9f0e9d1

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/json/ld/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def initialize(input, context, options = {}, &block)
136136
@context = Context.parse(context || {}, @options)
137137

138138
# If not set explicitly, the context figures out the processing mode
139-
@options[:processingMode] ||= @context.processingMode
139+
@options[:processingMode] ||= @context.processingMode || "json-ld-1.0"
140140
@options[:validate] ||= %w(json-ld-1.0 json-ld-1.1).include?(@options[:processingMode])
141141

142142
if block_given?

lib/json/ld/context.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,7 @@ def to_rb
13571357
defn << "base: #{self.base.to_s.inspect}" if self.base
13581358
defn << "language: #{self.default_language.inspect}" if self.default_language
13591359
defn << "vocab: #{self.vocab.to_s.inspect}" if self.vocab
1360+
defn << "processingMode: #{self.processingMode.inspect}" if self.processingMode
13601361
term_defs = term_definitions.map do |term, td|
13611362
" " + term.inspect + " => " + td.to_rb
13621363
end.sort

script/tc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def earl_preamble(options)
2727
end
2828

2929
def run_tc(man, tc, options)
30+
tc.options[:logger] = options[:logger]
3031
STDERR.write "run #{tc.property('input')}"
3132

3233
if options[:verbose]
@@ -140,12 +141,13 @@ logger.formatter = lambda {|severity, datetime, progname, msg| "#{severity}: #{m
140141

141142
options = {
142143
output: STDOUT,
143-
results: {}
144+
results: {},
145+
logger: logger
144146
}
145147

146148
opts = GetoptLong.new(
147149
["--help", "-?", GetoptLong::NO_ARGUMENT],
148-
["--dbg", GetoptLong::NO_ARGUMENT],
150+
["--debug", GetoptLong::NO_ARGUMENT],
149151
["--earl", GetoptLong::NO_ARGUMENT],
150152
["--quiet", "-q", GetoptLong::NO_ARGUMENT],
151153
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT],
@@ -166,11 +168,10 @@ def help(options)
166168
exit(0)
167169
end
168170

169-
170171
opts.each do |opt, arg|
171172
case opt
172173
when '--help' then help(options)
173-
when '--dbg' then logger.level = Logger::DEBUG
174+
when '--debug' then logger.level = Logger::DEBUG
174175
when '--earl'
175176
options[:quiet] = options[:earl] = true
176177
logger.level = Logger::FATAL

0 commit comments

Comments
 (0)