diff --git a/.github/workflows/lint-app.yml b/.github/workflows/lint-app.yml deleted file mode 100644 index 99b48ce..0000000 --- a/.github/workflows/lint-app.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Rubocop checking - -on: [push] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7 - - name: Install dependencies (bundle) - run: bundle install - - name: Run Rubocop - run: bundle exec rubocop diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5501c93..37a9997 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 diff --git a/.github/workflows/test-app.yml b/.github/workflows/test-app.yml index c89b792..49c8e0d 100644 --- a/.github/workflows/test-app.yml +++ b/.github/workflows/test-app.yml @@ -1,19 +1,26 @@ name: Ruby tests -on: [push, pull_request] +on: pull_request jobs: test: strategy: matrix: - ruby: ['2.7', '3.0', '3.1', '3.2', '3.3'] + # In support versions of Ruby this Gem will be tested against. + # This should correspond to the version range in the gemfile. + ruby: ['3.3', '3.4'] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1.316.0 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + - name: Run Rubocop + # Note that Rubocop will conservatively use the minimal version from the gemfile for its rules + # we should only run it on the minimal Ruby version + if: matrix.ruby == '3.3' + run: bundle exec rubocop - name: Run tests run: bundle exec rake test diff --git a/.rubocop.yml b/.rubocop.yml index 2ada576..8330b68 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,4 @@ AllCops: - TargetRubyVersion: 2.7 NewCops: enable Style/FrozenStringLiteralComment: Enabled: true diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 6a81b4c..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 012cbb5..13ad8f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes will be documented in this file. +## Unreleased + +- (Bogdan) Moved development dependencies from `gemspec` to `Gemfile` and updated + all dependencies [#37](https://github.com/epimorphics/nrw-landing/issues/37) + ## 1.4.0 - 2026-03-04 - (AlexT) When finding wrapper type, select the most specific type if more are available diff --git a/Gemfile b/Gemfile index c868835..bd332c2 100644 --- a/Gemfile +++ b/Gemfile @@ -6,3 +6,15 @@ source 'https://rubygems.org' # Specify your gem's dependencies in sapi-nt-client-ruby.gemspec gemspec + +group :development do + gem 'bundler' + gem 'byebug' + gem 'minitest', '~> 5.0' + gem 'minitest-reporters', '~> 1.0' + gem 'mocha', '~> 2.0' + gem 'rake' + gem 'rubocop' + gem 'simplecov' + gem 'vcr', '~> 6.0' +end diff --git a/Gemfile.lock b/Gemfile.lock index b4c138e..707123d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,12 +9,12 @@ GEM remote: https://rubygems.org/ specs: ansi (1.5.0) - ast (2.4.2) + ast (2.4.3) builder (3.3.0) byebug (11.1.3) - concurrent-ruby (1.3.4) + concurrent-ruby (1.3.7) docile (1.4.1) - faraday (1.10.4) + faraday (1.10.6) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -27,74 +27,83 @@ GEM faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) + faraday-em_synchrony (1.0.1) faraday-excon (1.1.0) faraday-httpclient (1.0.1) - faraday-multipart (1.1.0) + faraday-multipart (1.2.0) multipart-post (~> 2.0) faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) - faraday-retry (1.0.3) + faraday-retry (1.0.4) faraday_middleware (1.0.0) faraday (~> 1.0) - i18n (1.14.6) + i18n (1.14.8) concurrent-ruby (~> 1.0) - minitest (5.25.4) - minitest-reporters (1.7.1) + json (2.20.0) + language_server-protocol (3.17.0.6) + lint_roller (1.1.0) + minitest (5.26.1) + minitest-reporters (1.8.0) ansi builder - minitest (>= 5.0) + minitest (>= 5.0, < 7) ruby-progressbar - mocha (2.7.1) + mocha (2.8.2) ruby2_keywords (>= 0.0.5) multipart-post (2.4.1) - parallel (1.26.3) - parser (3.3.6.0) + parallel (1.28.0) + parser (3.3.11.1) ast (~> 2.4.1) racc + prism (1.9.0) racc (1.8.1) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.10.0) - rexml (3.4.0) - rubocop (1.26.1) - parallel (~> 1.10) - parser (>= 3.1.0.0) + rake (13.4.2) + regexp_parser (2.12.0) + rubocop (1.88.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (>= 1.10) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.16.0, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.37.0) - parser (>= 3.3.1.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.50.0) + parser (>= 3.3.7.2) + prism (~> 1.7) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.13.1) + simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - unicode-display_width (2.6.0) - vcr (6.0.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) + vcr (6.4.0) PLATFORMS - ruby + x86_64-darwin-24 + x86_64-linux DEPENDENCIES - bundler (~> 2.4.22) - byebug (~> 11.1.3) - minitest (~> 5.25) - minitest-reporters (~> 1.7) - mocha (~> 2.4) - rake (~> 13.0.1) - rubocop (~> 1.26.0) + bundler + byebug + minitest (~> 5.0) + minitest-reporters (~> 1.0) + mocha (~> 2.0) + rake + rubocop sapi-client-ruby! - simplecov (~> 0.21.1) - vcr (~> 6.0.0) + simplecov + vcr (~> 6.0) BUNDLED WITH 2.4.22 diff --git a/exe/sapi b/exe/sapi index e6fc03e..e2358b6 100755 --- a/exe/sapi +++ b/exe/sapi @@ -1,13 +1,13 @@ #!/usr/bin/env ruby -# frozen-string-literal: true +# frozen_string_literal: true require 'bundler/setup' require 'optparse' require 'sapi_client' options = { - base: ENV['SAPI_BASE_URL'], - spec: ENV['SAPI_SPEC_FILE'] || ENV['SAPI_SPEC'] + base: ENV.fetch('SAPI_BASE_URL', nil), + spec: ENV['SAPI_SPEC_FILE'] || ENV.fetch('SAPI_SPEC', nil) } def spec_file_or_dir(options) diff --git a/lib/sapi_client/application.rb b/lib/sapi_client/application.rb index f9b62f1..38346a0 100644 --- a/lib/sapi_client/application.rb +++ b/lib/sapi_client/application.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true module SapiClient # Wraps an entire Sapi-NT application, such that we can walk over all of the diff --git a/lib/sapi_client/endpoint_group.rb b/lib/sapi_client/endpoint_group.rb index 958f20a..0bb40b4 100644 --- a/lib/sapi_client/endpoint_group.rb +++ b/lib/sapi_client/endpoint_group.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true module SapiClient # Encapsulates the specification of a group of SAPI endpoints, and some diff --git a/lib/sapi_client/endpoint_values.rb b/lib/sapi_client/endpoint_values.rb index 253df01..04d4c7a 100644 --- a/lib/sapi_client/endpoint_values.rb +++ b/lib/sapi_client/endpoint_values.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true module SapiClient # Encapsulates a set of values from a given endpoint, conditioned by various diff --git a/lib/sapi_client/hierarchy_resource.rb b/lib/sapi_client/hierarchy_resource.rb index 8d1cf74..5677e49 100644 --- a/lib/sapi_client/hierarchy_resource.rb +++ b/lib/sapi_client/hierarchy_resource.rb @@ -8,7 +8,7 @@ class HierarchyResource < SapiResource attr_reader :children, :parent def initialize(resource) - super(resource) + super @children = [] end @@ -22,8 +22,8 @@ def add_child(resource, add_reciprocal: true) resource.send(:parent=, self, add_reciprocal: false) if add_reciprocal end - def each_child(&block) - children.each(&block) + def each_child(&) + children.each(&) end end end diff --git a/lib/sapi_client/instance.rb b/lib/sapi_client/instance.rb index 4683b49..88f11c8 100644 --- a/lib/sapi_client/instance.rb +++ b/lib/sapi_client/instance.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true module SapiClient # Denotes a particular instance of a Sapi-NT API. The instance has the basic diff --git a/lib/sapi_client/resource_wrapper.rb b/lib/sapi_client/resource_wrapper.rb index 45363fa..3a19414 100644 --- a/lib/sapi_client/resource_wrapper.rb +++ b/lib/sapi_client/resource_wrapper.rb @@ -30,11 +30,11 @@ def self.default_resource_wrapper_type # Find the first wrapper type for which there is an existing # class constant with the same name. If no such value is # found, return the default resource wrapper - # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength + # rubocop:disable Metrics/MethodLength def self.find_wrapper_type(types) all_wrapped = Array(types) .map { |type| wrapper_class_constant(de_uri(type)) } - .filter { |wrapper| !wrapper.nil? } + .compact most_specific_wrapped = all_wrapped .filter do |t| all_wrapped.none? do |a| @@ -45,7 +45,7 @@ def self.find_wrapper_type(types) default_resource_wrapper_type end - # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength + # rubocop:enable Metrics/MethodLength # Return the wrapper class for the given resource. If the # `options` specifies the wrapper class, then use that. diff --git a/lib/sapi_client/sapi_endpoint.rb b/lib/sapi_client/sapi_endpoint.rb index 7d83bd3..6a5cf03 100644 --- a/lib/sapi_client/sapi_endpoint.rb +++ b/lib/sapi_client/sapi_endpoint.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true module SapiClient # Denotes a single SAPI-NT endpoint, which we can call to get back JSON data diff --git a/lib/sapi_client/sapi_resource.rb b/lib/sapi_client/sapi_resource.rb index 80ac44e..8198f64 100644 --- a/lib/sapi_client/sapi_resource.rb +++ b/lib/sapi_client/sapi_resource.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true module SapiClient # Encapsulates a JSON-LD -style resource that we get back from a Sapi-NT endpoint, @@ -193,7 +193,7 @@ def lang_select(values, preferred_lang) # Return the given value as an un-wrapped resource. A Hash given to this # method will have its keys transformed to symbols. def as_resource(res) - if res.is_a?(SapiResource) # rubocop:disable Style/CaseLikeIf + if res.is_a?(SapiResource) res.resource.clone elsif res.is_a?(Hash) hash_with_symbol_keys(res) diff --git a/lib/sapi_client/version.rb b/lib/sapi_client/version.rb index 88ff5e8..962942a 100644 --- a/lib/sapi_client/version.rb +++ b/lib/sapi_client/version.rb @@ -4,5 +4,5 @@ module SapiClient MAJOR = 1 MINOR = 4 FIX = 0 - VERSION = "#{MAJOR}.#{MINOR}.#{FIX}" + VERSION = "#{MAJOR}.#{MINOR}.#{FIX}".freeze end diff --git a/lib/sapi_client/view.rb b/lib/sapi_client/view.rb index a8601a1..ae9f628 100644 --- a/lib/sapi_client/view.rb +++ b/lib/sapi_client/view.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true module SapiClient # Encapsulates a view of a Sapi-NT endpoint, which tells us information about diff --git a/sapi-client-ruby.gemspec b/sapi-client-ruby.gemspec index 449e96b..bbede1f 100644 --- a/sapi-client-ruby.gemspec +++ b/sapi-client-ruby.gemspec @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'sapi_client/version' Gem::Specification.new do |spec| - spec.required_ruby_version = '>= 2.7.8' + spec.required_ruby_version = '~> 3.3' spec.name = 'sapi-client-ruby' spec.version = SapiClient::VERSION spec.authors = ['Epimorphics Ltd'] @@ -33,14 +33,4 @@ Gem::Specification.new do |spec| spec.add_dependency 'faraday_middleware', '~> 1.0.0' spec.add_dependency 'i18n', '~> 1.5' - - spec.add_development_dependency 'bundler', '~> 2.4.22' - spec.add_development_dependency 'byebug', '~> 11.1.3' - spec.add_development_dependency 'minitest', '~> 5.25' - spec.add_development_dependency 'minitest-reporters', '~> 1.7' - spec.add_development_dependency 'mocha', '~> 2.4' - spec.add_development_dependency 'rake', '~> 13.0.1' - spec.add_development_dependency 'rubocop', '~> 1.26.0' - spec.add_development_dependency 'simplecov', '~> 0.21.1' - spec.add_development_dependency 'vcr', '~> 6.0.0' end diff --git a/test/sapi_client/endpoint_values_test.rb b/test/sapi_client/endpoint_values_test.rb index 5ae5a31..5ed98e6 100644 --- a/test/sapi_client/endpoint_values_test.rb +++ b/test/sapi_client/endpoint_values_test.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true require 'test_helper' require 'sapi_client' diff --git a/test/sapi_client/sapi_resource_test.rb b/test/sapi_client/sapi_resource_test.rb index 9df921d..1c6bb93 100644 --- a/test/sapi_client/sapi_resource_test.rb +++ b/test/sapi_client/sapi_resource_test.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: true +# frozen_string_literal: true require 'test_helper' require 'sapi_client'