From 54e5892180569bae364da7b20728347835661a92 Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Thu, 28 Mar 2024 11:51:50 +0100 Subject: [PATCH 1/3] Technical/Update readme (#22) --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fa4a286..b5e77ea 100644 --- a/README.md +++ b/README.md @@ -154,9 +154,10 @@ Please note, to start using this middleware you should configure `OnStrum::Healt ```ruby require 'on_strum/healthcheck' -OnStrum::Healthcheck.configure +# Configuring OnStrum::Healthcheck with default settings +OnStrum::Healthcheck.configure {} -RackCascade = Rack::Builder.app do +Rack::Builder.app do use OnStrum::Healthcheck::RackMiddleware run YourApplication end @@ -167,7 +168,8 @@ end ```ruby require 'on_strum/healthcheck' -OnStrum::Healthcheck.configure +# Configuring OnStrum::Healthcheck with default settings +OnStrum::Healthcheck.configure {} class YourApplication < Roda use OnStrum::Healthcheck::RackMiddleware @@ -181,8 +183,11 @@ end require 'on_strum/healthcheck' -OnStrum::Healthcheck.configure +# Configuring OnStrum::Healthcheck with default settings +OnStrum::Healthcheck.configure {} +``` +```ruby # config/environment.rb Hanami.configure do @@ -197,8 +202,11 @@ end require 'on_strum/healthcheck' -OnStrum::Healthcheck.configure +# Configuring OnStrum::Healthcheck with default settings +OnStrum::Healthcheck.configure {} +``` +```ruby # config/application.rb class Application < Rails::Application From 654142be53e6d0858d1b81e904ca528b8ed182b9 Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Thu, 28 Mar 2024 12:16:51 +0100 Subject: [PATCH 2/3] Feature/Ability to use configuration configuration with default settings without block (#23) * Updated OnStrum::Healthcheck.configure, tests * Updated gem documentation --- README.md | 8 ++++---- lib/on_strum/healthcheck.rb | 2 ++ spec/on_strum/healthcheck_spec.rb | 23 +++++++++++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b5e77ea..eac3a19 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ Please note, to start using this middleware you should configure `OnStrum::Healt require 'on_strum/healthcheck' # Configuring OnStrum::Healthcheck with default settings -OnStrum::Healthcheck.configure {} +OnStrum::Healthcheck.configure Rack::Builder.app do use OnStrum::Healthcheck::RackMiddleware @@ -169,7 +169,7 @@ end require 'on_strum/healthcheck' # Configuring OnStrum::Healthcheck with default settings -OnStrum::Healthcheck.configure {} +OnStrum::Healthcheck.configure class YourApplication < Roda use OnStrum::Healthcheck::RackMiddleware @@ -184,7 +184,7 @@ end require 'on_strum/healthcheck' # Configuring OnStrum::Healthcheck with default settings -OnStrum::Healthcheck.configure {} +OnStrum::Healthcheck.configure ``` ```ruby @@ -203,7 +203,7 @@ end require 'on_strum/healthcheck' # Configuring OnStrum::Healthcheck with default settings -OnStrum::Healthcheck.configure {} +OnStrum::Healthcheck.configure ``` ```ruby diff --git a/lib/on_strum/healthcheck.rb b/lib/on_strum/healthcheck.rb index 9b83bbe..866d4dd 100644 --- a/lib/on_strum/healthcheck.rb +++ b/lib/on_strum/healthcheck.rb @@ -14,6 +14,8 @@ def configuration(&block) end def configure(&block) + return configuration {} unless block # rubocop:disable Lint/EmptyBlock + configuration(&block) end diff --git a/spec/on_strum/healthcheck_spec.rb b/spec/on_strum/healthcheck_spec.rb index 78e5bf2..2290005 100644 --- a/spec/on_strum/healthcheck_spec.rb +++ b/spec/on_strum/healthcheck_spec.rb @@ -23,8 +23,27 @@ let(:config_block) { nil } context 'without block' do - it { expect(configuration).to be_nil } - it { expect { configuration }.not_to change(described_class, :configuration) } + it 'sets default attributes into configuration instance' do + expect { configuration } + .to change(described_class, :configuration) + .from(nil) + .to(be_instance_of(OnStrum::Healthcheck::Configuration)) + expect(configuration).to be_an_instance_of(OnStrum::Healthcheck::Configuration) + expect(configuration.services).to eq({}) + expect(configuration.services_startup).to eq([]) + expect(configuration.services_liveness).to eq([]) + expect(configuration.services_readiness).to eq([]) + expect(configuration.endpoints_namespace).to eq(OnStrum::Healthcheck::Configuration::ENDPOINTS_NAMESPACE) + expect(configuration.endpoint_startup).to eq(OnStrum::Healthcheck::Configuration::ENDPOINT_STARTUP) + expect(configuration.endpoint_liveness).to eq(OnStrum::Healthcheck::Configuration::ENDPOINT_LIVENESS) + expect(configuration.endpoint_readiness).to eq(OnStrum::Healthcheck::Configuration::ENDPOINT_READINESS) + expect(configuration.endpoint_startup_status_success).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_SUCCESS) + expect(configuration.endpoint_liveness_status_success).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_SUCCESS) + expect(configuration.endpoint_readiness_status_success).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_SUCCESS) + expect(configuration.endpoint_startup_status_failure).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_FAILURE) + expect(configuration.endpoint_liveness_status_failure).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_FAILURE) + expect(configuration.endpoint_readiness_status_failure).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_FAILURE) + end end context 'with block' do From 3aa5d8ae6b1298b21e2fb0dd583afa797b0e9635 Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Thu, 28 Mar 2024 12:23:54 +0100 Subject: [PATCH 3/3] Technical/Update gem version (#24) * Updated gem version * Updated changelog --- CHANGELOG.md | 15 +++++++++++++++ lib/on_strum/healthcheck/version.rb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f8c4c2..8ea0bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.0] - 2024-03-28 + +### Added + +- Added ability to use configuration with default settings without block passing + +```ruby +OnStrum::Healthcheck.configure # It will create configuration instance with default settings +``` + +### Updated + +- Updated `OnStrum::Healthcheck.configure`, tests +- Updated gem documentation + ## [0.1.0] - 2024-03-26 ### Added diff --git a/lib/on_strum/healthcheck/version.rb b/lib/on_strum/healthcheck/version.rb index b3d3c1d..2de7b4d 100644 --- a/lib/on_strum/healthcheck/version.rb +++ b/lib/on_strum/healthcheck/version.rb @@ -2,6 +2,6 @@ module OnStrum module Healthcheck - VERSION = '0.1.0' + VERSION = '0.2.0' end end