Skip to content

Commit

Permalink
Merge branch 'master' into swesterman/23-11-22/add-ops
Browse files Browse the repository at this point in the history
  • Loading branch information
sampersand authored Nov 22, 2023
2 parents de86470 + 77328dd commit f7443bd
Show file tree
Hide file tree
Showing 40 changed files with 1,115 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: |
echo "NO_MINITEST=true" >> $GITHUB_ENV
bundle config set --local without 'minitest'
if: "contains(matrix.container_tag, 'master-nightly')"
if: ${{ contains(matrix.container_tag, 'master-nightly') }}
- name: bin/setup
run: |
bin/setup
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Type check

on:
push:
branches:
- master
pull_request: {}
merge_group: {}

jobs:
test:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
container_tag:
- 3.2-dev-focal
container:
image: rubylang/ruby:${{ matrix.container_tag }}
steps:
- uses: actions/checkout@v4
- name: Set working directory as safe
run: git config --global --add safe.directory $(pwd)
- name: Install dependencies
run: |
apt-get update
apt-get install -y libdb-dev curl autoconf automake m4 libtool
- name: Update rubygems & bundler
run: |
ruby -v
gem update --system
- name: bin/setup
run: |
bin/setup
- name: Run steep check
run: |
bin/steep check -j 2
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

## master

## 3.3.2 (2023-11-21)

### Miscellaneous

* Require `bundler` explicitly for ruby/ruby CI ([#1629](https://github.com/ruby/rbs/pull/1629))

## 3.3.1 (2023-11-21)

### Library changes

* Allow to use RBS in symlinked tree ([#1624](https://github.com/ruby/rbs/pull/1624))
* Should escape if param name include not simple-word ([#1618](https://github.com/ruby/rbs/pull/1618))

#### rbs collection

* Load Bundler lazily ([#1612](https://github.com/ruby/rbs/pull/1612))

### Miscellaneous

* Stop using `bundle` command ([#1619](https://github.com/ruby/rbs/pull/1619))

## 3.3.0 (2023-11-09)

### Library changes
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rbs (3.3.0)
rbs (3.4.0.dev)
abbrev

PATH
Expand Down
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,53 @@ $ rbs methods ::Object
$ rbs method Object then
```

An end user of `rbs` will probably find `rbs prototype` the most useful. This command generates boilerplate signature declarations for ruby files. For example, say you have written the below ruby script.

```ruby
# person.rb
class Person
attr_reader :name
attr_reader :contacts

def initialize(name:)
@name = name
@contacts = []
end

def speak
"I'm #{@name} and I love Ruby!"
end
end
```

Running prototype on the above will automatically generate

```
$ rbs prototype rb person.rb
class Person
@name: untyped
@contacts: untyped
attr_reader name: untyped
attr_reader contacts: untyped
def initialize: (name: untyped) -> void
def speak: () -> ::String
end
```

It prints signatures for all methods, classes, instance variables, and constants.
This is only a starting point, and you should edit the output to match your signature more accurately.

`rbs prototpe` offers three options.

- `rb` generates from just the available Ruby code
- `rbi` generates from Sorbet RBI
- `runtime` generates from runtime API

## Library

There are two important concepts, _environment_ and _definition_.
Expand Down
3 changes: 1 addition & 2 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ target :lib do
"lib/rbs/test.rb"
)

library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint'
signature 'stdlib/yaml/0'
library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint', 'yaml'
signature "stdlib/strscan/0/"
signature "stdlib/optparse/0/"
signature "stdlib/rdoc/0/"
Expand Down
6 changes: 6 additions & 0 deletions core/hash.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@
class Hash[unchecked out K, unchecked out V] < Object
include Enumerable[[ K, V ]]

interface _Key
def hash: () -> Integer

def eql?: (untyped rhs) -> boolish
end

# <!--
# rdoc-file=hash.c
# - Hash[] -> new_empty_hash
Expand Down
3 changes: 2 additions & 1 deletion core/io.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,8 @@ class IO < Object
# f.gets(chomp: true) # => nil
# f.close
#
def gets: (?String sep, ?Integer limit) -> String?
def gets: (string? sep, ?int limit, ?chomp: boolish) -> String?
| (?int limit, ?chomp: boolish) -> String?

# <!--
# rdoc-file=io.c
Expand Down
Loading

0 comments on commit f7443bd

Please sign in to comment.