Skip to content

Commit cb79668

Browse files
committed
Support for ruby-3.x
- remove calls to File.exists? - use standardrb - use simplecov always - add github action
1 parent bd87706 commit cb79668

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

.github/workflows/tests.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Run Tests
2+
3+
on: push
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
name: Ruby ${{ matrix.ruby }}
9+
strategy:
10+
matrix:
11+
ruby: [2.7, 3.0, 3.1, 3.2]
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Ruby
15+
uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: ${{ matrix.ruby }}
18+
bundler-cache: true
19+
- name: Run linter for Ruby
20+
run: bundle exec standardrb
21+
- name: Run tests
22+
run: bundle exec rspec
23+
- name: Report to Coveralls
24+
uses: coverallsapp/[email protected]
25+
with:
26+
github-token: ${{ secrets.github_token }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ doc
1010

1111
# bundler
1212
.bundle
13+
vendor/
1314

1415
# jeweler generated
1516
pkg

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ source "https://rubygems.org"
44
gemspec
55

66

7-
gem 'rcov', :platform => :mri_18
8-
gem 'simplecov', :platforms => [:mri_19, :mri_20]
9-
gem 'simplecov-rcov', :platforms => [:mri_19, :mri_20]
7+
group :development, :test do
8+
gem 'simplecov'
9+
gem 'standardrb'
10+
gem "simplecov-lcov"
11+
end

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![Tests](https://github.com/mlibrary/pairtree/actions/workflows/tests.yaml/badge.svg)](https://github.com/mlibrary/pairtree/actions/workflows/tests.yaml)
2+
[![Coverage Status](https://coveralls.io/repos/github/mlibrary/pairtree/badge.svg?branch=main)](https://coveralls.io/github/mlibrary/pairtree?branch=main)
3+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
4+
15
# (r)pairtree
26

37
Ruby implementation of the [Pairtree](https://wiki.ucop.edu/display/Curation/PairTree) specification from the California Digital Library.

lib/pairtree.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def self.at path, args = {}
3030
existing_version_file = Dir[File.join(path, "pairtree_version*")].sort.last
3131

3232
if args.delete(:create)
33-
if File.exists?(path) and not File.directory?(path)
33+
if File.exist?(path) and not File.directory?(path)
3434
raise PathError, "#{path} exists, but is not a valid pairtree root"
3535
end
3636
FileUtils.mkdir_p(root_path)
3737

38-
unless File.exists? prefix_file
38+
unless File.exist? prefix_file
3939
File.open(prefix_file, 'w') { |f| f.write(args[:prefix].to_s) }
4040
end
4141

spec/spec_helper.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
require 'bundler/setup'
55
require 'rspec'
66

7-
if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
8-
require 'simplecov'
9-
SimpleCov.start
7+
require 'simplecov'
8+
require 'simplecov-lcov'
9+
SimpleCov::Formatter::LcovFormatter.config do |c|
10+
c.report_with_single_file = true
11+
c.single_report_path = "coverage/lcov.info"
1012
end
13+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
14+
SimpleCov::Formatter::HTMLFormatter,
15+
SimpleCov::Formatter::LcovFormatter
16+
])
17+
SimpleCov.start
1118

1219
require 'pairtree'
1320

0 commit comments

Comments
 (0)