Skip to content

Commit a1a35ef

Browse files
authored
Merge pull request #4 from nullscreen/fix-ci
Fix CI and update gems
2 parents 46f5cdf + 26ad2b8 commit a1a35ef

File tree

20 files changed

+248
-100
lines changed

20 files changed

+248
-100
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: CI
3+
on:
4+
push:
5+
tags: ['v*']
6+
branches: [master]
7+
pull_request:
8+
branches: ['**']
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
ruby: [2.5, 2.6, 2.7, 3.0, jruby-9.2.19, truffleruby-21.1.0]
16+
bundler: [default]
17+
include:
18+
- ruby: '2.3'
19+
bundler: '1'
20+
- ruby: '2.4'
21+
bundler: '1'
22+
steps:
23+
- uses: actions/checkout@v2
24+
- uses: ruby/setup-ruby@v1
25+
with:
26+
ruby-version: ${{ matrix.ruby }}
27+
bundler: ${{ matrix.bundler }}
28+
bundler-cache: true
29+
- run: bundle exec rubocop
30+
if: matrix.ruby == '2.7'
31+
- run: bundle exec rspec --format doc
32+
- uses: codecov/codecov-action@v3
33+
if: matrix.ruby == '2.7'
34+
with:
35+
files: coverage/coverage.xml
36+
- run: bin/yardoc --fail-on-warning
37+
if: matrix.ruby == '2.7'
38+
- run: bin/check-version
39+
40+
release:
41+
needs: test
42+
if: startsWith(github.ref, 'refs/tags/v')
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
- uses: dawidd6/action-publish-gem@v1
47+
with:
48+
api_key: ${{secrets.RUBYGEMS_API_KEY}}

.rubocop.yml

Lines changed: 116 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,125 @@
11
---
2+
require:
3+
- rubocop-rspec
4+
25
AllCops:
36
TargetRubyVersion: 2.3
47

5-
Layout/EndAlignment:
6-
EnforcedStyleAlignWith: variable
8+
Gemspec/DeprecatedAttributeAssignment: { Enabled: true }
9+
Gemspec/RequireMFA: { Enabled: true }
10+
11+
Layout/ArgumentAlignment: { EnforcedStyle: with_fixed_indentation }
12+
Layout/CaseIndentation: { EnforcedStyle: end }
13+
Layout/EndAlignment: { EnforcedStyleAlignWith: start_of_line }
14+
Layout/FirstArgumentIndentation: { EnforcedStyle: consistent }
15+
Layout/FirstArrayElementIndentation: { EnforcedStyle: consistent }
16+
Layout/FirstHashElementIndentation: { EnforcedStyle: consistent }
17+
Layout/LineContinuationLeadingSpace: { Enabled: true }
18+
Layout/LineContinuationSpacing: { Enabled: true }
19+
Layout/LineEndStringConcatenationIndentation: { Enabled: true }
20+
Layout/LineLength: { Max: 120 }
21+
Layout/MultilineMethodCallIndentation: { EnforcedStyle: indented }
22+
Layout/ParameterAlignment: { EnforcedStyle: with_fixed_indentation }
23+
Layout/RescueEnsureAlignment: { Enabled: false }
24+
Layout/SpaceBeforeBrackets: { Enabled: true }
25+
26+
Lint/AmbiguousAssignment: { Enabled: true }
27+
Lint/AmbiguousOperatorPrecedence: { Enabled: true }
28+
Lint/AmbiguousRange: { Enabled: true }
29+
Lint/ConstantOverwrittenInRescue: { Enabled: true }
30+
Lint/DeprecatedConstants: { Enabled: true }
31+
Lint/DuplicateBranch: { Enabled: true }
32+
Lint/DuplicateRegexpCharacterClassElement: { Enabled: true }
33+
Lint/EmptyBlock: { Enabled: true }
34+
Lint/EmptyClass: { Enabled: true }
35+
Lint/EmptyInPattern: { Enabled: true }
36+
Lint/IncompatibleIoSelectWithFiberScheduler: { Enabled: true }
37+
Lint/LambdaWithoutLiteralBlock: { Enabled: true }
38+
Lint/NoReturnInBeginEndBlocks: { Enabled: true }
39+
Lint/NonAtomicFileOperation: { Enabled: true }
40+
Lint/NumberedParameterAssignment: { Enabled: true }
41+
Lint/OrAssignmentToConstant: { Enabled: true }
42+
Lint/RaiseException: { Enabled: true }
43+
Lint/RedundantDirGlobSort: { Enabled: true }
44+
Lint/RefinementImportMethods: { Enabled: true }
45+
Lint/RequireRangeParentheses: { Enabled: true }
46+
Lint/RequireRelativeSelfPath: { Enabled: true }
47+
Lint/StructNewOverride: { Enabled: true }
48+
Lint/SymbolConversion: { Enabled: true }
49+
Lint/ToEnumArguments: { Enabled: true }
50+
Lint/TripleQuotes: { Enabled: true }
51+
Lint/UnexpectedBlockArity: { Enabled: true }
52+
Lint/UnmodifiedReduceAccumulator: { Enabled: true }
53+
Lint/UselessRuby2Keywords: { Enabled: true }
754

