Skip to content

Commit

Permalink
remove unnecessary method (#136, rggen/rggen#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
taichi-ishitani authored Dec 26, 2023
1 parent b27ef51 commit 8e97e79
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions lib/rggen/core/input_base/yaml_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ def mapping_key?
end

class Visitor < ::Psych::Visitors::ToRuby
if ::Psych::VERSION >= '3.2.0'
def initialize(scalar_scanner, class_loader)
super(scalar_scanner, class_loader, symbolize_names: true)
end
def initialize(scalar_scanner, class_loader)
super(scalar_scanner, class_loader, symbolize_names: true)
end

def accept(node)
Expand All @@ -79,7 +77,6 @@ def override_object?(node)
def load_yaml(file)
parse_yaml(File.binread(file), file)
.then { |result| to_ruby(result) }
.then { |result| symbolize_names(result) }
end

def parse_yaml(yaml, file)
Expand All @@ -93,20 +90,6 @@ def to_ruby(result)
ss = ::Psych::ScalarScanner.new(cl)
Visitor.new(ss, cl).accept(result)
end

def symbolize_names(result)
return result if ::Psych::VERSION >= '3.2.0'

if result.match_class?(Hash)
result
.transform_keys!(&:to_sym)
.transform_values!(&method(:symbolize_names))
elsif result.match_class?(Array)
result.map! { |value| symbolize_names(value) }
end

result
end
end
end
end
Expand Down

0 comments on commit 8e97e79

Please sign in to comment.