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/.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..35ab436 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,9 @@ AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.7 Exclude: - bin/**/* - vendor/**/* + NewCops: enable Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma @@ -16,6 +17,9 @@ Style/TrailingCommaInArrayLiteral: Style/RedundantSelf: Enabled: false +Style/Documentation: + Enabled: false + Layout/IndentationWidth: Enabled: false @@ -40,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: - ExcludedMethods: ['describe', 'context'] + IgnoredMethods: ['describe', 'context'] 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..2833e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changes +## 1.2.0 (2022-10-26) + +- Test against latest Ruby 3.1, minimum version 2.7 + ## 1.1.2 (2022-04-12) - Fix issue with mismatched case for Twitter screen_name. (#22) 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 1d95703..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) @@ -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,29 +89,28 @@ 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) - rubocop (0.92.0) + rspec-support (3.11.1) + 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) - rubocop-ast (1.17.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) @@ -119,7 +118,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 +135,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 +149,16 @@ GEM simple_oauth (~> 0.3.0) unf (0.1.4) unf_ext - unf_ext (0.0.8.1) - unicode-display_width (1.8.0) + unf_ext (0.0.8.2) + unicode-display_width (2.3.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 @@ -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) @@ -183,4 +182,4 @@ DEPENDENCIES webmock BUNDLED WITH - 2.1.4 + 2.3.24 diff --git a/augury.gemspec b/augury.gemspec index a7aa3b9..b68a408 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' @@ -20,8 +20,10 @@ 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 spec.add_dependency 'word_wrap', '~>1.0' + spec.metadata['rubygems_mfa_required'] = 'true' end 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"' 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/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( 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/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 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