Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Test
name: CI

on:
push:

jobs:
rspec:
test:
runs-on: ubuntu-latest

strategy:
Expand All @@ -23,3 +23,17 @@ jobs:
bundler-cache: true

- run: bundle exec rake test

steep:
name: Type check (Steep)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.4'
bundler-cache: true

- run: bundle exec steep check
5 changes: 5 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target :lib do
signature "sig"

check "lib"
end
3 changes: 2 additions & 1 deletion lib/predicateable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def predicate(name, values, prefix: false, strict: false)
method = prefix ? "#{name}_#{value}?" : "#{value}?"

define_method(method) do
actual = send(name)
# @type self: Object
actual = public_send(name)

if strict
actual == value
Expand Down
2 changes: 2 additions & 0 deletions predicateable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "minitest", "~> 5.22"
spec.add_development_dependency "rbs", "~> 3.9"
spec.add_development_dependency "steep", "~> 1.10"
end
12 changes: 10 additions & 2 deletions sig/predicateable.rbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
module Predicateable
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
def self.included: (Module base) -> void

module ClassMethods : Module
def predicate: (
Symbol | String name,
Array[Symbol | String] values,
?prefix: bool,
?strict: bool
) -> Array[Symbol | String]
end
end
3 changes: 3 additions & 0 deletions sig/predicateable/version.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Predicateable
VERSION: String
end