Skip to content

Commit

Permalink
Type linting
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed Apr 15, 2024
1 parent 9a865de commit 556575a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
30 changes: 30 additions & 0 deletions datasources/hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true
# typed: ignore

class Hash
def deep_merge_array(other_hash)
dup.deep_merge_array!(other_hash)
end

def deep_merge_array!(other_hash)
if size == 1 && keys[0] == '$ref'
# On JSON schema, when self hash is a ref, clear current value to only keep the other_hash
clear
end

if other_hash.size == 1 && other_hash.keys[0] == '$ref'
# On JSON schema, when other hash if a ref, clear current value to only keep the ref
clear
end

merge!(other_hash) do |_key, this_val, other_val|
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
this_val.deep_merge_array(other_val)
elsif this_val.is_a?(Array) && other_val.is_a?(Array)
(this_val + other_val).uniq
else
other_val
end
end
end
end
13 changes: 13 additions & 0 deletions datasources/logging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true
# typed: ignore

require 'logging'

include Logging.globally
Logging.logger.root.appenders = Logging.appenders.stdout(
layout: Logging.layouts.pattern(
pattern: '%m\n'
),
level: :info,
)
Logging.logger.root.level = :debug

0 comments on commit 556575a

Please sign in to comment.