lib/wcc/contentful/downloads_schema.rb in wcc-contentful-1.2.0 vs lib/wcc/contentful/downloads_schema.rb in wcc-contentful-1.2.1

- old
+ new

@@ -34,11 +34,11 @@ contents = begin JSON.parse(File.read(@file)) rescue JSON::ParserError - return true + return true # rubocop:disable Lint/NoReturnInBeginEndBlocks end existing_cts = contents['contentTypes'].sort_by { |ct| ct.dig('sys', 'id') } return true unless content_types.count == existing_cts.count return true unless deep_contains_all(content_types, existing_cts) @@ -81,17 +81,18 @@ .map { |c| c.slice('fieldId', 'settings', 'widgetId') } } end def deep_contains_all(expected, actual) - if expected.is_a? Array + case expected + when Array expected.each_with_index do |val, i| return false unless actual[i] return false unless deep_contains_all(val, actual[i]) end true - elsif expected.is_a? Hash + when Hash expected.each do |(key, val)| return false unless actual.key?(key) return false unless deep_contains_all(val, actual[key]) end true @@ -105,8 +106,8 @@ # The pretty_generate format differs from contentful-shell and nodejs formats # only in its treatment of empty arrays in the "validations" field. json_string = json_string.gsub(/\[\n\n\s+\]/, '[]') # contentful-shell also adds a newline at the end. - json_string + "\n" + "#{json_string}\n" end end