Skip to content

Commit d68157d

Browse files
Add helper methods, basic tests, usage examples, and rubocop linting rules. Lint/format all code. Update minimum ruby version and versions used for testing to current supported version list. Update and add missing dependencies for upcoming ruby changes. Update ca_certs.pem. (#42)
1 parent 8738f80 commit d68157d

26 files changed

Lines changed: 5577 additions & 535 deletions

.github/workflows/ruby-ci.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,32 @@ on:
88
- master
99

1010
jobs:
11+
ruby-ci-lint:
12+
name: Ruby CI - lint
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
ruby-version: [3.1]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Ruby ${{ matrix.ruby-version }}
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby-version }}
25+
- name: Install dependencies
26+
run: bundle install
27+
- name: Lint
28+
run: rake lint
29+
1130
ruby-ci:
1231
name: Ruby CI - test
1332
runs-on: ubuntu-latest
1433

1534
strategy:
1635
matrix:
17-
ruby-version: [3.0, 3.1, 3.2]
36+
ruby-version: [3.0, 3.1, 3.2, 3.3, 3.4]
1837

1938
steps:
2039
- uses: actions/checkout@v4
@@ -25,4 +44,4 @@ jobs:
2544
- name: Install dependencies
2645
run: bundle install
2746
- name: Test
28-
run: rake
47+
run: rake test

.rubocop.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
##
2+
# AllCops (Global)
3+
#
4+
AllCops:
5+
NewCops: enable
6+
SuggestExtensions: false
7+
Exclude:
8+
- vendor/**/*
9+
10+
##
11+
# Layout
12+
#
13+
Layout/FirstHashElementIndentation:
14+
EnforcedStyle: consistent
15+
16+
Layout/HashAlignment:
17+
EnforcedLastArgumentHashStyle: ignore_implicit
18+
19+
Layout/SpaceBeforeBlockBraces:
20+
EnforcedStyle: no_space
21+
22+
##
23+
# Metrics
24+
#
25+
Metrics/AbcSize:
26+
Max: 20
27+
CountRepeatedAttributes: false
28+
Exclude:
29+
- test/**/*
30+
AllowedMethods:
31+
- request
32+
- get_all
33+
34+
Metrics/BlockLength:
35+
Enabled: false
36+
37+
Metrics/ClassLength:
38+
Enabled: false
39+
40+
Metrics/CyclomaticComplexity:
41+
AllowedMethods:
42+
- get_all
43+
44+
Metrics/MethodLength:
45+
Enabled: false
46+
47+
Metrics/ParameterLists:
48+
Max: 6
49+
CountKeywordArgs: false
50+
51+
Metrics/PerceivedComplexity:
52+
Enabled: false
53+
54+
##
55+
# Naming
56+
#
57+
Naming/AccessorMethodName:
58+
Exclude:
59+
- lib/duo_api/*
60+
61+
##
62+
# Style
63+
#
64+
Style/NumericLiterals:
65+
Enabled: false
66+
67+
Style/Documentation:
68+
Exclude:
69+
- test/**/*
70+
71+
##
72+
# Gemspec
73+
#
74+
Gemspec/DevelopmentDependencies:
75+
EnforcedStyle: gemspec
76+
77+
Gemspec/RequireMFA:
78+
Enabled: false

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,22 @@
1212

1313
**Accounts** - https://www.duosecurity.com/docs/accountsapi
1414

15-
## Tested Against Ruby Versions:
16-
* 3.0
15+
# Compatibility
16+
While the gem should work for Ruby versions >= 2.5, tests and linting may only work properly on Ruby versions >= 3.0.
17+
18+
Tests are only run on currently supported Ruby versions.
19+
20+
### Tested Against Ruby Versions:
1721
* 3.1
1822
* 3.2
23+
* 3.3
24+
* 3.4
1925

20-
## TLS 1.2 and 1.3 Support
26+
### TLS 1.2 and 1.3 Support
2127

22-
Duo_api_ruby uses the Ruby openssl extension for TLS operations.
28+
duo_api_ruby uses the Ruby openssl extension for TLS operations.
2329

24-
All currently supported Ruby versions (2.7 and higher) support TLS 1.2 and 1.3.
30+
All Ruby versions compatible with this gem (2.5 and higher) support TLS 1.2 and 1.3.
2531

2632
# Installing
2733

@@ -45,27 +51,18 @@ gem 'duo_api', '~> 1.0'
4551
```
4652

4753
# Using
48-
49-
TODO
54+
- Examples of doing things [the hard way](/examples/the_hard_way.md)
55+
- Examples of doing things [the less hard way](/examples/the_less_hard_way.md)
56+
- Examples of doing things [the simple way](/examples/the_simple_way.md)
5057

5158
# Testing
52-
59+
###### (Testing and Linting can be done simultaneously by running `rake` without specifying a task)
5360
```
54-
$ rake
55-
Loaded suite /usr/lib/ruby/vendor_ruby/rake/rake_test_loader
56-
Started
57-
........
58-
59-
Finished in 0.002024715 seconds.
60-
--------------------------------------------------------------------------------------------------------
61-
8 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
62-
100% passed
63-
--------------------------------------------------------------------------------------------------------
64-
3951.17 tests/s, 4938.97 assertions/s
61+
rake test
6562
```
6663

6764
# Linting
68-
65+
###### (Testing and Linting can be done simultaneously by running `rake` without specifying a task)
6966
```
70-
$ rubocop
67+
rake lint
7168
```

Rakefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
# frozen_string_literal: true
2+
13
require 'rake/testtask'
4+
require 'rubocop/rake_task'
5+
6+
desc('Run tests & linting')
7+
task(default: %i[test lint])
28

3-
Rake::TestTask.new do |t|
4-
t.libs << 'test'
5-
end
9+
desc('Run tests')
10+
task(:test){ Rake::TestTask.new{ |t| t.libs << 'test' } }
611

7-
desc 'Run tests'
8-
task :default => :test
12+
desc('Run linting')
13+
task(lint: %i[rubocop])
14+
task(:rubocop){ RuboCop::RakeTask.new }

0 commit comments

Comments
 (0)