From d2ab0f6aff96ec656454cce8578b6584720a528e Mon Sep 17 00:00:00 2001 From: Kenny Hoxworth Date: Wed, 24 Jan 2024 11:44:36 -0800 Subject: [PATCH] chore: release 2.4.0 Ruby Gem (#953) Forgots. --------- Co-authored-by: Kenny Hoxworth --- packages/ruby/Gemfile.lock | 4 ++-- packages/ruby/lib/readme/http_request.rb | 4 +--- packages/ruby/lib/readme/mask.rb | 12 ++++++------ packages/ruby/lib/readme/metrics/version.rb | 2 +- packages/ruby/spec/readme/http_request_spec.rb | 4 +--- packages/ruby/spec/readme/payload_spec.rb | 4 ++-- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/ruby/Gemfile.lock b/packages/ruby/Gemfile.lock index 0b33315bca..0f8327f640 100644 --- a/packages/ruby/Gemfile.lock +++ b/packages/ruby/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - readme-metrics (2.3.0) + readme-metrics (2.4.0) httparty (~> 0.18) rack (>= 2.2, < 4) @@ -21,7 +21,7 @@ GEM json (2.6.2) json-schema (2.8.1) addressable (>= 2.4) - mini_mime (1.1.2) + mini_mime (1.1.5) multi_xml (0.6.0) parallel (1.22.1) parser (3.1.2.1) diff --git a/packages/ruby/lib/readme/http_request.rb b/packages/ruby/lib/readme/http_request.rb index 2657077e02..23a9190da1 100644 --- a/packages/ruby/lib/readme/http_request.rb +++ b/packages/ruby/lib/readme/http_request.rb @@ -27,9 +27,7 @@ class HttpRequest def initialize(env) # Sanitize the auth header, if it exists - if env.has_key?("HTTP_AUTHORIZATION") - env["HTTP_AUTHORIZATION"] = Readme::Mask.mask(env["HTTP_AUTHORIZATION"]) - end + env['HTTP_AUTHORIZATION'] = Readme::Mask.mask(env['HTTP_AUTHORIZATION']) if env.key?('HTTP_AUTHORIZATION') @request = Rack::Request.new(env) return unless IS_RACK_V3 diff --git a/packages/ruby/lib/readme/mask.rb b/packages/ruby/lib/readme/mask.rb index f9f2d53ca2..579f37ba36 100644 --- a/packages/ruby/lib/readme/mask.rb +++ b/packages/ruby/lib/readme/mask.rb @@ -1,11 +1,11 @@ require 'digest' module Readme - class Mask - def self.mask(data) - digest = Digest::SHA2.new(512).base64digest(data) - opts = data.length >= 4 ? data[-4,4] : data - "sha512-#{digest}?#{opts}" - end + class Mask + def self.mask(data) + digest = Digest::SHA2.new(512).base64digest(data) + opts = data.length >= 4 ? data[-4, 4] : data + "sha512-#{digest}?#{opts}" end + end end diff --git a/packages/ruby/lib/readme/metrics/version.rb b/packages/ruby/lib/readme/metrics/version.rb index 2d6d1d0331..c1884fc0e1 100644 --- a/packages/ruby/lib/readme/metrics/version.rb +++ b/packages/ruby/lib/readme/metrics/version.rb @@ -2,6 +2,6 @@ module Readme class Metrics - VERSION = '2.3.0' + VERSION = '2.4.0' end end diff --git a/packages/ruby/spec/readme/http_request_spec.rb b/packages/ruby/spec/readme/http_request_spec.rb index 07170301e4..357c2e25d5 100644 --- a/packages/ruby/spec/readme/http_request_spec.rb +++ b/packages/ruby/spec/readme/http_request_spec.rb @@ -172,12 +172,11 @@ expect(request.headers).to eq( { - 'Authorization' => Readme::Mask.mask('Basic xxx:aaa'), + 'Authorization' => Readme::Mask.mask('Basic xxx:aaa') } ) end - it 'matches the hashing output of the node.js SDK' do env = { 'HTTP_AUTHORIZATION' => 'Bearer: a-random-api-key' @@ -193,7 +192,6 @@ } ) end - end describe '#body' do diff --git a/packages/ruby/spec/readme/payload_spec.rb b/packages/ruby/spec/readme/payload_spec.rb index 009d7725ff..1e2c46201e 100644 --- a/packages/ruby/spec/readme/payload_spec.rb +++ b/packages/ruby/spec/readme/payload_spec.rb @@ -19,7 +19,7 @@ development: true ) - expect(JSON.parse(result.to_json)["group"]["id"]).to match(Readme::Mask.mask(id)) + expect(JSON.parse(result.to_json)['group']['id']).to match(Readme::Mask.mask(id)) expect(result.to_json).to match_json_schema('payload') end @@ -32,7 +32,7 @@ development: true ) - expect(JSON.parse(result.to_json)["group"]["id"]).to match(Readme::Mask.mask(api_key)) + expect(JSON.parse(result.to_json)['group']['id']).to match(Readme::Mask.mask(api_key)) expect(result.to_json).to match_json_schema('payload') end