From 15992832fc51628061490e12902abcdc08ae66c1 Mon Sep 17 00:00:00 2001 From: lindseytruong Date: Tue, 26 Nov 2024 10:46:05 -0500 Subject: [PATCH] [NO-TICKET] upgrades to ruby/setup-ruby and actions/cache@v4 (#39) Co-authored-by: Olivier --- .github/workflows/ci.yml | 20 ++--- .rubocop.yml | 85 +++++++++++++++---- .ruby-version | 2 +- .../errors/lightspeed_restaurant_error.rb | 7 +- lib/lightspeed_restaurant/request.rb | 10 +-- .../operations/operation_context.rb | 2 +- spec/lightspeed_restaurant_client_spec.rb | 2 +- 7 files changed, 86 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cea83c5..f3a365e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,18 +7,19 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.6] + ruby: ['3.3', '3.4.0-preview2'] steps: - uses: actions/checkout@master - name: Set up the Ruby version - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: '3.3' + bundler-cache: true - name: Ruby gem cache - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} @@ -27,7 +28,6 @@ jobs: - name: Set up the environment run: | - gem install bundler bundle config path vendor/bundle bundle install --jobs 4 --retry 3 @@ -38,18 +38,19 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.6] + ruby: ['3.3', '3.4.0-preview2'] steps: - uses: actions/checkout@master - name: Set up the Ruby version - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: '3.3' + bundler-cache: true - name: Ruby gem cache - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} @@ -58,7 +59,6 @@ jobs: - name: Set up the environment run: | - gem install bundler bundle config path vendor/bundle bundle install --jobs 4 --retry 3 diff --git a/.rubocop.yml b/.rubocop.yml index e1c800c..c457826 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,44 +1,87 @@ require: rubocop-rspec +Gemspec/RequiredRubyVersion: + Enabled: false + Layout/LineLength: - Max: 100 + Enabled: false -Metrics/ParameterLists: - Max: 6 +Layout/MultilineMethodCallIndentation: + Enabled: false -Metrics/MethodLength: - Max: 15 +Lint/ConstantDefinitionInBlock: + Enabled: false -Style/StringLiterals: - EnforcedStyle: single_quotes - SupportedStyles: - - single_quotes - - double_quotes - ConsistentQuotesInMultiline: false +Lint/MissingSuper: + Enabled: false + +Lint/NonDeterministicRequireOrder: + Enabled: false + +Lint/SuppressedException: + Enabled: false + +Lint/ToJSON: + Enabled: false + +Lint/UselessMethodDefinition: + Enabled: false + +Metrics/AbcSize: + Enabled: false Metrics/BlockLength: Severity: warning Exclude: - spec/**/* -Lint/SuppressedException: +Metrics/ClassLength: + Max: 200 + Severity: warning + +Metrics/ParameterLists: + Max: 6 + MaxOptionalParameters: 6 + +Metrics/MethodLength: + Max: 15 + +Naming/BinaryOperatorParameterName: + Enabled: false + +RSpec/ContextWording: + Enabled: false + +RSpec/InstanceVariable: + Enabled: false + +RSpec/LeakyConstantDeclaration: Enabled: false RSpec/MultipleExpectations: Max: 3 -Security/YAMLLoad: +RSpec/MessageSpies: Enabled: false -Style/Documentation: +RSpec/NoExpectationExample: Enabled: false -Layout/MultilineMethodCallIndentation: +RSpec/StubbedMock: + Enabled: false + +RSpec/ExampleLength: Enabled: false Style/ClassAndModuleChildren: Enabled: false +Style/Documentation: + Enabled: false + +Style/NumericLiterals: + Enabled: false + Style/PercentLiteralDelimiters: PreferredDelimiters: default: () @@ -48,6 +91,12 @@ Style/PercentLiteralDelimiters: '%w': '[]' '%W': '[]' -Metrics/ClassLength: - Max: 200 - Severity: warning +Style/StringLiterals: + EnforcedStyle: single_quotes + SupportedStyles: + - single_quotes + - double_quotes + ConsistentQuotesInMultiline: false + +Security/YAMLLoad: + Enabled: false diff --git a/.ruby-version b/.ruby-version index d7edb56..e391e18 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.6.5 +ruby-3.3.6 diff --git a/lib/lightspeed_restaurant/errors/lightspeed_restaurant_error.rb b/lib/lightspeed_restaurant/errors/lightspeed_restaurant_error.rb index d6d2ab8..d786068 100644 --- a/lib/lightspeed_restaurant/errors/lightspeed_restaurant_error.rb +++ b/lib/lightspeed_restaurant/errors/lightspeed_restaurant_error.rb @@ -2,12 +2,7 @@ module LightspeedRestaurantClient class LightspeedRestaurantClientError < StandardError - attr_reader :message - attr_reader :http_status - attr_reader :http_body - attr_reader :http_headers - attr_reader :request_id - attr_reader :json_body + attr_reader :message, :http_status, :http_body, :http_headers, :request_id, :json_body def initialize(message = nil, http_status = nil, http_body = nil, http_headers = nil) @message = message diff --git a/lib/lightspeed_restaurant/request.rb b/lib/lightspeed_restaurant/request.rb index d452419..43cb55c 100644 --- a/lib/lightspeed_restaurant/request.rb +++ b/lib/lightspeed_restaurant/request.rb @@ -19,7 +19,7 @@ def initialize(base_uri, path, token, body = {}, query = {}, logger = nil) @headers = { 'Content-Type' => 'application/json', 'X-Auth-Token' => token } @body = body.to_json @query = query - @path = '/PosServer' + path + @path = "/PosServer#{path}" @connection = Excon.new(@base_uri) @logger = logger || begin require 'logger' @@ -73,22 +73,22 @@ def not_found_error(response) def response_object_error(response) APIError.new("Invalid response object from API: #{JSON.parse(response.body)['description']}", - response.status, response.body, response.headers) + response.status, response.body, response.headers) end def invalid_request_error(response) InvalidRequestError.new(JSON.parse(response.body)['description'], - response.status, response.body, response.headers) + response.status, response.body, response.headers) end def authentication_error(response) AuthenticationError.new(JSON.parse(response.body)['description'], - response.status, response.body, response.headers) + response.status, response.body, response.headers) end def rate_limit_error(response) RateLimitError.new(JSON.parse(response.body)['description'], - response.status, response.body, response.headers) + response.status, response.body, response.headers) end end end diff --git a/spec/lightspeed_restaurant/operations/operation_context.rb b/spec/lightspeed_restaurant/operations/operation_context.rb index bc2b05b..4237861 100644 --- a/spec/lightspeed_restaurant/operations/operation_context.rb +++ b/spec/lightspeed_restaurant/operations/operation_context.rb @@ -33,6 +33,6 @@ def ==(value) end def custom_configuration - @config ||= LightspeedRestaurantClient.default_configuration.with(api_token: 'CUSTOM-1234') + @custom_configuration ||= LightspeedRestaurantClient.default_configuration.with(api_token: 'CUSTOM-1234') end end diff --git a/spec/lightspeed_restaurant_client_spec.rb b/spec/lightspeed_restaurant_client_spec.rb index 31b8fea..f894b6a 100644 --- a/spec/lightspeed_restaurant_client_spec.rb +++ b/spec/lightspeed_restaurant_client_spec.rb @@ -6,7 +6,7 @@ subject(:client) { described_class } it 'has a version number' do - expect(client::VERSION).not_to be nil + expect(client::VERSION).not_to be_nil end it 'uses global configuration' do