From 06ce10a2a4c4efeafff7881d17d59bdc285a9eb2 Mon Sep 17 00:00:00 2001 From: Clayton Parker Date: Fri, 21 Oct 2022 16:30:01 -0400 Subject: [PATCH 1/6] test against latest ruby 3.1 --- .github/workflows/ci.yml | 4 ++-- .rubocop.yml | 2 +- .ruby-version | 2 +- CHANGELOG.md | 4 ++++ Gemfile.lock | 2 +- augury.gemspec | 2 +- bin/extract_creds | 5 ++++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 896da4c..95fbe46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - ruby: [2.6, 2.7, '3.0'] + ruby: [2.7, '3.0', '3.1'] runs-on: ${{ matrix.os }} env: TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }} @@ -23,7 +23,7 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: true - run: bundle exec rake - - if: matrix.os == 'ubuntu-latest' && matrix.ruby == '3.0' + - if: matrix.os == 'ubuntu-latest' && matrix.ruby == '3.1' run: | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter chmod +x ./cc-test-reporter diff --git a/.rubocop.yml b/.rubocop.yml index 78af421..8b1a83e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.7 Exclude: - bin/**/* - vendor/**/* diff --git a/.ruby-version b/.ruby-version index 37c2961..49cdd66 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +2.7.6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b12d33..b0adf29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changes +## x.x.x (xxxx-xx-xx) + +- Test against latest Ruby 3.1 + ## 1.1.2 (2022-04-12) - Fix issue with mismatched case for Twitter screen_name. (#22) diff --git a/Gemfile.lock b/Gemfile.lock index 1d95703..c30e7b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -183,4 +183,4 @@ DEPENDENCIES webmock BUNDLED WITH - 2.1.4 + 2.3.24 diff --git a/augury.gemspec b/augury.gemspec index a7aa3b9..43180ee 100644 --- a/augury.gemspec +++ b/augury.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |spec| spec.description = 'This gem turns a twitter feed into a fortune file that you can use with the fortune program' spec.homepage = 'https://github.com/claytron/augury' spec.license = 'MIT' - spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0') + spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0') spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = 'exe' diff --git a/bin/extract_creds b/bin/extract_creds index 251b132..048dc34 100755 --- a/bin/extract_creds +++ b/bin/extract_creds @@ -4,7 +4,10 @@ require 'yaml' begin - augury_config = YAML.load_file(File.expand_path('~/.augury.yml')) + augury_config = YAML.load_file( + File.expand_path('~/.augury.yml'), + permitted_classes: [Regexp], + ) puts augury_config['twitter'].collect { |k, v| "export TWITTER_#{k.upcase}=#{v}" }.join("\n") rescue Errno::ENOENT puts 'echo "No config file present (~/.augury.yml) no env vars set"' From 097559ce8ba1493b110e2d66940b4cadf179d021 Mon Sep 17 00:00:00 2001 From: Clayton Parker Date: Fri, 21 Oct 2022 17:10:10 -0400 Subject: [PATCH 2/6] update dependencies --- Gemfile.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c30e7b2..a029d15 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,14 +9,14 @@ PATH GEM remote: https://rubygems.org/ specs: - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) awesome_print (1.9.2) backport (1.2.0) benchmark (0.2.0) buftok (0.2.0) - bundler-audit (0.9.0.1) + bundler-audit (0.9.1) bundler (>= 1.2.0, < 3) thor (~> 1.0) byebug (11.1.3) @@ -39,15 +39,15 @@ GEM http-cookie (~> 1.0) http-form_data (~> 2.2) http-parser (~> 1.2.0) - http-cookie (1.0.4) + http-cookie (1.0.5) domain_name (~> 0.5) http-form_data (2.3.0) http-parser (1.2.3) ffi-compiler (>= 1.0, < 2.0) http_parser.rb (0.6.0) jaro_winkler (1.5.4) - json (2.6.1) - kramdown (2.3.2) + json (2.6.2) + kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) @@ -55,13 +55,13 @@ GEM thread_safe (~> 0.3, >= 0.3.1) method_source (1.0.0) mini_portile2 (2.8.0) - multipart-post (2.1.1) + multipart-post (2.2.3) naught (1.1.0) - nokogiri (1.13.4) + nokogiri (1.13.9) mini_portile2 (~> 2.8.0) racc (~> 1.4) parallel (1.22.1) - parser (3.1.1.0) + parser (3.1.2.1) ast (~> 2.4.1) pry (0.14.1) coderay (~> 1.1) @@ -69,17 +69,17 @@ GEM pry-awesome_print (9.6.11) awesome_print (>= 1.1.0, < 999) pry (>= 0.9.0, < 999) - pry-byebug (3.8.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.10) + pry (>= 0.13, < 0.15) pry-doc (1.3.0) pry (~> 0.11) yard (~> 0.9.11) - public_suffix (4.0.7) + public_suffix (5.0.0) racc (1.6.0) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.3.0) + regexp_parser (2.6.0) reverse_markdown (2.1.1) nokogiri rexml (3.2.5) @@ -89,13 +89,13 @@ GEM rspec-mocks (~> 3.11.0) rspec-core (3.11.0) rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec-expectations (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-support (3.11.0) + rspec-support (3.11.1) rubocop (0.92.0) parallel (~> 1.10) parser (>= 2.7.1.5) @@ -105,7 +105,7 @@ GEM rubocop-ast (>= 0.5.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.17.0) + rubocop-ast (1.23.0) parser (>= 3.1.1.0) rubocop-rake (0.5.1) rubocop @@ -119,7 +119,7 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - solargraph (0.44.3) + solargraph (0.47.2) backport (~> 1.2) benchmark bundler (>= 1.17.2) @@ -136,7 +136,7 @@ GEM yard (~> 0.9, >= 0.9.24) thor (1.0.1) thread_safe (0.3.6) - tilt (2.0.10) + tilt (2.0.11) twitter (7.0.0) addressable (~> 2.3) buftok (~> 0.2.0) @@ -150,16 +150,16 @@ GEM simple_oauth (~> 0.3.0) unf (0.1.4) unf_ext - unf_ext (0.0.8.1) + unf_ext (0.0.8.2) unicode-display_width (1.8.0) vcr (6.1.0) - webmock (3.14.0) + webmock (3.18.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webrick (1.7.0) word_wrap (1.0.0) - yard (0.9.27) + yard (0.9.28) webrick (~> 1.7.0) PLATFORMS From a445fc2928e60bd0c3f0600ef29e236c9f30169d Mon Sep 17 00:00:00 2001 From: Clayton Parker Date: Fri, 21 Oct 2022 17:11:14 -0400 Subject: [PATCH 3/6] note about thor version being pinned --- augury.gemspec | 1 + lib/augury/cli.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/augury.gemspec b/augury.gemspec index 43180ee..357e262 100644 --- a/augury.gemspec +++ b/augury.gemspec @@ -20,6 +20,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] # Actual dependencies + # TODO: The options override in Augury::CLI doesn't work in Thor 1.1+ spec.add_dependency 'thor', '~>1.0.0' spec.add_dependency 'twitter', '~>7.0' ## For the word_wrap function diff --git a/lib/augury/cli.rb b/lib/augury/cli.rb index 64e84a7..ae1a3bc 100644 --- a/lib/augury/cli.rb +++ b/lib/augury/cli.rb @@ -74,6 +74,7 @@ def generate(username, *path) private + # TODO: This override doesn't work in Thor 1.1+ def options original_options = super defaults = Thor::CoreExt::HashWithIndifferentAccess.new( From a395a395b4c9af21a444d5b319b5baf64d3eed1b Mon Sep 17 00:00:00 2001 From: Clayton Parker Date: Fri, 21 Oct 2022 17:14:16 -0400 Subject: [PATCH 4/6] update to latest rubocop supported by code climate --- .codeclimate.yml | 2 +- .rubocop.yml | 3 ++- Gemfile | 3 ++- Gemfile.lock | 25 ++++++++++++------------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 922df55..8fac1a2 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -4,7 +4,7 @@ plugins: enabled: true rubocop: enabled: true - channel: rubocop-0-92 + channel: rubocop-1-31-0 markdownlint: enabled: true bundler-audit: diff --git a/.rubocop.yml b/.rubocop.yml index 8b1a83e..2db6241 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,6 +3,7 @@ AllCops: Exclude: - bin/**/* - vendor/**/* + NewCops: enable Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma @@ -42,4 +43,4 @@ Layout/CaseIndentation: # Ignore for rspec Metrics/BlockLength: - ExcludedMethods: ['describe', 'context'] + IgnoredMethods: ['describe', 'context'] diff --git a/Gemfile b/Gemfile index d0c907a..2e0c652 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,8 @@ gem 'pry-doc' # Linting / completion gem 'bundler-audit' -gem 'rubocop', '0.92' +# This has to match the code climate channel in .codeclimate.yml +gem 'rubocop', '1.31.0' gem 'rubocop-rake' gem 'rubocop-rspec' gem 'solargraph' diff --git a/Gemfile.lock b/Gemfile.lock index a029d15..da19a9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,22 +96,21 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.1) - rubocop (0.92.0) + rubocop (1.31.0) parallel (~> 1.10) - parser (>= 2.7.1.5) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) - rexml - rubocop-ast (>= 0.5.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.18.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) + unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.23.0) parser (>= 3.1.1.0) - rubocop-rake (0.5.1) - rubocop - rubocop-rspec (1.44.1) - rubocop (~> 0.87) - rubocop-ast (>= 0.7.1) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.12.1) + rubocop (~> 1.31) ruby-progressbar (1.11.0) simple_oauth (0.3.1) simplecov (0.17.1) @@ -151,7 +150,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.8.2) - unicode-display_width (1.8.0) + unicode-display_width (2.3.0) vcr (6.1.0) webmock (3.18.1) addressable (>= 2.8.0) @@ -174,7 +173,7 @@ DEPENDENCIES pry-doc rake rspec (~> 3.0) - rubocop (= 0.92) + rubocop (= 1.31.0) rubocop-rake rubocop-rspec simplecov (< 0.18) From 64e6a1973708da2f2bab28960b9de29a442bfd65 Mon Sep 17 00:00:00 2001 From: Clayton Parker Date: Wed, 26 Oct 2022 10:34:49 -0400 Subject: [PATCH 5/6] fix up rubocop issues --- .rubocop.yml | 12 ++++++++++++ augury.gemspec | 1 + exe/augury | 2 ++ lib/augury/fortune.rb | 2 +- spec/lib/augury/fortune_spec.rb | 8 ++++---- spec/lib/augury_spec.rb | 6 ------ 6 files changed, 20 insertions(+), 11 deletions(-) delete mode 100644 spec/lib/augury_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index 2db6241..35ab436 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -17,6 +17,9 @@ Style/TrailingCommaInArrayLiteral: Style/RedundantSelf: Enabled: false +Style/Documentation: + Enabled: false + Layout/IndentationWidth: Enabled: false @@ -41,6 +44,15 @@ Layout/CaseIndentation: EnforcedStyle: end IndentOneStep: true +Metrics/AbcSize: + Max: 25 + +Metrics/CyclomaticComplexity: + Max: 25 + +Metrics/MethodLength: + Max: 20 + # Ignore for rspec Metrics/BlockLength: IgnoredMethods: ['describe', 'context'] diff --git a/augury.gemspec b/augury.gemspec index 357e262..b68a408 100644 --- a/augury.gemspec +++ b/augury.gemspec @@ -25,4 +25,5 @@ Gem::Specification.new do |spec| spec.add_dependency 'twitter', '~>7.0' ## For the word_wrap function spec.add_dependency 'word_wrap', '~>1.0' + spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/exe/augury b/exe/augury index 7c59847..b8cd5fa 100755 --- a/exe/augury +++ b/exe/augury @@ -1,3 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require 'augury/cli' Augury::CLI.start diff --git a/lib/augury/fortune.rb b/lib/augury/fortune.rb index b17cdb4..7aa09eb 100644 --- a/lib/augury/fortune.rb +++ b/lib/augury/fortune.rb @@ -92,7 +92,7 @@ def twitter_setup def transforms all_transforms = [] - all_transforms << [/https?:\/\/[^\s]+/, ''] if @config[:remove_links] + all_transforms << [%r{https?://[^\s]+}, ''] if @config[:remove_links] return all_transforms unless @config[:apply_transforms] all_transforms.push(*@config.dig('transforms', @username) || []) diff --git a/spec/lib/augury/fortune_spec.rb b/spec/lib/augury/fortune_spec.rb index eef87eb..fbff0fd 100644 --- a/spec/lib/augury/fortune_spec.rb +++ b/spec/lib/augury/fortune_spec.rb @@ -14,10 +14,10 @@ let(:twitter_auth) do { twitter: { - 'consumer_key' => ENV['TWITTER_CONSUMER_KEY'], - 'consumer_secret' => ENV['TWITTER_CONSUMER_SECRET'], - 'access_token' => ENV['TWITTER_ACCESS_TOKEN'], - 'access_token_secret' => ENV['TWITTER_ACCESS_TOKEN_SECRET'], + 'consumer_key' => ENV.fetch('TWITTER_CONSUMER_KEY', nil), + 'consumer_secret' => ENV.fetch('TWITTER_CONSUMER_SECRET', nil), + 'access_token' => ENV.fetch('TWITTER_ACCESS_TOKEN', nil), + 'access_token_secret' => ENV.fetch('TWITTER_ACCESS_TOKEN_SECRET', nil), }, } end diff --git a/spec/lib/augury_spec.rb b/spec/lib/augury_spec.rb deleted file mode 100644 index b4d079a..0000000 --- a/spec/lib/augury_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Augury do -end From 2feb867ae60cdc3661f0e98f679a2352f8096262 Mon Sep 17 00:00:00 2001 From: Clayton Parker Date: Wed, 26 Oct 2022 10:38:22 -0400 Subject: [PATCH 6/6] new version --- CHANGELOG.md | 4 ++-- Gemfile.lock | 2 +- lib/augury/version.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0adf29..2833e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Changes -## x.x.x (xxxx-xx-xx) +## 1.2.0 (2022-10-26) -- Test against latest Ruby 3.1 +- Test against latest Ruby 3.1, minimum version 2.7 ## 1.1.2 (2022-04-12) diff --git a/Gemfile.lock b/Gemfile.lock index da19a9d..55e9871 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - augury (1.1.2) + augury (1.2.0) thor (~> 1.0.0) twitter (~> 7.0) word_wrap (~> 1.0) diff --git a/lib/augury/version.rb b/lib/augury/version.rb index e325d2b..eb50660 100644 --- a/lib/augury/version.rb +++ b/lib/augury/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Augury - VERSION = '1.1.2' + VERSION = '1.2.0' end