8-
Layout/AlignParameters:
9-
EnforcedStyle: with_fixed_indentation
55+
RSpec/BeEq: { Enabled: true }
56+
RSpec/BeNil: { Enabled: true }
57+
RSpec/Capybara/SpecificMatcher: { Enabled: true }
58+
RSpec/ChangeByZero: { Enabled: true }
59+
RSpec/ExampleLength: { Enabled: false }
60+
RSpec/ExcessiveDocstringSpacing: { Enabled: true }
61+
RSpec/FactoryBot/SyntaxMethods: { Enabled: true }
62+
RSpec/FilePath: { Enabled: false }
63+
RSpec/IdenticalEqualityAssertion: { Enabled: true }
64+
RSpec/MessageSpies: { Enabled: false }
65+
RSpec/MultipleExpectations: { Enabled: false }
66+
RSpec/MultipleMemoizedHelpers: { Enabled: false }
67+
RSpec/NamedSubject: { Enabled: false }
68+
RSpec/Rails/AvoidSetupHook: { Enabled: true }
69+
RSpec/Rails/HaveHttpStatus: { Enabled: true }
70+
RSpec/SubjectDeclaration: { Enabled: true }
71+
RSpec/SubjectStub: { Enabled: false }
72+
RSpec/VerifiedDoubleReference: { Enabled: true }
1073

11-
Layout/IndentArray:
12-
EnforcedStyle: consistent
74+
Metrics/AbcSize: { Max: 40 }
75+
Metrics/BlockLength: { Enabled: false }
76+
Metrics/ClassLength: { Enabled: false }
77+
Metrics/CyclomaticComplexity: { Enabled: false }
78+
Metrics/MethodLength: { Max: 30 }
79+
Metrics/PerceivedComplexity: { Enabled: false }
1380

14-
Layout/IndentHash:
15-
EnforcedStyle: consistent
81+
Naming/BlockForwarding: { Enabled: true }
82+
Naming/MethodParameterName: { MinNameLength: 1 }
1683

17-
Layout/MultilineMethodCallIndentation:
18-
EnforcedStyle: indented
84+
Security/CompoundHash: { Enabled: true }
85+
Security/IoMethods: { Enabled: true }
1986

20-
Lint/MissingCopEnableDirective:
21-
Enabled: false
87+
Style/ArgumentsForwarding: { Enabled: true }
88+
Style/CollectionCompact: { Enabled: true }
89+
Style/DocumentDynamicEvalDefinition: { Enabled: false }
90+
Style/Documentation: { Enabled: false }
91+
Style/EmptyHeredoc: { Enabled: true }
92+
Style/EmptyMethod: { EnforcedStyle: expanded }
93+
Style/EndlessMethod: { Enabled: true }
94+
Style/ExplicitBlockArgument: { Enabled: false }
95+
Style/EnvHome: { Enabled: true }
96+
Style/FetchEnvVar: { Enabled: true }
97+
Style/FileRead: { Enabled: true }
98+
Style/FileWrite: { Enabled: true }
99+
Style/FrozenStringLiteralComment: { Enabled: true, EnforcedStyle: always }
100+
Style/GuardClause: { Enabled: false }
101+
Style/HashConversion: { Enabled: true }
102+
Style/HashEachMethods: { Enabled: true }
103+
Style/HashExcept: { Enabled: true }
104+
Style/HashTransformKeys: { Enabled: false }
105+
Style/HashTransformValues: { Enabled: false }
106+
Style/IfUnlessModifier: { Enabled: false }
107+
Style/IfWithBooleanLiteralBranches: { Enabled: true }
108+
Style/InPatternThen: { Enabled: true }
109+
Style/MapCompactWithConditionalBlock: { Enabled: true }
110+
Style/MapToHash: { Enabled: true }
111+
Style/MultilineInPatternThen: { Enabled: true }
112+
Style/NegatedIfElseCondition: { Enabled: true }
113+
Style/NestedFileDirname: { Enabled: true }
114+
Style/NilLambda: { Enabled: true }
115+
Style/NumberedParameters: { Enabled: true }
116+
Style/NumberedParametersLimit: { Enabled: true }
117+
Style/ObjectThen: { Enabled: true }
118+
Style/OpenStructUse: { Enabled: false }
119+
Style/QuotedSymbols: { Enabled: true }
120+
Style/RedundantArgument: { Enabled: true }
121+
Style/RedundantInitialize: { Enabled: true }
122+
Style/RedundantSelfAssignmentBranch: { Enabled: true }
123+
Style/SelectByRegexp: { Enabled: true }
124+
Style/StringChars: { Enabled: true }
125+
Style/SwapValues: { Enabled: true }

