-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mlibrary/ruby-3.x
Support for ruby 3.x; use standardrb
- Loading branch information
Showing
18 changed files
with
282 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Run Tests | ||
|
||
on: push | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: Ruby ${{ matrix.ruby }} | ||
strategy: | ||
matrix: | ||
ruby: [2.7, 3.0, 3.1, 3.2] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true | ||
- name: Run linter for Ruby | ||
run: bundle exec standardrb | ||
- name: Run tests | ||
run: bundle exec rspec | ||
- name: Report to Coveralls | ||
uses: coverallsapp/[email protected] | ||
with: | ||
github-token: ${{ secrets.github_token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ doc | |
|
||
# bundler | ||
.bundle | ||
vendor/ | ||
|
||
# jeweler generated | ||
pkg | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,44 @@ | ||
require 'rubygems' | ||
require 'bundler' | ||
require "rubygems" | ||
require "bundler" | ||
begin | ||
Bundler.setup(:default, :development) | ||
rescue Bundler::BundlerError => e | ||
$stderr.puts e.message | ||
$stderr.puts "Run `bundle install` to install missing gems" | ||
warn e.message | ||
warn "Run `bundle install` to install missing gems" | ||
exit e.status_code | ||
end | ||
|
||
Bundler::GemHelper.install_tasks | ||
|
||
require 'rake' | ||
require 'rspec' | ||
require 'rspec/core/rake_task' | ||
require "rake" | ||
require "rspec" | ||
require "rspec/core/rake_task" | ||
|
||
desc 'Default: run specs.' | ||
task :default => :spec | ||
desc "Default: run specs." | ||
task default: :spec | ||
|
||
RSpec::Core::RakeTask.new do |t| | ||
if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.8/ | ||
if ENV["COVERAGE"] && RUBY_VERSION =~ (/^1.8/) | ||
t.rcov = true | ||
t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems'] | ||
t.rcov_opts = ["--exclude", "spec", "--exclude", "gems"] | ||
end | ||
end | ||
|
||
# Use yard to build docs | ||
begin | ||
require 'yard' | ||
require 'yard/rake/yardoc_task' | ||
project_root = File.expand_path(File.dirname(__FILE__)) | ||
doc_destination = File.join(project_root, 'doc') | ||
require "yard" | ||
require "yard/rake/yardoc_task" | ||
project_root = __dir__ | ||
doc_destination = File.join(project_root, "doc") | ||
|
||
YARD::Rake::YardocTask.new(:doc) do |yt| | ||
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) + | ||
[ File.join(project_root, 'README.md') ] | ||
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md'] | ||
yt.files = Dir.glob(File.join(project_root, "lib", "**", "*.rb")) + | ||
[File.join(project_root, "README.md")] | ||
yt.options = ["--output-dir", doc_destination, "--readme", "README.md"] | ||
end | ||
rescue LoadError | ||
desc "Generate YARD Documentation" | ||
task :doc do | ||
abort "Please install the YARD gem to generate rdoc." | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,51 @@ | ||
module Pairtree | ||
module Pairtree | ||
class Obj < ::Dir | ||
|
||
FILE_METHODS = [:atime, :open, :read, :file?, :directory?, :exist?, :exists?, :file?, :ftype, :lstat, | ||
FILE_METHODS = [:atime, :open, :read, :file?, :directory?, :exist?, :exists?, :file?, :ftype, :lstat, | ||
:mtime, :readable?, :size, :stat, :truncate, :writable?, :zero?] | ||
FILE_METHODS.each do |file_method| | ||
define_method file_method do |fname,*args,&block| | ||
File.send(file_method, File.join(self.path, fname), *args, &block) | ||
define_method file_method do |fname, *args, &block| | ||
File.send(file_method, File.join(path, fname), *args, &block) | ||
end | ||
end | ||
|
||
def delete *args | ||
File.delete(*(prepend_filenames(args))) | ||
File.delete(*prepend_filenames(args)) | ||
end | ||
alias_method :unlink, :delete | ||
|
||
def link *args | ||
File.link(*(prepend_filenames(args))) | ||
File.link(*prepend_filenames(args)) | ||
end | ||
|
||
def rename *args | ||
File.rename(*(prepend_filenames(args))) | ||
File.rename(*prepend_filenames(args)) | ||
end | ||
|
||
def utime atime, mtime, *args | ||
File.utime(atime, mtime, *(prepend_filenames(args))) | ||
File.utime(atime, mtime, *prepend_filenames(args)) | ||
end | ||
|
||
def entries | ||
super - ['.','..'] | ||
super - [".", ".."] | ||
end | ||
|
||
def each &block | ||
super { |entry| yield(entry) unless entry =~ /^\.{1,2}$/ } | ||
super { |entry| yield(entry) unless /^\.{1,2}$/.match?(entry) } | ||
end | ||
|
||
def glob(string, flags = 0) | ||
result = Dir.glob(File.join(self.path, string), flags) - ['.','..'] | ||
result.collect { |f| f.sub(%r{^#{self.path}/},'') } | ||
result = Dir.glob(File.join(path, string), flags) - [".", ".."] | ||
result.collect { |f| f.sub(%r{^#{path}/}, "") } | ||
end | ||
|
||
def [](string) | ||
glob(string, 0) | ||
end | ||
|
||
private | ||
|
||
def prepend_filenames(files) | ||
files.collect { |fname| File.join(self.path, fname) } | ||
files.collect { |fname| File.join(path, fname) } | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.