Skip to content

Commit

Permalink
Support Ruby 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv committed Feb 14, 2024
1 parent ac7fb93 commit dcbc712
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 92 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@ on:
push:
branches:
- main

pull_request:
schedule:
- cron: 0 0 * * 1 # At 00:00 on Monday

jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby:
- '3.3.0'

ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4"]
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake
rubygems: latest

- name: Run tests
run: bundle exec rake test

- name: Run linter
run: bundle exec rake standard
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/pkg/
/spec/reports/
/tmp/
Gemfile.lock

# Mac OS files
.DS_Store
4 changes: 3 additions & 1 deletion .standard.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# For available configuration options, see:
# https://github.com/standardrb/standard
ruby_version: 3.0
ruby_version: 3.3
format: progress
parallel: true
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source "https://rubygems.org"
# Specify your gem's dependencies in phlex-slotable.gemspec
gemspec

gem "rake", "~> 13.0"
gem "minitest", "~> 5.16"
gem "standard", "~> 1.3"
gem "benchmark-ips"
gem "benchmark-ips", "2.13.0"
gem "minitest", "5.22.2"
gem "rake", "13.1.0"
gem "standard", "1.34.0"
77 changes: 0 additions & 77 deletions Gemfile.lock

This file was deleted.

1 change: 1 addition & 0 deletions benchmark/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ def template
Benchmark.ips do |x|
x.report("Deferred") { DeferredListExample.new.call }
x.report("Slotable") { SlotableListExample.new.call }
x.compare!
end
12 changes: 9 additions & 3 deletions lib/phlex/slotable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def #{slot_name}_slots
RUBY
else
<<-RUBY
def #{slot_name}_slot = @#{slot_name}_slot
def #{slot_name}_slot
@#{slot_name}_slot
end
private :#{slot_name}_slot
RUBY
end
Expand All @@ -73,12 +75,16 @@ def #{slot_name}_slot = @#{slot_name}_slot
def define_predicate_method(slot_name, many:)
predicate_method = if many
<<-RUBY
def #{slot_name}_slots? = #{slot_name}_slots.any?
def #{slot_name}_slots?
#{slot_name}_slots.any?
end
private :#{slot_name}_slots?
RUBY
else
<<-RUBY
def #{slot_name}_slot? = !#{slot_name}_slot.nil?
def #{slot_name}_slot?
!#{slot_name}_slot.nil?
end
private :#{slot_name}_slot?
RUBY
end
Expand Down

0 comments on commit dcbc712

Please sign in to comment.