diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 72c089b..9d50b9c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} + rubygems: latest bundler-cache: true - run: psql -c 'CREATE DATABASE umbrellio_utils_test' diff --git a/Gemfile b/Gemfile index c89bf3e..a161c58 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development, :test do gem "bundler" gem "ci-helper" gem "http" - gem "nokogiri", "~> 1.15.0" + gem "nokogiri" gem "nori" gem "pg" gem "pry" diff --git a/Gemfile.lock b/Gemfile.lock index 4e5c061..bff154d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,41 +1,41 @@ PATH remote: . specs: - umbrellio-utils (1.2.1) + umbrellio-utils (1.3.0) memery (~> 1) GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3.2) - actionpack (= 7.1.3.2) - activesupport (= 7.1.3.2) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.2) - actionpack (= 7.1.3.2) - activejob (= 7.1.3.2) - activerecord (= 7.1.3.2) - activestorage (= 7.1.3.2) - activesupport (= 7.1.3.2) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.3.2) - actionpack (= 7.1.3.2) - actionview (= 7.1.3.2) - activejob (= 7.1.3.2) - activesupport (= 7.1.3.2) + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.3.2) - actionview (= 7.1.3.2) - activesupport (= 7.1.3.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -43,35 +43,35 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.2) - actionpack (= 7.1.3.2) - activerecord (= 7.1.3.2) - activestorage (= 7.1.3.2) - activesupport (= 7.1.3.2) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.2) - activesupport (= 7.1.3.2) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3.2) - activesupport (= 7.1.3.2) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - activemodel (7.1.3.2) - activesupport (= 7.1.3.2) - activerecord (7.1.3.2) - activemodel (= 7.1.3.2) - activesupport (= 7.1.3.2) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) timeout (>= 0.4.0) - activestorage (7.1.3.2) - actionpack (= 7.1.3.2) - activejob (= 7.1.3.2) - activerecord (= 7.1.3.2) - activesupport (= 7.1.3.2) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) marcel (~> 1.0) - activesupport (7.1.3.2) + activesupport (7.1.3.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -81,15 +81,15 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) amazing_print (1.6.0) amq-protocol (2.3.2) ast (2.4.2) base64 (0.2.0) - bigdecimal (3.1.7) - builder (3.2.4) - bunny (2.22.0) + bigdecimal (3.1.8) + builder (3.3.0) + bunny (2.23.0) amq-protocol (~> 2.3, >= 2.3.1) sorted_set (~> 1, >= 1.0.2) ci-helper (0.6.0) @@ -98,7 +98,7 @@ GEM umbrellio-sequel-plugins (~> 0.14) coderay (1.1.3) colorize (1.1.0) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) connection_pool (2.4.1) crass (1.0.6) date (3.3.4) @@ -107,8 +107,11 @@ GEM domain_name (0.6.20240107) drb (2.2.1) dry-inflector (1.0.0) - erubi (1.12.0) - ffi (1.16.3) + erubi (1.13.0) + ffi (1.17.0) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) ffi-compiler (1.3.2) ffi (>= 1.15.5) rake @@ -120,18 +123,19 @@ GEM http-cookie (~> 1.0) http-form_data (~> 2.2) llhttp-ffi (~> 0.5.0) - http-cookie (1.0.5) + http-cookie (1.0.6) domain_name (~> 0.5) http-form_data (2.3.0) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) io-console (0.7.2) - irb (1.12.0) - rdoc + irb (1.13.2) + rdoc (>= 4.0.0) reline (>= 0.4.2) json (2.7.2) - lamian (1.8.0) + lamian (1.9.0) rails (>= 4.2) + language_server-protocol (3.17.0.3) llhttp-ffi (0.5.0) ffi-compiler (~> 1.0) rake (~> 13.0) @@ -148,26 +152,31 @@ GEM ruby2_keywords (~> 0.0.2) method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.6) - minitest (5.22.3) + mini_portile2 (2.8.7) + minitest (5.24.1) mutex_m (0.2.0) - net-imap (0.4.10) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) - net-protocol net-protocol (0.2.2) timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.1) - nokogiri (1.15.6) + nio4r (2.7.3) + nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) + nokogiri (1.16.6-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-linux) + racc (~> 1.4) nori (2.7.0) bigdecimal - parallel (1.24.0) - parser (3.3.0.5) + parallel (1.25.1) + parser (3.3.3.0) ast (~> 2.4.1) racc pg (1.5.6) @@ -176,15 +185,15 @@ GEM method_source (~> 1.0) psych (5.1.2) stringio - public_suffix (5.0.5) - rabbit_messaging (0.13.0) + public_suffix (6.0.0) + rabbit_messaging (0.15.0) bunny (~> 2.0) lamian rails (>= 5.2) sneakers (~> 2.0) tainbox - racc (1.7.3) - rack (3.0.10) + racc (1.8.0) + rack (3.1.4) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -192,20 +201,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.3.2) - actioncable (= 7.1.3.2) - actionmailbox (= 7.1.3.2) - actionmailer (= 7.1.3.2) - actionpack (= 7.1.3.2) - actiontext (= 7.1.3.2) - actionview (= 7.1.3.2) - activejob (= 7.1.3.2) - activemodel (= 7.1.3.2) - activerecord (= 7.1.3.2) - activestorage (= 7.1.3.2) - activesupport (= 7.1.3.2) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) bundler (>= 1.15.0) - railties (= 7.1.3.2) + railties (= 7.1.3.4) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -213,9 +222,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3.2) - actionpack (= 7.1.3.2) - activesupport (= 7.1.3.2) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -224,61 +233,70 @@ GEM rainbow (3.1.1) rake (13.2.1) rbtree (0.4.6) - rdoc (6.6.3.1) + rdoc (6.7.0) psych (>= 4.0.0) - regexp_parser (2.9.0) - reline (0.5.1) + regexp_parser (2.9.2) + reline (0.5.9) io-console (~> 0.5) - rexml (3.2.6) + rexml (3.3.1) + strscan rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) rspec-core (3.13.0) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-json_matcher (0.2.0) amazing_print json - rspec-mocks (3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.50.2) + rubocop (1.63.5) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) - rubocop-capybara (2.20.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) rubocop (~> 1.41) - rubocop-config-umbrellio (1.50.0.85) - rubocop (~> 1.50.0) - rubocop-performance (~> 1.17.0) - rubocop-rails (~> 2.19.0) + rubocop-config-umbrellio (1.63.0.93) + rubocop (~> 1.63.0) + rubocop-performance (~> 1.21.0) + rubocop-rails (~> 2.24.0) rubocop-rake (~> 0.6.0) - rubocop-rspec (~> 2.20.0) + rubocop-rspec (~> 2.29.0) rubocop-sequel (~> 0.3.3) - rubocop-performance (1.17.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.19.1) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) + rubocop-performance (1.21.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.24.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.20.0) - rubocop (~> 1.33) + rubocop-rspec (2.29.2) + rubocop (~> 1.40) rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.29.1) + rubocop (~> 1.61) rubocop-sequel (0.3.4) rubocop (~> 1.0) ruby-progressbar (1.13.0) @@ -286,7 +304,7 @@ GEM self_data (1.3.0) semantic_logger (4.15.0) concurrent-ruby (~> 1.0) - sequel (5.79.0) + sequel (5.81.0) bigdecimal sequel-batches (2.0.2) sequel @@ -310,7 +328,8 @@ GEM sorted_set (1.0.3) rbtree set (~> 1.0) - stringio (3.1.0) + stringio (3.1.1) + strscan (3.1.0) symbiont-ruby (0.7.0) table_sync (6.5.0) memery @@ -320,11 +339,11 @@ GEM tainbox (2.1.2) activesupport thor (1.3.1) - timecop (0.9.8) + timecop (0.9.10) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - umbrellio-sequel-plugins (0.14.0.192) + umbrellio-sequel-plugins (0.15.0.198) sequel symbiont-ruby unicode-display_width (2.5.0) @@ -333,7 +352,7 @@ GEM websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) yard (0.9.36) - zeitwerk (2.6.13) + zeitwerk (2.6.16) PLATFORMS arm64-darwin-20 @@ -348,7 +367,7 @@ DEPENDENCIES bundler ci-helper http - nokogiri (~> 1.15.0) + nokogiri nori pg pry @@ -367,4 +386,4 @@ DEPENDENCIES yard BUNDLED WITH - 2.5.9 + 2.5.14 diff --git a/lib/umbrellio_utils/database.rb b/lib/umbrellio_utils/database.rb index d7d458b..eda5f9c 100644 --- a/lib/umbrellio_utils/database.rb +++ b/lib/umbrellio_utils/database.rb @@ -48,21 +48,15 @@ def with_temp_table(dataset, page_size: 1_000, sleep: nil, **options) break if pk_set.empty? Kernel.sleep(sleep_interval) if sleep_interval.positive? - clear_lamian_logs! end ensure DB.drop_table(temp_table_name) end - def clear_lamian_logs! - return unless defined?(Lamian) - Lamian.logger.send(:logdevs).each { |x| x.truncate(0) && x.rewind } - end - def create_temp_table(dataset, **options) time = Time.current model = dataset.model - temp_table_name = "temp_#{model.table_name}_#{time.to_i}_#{time.nsec}".to_sym + temp_table_name = :"temp_#{model.table_name}_#{time.to_i}_#{time.nsec}" primary_key = primary_key_from(dataset, **options) DB.create_table(temp_table_name, unlogged: true) do diff --git a/lib/umbrellio_utils/vault.rb b/lib/umbrellio_utils/vault.rb index c5c08b1..bba247e 100644 --- a/lib/umbrellio_utils/vault.rb +++ b/lib/umbrellio_utils/vault.rb @@ -5,7 +5,7 @@ module Vault extend self def secret_engine_present?(engine_path) - ::Vault.logical.read("sys/mounts").data.key?("#{engine_path}/".to_sym) + ::Vault.logical.read("sys/mounts").data.key?(:"#{engine_path}/") end def create_kv_engine(path) diff --git a/lib/umbrellio_utils/version.rb b/lib/umbrellio_utils/version.rb index 95f278a..2180d57 100644 --- a/lib/umbrellio_utils/version.rb +++ b/lib/umbrellio_utils/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module UmbrellioUtils - VERSION = "1.2.1" + VERSION = "1.3.0" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ec7c1f1..f9018dd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -43,6 +43,7 @@ config.project_id = :umbrellio_utils config.group_id = :umbrellio_utils config.environment = :test + config.exception_notifier = proc {} end RSpec.configure do |config| diff --git a/spec/umbrellio_utils/database_spec.rb b/spec/umbrellio_utils/database_spec.rb index a236217..174bd2e 100644 --- a/spec/umbrellio_utils/database_spec.rb +++ b/spec/umbrellio_utils/database_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe UmbrellioUtils::Database, db: true do +describe UmbrellioUtils::Database, :db do describe "#create_temp_table" do before do Timecop.freeze("2021-12-06 UTC") diff --git a/spec/umbrellio_utils/formatting_spec.rb b/spec/umbrellio_utils/formatting_spec.rb index e0c04e0..3820913 100644 --- a/spec/umbrellio_utils/formatting_spec.rb +++ b/spec/umbrellio_utils/formatting_spec.rb @@ -17,7 +17,7 @@ let(:hash) { Hash["deep,first": true, "deep,second": false, root: "kek"] } let(:kwargs) { Hash[delimiter: ","] } - specify { is_expected.to eq(deep: { first: true, second: false }, root: "kek") } + it { is_expected.to eq(deep: { first: true, second: false }, root: "kek") } end context "with custom key converter" do @@ -38,7 +38,7 @@ let(:hash) { Hash[app: { "very.deep": "value" }, key: "value"] } let(:kwargs) { Hash[] } - specify { is_expected.to eq(app: { very: { deep: "value" } }, key: "value") } + it { is_expected.to eq(app: { very: { deep: "value" } }, key: "value") } context "with custom key converter" do let(:kwargs) { Hash[key_converter: :to_s] } diff --git a/spec/umbrellio_utils/misc_spec.rb b/spec/umbrellio_utils/misc_spec.rb index c59c89f..32a80eb 100644 --- a/spec/umbrellio_utils/misc_spec.rb +++ b/spec/umbrellio_utils/misc_spec.rb @@ -4,7 +4,7 @@ describe "::build_infinite_hash" do subject(:hash) { described_class.build_infinite_hash } - specify { is_expected.to be_an_instance_of(Hash) } + it { is_expected.to be_an_instance_of(Hash) } context "with deep accessing" do it "generates new hashes" do diff --git a/spec/umbrellio_utils/request_wrapper_spec.rb b/spec/umbrellio_utils/request_wrapper_spec.rb index cc39b8a..b8e5640 100644 --- a/spec/umbrellio_utils/request_wrapper_spec.rb +++ b/spec/umbrellio_utils/request_wrapper_spec.rb @@ -134,7 +134,6 @@ describe "#http_headers" do let(:expected_headers) do { - "CONTENT_LENGTH" => "0", "CONTENT_TYPE" => "application/json", "HTTP_HOST" => "test.host", "HTTP_USER_AGENT" => "Rails Testing", @@ -151,7 +150,7 @@ end specify do - expect(wrapped_request.http_headers.to_h).to eq(expected_headers) + expect(wrapped_request.http_headers.to_h).to include(expected_headers) end end diff --git a/spec/umbrellio_utils/semantic_logger/tiny_json_formatter_spec.rb b/spec/umbrellio_utils/semantic_logger/tiny_json_formatter_spec.rb index 5652f91..4053b4a 100644 --- a/spec/umbrellio_utils/semantic_logger/tiny_json_formatter_spec.rb +++ b/spec/umbrellio_utils/semantic_logger/tiny_json_formatter_spec.rb @@ -16,13 +16,15 @@ let(:log) do instance_double(SemanticLogger::Log).tap do |instance| - allow(instance).to receive(:level).and_return(log_level) - allow(instance).to receive(:name).and_return(log_name) - allow(instance).to receive(:message).and_return(log_message) - allow(instance).to receive(:exception).and_return(log_exception) - allow(instance).to receive(:tags).and_return(log_tags) - allow(instance).to receive(:named_tags).and_return(log_named_tags) - allow(instance).to receive(:time).and_return(log_time) + allow(instance).to receive_messages( + level: log_level, + name: log_name, + message: log_message, + exception: log_exception, + tags: log_tags, + named_tags: log_named_tags, + time: log_time, + ) end end let(:result) { formatter.call(log, nil) } diff --git a/spec/umbrellio_utils_spec.rb b/spec/umbrellio_utils_spec.rb index e7be307..52b845d 100644 --- a/spec/umbrellio_utils_spec.rb +++ b/spec/umbrellio_utils_spec.rb @@ -42,7 +42,7 @@ around do |example| old_const = UmbrellioUtils::Constants.dup example.call - UmbrellioUtils.send(:remove_const, :Constants) + UmbrellioUtils.send(:remove_const, :Constants) # rubocop:disable RSpec/RemoveConst UmbrellioUtils.const_set(:Constants, old_const) end