Skip to content

Commit 8f265d7

Browse files
committed
use cached config in parse
1 parent edadb42 commit 8f265d7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.rubocop.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ Lint/RedundantCopDisableDirective:
4444
Enabled: false
4545

4646
Metrics/AbcSize:
47-
Max: 17
47+
Max: 20
48+
49+
Metrics/MethodLength:
50+
Max: 15
4851

4952
Bundler/DuplicatedGem:
5053
Enabled: false

lib/json_scanner.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class Error < StandardError; end
1515
private_constant :ALLOWED_OPTS
1616
STUB = :stub
1717
private_constant :STUB
18+
SCAN_OPTS = { with_path: true, with_roots_info: true }.freeze
19+
private_constant :SCAN_OPTS
20+
SCAN_OPTIONS = Options.new(SCAN_OPTS)
21+
private_constant :SCAN_OPTIONS
1822

1923
def self.parse(json_str, config_or_path_ary, **opts)
2024
# with_path and with_roots_info is set here
@@ -23,7 +27,11 @@ def self.parse(json_str, config_or_path_ary, **opts)
2327
end
2428

2529
opts[:symbolize_path_keys] = opts.delete(:symbolize_names) if opts.key?(:symbolize_names)
26-
results, roots = scan(json_str, config_or_path_ary, **opts, with_path: true, with_roots_info: true)
30+
results, roots = if opts.empty?
31+
scan(json_str, config_or_path_ary, SCAN_OPTIONS)
32+
else
33+
scan(json_str, config_or_path_ary, **opts, **SCAN_OPTS)
34+
end
2735

2836
res = process_results(json_str, results, roots, opts[:symbolize_path_keys])
2937

0 commit comments

Comments
 (0)