diff --git a/.rubocop.yml b/.rubocop.yml index e3462a7..761dd23 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,14 @@ AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.2 + +Layout/LineLength: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Style/Documentation: + Enabled: false Style/StringLiterals: Enabled: true @@ -8,6 +17,3 @@ Style/StringLiterals: Style/StringLiteralsInInterpolation: Enabled: true EnforcedStyle: double_quotes - -Layout/LineLength: - Max: 120 diff --git a/lib/open_router.rb b/lib/open_router.rb index 8bdbc64..8e523c2 100644 --- a/lib/open_router.rb +++ b/lib/open_router.rb @@ -17,7 +17,7 @@ class Configuration DEFAULT_API_VERSION = "v1" DEFAULT_REQUEST_TIMEOUT = 120 - DEFAULT_URI_BASE = 'https://openrouter.ai/api' + DEFAULT_URI_BASE = "https://openrouter.ai/api" def initialize @access_token = nil diff --git a/lib/open_router/client.rb b/lib/open_router/client.rb index 8f047bf..5ba4101 100644 --- a/lib/open_router/client.rb +++ b/lib/open_router/client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'http' +require_relative "http" module OpenRouter class Client @@ -19,7 +19,7 @@ def initialize # @param extras [Hash] Optional hash of model-specific parameters to send to the OpenRouter API # @param stream [Proc, nil] Optional callable object for streaming # @return [Hash] The completion response. - def complete(messages, model: 'openrouter/auto', providers: [], transforms: [], extras: {}, stream: nil) + def complete(messages, model: "openrouter/auto", providers: [], transforms: [], extras: {}, stream: nil) # rubocop:disable Metrics/ParameterLists parameters = { model:, messages: } parameters[:provider] = { provider: { order: providers } } if providers.any? parameters[:transforms] = transforms if transforms.any? diff --git a/open_router.gemspec b/open_router.gemspec index 88c7400..f4526d5 100644 --- a/open_router.gemspec +++ b/open_router.gemspec @@ -19,7 +19,8 @@ Gem::Specification.new do |spec| spec.files = Dir.chdir(__dir__) do `git ls-files -z`.split("\x0").reject do |f| - (File.expand_path(f) == __FILE__) || f.end_with?('.gem') || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor]) + (File.expand_path(f) == __FILE__) || f.end_with?(".gem") || f.start_with?(*%w[bin/ test/ spec/ features/ .git + .circleci appveyor]) end end diff --git a/spec/open_router_spec.rb b/spec/open_router_spec.rb index 93dfa83..fae9e6a 100644 --- a/spec/open_router_spec.rb +++ b/spec/open_router_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true # frozen_string_literal: true + RSpec.describe OpenRouter do it "has a version number" do expect(OpenRouter::VERSION).not_to be nil @@ -18,8 +19,8 @@ describe "#complete" do let(:messages) { [{ role: "user", content: "What is the meaning of life?" }] } let(:model) { "openrouter/auto" } - let(:providers) { ["provider1", "provider2"] } - let(:transforms) { ["transform1", "transform2"] } + let(:providers) { %w[provider1 provider2] } + let(:transforms) { %w[transform1 transform2] } let(:extras) { { max_tokens: 100 } } let(:stream) { proc { |response| } } @@ -27,15 +28,15 @@ expect(client).to receive(:json_post).with( path: "/chat/completions", parameters: { - model: model, - messages: messages, + model:, + messages:, provider: { provider: { order: providers } }, - transforms: transforms, - stream: stream, + transforms:, + stream:, max_tokens: 100 } ) - client.complete(messages, model: model, providers: providers, transforms: transforms, extras: extras, stream: stream) + client.complete(messages, model:, providers:, transforms:, extras:, stream:) end end