From 8933ce7f9bdc0beac9677ef83da43b9eda94687b Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 13:10:04 +0300 Subject: [PATCH 01/14] Use github actions (#137) --- .github/workflows/ruby.yml | 27 +++++++++++++++++++++++++++ .travis.yml | 18 ------------------ 2 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/ruby.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..006c4c1 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,27 @@ +name: Ruby + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: [ '2.5.x', '2.6.x', '2.7.x' ] + name: ${{ matrix.ruby }} + + steps: + - uses: actions/checkout@v1 + - name: Set up ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Install dependencies + run: | + gem install bundler --force --version=2.0.1 + bundler --version + bundle install --jobs 4 --retry 3 + - name: Test + run: bundle exec rake spec + - name: Lint + run: bundle exec rake rubocop diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 210a378..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -addons: - apt: - packages: - - libgmp-dev -env: JRUBY_OPTS=--debug RAKE_TASK=spec -cache: bundler -language: ruby -matrix: - include: - - env: RAKE_TASK=rubocop - rvm: '2.6.0' -rvm: - - '2.7' - - '2.6' - - '2.5' - - '2.4' -script: bundle exec rake $RAKE_TASK -sudo: false From 00e2d3dd6c88965c82e0d1aba2e34312436d2a23 Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 13:25:46 +0300 Subject: [PATCH 02/14] Feature/change org (#138) Update links in the README file --- README.md | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 82a6df2..c64cf39 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Build badge][]][build] [![Coverage badge][]][coverage] [![Climate badge][]][climate] -[![Dependencies badge][]][dependencies] Stoplight is traffic control for code. It's an implementation of the circuit breaker pattern in Ruby. @@ -495,24 +494,22 @@ stoplight = Stoplight("test-#{rand}") { ... } ## Credits -Stoplight is brought to you by [@camdez][] and [@tfausak][] from [@OrgSync][]. -A [complete list of contributors][] is available on GitHub. We were inspired by -Martin Fowler's [CircuitBreaker][] article. +Stoplight is brought to you by [@camdez][] and [@tfausak][] from [@OrgSync][]. [@bolshakov][] is the current +maintainer of the gem. A [complete list of contributors][] is available on GitHub. We were inspired by +Martin Fowler's [CircuitBreaker][] article. Stoplight is licensed under [the MIT License][]. -[Stoplight]: https://github.com/orgsync/stoplight +[Stoplight]: https://github.com/bolshakov/stoplight [Version badge]: https://img.shields.io/gem/v/stoplight.svg?label=version [version]: https://rubygems.org/gems/stoplight -[Build badge]: https://img.shields.io/travis/orgsync/stoplight/master.svg?label=build -[build]: https://travis-ci.org/orgsync/stoplight -[Coverage badge]: https://img.shields.io/coveralls/orgsync/stoplight/master.svg?label=coverage -[coverage]: https://coveralls.io/r/orgsync/stoplight -[Climate badge]: https://img.shields.io/codeclimate/github/orgsync/stoplight.svg?label=climate -[climate]: https://codeclimate.com/github/orgsync/stoplight -[Dependencies badge]: https://img.shields.io/gemnasium/orgsync/stoplight.svg?label=dependencies -[dependencies]: https://gemnasium.com/orgsync/stoplight -[stoplight-admin]: https://github.com/orgsync/stoplight-admin +[Build badge]: https://github.com/bolshakov/stoplight/workflows/Ruby/badge.svg +[build]: https://github.com/bolshakov/stoplight/actions?query=branch%3Amaster +[Coverage badge]: https://img.shields.io/coveralls/bolshakov/stoplight/master.svg?label=coverage +[coverage]: https://coveralls.io/r/bolshakov/stoplight +[Climate badge]: https://img.shields.io/codeclimate/github/bolshakov/stoplight.svg?label=climate +[climate]: https://codeclimate.com/github/bolshakov/stoplight +[stoplight-admin]: https://github.com/bolshakov/stoplight-admin [Semantic Versioning]: http://semver.org/spec/v2.0.0.html [the change log]: CHANGELOG.md [the notifiers section]: #notifiers @@ -529,6 +526,7 @@ Stoplight is licensed under [the MIT License][]. [@camdez]: https://github.com/camdez [@tfausak]: https://github.com/tfausak [@orgsync]: https://github.com/OrgSync -[complete list of contributors]: https://github.com/orgsync/stoplight/graphs/contributors +[@bolshakov]: https://github.com/bolshakov +[complete list of contributors]: https://github.com/bolshakov/stoplight/graphs/contributors [CircuitBreaker]: http://martinfowler.com/bliki/CircuitBreaker.html [the MIT license]: LICENSE.md From f14d12b15fc346a14fa8fb83f775035569d986cf Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 15:27:13 +0300 Subject: [PATCH 03/14] Update rubocop (#139) Update rubocop * Create rubocop-analysis.yml * Rename ruby to specs * Fix Style/SafeNavigation offences * Fix Style/RescueStandardError offences * Fix Style/RedundantBegin offences * Fix Style/Encoding and Style/FrozenStringLiteralComment offences * Fix Style/EmptyMethod offences * Fix Naming/RescuedExceptionsVariableName offences * Disabel Lint/MissingSuper * Disable Lint/AmbiguousBlockAssociation for specs * Fix Layout/SpaceInLambdaLiteral offences * Fix Layout/EmptyLineAfterGuardClause offences * Remove rubocop_todo.yml --- .github/workflows/rubocop-analysis.yml | 40 +++++++++++++++++++++ .github/workflows/{ruby.yml => specs.yml} | 4 +-- .rubocop.yml | 14 ++++++++ Gemfile | 2 +- README.md | 2 +- Rakefile | 4 +-- bench/memory_bench.rb | 2 +- bench/redis_bench.rb | 2 +- lib/stoplight.rb | 2 +- lib/stoplight/color.rb | 8 ++--- lib/stoplight/data_store.rb | 2 +- lib/stoplight/data_store/base.rb | 2 +- lib/stoplight/data_store/memory.rb | 2 +- lib/stoplight/data_store/redis.rb | 16 ++++----- lib/stoplight/default.rb | 6 ++-- lib/stoplight/error.rb | 2 +- lib/stoplight/failure.rb | 4 +-- lib/stoplight/light.rb | 2 +- lib/stoplight/light/runnable.rb | 12 ++++--- lib/stoplight/notifier.rb | 2 +- lib/stoplight/notifier/base.rb | 2 +- lib/stoplight/notifier/bugsnag.rb | 2 +- lib/stoplight/notifier/generic.rb | 2 +- lib/stoplight/notifier/hip_chat.rb | 2 +- lib/stoplight/notifier/honeybadger.rb | 4 +-- lib/stoplight/notifier/io.rb | 2 +- lib/stoplight/notifier/logger.rb | 2 +- lib/stoplight/notifier/pagerduty.rb | 2 +- lib/stoplight/notifier/raven.rb | 4 +-- lib/stoplight/notifier/rollbar.rb | 2 +- lib/stoplight/notifier/slack.rb | 2 +- lib/stoplight/state.rb | 8 ++--- lib/stoplight/version.rb | 2 +- spec/spec_helper.rb | 2 +- spec/stoplight/color_spec.rb | 2 +- spec/stoplight/data_store/base_spec.rb | 2 +- spec/stoplight/data_store/memory_spec.rb | 2 +- spec/stoplight/data_store/redis_spec.rb | 2 +- spec/stoplight/data_store_spec.rb | 2 +- spec/stoplight/default_spec.rb | 2 +- spec/stoplight/error_spec.rb | 2 +- spec/stoplight/failure_spec.rb | 2 +- spec/stoplight/light/runnable_spec.rb | 16 ++++----- spec/stoplight/light_spec.rb | 10 +++--- spec/stoplight/notifier/base_spec.rb | 2 +- spec/stoplight/notifier/bugsnag_spec.rb | 2 +- spec/stoplight/notifier/generic_spec.rb | 2 +- spec/stoplight/notifier/hip_chat_spec.rb | 5 ++- spec/stoplight/notifier/honeybadger_spec.rb | 2 +- spec/stoplight/notifier/io_spec.rb | 2 +- spec/stoplight/notifier/logger_spec.rb | 2 +- spec/stoplight/notifier/pagerduty_spec.rb | 2 +- spec/stoplight/notifier/raven_spec.rb | 2 +- spec/stoplight/notifier/rollbar_spec.rb | 2 +- spec/stoplight/notifier/slack_spec.rb | 5 ++- spec/stoplight/notifier_spec.rb | 2 +- spec/stoplight/state_spec.rb | 2 +- spec/stoplight/version_spec.rb | 2 +- spec/stoplight_spec.rb | 2 +- stoplight.gemspec | 11 +++--- 60 files changed, 153 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/rubocop-analysis.yml rename .github/workflows/{ruby.yml => specs.yml} (89%) create mode 100644 .rubocop.yml diff --git a/.github/workflows/rubocop-analysis.yml b/.github/workflows/rubocop-analysis.yml new file mode 100644 index 0000000..30534db --- /dev/null +++ b/.github/workflows/rubocop-analysis.yml @@ -0,0 +1,40 @@ +# pulled from repo +name: "Rubocop" + +on: push + +jobs: + rubocop: + runs-on: ubuntu-latest + strategy: + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # If running on a self-hosted runner, check it meets the requirements + # listed at https://github.com/ruby/setup-ruby#using-self-hosted-runners + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + + # This step is not necessary if you add the gem to your Gemfile + - name: Install Code Scanning integration + run: bundle add code-scanning-rubocop --version 0.4.0 --skip-install + + - name: Install dependencies + run: bundle install + + - name: Rubocop run + run: | + bash -c " + bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif + [[ $? -ne 2 ]] + " + + - name: Upload Sarif output + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: rubocop.sarif diff --git a/.github/workflows/ruby.yml b/.github/workflows/specs.yml similarity index 89% rename from .github/workflows/ruby.yml rename to .github/workflows/specs.yml index 006c4c1..a2b99d0 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/specs.yml @@ -1,4 +1,4 @@ -name: Ruby +name: Specs on: [push] @@ -23,5 +23,3 @@ jobs: bundle install --jobs 4 --retry 3 - name: Test run: bundle exec rake spec - - name: Lint - run: bundle exec rake rubocop diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..6fbc623 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,14 @@ +AllCops: + TargetRubyVersion: 2.5 + +Metrics/BlockLength: + Exclude: + - 'spec/**/*' + - 'stoplight.gemspec' + +Lint/MissingSuper: + Enabled: false + +Lint/AmbiguousBlockAssociation: + Exclude: + - 'spec/**/*' diff --git a/Gemfile b/Gemfile index 0a8a26f..7f4f5e9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true source 'https://rubygems.org' diff --git a/README.md b/README.md index c64cf39..9cf00f4 100644 --- a/README.md +++ b/README.md @@ -503,7 +503,7 @@ Stoplight is licensed under [the MIT License][]. [Stoplight]: https://github.com/bolshakov/stoplight [Version badge]: https://img.shields.io/gem/v/stoplight.svg?label=version [version]: https://rubygems.org/gems/stoplight -[Build badge]: https://github.com/bolshakov/stoplight/workflows/Ruby/badge.svg +[Build badge]: https://github.com/bolshakov/stoplight/workflows/Specs/badge.svg [build]: https://github.com/bolshakov/stoplight/actions?query=branch%3Amaster [Coverage badge]: https://img.shields.io/coveralls/bolshakov/stoplight/master.svg?label=coverage [coverage]: https://coveralls.io/r/bolshakov/stoplight diff --git a/Rakefile b/Rakefile index 14ce152..aebc620 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' @@ -7,4 +7,4 @@ require 'rubocop/rake_task' RSpec::Core::RakeTask.new RuboCop::RakeTask.new -task default: %w(spec rubocop) +task default: %w[spec rubocop] diff --git a/bench/memory_bench.rb b/bench/memory_bench.rb index 1c4f0ba..17c18af 100644 --- a/bench/memory_bench.rb +++ b/bench/memory_bench.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'benchmark/ips' require 'stoplight' diff --git a/bench/redis_bench.rb b/bench/redis_bench.rb index ea3fbce..2a93be2 100644 --- a/bench/redis_bench.rb +++ b/bench/redis_bench.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'benchmark/ips' require 'fakeredis' diff --git a/lib/stoplight.rb b/lib/stoplight.rb index 0f4b738..5042651 100644 --- a/lib/stoplight.rb +++ b/lib/stoplight.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight # rubocop:disable Style/Documentation end diff --git a/lib/stoplight/color.rb b/lib/stoplight/color.rb index 2f56a2b..14a5f14 100644 --- a/lib/stoplight/color.rb +++ b/lib/stoplight/color.rb @@ -1,9 +1,9 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Color - GREEN = 'green'.freeze - YELLOW = 'yellow'.freeze - RED = 'red'.freeze + GREEN = 'green' + YELLOW = 'yellow' + RED = 'red' end end diff --git a/lib/stoplight/data_store.rb b/lib/stoplight/data_store.rb index 4eb8493..47fe67b 100644 --- a/lib/stoplight/data_store.rb +++ b/lib/stoplight/data_store.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module DataStore # rubocop:disable Style/Documentation diff --git a/lib/stoplight/data_store/base.rb b/lib/stoplight/data_store/base.rb index 74b0b9b..613d479 100644 --- a/lib/stoplight/data_store/base.rb +++ b/lib/stoplight/data_store/base.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module DataStore diff --git a/lib/stoplight/data_store/memory.rb b/lib/stoplight/data_store/memory.rb index 3caefad..e0202d4 100644 --- a/lib/stoplight/data_store/memory.rb +++ b/lib/stoplight/data_store/memory.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'monitor' diff --git a/lib/stoplight/data_store/redis.rb b/lib/stoplight/data_store/redis.rb index 47fc707..fff8dfc 100644 --- a/lib/stoplight/data_store/redis.rb +++ b/lib/stoplight/data_store/redis.rb @@ -1,11 +1,11 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module DataStore # @see Base class Redis < Base - KEY_PREFIX = 'stoplight'.freeze - KEY_SEPARATOR = ':'.freeze + KEY_PREFIX = 'stoplight' + KEY_SEPARATOR = ':' # @param redis [::Redis] def initialize(redis) @@ -84,12 +84,10 @@ def query_failures(light) def normalize_failures(failures, error_notifier) failures.map do |json| - begin - Failure.from_json(json) - rescue => error - error_notifier.call(error) - Failure.from_error(error) - end + Failure.from_json(json) + rescue StandardError => e + error_notifier.call(e) + Failure.from_error(e) end end diff --git a/lib/stoplight/default.rb b/lib/stoplight/default.rb index d2957e9..044b6a3 100644 --- a/lib/stoplight/default.rb +++ b/lib/stoplight/default.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Default @@ -6,9 +6,9 @@ module Default DATA_STORE = DataStore::Memory.new - ERROR_HANDLER = -> (error, handler) { handler.call(error) } + ERROR_HANDLER = ->(error, handler) { handler.call(error) } - ERROR_NOTIFIER = -> (error) { warn error } + ERROR_NOTIFIER = ->(error) { warn error } FALLBACK = nil diff --git a/lib/stoplight/error.rb b/lib/stoplight/error.rb index c72b1da..40fe9a2 100644 --- a/lib/stoplight/error.rb +++ b/lib/stoplight/error.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Error diff --git a/lib/stoplight/failure.rb b/lib/stoplight/failure.rb index e956003..bba4000 100644 --- a/lib/stoplight/failure.rb +++ b/lib/stoplight/failure.rb @@ -1,11 +1,11 @@ -# coding: utf-8 +# frozen_string_literal: true require 'json' require 'time' module Stoplight class Failure # rubocop:disable Style/Documentation - TIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%N%:z'.freeze + TIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%N%:z' # @return [String] attr_reader :error_class diff --git a/lib/stoplight/light.rb b/lib/stoplight/light.rb index 2c3768f..588899b 100644 --- a/lib/stoplight/light.rb +++ b/lib/stoplight/light.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight class Light # rubocop:disable Style/Documentation diff --git a/lib/stoplight/light/runnable.rb b/lib/stoplight/light/runnable.rb index 1964c68..de22991 100644 --- a/lib/stoplight/light/runnable.rb +++ b/lib/stoplight/light/runnable.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight class Light @@ -44,23 +44,25 @@ def run_yellow def run_red raise Error::RedLight, name unless fallback + fallback.call(nil) end def run_code(on_success, on_failure) result = code.call failures = clear_failures - on_success.call(failures) if on_success + on_success&.call(failures) result - rescue Exception => error # rubocop:disable Lint/RescueException - handle_error(error, on_failure) + rescue Exception => e # rubocop:disable Lint/RescueException + handle_error(e, on_failure) end def handle_error(error, on_failure) error_handler.call(error, Error::HANDLER) size = record_failure(error) - on_failure.call(size, error) if on_failure + on_failure&.call(size, error) raise error unless fallback + fallback.call(error) end diff --git a/lib/stoplight/notifier.rb b/lib/stoplight/notifier.rb index 81d3b95..00bb2ca 100644 --- a/lib/stoplight/notifier.rb +++ b/lib/stoplight/notifier.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier # rubocop:disable Style/Documentation diff --git a/lib/stoplight/notifier/base.rb b/lib/stoplight/notifier/base.rb index ab2c9b9..a925fee 100644 --- a/lib/stoplight/notifier/base.rb +++ b/lib/stoplight/notifier/base.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/bugsnag.rb b/lib/stoplight/notifier/bugsnag.rb index dc9c4f3..cd779da 100644 --- a/lib/stoplight/notifier/bugsnag.rb +++ b/lib/stoplight/notifier/bugsnag.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/generic.rb b/lib/stoplight/notifier/generic.rb index ed98a04..94d2c2a 100644 --- a/lib/stoplight/notifier/generic.rb +++ b/lib/stoplight/notifier/generic.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/hip_chat.rb b/lib/stoplight/notifier/hip_chat.rb index 118e875..c96d08f 100644 --- a/lib/stoplight/notifier/hip_chat.rb +++ b/lib/stoplight/notifier/hip_chat.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/honeybadger.rb b/lib/stoplight/notifier/honeybadger.rb index 0735e31..61f4752 100644 --- a/lib/stoplight/notifier/honeybadger.rb +++ b/lib/stoplight/notifier/honeybadger.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier @@ -34,7 +34,7 @@ def notify(light, from_color, to_color, error) h = options.merge( api_key: api_key, error_message: message, - backtrace: (error.backtrace if error) + backtrace: error&.backtrace ) ::Honeybadger.notify(h) message diff --git a/lib/stoplight/notifier/io.rb b/lib/stoplight/notifier/io.rb index a532499..8395e8d 100644 --- a/lib/stoplight/notifier/io.rb +++ b/lib/stoplight/notifier/io.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/logger.rb b/lib/stoplight/notifier/logger.rb index 3b88ae0..ed4a5ed 100644 --- a/lib/stoplight/notifier/logger.rb +++ b/lib/stoplight/notifier/logger.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/pagerduty.rb b/lib/stoplight/notifier/pagerduty.rb index f6c032c..70bfa93 100644 --- a/lib/stoplight/notifier/pagerduty.rb +++ b/lib/stoplight/notifier/pagerduty.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/raven.rb b/lib/stoplight/notifier/raven.rb index 81e6edf..fe5f8bb 100644 --- a/lib/stoplight/notifier/raven.rb +++ b/lib/stoplight/notifier/raven.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier @@ -30,7 +30,7 @@ def notify(light, from_color, to_color, error) h = options.merge( configuration: configuration, - backtrace: (error.backtrace if error) + backtrace: error&.backtrace ) ::Raven.capture_message(message, h) message diff --git a/lib/stoplight/notifier/rollbar.rb b/lib/stoplight/notifier/rollbar.rb index 4a17911..0435987 100644 --- a/lib/stoplight/notifier/rollbar.rb +++ b/lib/stoplight/notifier/rollbar.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/notifier/slack.rb b/lib/stoplight/notifier/slack.rb index 8985517..133998f 100644 --- a/lib/stoplight/notifier/slack.rb +++ b/lib/stoplight/notifier/slack.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module Notifier diff --git a/lib/stoplight/state.rb b/lib/stoplight/state.rb index 3c51fa6..0be6d61 100644 --- a/lib/stoplight/state.rb +++ b/lib/stoplight/state.rb @@ -1,9 +1,9 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight module State - UNLOCKED = 'unlocked'.freeze - LOCKED_GREEN = 'locked_green'.freeze - LOCKED_RED = 'locked_red'.freeze + UNLOCKED = 'unlocked' + LOCKED_GREEN = 'locked_green' + LOCKED_RED = 'locked_red' end end diff --git a/lib/stoplight/version.rb b/lib/stoplight/version.rb index a53f0a3..6ed1d01 100644 --- a/lib/stoplight/version.rb +++ b/lib/stoplight/version.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true module Stoplight VERSION = Gem::Version.new('2.2.1') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9b9f3d1..c37b45e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'coveralls' Coveralls.wear! diff --git a/spec/stoplight/color_spec.rb b/spec/stoplight/color_spec.rb index 3dde77a..008010f 100644 --- a/spec/stoplight/color_spec.rb +++ b/spec/stoplight/color_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/data_store/base_spec.rb b/spec/stoplight/data_store/base_spec.rb index b477674..df73ba2 100644 --- a/spec/stoplight/data_store/base_spec.rb +++ b/spec/stoplight/data_store/base_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/data_store/memory_spec.rb b/spec/stoplight/data_store/memory_spec.rb index fb0189f..3688684 100644 --- a/spec/stoplight/data_store/memory_spec.rb +++ b/spec/stoplight/data_store/memory_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/data_store/redis_spec.rb b/spec/stoplight/data_store/redis_spec.rb index d974231..d4d4e2e 100644 --- a/spec/stoplight/data_store/redis_spec.rb +++ b/spec/stoplight/data_store/redis_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' require 'fakeredis' diff --git a/spec/stoplight/data_store_spec.rb b/spec/stoplight/data_store_spec.rb index 6d4df9b..d3e8a4a 100644 --- a/spec/stoplight/data_store_spec.rb +++ b/spec/stoplight/data_store_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/default_spec.rb b/spec/stoplight/default_spec.rb index b8d5735..0e15b7b 100644 --- a/spec/stoplight/default_spec.rb +++ b/spec/stoplight/default_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/error_spec.rb b/spec/stoplight/error_spec.rb index 8732fbb..90a8a58 100644 --- a/spec/stoplight/error_spec.rb +++ b/spec/stoplight/error_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/failure_spec.rb b/spec/stoplight/failure_spec.rb index f19a8bf..bdbe703 100644 --- a/spec/stoplight/failure_spec.rb +++ b/spec/stoplight/failure_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/light/runnable_spec.rb b/spec/stoplight/light/runnable_spec.rb index 3598912..cc560a2 100644 --- a/spec/stoplight/light/runnable_spec.rb +++ b/spec/stoplight/light/runnable_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' require 'stringio' @@ -8,7 +8,7 @@ let(:code) { -> { code_result } } let(:code_result) { random_string } - let(:fallback) { -> (_) { fallback_result } } + let(:fallback) { ->(_) { fallback_result } } let(:fallback_result) { random_string } let(:name) { random_string } @@ -123,12 +123,10 @@ def random_string context 'with an error handler' do let(:result) do - begin - subject.run - expect(false).to be(true) - rescue error.class - expect(true).to be(true) - end + subject.run + expect(false).to be(true) + rescue error.class + expect(true).to be(true) end it 'records the failure when the handler does nothing' do @@ -171,7 +169,7 @@ def random_string context 'when the data store is failing' do let(:data_store) { Object.new } - let(:error_notifier) { -> (_) {} } + let(:error_notifier) { ->(_) {} } before do subject diff --git a/spec/stoplight/light_spec.rb b/spec/stoplight/light_spec.rb index b289025..0b120fe 100644 --- a/spec/stoplight/light_spec.rb +++ b/spec/stoplight/light_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' require 'stringio' @@ -42,7 +42,7 @@ after { described_class.default_error_notifier = @default_error_notifier } it 'sets the error notifier' do - default_error_notifier = -> (_) {} + default_error_notifier = ->(_) {} described_class.default_error_notifier = default_error_notifier expect(described_class.default_error_notifier) .to eql(default_error_notifier) @@ -140,7 +140,7 @@ describe '#with_error_handler' do it 'sets the error handler' do - error_handler = -> (_, _) {} + error_handler = ->(_, _) {} light.with_error_handler(&error_handler) expect(light.error_handler).to eql(error_handler) end @@ -148,7 +148,7 @@ describe '#with_error_notifier' do it 'sets the error notifier' do - error_notifier = -> (_) {} + error_notifier = ->(_) {} light.with_error_notifier(&error_notifier) expect(light.error_notifier).to eql(error_notifier) end @@ -156,7 +156,7 @@ describe '#with_fallback' do it 'sets the fallback' do - fallback = -> (_) {} + fallback = ->(_) {} light.with_fallback(&fallback) expect(light.fallback).to eql(fallback) end diff --git a/spec/stoplight/notifier/base_spec.rb b/spec/stoplight/notifier/base_spec.rb index 1b09343..2efb152 100644 --- a/spec/stoplight/notifier/base_spec.rb +++ b/spec/stoplight/notifier/base_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/notifier/bugsnag_spec.rb b/spec/stoplight/notifier/bugsnag_spec.rb index 1fa1ce1..1ac5d78 100644 --- a/spec/stoplight/notifier/bugsnag_spec.rb +++ b/spec/stoplight/notifier/bugsnag_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/notifier/generic_spec.rb b/spec/stoplight/notifier/generic_spec.rb index d864e3e..f28df87 100644 --- a/spec/stoplight/notifier/generic_spec.rb +++ b/spec/stoplight/notifier/generic_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/notifier/hip_chat_spec.rb b/spec/stoplight/notifier/hip_chat_spec.rb index 1c57180..af10c28 100644 --- a/spec/stoplight/notifier/hip_chat_spec.rb +++ b/spec/stoplight/notifier/hip_chat_spec.rb @@ -1,12 +1,11 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' # require 'hipchat' module HipChat class Client - def initialize(*) - end + def initialize(*); end end end diff --git a/spec/stoplight/notifier/honeybadger_spec.rb b/spec/stoplight/notifier/honeybadger_spec.rb index 9f0e9d4..db76ce3 100644 --- a/spec/stoplight/notifier/honeybadger_spec.rb +++ b/spec/stoplight/notifier/honeybadger_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/notifier/io_spec.rb b/spec/stoplight/notifier/io_spec.rb index a54b79f..d25a348 100644 --- a/spec/stoplight/notifier/io_spec.rb +++ b/spec/stoplight/notifier/io_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' require 'stringio' diff --git a/spec/stoplight/notifier/logger_spec.rb b/spec/stoplight/notifier/logger_spec.rb index 29a1839..eb6ae50 100644 --- a/spec/stoplight/notifier/logger_spec.rb +++ b/spec/stoplight/notifier/logger_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' require 'logger' diff --git a/spec/stoplight/notifier/pagerduty_spec.rb b/spec/stoplight/notifier/pagerduty_spec.rb index 9429376..b666c9b 100644 --- a/spec/stoplight/notifier/pagerduty_spec.rb +++ b/spec/stoplight/notifier/pagerduty_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' require 'pagerduty' diff --git a/spec/stoplight/notifier/raven_spec.rb b/spec/stoplight/notifier/raven_spec.rb index 5c26b8a..968d938 100644 --- a/spec/stoplight/notifier/raven_spec.rb +++ b/spec/stoplight/notifier/raven_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/notifier/rollbar_spec.rb b/spec/stoplight/notifier/rollbar_spec.rb index 3a56300..e3ddc35 100644 --- a/spec/stoplight/notifier/rollbar_spec.rb +++ b/spec/stoplight/notifier/rollbar_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/notifier/slack_spec.rb b/spec/stoplight/notifier/slack_spec.rb index 8543fa8..5df87be 100644 --- a/spec/stoplight/notifier/slack_spec.rb +++ b/spec/stoplight/notifier/slack_spec.rb @@ -1,12 +1,11 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' # require 'slack-notifier' module Slack class Notifier - def initialize(*) - end + def initialize(*); end end end diff --git a/spec/stoplight/notifier_spec.rb b/spec/stoplight/notifier_spec.rb index 2f357ca..45b4de6 100644 --- a/spec/stoplight/notifier_spec.rb +++ b/spec/stoplight/notifier_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/state_spec.rb b/spec/stoplight/state_spec.rb index 5beb5ca..072c9bb 100644 --- a/spec/stoplight/state_spec.rb +++ b/spec/stoplight/state_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight/version_spec.rb b/spec/stoplight/version_spec.rb index d6356ae..53b3ad9 100644 --- a/spec/stoplight/version_spec.rb +++ b/spec/stoplight/version_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/spec/stoplight_spec.rb b/spec/stoplight_spec.rb index 71ad1b6..479719d 100644 --- a/spec/stoplight_spec.rb +++ b/spec/stoplight_spec.rb @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true require 'spec_helper' diff --git a/stoplight.gemspec b/stoplight.gemspec index 6a53c94..9653c2a 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -1,4 +1,4 @@ -# coding: utf-8 +# frozen_string_literal: true lib = File.expand_path('lib', File.dirname(__FILE__)) $LOAD_PATH.push(lib) unless $LOAD_PATH.include?(lib) @@ -22,14 +22,14 @@ Gem::Specification.new do |gem| gem.email = hash.values end - gem.files = %w( + gem.files = %w[ CHANGELOG.md LICENSE.md README.md - ) + Dir.glob(File.join('lib', '**', '*.rb')) + ] + Dir.glob(File.join('lib', '**', '*.rb')) gem.test_files = Dir.glob(File.join('spec', '**', '*.rb')) - gem.required_ruby_version = '>= 2.1' + gem.required_ruby_version = '>= 2.5' { 'benchmark-ips' => '2.3', @@ -42,11 +42,12 @@ Gem::Specification.new do |gem| 'rake' => '11.1', 'redis' => '3.2', 'rspec' => '3.3', - 'rubocop' => '0.40.0', 'sentry-raven' => '1.2', 'slack-notifier' => '1.3', 'timecop' => '0.8' }.each do |name, version| gem.add_development_dependency(name, "~> #{version}") end + + gem.add_development_dependency('rubocop', '~> 1.0.0') end From 6e9c858861e671bb7472510b498cf44a89702c4a Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 15:43:55 +0300 Subject: [PATCH 04/14] Explicitly mention deps, so dependabot is able to update them (#140) --- stoplight.gemspec | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/stoplight.gemspec b/stoplight.gemspec index 9653c2a..82c50ac 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -31,23 +31,18 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.5' - { - 'benchmark-ips' => '2.3', - 'bugsnag' => '4.0', - 'coveralls' => '0.8', - 'fakeredis' => '0.5', - 'hipchat' => '1.5', - 'honeybadger' => '2.5', - 'pagerduty' => '2.1.1', - 'rake' => '11.1', - 'redis' => '3.2', - 'rspec' => '3.3', - 'sentry-raven' => '1.2', - 'slack-notifier' => '1.3', - 'timecop' => '0.8' - }.each do |name, version| - gem.add_development_dependency(name, "~> #{version}") - end - + gem.add_development_dependency('benchmark-ips', '~> 2.3') + gem.add_development_dependency('bugsnag', '~> 4.0') + gem.add_development_dependency('coveralls', '~> 0.8') + gem.add_development_dependency('fakeredis', '~> 0.5') + gem.add_development_dependency('hipchat', '~> 1.5') + gem.add_development_dependency('honeybadger', '~> 2.5') + gem.add_development_dependency('pagerduty', '~> 2.1.1') + gem.add_development_dependency('rake', '~> 11.1') + gem.add_development_dependency('redis', '~> 3.2') + gem.add_development_dependency('rspec', '~> 3.3') gem.add_development_dependency('rubocop', '~> 1.0.0') + gem.add_development_dependency('sentry-raven', '~> 1.2') + gem.add_development_dependency('slack-notifier', '~> 1.3') + gem.add_development_dependency('timecop', '~> 0.8') end From c8ee69611206b72c0f386779442916b65fc71952 Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 19:10:29 +0300 Subject: [PATCH 05/14] Enable coverails (#141) --- .github/workflows/specs.yml | 18 +++++++++++++++++- .simplecov | 17 +++++++++++++++++ spec/spec_helper.rb | 3 +-- stoplight.gemspec | 3 ++- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .simplecov diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index a2b99d0..5c8ad93 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -3,7 +3,7 @@ name: Specs on: [push] jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: @@ -23,3 +23,19 @@ jobs: bundle install --jobs 4 --retry 3 - name: Test run: bundle exec rake spec + - name: Coveralls + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: ruby-${{ matrix.ruby }} + parallel: true + + finish: + needs: test + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true diff --git a/.simplecov b/.simplecov new file mode 100644 index 0000000..e8f6956 --- /dev/null +++ b/.simplecov @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'simplecov-lcov' + +SimpleCov::Formatter::LcovFormatter.config do |c| + c.report_with_single_file = true + c.single_report_path = 'coverage/lcov.info' +end +SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new( + [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::LcovFormatter + ] +) +SimpleCov.start do + add_filter 'spec/' +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c37b45e..8fce8cd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true -require 'coveralls' -Coveralls.wear! +require 'simplecov' require 'stoplight' require 'timecop' diff --git a/stoplight.gemspec b/stoplight.gemspec index 82c50ac..d0d8fd9 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -33,7 +33,6 @@ Gem::Specification.new do |gem| gem.add_development_dependency('benchmark-ips', '~> 2.3') gem.add_development_dependency('bugsnag', '~> 4.0') - gem.add_development_dependency('coveralls', '~> 0.8') gem.add_development_dependency('fakeredis', '~> 0.5') gem.add_development_dependency('hipchat', '~> 1.5') gem.add_development_dependency('honeybadger', '~> 2.5') @@ -43,6 +42,8 @@ Gem::Specification.new do |gem| gem.add_development_dependency('rspec', '~> 3.3') gem.add_development_dependency('rubocop', '~> 1.0.0') gem.add_development_dependency('sentry-raven', '~> 1.2') + gem.add_development_dependency('simplecov', '~> 0.19') + gem.add_development_dependency('simplecov-lcov', '~> 0.8') gem.add_development_dependency('slack-notifier', '~> 1.3') gem.add_development_dependency('timecop', '~> 0.8') end From 917bbc4b73b3a896ffb7604d43a3db94506e2925 Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 19:41:53 +0300 Subject: [PATCH 06/14] Fix code climate badge (#142) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cf00f4..de13d71 100644 --- a/README.md +++ b/README.md @@ -507,7 +507,7 @@ Stoplight is licensed under [the MIT License][]. [build]: https://github.com/bolshakov/stoplight/actions?query=branch%3Amaster [Coverage badge]: https://img.shields.io/coveralls/bolshakov/stoplight/master.svg?label=coverage [coverage]: https://coveralls.io/r/bolshakov/stoplight -[Climate badge]: https://img.shields.io/codeclimate/github/bolshakov/stoplight.svg?label=climate +[Climate badge]: https://api.codeclimate.com/v1/badges/3451c2d281ffa345441a/maintainability [climate]: https://codeclimate.com/github/bolshakov/stoplight [stoplight-admin]: https://github.com/bolshakov/stoplight-admin [Semantic Versioning]: http://semver.org/spec/v2.0.0.html From d3215b157c425c0a0797d75db00d4128465d3958 Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 19:48:40 +0300 Subject: [PATCH 07/14] Add Gemfile.lock (#143) --- .gitignore | 1 - Gemfile.lock | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index 9bb03c4..8065980 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /.bundle/ /.yardoc/ -/Gemfile.lock /coverage/ /doc/ /pkg/ diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..3810269 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,100 @@ +PATH + remote: . + specs: + stoplight (2.2.1) + +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.1) + benchmark-ips (2.7.2) + bugsnag (4.2.1) + diff-lcs (1.3) + docile (1.3.2) + fakeredis (0.7.0) + redis (>= 3.2, < 5.0) + faraday (0.9.2) + multipart-post (>= 1.2, < 3) + hipchat (1.6.0) + httparty + mimemagic + honeybadger (2.7.2) + httparty (0.17.1) + mime-types (~> 3.0) + multi_xml (>= 0.5.2) + json (2.3.1) + mime-types (3.3) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.1009) + mimemagic (0.3.3) + multi_xml (0.6.0) + multipart-post (2.1.1) + pagerduty (2.1.2) + json (>= 1.7.7) + parallel (1.20.0) + parser (2.7.2.0) + ast (~> 2.4.1) + rainbow (3.0.0) + rake (11.3.0) + redis (3.3.5) + regexp_parser (1.8.2) + rexml (3.2.4) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.0) + rubocop (1.0.0) + parallel (~> 1.10) + parser (>= 2.7.1.5) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8) + rexml + rubocop-ast (>= 0.6.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (1.1.1) + parser (>= 2.7.1.5) + ruby-progressbar (1.10.1) + sentry-raven (1.2.3) + faraday (>= 0.7.6, < 0.10.x) + simplecov (0.19.1) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov-html (0.12.3) + simplecov-lcov (0.8.0) + slack-notifier (1.5.1) + timecop (0.9.1) + unicode-display_width (1.7.0) + +PLATFORMS + ruby + +DEPENDENCIES + benchmark-ips (~> 2.3) + bugsnag (~> 4.0) + fakeredis (~> 0.5) + hipchat (~> 1.5) + honeybadger (~> 2.5) + pagerduty (~> 2.1.1) + rake (~> 11.1) + redis (~> 3.2) + rspec (~> 3.3) + rubocop (~> 1.0.0) + sentry-raven (~> 1.2) + simplecov (~> 0.19) + simplecov-lcov (~> 0.8) + slack-notifier (~> 1.3) + stoplight! + timecop (~> 0.8) + +BUNDLED WITH + 2.0.2 From 9787b1c9fdce0c699e15c4ccd072c29db3d0db59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2020 19:50:34 +0300 Subject: [PATCH 08/14] Update rake requirement from ~> 11.1 to ~> 13.0 (#144) Updates the requirements on [rake](https://github.com/ruby/rake) to permit the latest version. - [Release notes](https://github.com/ruby/rake/releases) - [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc) - [Commits](https://github.com/ruby/rake/compare/v11.3.0...v13.0.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- stoplight.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3810269..dd631a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,7 +35,7 @@ GEM parser (2.7.2.0) ast (~> 2.4.1) rainbow (3.0.0) - rake (11.3.0) + rake (13.0.1) redis (3.3.5) regexp_parser (1.8.2) rexml (3.2.4) @@ -85,7 +85,7 @@ DEPENDENCIES hipchat (~> 1.5) honeybadger (~> 2.5) pagerduty (~> 2.1.1) - rake (~> 11.1) + rake (~> 13.0) redis (~> 3.2) rspec (~> 3.3) rubocop (~> 1.0.0) diff --git a/stoplight.gemspec b/stoplight.gemspec index d0d8fd9..4eb1001 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency('hipchat', '~> 1.5') gem.add_development_dependency('honeybadger', '~> 2.5') gem.add_development_dependency('pagerduty', '~> 2.1.1') - gem.add_development_dependency('rake', '~> 11.1') + gem.add_development_dependency('rake', '~> 13.0') gem.add_development_dependency('redis', '~> 3.2') gem.add_development_dependency('rspec', '~> 3.3') gem.add_development_dependency('rubocop', '~> 1.0.0') From 1e59faf32cf2a1e59b0b6c33a72c4bd654075d92 Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Sat, 14 Nov 2020 23:20:10 +0300 Subject: [PATCH 09/14] Fix repo link --- stoplight.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stoplight.gemspec b/stoplight.gemspec index 4eb1001..28b1cf2 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |gem| gem.version = Stoplight::VERSION gem.summary = 'Traffic control for code.' gem.description = 'An implementation of the circuit breaker pattern.' - gem.homepage = 'https://github.com/orgsync/stoplight' + gem.homepage = 'https://github.com/bolshakov/stoplight' gem.license = 'MIT' { From ee0cadbebc6601ad4a575c8c9a356d0385857c64 Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Wed, 27 Jan 2021 11:24:31 +0300 Subject: [PATCH 10/14] Fix gem link (#145) From f09b82aa897815e22baf604c76bf472a330d2298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=ABma=20Bolshakov?= Date: Mon, 17 Jan 2022 21:22:36 +0300 Subject: [PATCH 11/14] Test against ruby 3.0.x (#146) * Test against ruby 3.0.x * Drop ruby 2.5 support Co-authored-by: John Andrews --- .github/workflows/specs.yml | 4 ++-- Gemfile.lock | 19 ++++++++++++++----- stoplight.gemspec | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index 5c8ad93..0c9d375 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [ '2.5.x', '2.6.x', '2.7.x' ] + ruby: ['2.6.x', '2.7.x', '3.0.x' ] name: ${{ matrix.ruby }} steps: @@ -18,7 +18,7 @@ jobs: ruby-version: ${{ matrix.ruby }} - name: Install dependencies run: | - gem install bundler --force --version=2.0.1 + gem install bundler --force --version=2.2.31 bundler --version bundle install --jobs 4 --retry 3 - name: Test diff --git a/Gemfile.lock b/Gemfile.lock index dd631a1..29823d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GEM benchmark-ips (2.7.2) bugsnag (4.2.1) diff-lcs (1.3) - docile (1.3.2) + docile (1.4.0) fakeredis (0.7.0) redis (>= 3.2, < 5.0) faraday (0.9.2) @@ -26,14 +26,21 @@ GEM mime-types (3.3) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) - mimemagic (0.3.3) + mimemagic (0.4.3) + nokogiri (~> 1) + rake + mini_portile2 (2.7.1) multi_xml (0.6.0) multipart-post (2.1.1) + nokogiri (1.13.0) + mini_portile2 (~> 2.7.0) + racc (~> 1.4) pagerduty (2.1.2) json (>= 1.7.7) parallel (1.20.0) parser (2.7.2.0) ast (~> 2.4.1) + racc (1.6.0) rainbow (3.0.0) rake (13.0.1) redis (3.3.5) @@ -66,11 +73,13 @@ GEM ruby-progressbar (1.10.1) sentry-raven (1.2.3) faraday (>= 0.7.6, < 0.10.x) - simplecov (0.19.1) + simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov-lcov (0.8.0) + simplecov_json_formatter (0.1.3) slack-notifier (1.5.1) timecop (0.9.1) unicode-display_width (1.7.0) @@ -90,11 +99,11 @@ DEPENDENCIES rspec (~> 3.3) rubocop (~> 1.0.0) sentry-raven (~> 1.2) - simplecov (~> 0.19) + simplecov (~> 0.21) simplecov-lcov (~> 0.8) slack-notifier (~> 1.3) stoplight! timecop (~> 0.8) BUNDLED WITH - 2.0.2 + 2.2.31 diff --git a/stoplight.gemspec b/stoplight.gemspec index 28b1cf2..031a866 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -42,7 +42,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency('rspec', '~> 3.3') gem.add_development_dependency('rubocop', '~> 1.0.0') gem.add_development_dependency('sentry-raven', '~> 1.2') - gem.add_development_dependency('simplecov', '~> 0.19') + gem.add_development_dependency('simplecov', '~> 0.21') gem.add_development_dependency('simplecov-lcov', '~> 0.8') gem.add_development_dependency('slack-notifier', '~> 1.3') gem.add_development_dependency('timecop', '~> 0.8') From 3d12134f842be42d6f3ec585e1a9f0cf4513ffea Mon Sep 17 00:00:00 2001 From: Jean byroot Boussier Date: Wed, 23 Feb 2022 15:38:21 +0100 Subject: [PATCH 12/14] Fix deprecated uses of `Redis#pipelined` (#150) Context: https://github.com/redis/redis-rb/pull/1059 The following is deprecated ```ruby redis.pipelined do redis.get(key) end ``` And should be rewritten as: ```ruby redis.pipelined do |pipeline| pipeline.get(key) end ``` Functionally it makes no difference. This API is available since Redis 3.0. Co-authored-by: Jean Boussier --- lib/stoplight/data_store/redis.rb | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/stoplight/data_store/redis.rb b/lib/stoplight/data_store/redis.rb index fff8dfc..0474bfb 100644 --- a/lib/stoplight/data_store/redis.rb +++ b/lib/stoplight/data_store/redis.rb @@ -25,9 +25,9 @@ def names end def get_all(light) - failures, state = @redis.multi do - query_failures(light) - @redis.hget(states_key, light.name) + failures, state = @redis.multi do |transaction| + query_failures(light, transaction: transaction) + transaction.hget(states_key, light.name) end [ @@ -41,18 +41,18 @@ def get_failures(light) end def record_failure(light, failure) - size, = @redis.multi do - @redis.lpush(failures_key(light), failure.to_json) - @redis.ltrim(failures_key(light), 0, light.threshold - 1) + size, = @redis.multi do |transaction| + transaction.lpush(failures_key(light), failure.to_json) + transaction.ltrim(failures_key(light), 0, light.threshold - 1) end size end def clear_failures(light) - failures, = @redis.multi do - query_failures(light) - @redis.del(failures_key(light)) + failures, = @redis.multi do |transaction| + query_failures(light, transaction: transaction) + transaction.del(failures_key(light)) end normalize_failures(failures, light.error_notifier) @@ -68,9 +68,9 @@ def set_state(light, state) end def clear_state(light) - state, = @redis.multi do - query_state(light) - @redis.hdel(states_key, light.name) + state, = @redis.multi do |transaction| + query_state(light, transaction: transaction) + transaction.hdel(states_key, light.name) end normalize_state(state) @@ -78,8 +78,8 @@ def clear_state(light) private - def query_failures(light) - @redis.lrange(failures_key(light), 0, -1) + def query_failures(light, transaction: @redis) + transaction.lrange(failures_key(light), 0, -1) end def normalize_failures(failures, error_notifier) @@ -91,8 +91,8 @@ def normalize_failures(failures, error_notifier) end end - def query_state(light) - @redis.hget(states_key, light.name) + def query_state(light, transaction: @redis) + transaction.hget(states_key, light.name) end def normalize_state(state) From 6fde06aa9e9a6286b1deda0ed5e1a2a9db235a00 Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Mon, 17 Jan 2022 21:24:52 +0300 Subject: [PATCH 13/14] Set required ruby version in gemspec --- stoplight.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stoplight.gemspec b/stoplight.gemspec index 031a866..d104d6a 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |gem| ] + Dir.glob(File.join('lib', '**', '*.rb')) gem.test_files = Dir.glob(File.join('spec', '**', '*.rb')) - gem.required_ruby_version = '>= 2.5' + gem.required_ruby_version = '>= 2.6' gem.add_development_dependency('benchmark-ips', '~> 2.3') gem.add_development_dependency('bugsnag', '~> 4.0') From ad349fe5ddddb5f2665a4a839dde840aed21873c Mon Sep 17 00:00:00 2001 From: Tema Bolshakov Date: Mon, 17 Jan 2022 21:25:08 +0300 Subject: [PATCH 14/14] Bump version --- Gemfile.lock | 2 +- lib/stoplight/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 29823d6..2d59334 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - stoplight (2.2.1) + stoplight (3.0.0) GEM remote: https://rubygems.org/ diff --git a/lib/stoplight/version.rb b/lib/stoplight/version.rb index 6ed1d01..aa3971b 100644 --- a/lib/stoplight/version.rb +++ b/lib/stoplight/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stoplight - VERSION = Gem::Version.new('2.2.1') + VERSION = Gem::Version.new('3.0.0') end