diff --git a/.ruby-version b/.ruby-version index 4560fb9..b502146 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.6.3 +3.0.2 diff --git a/Gemfile b/Gemfile index 7f4f5e9..a436af8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,8 @@ source 'https://rubygems.org' +gem 'rubocop', '>= 1.18.4' + +gem 'root-ruby-style', git: 'https://github.com/Root-App/root-ruby-style.git', ref: '393b968dbf59567977a812489d8da807ba3248ec' + gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 78b0d93..ad703da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,15 @@ +GIT + remote: https://github.com/Root-App/root-ruby-style.git + revision: 393b968dbf59567977a812489d8da807ba3248ec + ref: 393b968dbf59567977a812489d8da807ba3248ec + specs: + root-ruby-style (0.0.7) + activesupport (>= 5.0, < 7.x) + rubocop (~> 1.18.4) + rubocop-performance (= 1.5.2) + rubocop-rails (~> 2.5.0) + rubocop-rspec (~> 1.38.1) + PATH remote: . specs: @@ -9,32 +21,32 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.0.3.1) + activesupport (6.1.5) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) - ast (2.4.0) - coderay (1.1.2) - concurrent-ruby (1.1.6) - crack (0.4.3) - safe_yaml (~> 1.0.0) - diff-lcs (1.3) - docile (1.3.2) + ast (2.4.2) + coderay (1.1.3) + concurrent-ruby (1.1.10) + crack (0.4.5) + rexml + diff-lcs (1.5.0) + docile (1.4.0) factory_bot (5.0.2) activesupport (>= 4.2.0) - ffi (1.11.1) - formatador (0.2.5) - guard (2.15.0) + ffi (1.15.5) + formatador (1.1.0) + guard (2.18.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) - pry (>= 0.9.12) + pry (>= 0.13.0) shellany (~> 0.0) thor (>= 0.18.1) guard-compat (1.2.1) @@ -42,59 +54,70 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - hashdiff (0.4.0) - i18n (1.8.2) + hashdiff (1.0.1) + i18n (1.10.0) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.3) - json (2.3.1) + json (2.6.1) jwt (2.2.1) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - lumberjack (1.0.13) - method_source (0.9.2) - minitest (5.14.1) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + lumberjack (1.2.8) + method_source (1.0.0) + minitest (5.15.0) mixpanel-ruby (2.2.0) nenv (0.3.0) - notiffany (0.1.1) + notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.18.0) - parser (2.6.5.0) - ast (~> 2.4.0) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) + parallel (1.22.0) + parser (3.1.1.0) + ast (~> 2.4.1) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) public_suffix (4.0.6) - rainbow (3.0.0) - rake (13.0.1) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rack (2.2.3) + rainbow (3.1.1) + rake (13.0.6) + rb-fsevent (0.11.1) + rb-inotify (0.10.1) ffi (~> 1.0) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) + regexp_parser (2.2.1) + rexml (3.2.5) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - rubocop (0.75.1) - jaro_winkler (~> 1.5.1) + rspec-support (~> 3.11.0) + rspec-support (3.11.0) + rubocop (1.18.4) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.8.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - ruby-progressbar (1.10.1) - ruby_dep (1.5.0) - safe_yaml (1.0.5) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) + rubocop-performance (1.5.2) + rubocop (>= 0.71.0) + rubocop-rails (2.5.2) + activesupport + rack (>= 1.1) + rubocop (>= 0.72.0) + rubocop-rspec (1.38.1) + rubocop (>= 0.68.1) + ruby-progressbar (1.11.0) semantic (1.6.1) shellany (0.0.1) simplecov (0.16.1) @@ -102,17 +125,16 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - thor (0.20.3) - thread_safe (0.3.6) - timecop (0.9.1) - tzinfo (1.2.7) - thread_safe (~> 0.1) - unicode-display_width (1.6.0) - webmock (3.6.0) + thor (1.2.1) + timecop (0.9.5) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + unicode-display_width (2.1.0) + webmock (3.6.2) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - zeitwerk (2.3.0) + zeitwerk (2.5.4) PLATFORMS ruby @@ -124,12 +146,13 @@ DEPENDENCIES guard-rspec (~> 4.7.3) pry (~> 0.12) rake (~> 13.0) + root-ruby-style! rspec (~> 3.0) - rubocop (~> 0.75.0) + rubocop (>= 1.18.4) semantic (~> 1.5) simplecov (~> 0.16.1) timecop (~> 0.9.1) webmock (~> 3.6.0) BUNDLED WITH - 2.1.4 + 2.2.22 diff --git a/app_store_connect.gemspec b/app_store_connect.gemspec index eb8e444..d8ccc63 100644 --- a/app_store_connect.gemspec +++ b/app_store_connect.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.email = ['kyle.decot@icloud.com'] spec.summary = 'A Ruby interface to the App Store Connect API' - spec.homepage = 'https://github.com/kyledecot/app_store_connect' + spec.homepage = 'https://github.com/Root-App/root_app_store_connect' spec.license = 'MIT' spec.files = Dir.chdir(File.expand_path(__dir__)) do @@ -19,6 +19,7 @@ Gem::Specification.new do |spec| end spec.require_paths = ['lib'] + spec.required_ruby_version = '>= 3.0.2' spec.add_runtime_dependency 'activesupport', '>= 6.0.3.1' spec.add_runtime_dependency 'jwt', '>= 1.4', '<= 2.2.1' diff --git a/lib/app_store_connect.rb b/lib/app_store_connect.rb index f12e9eb..00e0dd6 100644 --- a/lib/app_store_connect.rb +++ b/lib/app_store_connect.rb @@ -20,13 +20,12 @@ module AppStoreConnect class << self attr_accessor :config - def rel(id, type, array = false) + def rel(id, type, array: false) if array - return {data: [{id: id, type: type}]}.freeze + { data: [{ id: id, type: type }] }.freeze else - return {data: {id: id, type: type}}.freeze + { data: { id: id, type: type } }.freeze end end - end end diff --git a/lib/app_store_connect/client.rb b/lib/app_store_connect/client.rb index cf8c1b0..ee83914 100644 --- a/lib/app_store_connect/client.rb +++ b/lib/app_store_connect/client.rb @@ -23,12 +23,12 @@ def respond_to_missing?(method_name, include_private = false) web_service_endpoint_aliases.include?(method_name) || super end - def method_missing(method_name, *kwargs) + def method_missing(method_name, **kwargs) super unless web_service_endpoint_aliases.include?(method_name) web_service_endpoint = web_service_endpoint_by(method_name) - call(web_service_endpoint, *kwargs) + call(web_service_endpoint, **kwargs) end # :nocov: @@ -82,7 +82,7 @@ def build_request(web_service_endpoint, **kwargs) options[:http_body] = http_body(web_service_endpoint, **kwargs) if web_service_endpoint.http_method == :post - Request.new(options) + Request.new(**options) end def headers diff --git a/lib/app_store_connect/client/options.rb b/lib/app_store_connect/client/options.rb index 6b86309..d021811 100644 --- a/lib/app_store_connect/client/options.rb +++ b/lib/app_store_connect/client/options.rb @@ -13,7 +13,7 @@ class Options < SimpleDelegator }.freeze private_constant :DEFAULTS - ENV_REGEXP = /APP_STORE_CONNECT_(?[A-Z_]+)/.freeze + ENV_REGEXP = /APP_STORE_CONNECT_(?[A-Z_]+)/ private_constant :ENV_REGEXP def initialize(kwargs = {}) diff --git a/lib/app_store_connect/client/registry.rb b/lib/app_store_connect/client/registry.rb index 0f6fb66..78eb75e 100644 --- a/lib/app_store_connect/client/registry.rb +++ b/lib/app_store_connect/client/registry.rb @@ -8,7 +8,7 @@ class Registry < SimpleDelegator OPTIONS = %i[schema].freeze def initialize(options = {}) - super(options .fetch(:schema).web_service_endpoints.map { |s| [s.alias, s] }.to_h) + super(options.fetch(:schema).web_service_endpoints.map { |s| [s.alias, s] }.to_h) end end end diff --git a/lib/app_store_connect/create_request.rb b/lib/app_store_connect/create_request.rb index dfb8a01..bc1ed4c 100644 --- a/lib/app_store_connect/create_request.rb +++ b/lib/app_store_connect/create_request.rb @@ -3,11 +3,12 @@ module AppStoreConnect class CreateRequest def self.inherited(klass) + super(klass) klass.include(Object::Data) end def initialize(**kwargs) - @data = self.class::Data.new(kwargs) + @data = self.class::Data.new(**kwargs) end end end diff --git a/lib/app_store_connect/object/attributes.rb b/lib/app_store_connect/object/attributes.rb index 8542200..156d7af 100644 --- a/lib/app_store_connect/object/attributes.rb +++ b/lib/app_store_connect/object/attributes.rb @@ -31,7 +31,7 @@ def attributes(&block) def to_h {}.tap do |hash| - self.class.properties.keys.each do |name| + self.class.properties.each_key do |name| value = instance_variable_get("@#{name}") hash[name] = value unless value.nil? diff --git a/lib/app_store_connect/object/data.rb b/lib/app_store_connect/object/data.rb index 68ee252..b1ae60e 100644 --- a/lib/app_store_connect/object/data.rb +++ b/lib/app_store_connect/object/data.rb @@ -16,7 +16,7 @@ module Data data.send(:define_method, :initialize) do |**kwargs| instance_variable_set('@relationships', kwargs.delete(:relationships).to_h) - instance_variable_set('@attributes', data::Attributes.new(kwargs)) + instance_variable_set('@attributes', data::Attributes.new(**kwargs)) end def to_h diff --git a/spec/app_store_connect/client_spec.rb b/spec/app_store_connect/client_spec.rb index e3cfeb4..a8f3185 100644 --- a/spec/app_store_connect/client_spec.rb +++ b/spec/app_store_connect/client_spec.rb @@ -6,11 +6,11 @@ let(:issuer_id) { '69a6de70-03db-47e3-e053-5b8c7c11a4d1' } subject(:client) do - described_class.new( - issuer_id: issuer_id, - key_id: key_id, - private_key: private_key - ) + described_class.new(**{ + issuer_id: issuer_id, + key_id: key_id, + private_key: private_key + }) end describe '#users' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d94ed34..2c67410 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,7 +13,7 @@ require 'app_store_connect' -Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f } +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| config.example_status_persistence_file_path = '.rspec_status' diff --git a/spec/support/factories/bundle_id_create_request.rb b/spec/support/factories/bundle_id_create_request.rb index d8db809..32980fc 100644 --- a/spec/support/factories/bundle_id_create_request.rb +++ b/spec/support/factories/bundle_id_create_request.rb @@ -16,12 +16,12 @@ end initialize_with do - AppStoreConnect::BundleIdCreateRequest.new( - identifier: identifier, - seed_id: seed_id, - platform: platform, - name: name - ) + AppStoreConnect::BundleIdCreateRequest.new(**{ + identifier: identifier, + seed_id: seed_id, + platform: platform, + name: name + }) end end end