Skip to content

Commit b1c05b1

Browse files
ggilderNecroRuby
andauthored
NecroRuby: Modernize commander (#104)
* NecroRuby: modernize commander for the current Ruby ecosystem * NecroRuby: apply reviewer feedback on PR #103 * NecroRuby: apply reviewer feedback on PR #103 * Remove re-added AI bot files * Add deprecated constant SortedSet * Relax simplecov requirement to work with Ruby 3.1 * Fix test for JRuby * Fix simplecov settings for Ruby 3.1/JRuby --------- Co-authored-by: NecroRuby <necro-ruby@users.noreply.github.com>
1 parent 98dee54 commit b1c05b1

31 files changed

Lines changed: 709 additions & 272 deletions

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Ruby ${{ matrix.ruby }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
ruby:
20+
- '3.1'
21+
- '3.2'
22+
- '3.3'
23+
- '3.4'
24+
- '4.0.6'
25+
- jruby
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Set up Ruby
31+
uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: ${{ matrix.ruby }}
34+
bundler-cache: true
35+
36+
- name: Run tests
37+
run: bundle exec rake spec
38+
39+
lint:
40+
name: RuboCop
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Set up Ruby
46+
uses: ruby/setup-ruby@v1
47+
with:
48+
ruby-version: '4.0.6'
49+
bundler-cache: true
50+
51+
- name: Run RuboCop
52+
run: bundle exec rubocop
53+
54+
security:
55+
name: Bundler Audit
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Ruby
61+
uses: ruby/setup-ruby@v1
62+
with:
63+
ruby-version: '4.0.6'
64+
bundler-cache: true
65+
66+
- name: Run bundler-audit
67+
run: bundle exec bundler-audit check --update

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
Gemfile.lock
44
pkg/*
55
.rvmrc
6-
.ruby-version
76
coverage/*

.rubocop.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4-
TargetRubyVersion: 3.0
4+
TargetRubyVersion: 3.1
55
NewCops: enable
66
SuggestExtensions: false
77

@@ -54,9 +54,6 @@ Style/FormatStringToken:
5454
Style/MixinUsage:
5555
Enabled: false
5656

57-
Lint/ErbNewArguments:
58-
Enabled: false
59-
6057
Style/DocumentDynamicEvalDefinition:
6158
Enabled: false
6259

.rubocop_todo.yml

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,81 @@
1-
# This configuration was generated by `rubocop --auto-gen-config`
2-
# on 2015-02-16 16:08:54 -0800 using RuboCop version 0.29.0.
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
3+
# using RuboCop version 1.88.2.
34
# The point is for the user to remove these configuration records
45
# one by one as the offenses are removed from the code base.
56
# Note that changes in the inspected code, or installation of new
67
# versions of RuboCop, may require this file to be generated again.
78

8-
# Offense count: 2
9-
Security/Eval:
10-
Enabled: false
11-
12-
# Offense count: 2
9+
# Offense count: 1
10+
# Configuration parameters: AllowComments, AllowNil.
1311
Lint/SuppressedException:
14-
Enabled: false
12+
Exclude:
13+
- 'lib/commander/user_interaction.rb'
1514

16-
# Offense count: 5
15+
# Offense count: 6
16+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
1717
Metrics/AbcSize:
1818
Max: 30
1919

2020
# Offense count: 1
21-
# Configuration parameters: CountComments.
21+
# Configuration parameters: CountComments, CountAsOne.
2222
Metrics/ClassLength:
23-
Enabled: false
23+
Max: 250
2424

25-
# Offense count: 4
25+
# Offense count: 5
26+
# Configuration parameters: AllowedMethods, AllowedPatterns.
2627
Metrics/CyclomaticComplexity:
2728
Max: 13
2829

29-
# Offense count: 89
30-
# Configuration parameters: AllowURI, URISchemes.
31-
Layout/LineLength:
32-
Max: 242
33-
34-
# Offense count: 7
35-
# Configuration parameters: CountComments.
30+
# Offense count: 8
31+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
3632
Metrics/MethodLength:
3733
Max: 36
3834

39-
# Offense count: 4
35+
# Offense count: 5
36+
# Configuration parameters: AllowedMethods, AllowedPatterns.
4037
Metrics/PerceivedComplexity:
4138
Max: 14
4239

43-
# Offense count: 1
40+
# Offense count: 2
4441
Naming/AccessorMethodName:
45-
Enabled: false
46-
47-
# Offense count: 18
48-
Style/Documentation:
49-
Enabled: false
50-
51-
# Offense count: 12
52-
# Configuration parameters: AllowedVariables.
53-
Style/GlobalVars:
54-
Enabled: false
42+
Exclude:
43+
- 'lib/commander/core_ext/object.rb'
44+
- 'lib/commander/help_formatters.rb'
5545

5646
# Offense count: 1
57-
# Configuration parameters: MaxLineLength.
47+
Security/Eval:
48+
Exclude:
49+
- 'lib/commander/delegates.rb'
50+
51+
# Offense count: 2
52+
# This cop supports safe autocorrection (--autocorrect).
5853
Style/IfUnlessModifier:
59-
Enabled: false
54+
Exclude:
55+
- 'lib/commander/runner.rb'
56+
- 'lib/commander/user_interaction.rb'
6057

6158
# Offense count: 1
6259
Style/MultilineBlockChain:
63-
Enabled: false
60+
Exclude:
61+
- 'lib/commander/user_interaction.rb'
6462

6563
# Offense count: 1
64+
# This cop supports safe autocorrection (--autocorrect).
6665
Style/MultilineTernaryOperator:
67-
Enabled: false
66+
Exclude:
67+
- 'lib/commander/user_interaction.rb'
6868

69-
# Offense count: 5
69+
# Offense count: 4
70+
# This cop supports safe autocorrection (--autocorrect).
7071
Style/RescueModifier:
71-
Enabled: false
72+
Exclude:
73+
- 'lib/commander/runner.rb'
74+
- 'lib/commander/user_interaction.rb'
7275

73-
# Offense count: 2
74-
# Cop supports --auto-correct.
75-
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
76-
Style/TrivialAccessors:
77-
Enabled: false
76+
# Offense count: 5
77+
# This cop supports safe autocorrection (--autocorrect).
78+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
79+
# URISchemes: http, https
80+
Layout/LineLength:
81+
Max: 242

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0.6

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33
source 'https://rubygems.org'
44

55
gemspec
6+
7+
group :development, :test do
8+
gem 'bundler-audit', '~> 0.9'
9+
gem 'rake', '~> 13.0'
10+
gem 'rspec', '~> 3.13'
11+
gem 'rubocop', '~> 1.88'
12+
# 1.x requires Ruby >= 3.2; allow the last 0.x on Ruby 3.1 while newer
13+
# rubies still resolve to 1.x.
14+
gem 'simplecov', '>= 0.22', '< 2'
15+
end

Manifest

Lines changed: 0 additions & 38 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
[<img src="https://api.travis-ci.org/commander-rb/commander.svg" alt="Build Status" />](https://travis-ci.org/commander-rb/commander)
2-
[![Inline docs](https://inch-ci.org/github/commander-rb/commander.svg)](https://inch-ci.org/github/commander-rb/commander)
1+
[![CI](https://github.com/commander-rb/commander/actions/workflows/ci.yml/badge.svg)](https://github.com/commander-rb/commander/actions/workflows/ci.yml)
32

43
# Commander
54

@@ -24,9 +23,12 @@ features, and an elegant API.
2423
* Sexy paging for long bodies of text
2524
* Support for MacOS text-to-speech
2625
* Command aliasing (very powerful, as both switches and arguments can be used)
27-
* Growl notification support for MacOS
2826
* Use the `commander` executable to initialize a commander driven program
2927

28+
## Requirements
29+
30+
Ruby >= 3.1 (tested through Ruby 4.0).
31+
3032
## Installation
3133

3234
$ gem install commander
@@ -50,7 +52,6 @@ as well as an object, specifying a method to call, so view the RDoc for more inf
5052
### Classic style
5153

5254
```ruby
53-
require 'rubygems'
5455
require 'commander/import'
5556

5657
# :name is optional, otherwise uses the basename of this executable
@@ -93,7 +94,6 @@ $ foobar bar --suffix '}' --prefix '{'
9394
**NOTE:** Make sure to use `require 'commander'` rather than `require 'commander/import'`, otherwise Commander methods will still be imported into the global namespace.
9495

9596
```ruby
96-
require 'rubygems'
9797
require 'commander'
9898

9999
class MyApplication
@@ -122,7 +122,6 @@ MyApplication.new.run if $0 == __FILE__
122122
### Block style
123123

124124
```ruby
125-
require 'rubygems'
126125
require 'commander'
127126

128127
Commander.configure do
@@ -240,30 +239,6 @@ else
240239
end
241240
```
242241

243-
## Growl Notifications
244-
245-
Commander provides methods for displaying Growl notifications. To use these
246-
methods you need to install https://github.com/tj/growl which utilizes
247-
the [growlnotify](https://growl.info/extras.php#growlnotify) executable. Note that
248-
growl is auto-imported by Commander when available, no need to require.
249-
250-
```ruby
251-
# Display a generic Growl notification
252-
notify 'Something happened'
253-
254-
# Display an 'info' status notification
255-
notify_info 'You have #{emails.length} new email(s)'
256-
257-
# Display an 'ok' status notification
258-
notify_ok 'Gems updated'
259-
260-
# Display a 'warning' status notification
261-
notify_warning '1 gem failed installation'
262-
263-
# Display an 'error' status notification
264-
notify_error "Gem #{name} failed"
265-
```
266-
267242
## Commander Goodies
268243

269244
### Option Defaults
@@ -459,11 +434,11 @@ For feature rich ASCII tables for your terminal app check out the terminal-table
459434

460435
## Running Specifications
461436

462-
$ rake spec
437+
$ bundle exec rake spec
463438

464439
OR
465440

466-
$ spec --color spec
441+
$ bundle exec rspec
467442

468443
## Contrib
469444

commander.gemspec

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ Gem::Specification.new do |s|
1818
'documentation_uri' => "https://www.rubydoc.info/gems/commander/#{s.version}",
1919
'homepage_uri' => s.homepage,
2020
'source_code_uri' => "#{s.homepage}/tree/v#{s.version}",
21+
'rubygems_mfa_required' => 'true',
2122
}
22-
s.required_ruby_version = '>= 3.0'
23+
s.required_ruby_version = '>= 3.1'
2324

2425
s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|spec|features)/}) }
25-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
2626
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
2727
s.require_paths = ['lib']
2828

29-
s.add_runtime_dependency('highline', '~> 3.0.0')
30-
31-
s.add_development_dependency('rake')
32-
s.add_development_dependency('rspec', '~> 3.2')
33-
s.add_development_dependency('rubocop', '~> 1.12.1')
34-
s.add_development_dependency('simplecov')
29+
s.add_dependency('highline', '~> 3.1')
3530
end

0 commit comments

Comments
 (0)