diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 43ccc2f..a4f0a0f 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ["2.5", "2.6", "2.7", "3.0"] + ruby: ["2.7", "3.0", "3.1"] name: Ruby Test ${{ matrix.ruby }} steps: @@ -31,7 +31,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.0 + ruby-version: "3.0" bundler-cache: true # Runs bundle install and caches gems. See the ruby_test.yml # example if you need more control over bundler. diff --git a/.rubocop.yml b/.rubocop.yml index 918d5c9..6bb5572 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,7 +11,7 @@ inherit_from: .rubocop_todo.yml # # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: "2.7" Style/ClassAndModuleChildren: Enabled: false Layout/LineLength: @@ -19,7 +19,7 @@ Layout/LineLength: AutoCorrect: true Naming/FileName: Exclude: - - 'lib/sequencescape-api.rb' + - "lib/sequencescape-api.rb" # Pending Cops Lint/DuplicateBranch: # (new in 1.3) diff --git a/.ruby-version b/.ruby-version index 56b1397..a4dd9db 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.5.8 +2.7.4 diff --git a/README.markdown b/README.markdown index c737086..6da9782 100644 --- a/README.markdown +++ b/README.markdown @@ -12,8 +12,10 @@ Documentation can be found [on the wiki](https://github.com/sanger/sequencescape - 0.6.x Removes usage of WTSISignOn cookie. Replaces with user specific api key, can be provided to Sequencescape::Api.new as user_api_key: or via `api_connection_options` in the controller. +- 1.0.x Enables HTTPS +- 2.0.x Drops support for versions less than Ruby 2.7 -- master currently corresponds to 0.6.x +- master currently corresponds to 2.x Rails 6 appears to be supported judging by Specs, but haven't used it in anger yet. @@ -22,7 +24,7 @@ yet. 1. Update the version number in `lib/sequencescape-api/version.rb` 2. For pre-releases the version number should be in the format: - major.minor.point-rcx + major.minor.point-rcx (increment x to prevent burning though version numbers when testing release candidates) 3. For release version the version number should be in the format: major.minor.point 4. Ensure everything is committed, and for non-pre-releases, make sure you are diff --git a/lib/sequencescape-api/connection_factory/actions.rb b/lib/sequencescape-api/connection_factory/actions.rb index 4022126..51f0a51 100644 --- a/lib/sequencescape-api/connection_factory/actions.rb +++ b/lib/sequencescape-api/connection_factory/actions.rb @@ -8,8 +8,8 @@ Net::HTTP.module_eval do alias_method '__initialize__', 'initialize' - def initialize(*args, &block) - __initialize__(*args, &block) + def initialize(...) + __initialize__(...) ensure @debug_output = $stderr if ENV['HTTP_DEBUG'] end @@ -105,7 +105,7 @@ def perform(http_verb, url, body = nil, accepts = nil) # rubocop:todo Metrics/Me rescue URI::InvalidURIError => e raise URI::InvalidURIError, "#{http_verb} failed: #{url.inspect} is not a valid uri" end - Net::HTTP.start(uri.host, uri.port) do |connection| + Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |connection| connection.read_timeout = read_timeout request_headers = headers request_headers.merge!('Accept' => accepts) unless accepts.nil? @@ -122,7 +122,7 @@ def perform(http_verb, url, body = nil, accepts = nil) # rubocop:todo Metrics/Me def perform_for_file(http_verb, url, file, filename, content_type) uri = URI.parse(url) - Net::HTTP.start(uri.host, uri.port) do |connection| + Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |connection| connection.read_timeout = read_timeout file_headers = headers.merge!({ 'Content-Disposition' => "form-data; filename=\"#{filename}\"" }) request = Net::HTTP.const_get(http_verb.to_s.classify).new(uri.request_uri, file_headers) diff --git a/lib/sequencescape-api/error_handling.rb b/lib/sequencescape-api/error_handling.rb index ed971cc..d6e5b91 100644 --- a/lib/sequencescape-api/error_handling.rb +++ b/lib/sequencescape-api/error_handling.rb @@ -5,6 +5,7 @@ require 'active_model/errors' # Uh, ok, so why do I have to include these when I've kind of said I want everything!?!! +require 'active_support/core_ext/module/deprecation' require 'active_model/validator' require 'active_model/validations' require 'active_model/callbacks' diff --git a/lib/sequencescape-api/resource/attribute_groups.rb b/lib/sequencescape-api/resource/attribute_groups.rb index aeda953..ff9085b 100644 --- a/lib/sequencescape-api/resource/attribute_groups.rb +++ b/lib/sequencescape-api/resource/attribute_groups.rb @@ -28,19 +28,17 @@ def eager_loaded_attribute?(name) end module Json - def as_json_for_update(options) # rubocop:todo Metrics/MethodLength + def as_json_for_update(options) super.tap do |json| - begin - if options[:root] - json.fetch(json_root).merge!(attribute_group_json(options)) - else - json.merge!(attribute_group_json(options)) - end - rescue KeyError => e - # If we get a key error, append the json to out exception to assist diagnosing issues - e.message << " in #{json.to_json}" - raise e + if options[:root] + json.fetch(json_root).merge!(attribute_group_json(options)) + else + json.merge!(attribute_group_json(options)) end + rescue KeyError => e + # If we get a key error, append the json to out exception to assist diagnosing issues + e.message << " in #{json.to_json}" + raise e end end private :as_json_for_update diff --git a/lib/sequencescape-api/version.rb b/lib/sequencescape-api/version.rb index 6576379..8f47958 100644 --- a/lib/sequencescape-api/version.rb +++ b/lib/sequencescape-api/version.rb @@ -1,5 +1,5 @@ module Sequencescape class Api - VERSION = '0.7.1'.freeze + VERSION = '2.0.0'.freeze end end diff --git a/sequencescape-api.gemspec b/sequencescape-api.gemspec index ab83cd5..a782c4c 100644 --- a/sequencescape-api.gemspec +++ b/sequencescape-api.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.homepage = '' s.summary = 'Gem for the client side of the Sequencescape API' s.description = 'Provides all of the necessary code for interacting with the Sequencescape API' - s.required_ruby_version = '> 2.4' + s.required_ruby_version = '>= 2.7' s.rubyforge_project = 'sequencescape-client-api' diff --git a/spec/sequencescape-api/modifications_spec.rb b/spec/sequencescape-api/modifications_spec.rb index 2b0d4c5..2edaf83 100644 --- a/spec/sequencescape-api/modifications_spec.rb +++ b/spec/sequencescape-api/modifications_spec.rb @@ -11,11 +11,9 @@ end it 'includes the error on the field' do - begin - target.__send__(action, attribute_validated_at_client: 'please error') - rescue Sequencescape::Api::ResourceInvalid => e - e.resource.errors[:attribute_validated_at_client].should == ['cannot be set'] - end + target.__send__(action, attribute_validated_at_client: 'please error') + rescue Sequencescape::Api::ResourceInvalid => e + e.resource.errors[:attribute_validated_at_client].should == ['cannot be set'] end end @@ -29,11 +27,9 @@ end it 'includes the error on the field' do - begin - target.__send__(action, attribute_validated_at_server: 'please error') - rescue Sequencescape::Api::ResourceInvalid => e - e.resource.errors[:attribute_validated_at_server].should == ['cannot be set'] - end + target.__send__(action, attribute_validated_at_server: 'please error') + rescue Sequencescape::Api::ResourceInvalid => e + e.resource.errors[:attribute_validated_at_server].should == ['cannot be set'] end end end