.travis.yml

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

.yamllint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
rules:
3+
braces:
4+
min-spaces-inside: 1
5+
max-spaces-inside: 1
6+

Gemfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
# frozen_string_literal: true
22

33
source 'https://rubygems.org'
4+
45
gemspec
6+
7+
not_jruby = %i[ruby mingw x64_mingw].freeze
8+
9+
gem 'byebug', platforms: not_jruby
10+
gem 'redcarpet', '~> 3.5', platforms: not_jruby
11+
gem 'yard', '~> 0.9.25', platforms: not_jruby
12+
13+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
14+
gem 'rubocop', '~> 1.32.0'
15+
gem 'rubocop-rspec', '~> 2.12'
16+
gem 'simplecov', '>= 0.17.1'
17+
gem 'simplecov-cobertura', '~> 2.1'
18+
end

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ After checking out the repo, run `bundle` to install dependencies. You
137137
can also run `bin/console` for an interactive prompt that will allow you to
138138
experiment.
139139

140-
To check your work, run `bin/rake` to check code style and run the tests. To
141-
generate a code coverage report, set the `COVERAGE` environment variable when
142-
running the tests.
140+
To check your work, run `bin/rspec` run the tests and `bin/rubocop` to check
141+
style. To generate a code coverage report, set the `COVERAGE` environment
142+
variable when running the tests.
143143

144144
```sh
145-
COVERAGE=1 bin/rake
145+
COVERAGE=1 bin/rspec
146+
bin/rubocop
146147
```
147148

148149
## Contributing

Rakefile

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

bin/check-version

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/usr/bin/env sh
22

3-
tag="$(git describe --abbrev=0)"
3+
set -e
4+
5+
tag="$(git describe --abbrev=0 2>/dev/null || echo)"
6+
echo "Tag: ${tag}"
47
tag="${tag#v}"
5-
gt=$(ruby -r ./lib/uncsv/version -e "puts Gem::Version.new(Uncsv::VERSION) >= Gem::Version.new('${tag}')")
6-
test "$gt" = true
8+
echo "Git Version: ${tag}"
9+
[ "$tag" = '' ] && exit 0
10+
gem_version="$(ruby -r ./lib/uncsv/version -e "puts Uncsv.version" | tail -n1)"
11+
echo "Gem Version: ${gem_version}"
12+
13+
tag_gt_version="$(ruby -r ./lib/uncsv/version -e "puts Uncsv.version >= Gem::Version.new('${tag}')" | tail -n1)"
14+
test "$tag_gt_version" = true

bin/console

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# frozen_string_literal: true
33

44
require 'bundler/setup'
5+
require 'byebug'
56
require 'uncsv'
67

78
# You can add fixtures and/or initialization code here to make experimenting

lib/uncsv.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ class Uncsv
2828
def initialize(data, opts = {})
2929
@config = Config.new(opts)
3030
yield @config if block_given?
31-
@csv = CSV.new(data, @config.csv_opts)
31+
@csv = if CSV.method(:new).arity == 2
32+
CSV.new(data, @config.csv_opts)
33+
else
34+
CSV.new(data, **@config.csv_opts)
35+
end
3236
end
3337

3438
# Create a new `Uncsv` parser from a file

0 commit comments

Comments
 (0)