forked from ruby/gem_rbs_collection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See also: - ruby/rbs#2258
- Loading branch information
Showing
5 changed files
with
123 additions
and
0 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,19 @@ | ||
# This configuration inherits from /.rubocop.yml. | ||
# You can configure RBS style of this gem. | ||
# This file is used on CI. It is configured to automatically | ||
# make rubocop suggestions on pull requests for this gem. | ||
# If you do not like the style enforcement, you should remove this file. | ||
inherit_from: ../../.rubocop.yml | ||
|
||
## | ||
# If you want to customize the style, please consult with the gem reviewers. | ||
# You can see the list of cops at https://github.com/ksss/rubocop-on-rbs/blob/main/docs/modules/ROOT/pages/cops.adoc | ||
|
||
RBS/Layout: | ||
Enabled: true | ||
|
||
RBS/Lint: | ||
Enabled: true | ||
|
||
RBS/Style: | ||
Enabled: true |
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,10 @@ | ||
# Write Ruby code to test the RBS. | ||
# It is type checked by `steep check` command. | ||
|
||
require "abbrev" | ||
|
||
Abbrev.abbrev([]) | ||
Abbrev.abbrev(%w(abbrev)) | ||
Abbrev.abbrev(%w(abbrev), 'abb') | ||
Abbrev.abbrev(%w(abbrev), /^abb/) | ||
Abbrev.abbrev(%w(abbrev), nil) |
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,66 @@ | ||
# <!-- rdoc-file=lib/abbrev.rb --> | ||
# Calculates the set of unambiguous abbreviations for a given set of strings. | ||
# | ||
# require 'abbrev' | ||
# require 'pp' | ||
# | ||
# pp Abbrev.abbrev(['ruby']) | ||
# #=> {"ruby"=>"ruby", "rub"=>"ruby", "ru"=>"ruby", "r"=>"ruby"} | ||
# | ||
# pp Abbrev.abbrev(%w{ ruby rules }) | ||
# | ||
# *Generates:* | ||
# { "ruby" => "ruby", | ||
# "rub" => "ruby", | ||
# "rules" => "rules", | ||
# "rule" => "rules", | ||
# "rul" => "rules" } | ||
# | ||
# It also provides an array core extension, Array#abbrev. | ||
# | ||
# pp %w{ summer winter }.abbrev | ||
# | ||
# *Generates:* | ||
# { "summer" => "summer", | ||
# "summe" => "summer", | ||
# "summ" => "summer", | ||
# "sum" => "summer", | ||
# "su" => "summer", | ||
# "s" => "summer", | ||
# "winter" => "winter", | ||
# "winte" => "winter", | ||
# "wint" => "winter", | ||
# "win" => "winter", | ||
# "wi" => "winter", | ||
# "w" => "winter" } | ||
# | ||
module Abbrev | ||
# <!-- | ||
# rdoc-file=lib/abbrev.rb | ||
# - abbrev(words, pattern = nil) | ||
# --> | ||
# Given a set of strings, calculate the set of unambiguous abbreviations for | ||
# those strings, and return a hash where the keys are all the possible | ||
# abbreviations and the values are the full strings. | ||
# | ||
# Thus, given `words` is "car" and "cone", the keys pointing to "car" would be | ||
# "ca" and "car", while those pointing to "cone" would be "co", "con", and | ||
# "cone". | ||
# | ||
# require 'abbrev' | ||
# | ||
# Abbrev.abbrev(%w{ car cone }) | ||
# #=> {"ca"=>"car", "con"=>"cone", "co"=>"cone", "car"=>"car", "cone"=>"cone"} | ||
# | ||
# The optional `pattern` parameter is a pattern or a string. Only input strings | ||
# that match the pattern or start with the string are included in the output | ||
# hash. | ||
# | ||
# Abbrev.abbrev(%w{car box cone crab}, /b/) | ||
# #=> {"box"=>"box", "bo"=>"box", "b"=>"box", "crab" => "crab"} | ||
# | ||
# Abbrev.abbrev(%w{car box cone}, 'ca') | ||
# #=> {"car"=>"car", "ca"=>"car"} | ||
# | ||
def self?.abbrev: (Array[String], ?String | Regexp | nil) -> Hash[String, String] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
%a{annotate:rdoc:skip} | ||
class Array[unchecked out Elem] | ||
# <!-- | ||
# rdoc-file=lib/abbrev.rb | ||
# - abbrev(pattern = nil) | ||
# --> | ||
# Calculates the set of unambiguous abbreviations for the strings in `self`. | ||
# | ||
# require 'abbrev' | ||
# %w{ car cone }.abbrev | ||
# #=> {"car"=>"car", "ca"=>"car", "cone"=>"cone", "con"=>"cone", "co"=>"cone"} | ||
# | ||
# The optional `pattern` parameter is a pattern or a string. Only input strings | ||
# that match the pattern or start with the string are included in the output | ||
# hash. | ||
# | ||
# %w{ fast boat day }.abbrev(/^.a/) | ||
# #=> {"fast"=>"fast", "fas"=>"fast", "fa"=>"fast", "day"=>"day", "da"=>"day"} | ||
# | ||
# Abbrev.abbrev(%w{car box cone}, "ca") | ||
# #=> {"car"=>"car", "ca"=>"car"} | ||
# | ||
# See also Abbrev.abbrev | ||
# | ||
def abbrev: (?String | Regexp | nil) -> Hash[String, String] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
reviewers: | ||
- ksss |