class Elastic::Commands::CompareMappings
Public Instance Methods
perform()
click to toggle source
# File lib/elastic/commands/compare_mappings.rb, line 3 def perform user_properties.reject do |field, property| compare_field_properties(current_properties[field], property) end.map { |f| f[0] } end
Private Instance Methods
compare_field_properties(_current, _user)
click to toggle source
# File lib/elastic/commands/compare_mappings.rb, line 33 def compare_field_properties(_current, _user) return false if _current.nil? case _current['type'] when 'date' return _current == { 'format' => 'dateOptionalTime' }.merge(_user) else return _current == _user end end
current_properties()
click to toggle source
# File lib/elastic/commands/compare_mappings.rb, line 11 def current_properties @current_properties ||= Hash[flatten(current)] end
flatten(_raw, _prefix = '')
click to toggle source
# File lib/elastic/commands/compare_mappings.rb, line 19 def flatten(_raw, _prefix = '') _raw['properties'].flat_map do |name, raw_field| if raw_field['type'] == 'nested' childs = flatten(raw_field, name + '.') childs << [ _prefix + name, raw_field.slice(*(raw_field.keys - ['properties'])) ] else [[_prefix + name, raw_field.dup]] end end end
user_properties()
click to toggle source
# File lib/elastic/commands/compare_mappings.rb, line 15 def user_properties @user_properties ||= Hash[flatten(user)] end