Skip to content

Commit bb89c49

Browse files
Update rubocop requirement from ~> 0.79 to ~> 1.64 (#20)
* Update rubocop requirement from ~> 0.79 to ~> 1.64 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v0.79.0...v1.64.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * Add require ostruct to fix unitialized constant error * Autocorrect rubocop fixes * Address manual rubocop fixes * Enable new cops and autocorrect --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JDutil <jeff.dutil@juul.com>
1 parent 972b261 commit bb89c49

11 files changed

Lines changed: 15 additions & 9 deletions

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Relaxed.Ruby.Style
22
## Version 2.1
33
AllCops:
4-
TargetRubyVersion: 2.7.5
4+
NewCops: enable
5+
TargetRubyVersion: 3.0.0
56

67
Gemspec/OrderedDependencies:
78
Enabled: false

contentful_lite.gemspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
1313
spec.required_ruby_version = '>= 3.0.0'
1414

1515
spec.files = Dir["lib/**/*", "LICENSE", "README.md"]
16-
spec.test_files = Dir["spec/**/*"]
1716
spec.require_paths = ["lib"]
1817

1918
spec.add_dependency "http", '~> 5.0'
@@ -23,5 +22,5 @@ Gem::Specification.new do |spec|
2322
spec.add_development_dependency "webmock", '~> 3.18'
2423
spec.add_development_dependency "simplecov", '~> 0.17'
2524
spec.add_development_dependency "vcr", '~> 6.0'
26-
spec.add_development_dependency "rubocop", '~> 0.79'
25+
spec.add_development_dependency "rubocop", '~> 1.64'
2726
end

lib/contentful_lite/assets_array.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class AssetsArray < BaseArray
33
# @param raw [Hash] raw response from Contentful API
44
# @api private
55
def initialize(raw)
6-
super(raw)
6+
super
77

88
# Create the array of asset objects
99
@items.collect! { |item| ContentfulLite::Asset.new(item) }

lib/contentful_lite/base_array.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class BaseArray < Delegator
1010
# @param raw [Hash] raw response from Contentful API
1111
# @api private
1212
def initialize(raw)
13+
super
1314
@total = raw['total']
1415
@skip = raw['skip']
1516
@limit = raw['limit']

lib/contentful_lite/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def initialize(response, body)
1111
super(body['sys'] && body['sys']['type'] == 'Error' ? "#{body['sys']['id']}: #{body['message']}" : "Invalid Contentful Response: #{body}")
1212
end
1313
end
14+
1415
class NotFoundError < RequestError; end
1516

1617
attr_reader :space_id, :environment, :preview

lib/contentful_lite/entries_array.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class EntriesArray < BaseArray
33
# @param raw [Hash] raw response from Contentful API
44
# @api private
55
def initialize(raw)
6-
super(raw)
6+
super
77

88
# Collect arrays of missing (unresolvable) links
99
@errors = raw.fetch('errors', []).collect! { |error| error.fetch('details', {}) }.each_with_object({}) do |error_detail, hash|
@@ -52,7 +52,7 @@ def build_entry(id)
5252

5353
klass = ContentfulLite::Entry.get_class(hash['sys']['contentType']['sys']['id'])
5454
@entries[id] = klass.new(hash)
55-
@entries[id].localized_fields.values.each do |fields|
55+
@entries[id].localized_fields.each_value do |fields|
5656
fields.transform_values! { |field| solve_link(field) }
5757
end
5858
@entries[id]

lib/contentful_lite/entry.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class Entry
1010
# @param raw [Hash] raw response from Contentful API
1111
# @api private
1212
def initialize(raw)
13-
super(raw)
13+
super
1414
@content_type_id = raw['sys']['contentType']['sys']['id']
15-
@localized_fields.values.each do |fields|
15+
@localized_fields.each_value do |fields|
1616
fields.transform_values! { |value| build_link(value) }
1717
end
1818
end

lib/contentful_lite/validations/included_asset_validator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class IncludedAssetValidator < ActiveModel::EachValidator
77

88
def validate_child(record, attr_name, value, idx = nil)
99
record_error(record, attr_name, "value#{idx} is not a published asset") && return unless value.is_a?(ContentfulLite::Asset)
10+
1011
record_error(record, attr_name, "value#{idx} has an invalid asset type. Expecting #{options[:type]}") if options[:type] && !value&.content_type&.include?(options[:type].to_s)
1112
end
1213
end

lib/contentful_lite/validations/included_child_validator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ def validate_each(record, attr_name, value)
1818
private
1919

2020
def record_error(record, attr_name, message)
21-
record.errors.add(attr_name, :invalid, **{ message: message }.merge(options.except(self.class.options_keys)))
21+
record.errors.add(attr_name, :invalid, message: message, **options.except(self.class.options_keys))
2222
end
2323

2424
def validate_array(record, attr_name, value)
2525
record_error(record, attr_name, "value is not an array") && return unless value.is_a?(Array)
26+
2627
value.each_with_index { |asset, idx| validate_child(record, attr_name, asset, "[#{idx}]") }
2728
end
2829

spec/link_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper'
2+
require 'ostruct'
23

34
RSpec.describe ContentfulLite::Link do
45
let(:entry_hash) { JSON.parse(File.read('fixtures/entries/nyancat.json')) }

0 commit comments

Comments
 (0)