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: 18 additions & 0 deletions .github/workflows/sig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: sig

on: [push, pull_request]

jobs:
sig:
runs-on: "ubuntu-latest"
env:
BUNDLE_WITH: sig
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ruby
- name: Run RBS test
run: bundle exec rake rbs:test
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
- ruby: 2.5
os: macos-latest
runs-on: ${{ matrix.os }}
env:
BUNDLE_WITHOUT: sig
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
Expand Down
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
source "https://rubygems.org"

gemspec

gem "rake"
gem "rake-compiler"
gem "test-unit"

group :sig do
gem "rbs"
gem "rdoc"
end
19 changes: 19 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/test_*.rb"]
end

namespace :rbs do
Rake::TestTask.new(test: :compile) do |t|
t.libs << "test_sig"
t.ruby_opts << "-rtest_helper"
t.test_files = FileList["test_sig/test_*.rb"]
t.warning = true
end

desc 'Update RBS comments'
task :annotate do
require "tmpdir"

Dir.mktmpdir do |tmpdir|
sh("rdoc --ri --output #{tmpdir}/doc --root=. lib")
sh("rbs annotate --no-system --no-gems --no-site --no-home -d #{tmpdir}/doc sig")
end
end
end

if RUBY_ENGINE == "jruby"
require "rake/javaextensiontask"
Rake::JavaExtensionTask.new("nkf") do |ext|
Expand Down
166 changes: 166 additions & 0 deletions sig/kconv.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# <!-- rdoc-file=lib/kconv.rb -->
# Kanji Converter for Ruby.
#
module Kconv
# <!-- rdoc-file=lib/kconv.rb -->
# ASCII
#
ASCII: Encoding

# <!-- rdoc-file=lib/kconv.rb -->
# Auto-Detect
#
AUTO: nil

# <!-- rdoc-file=lib/kconv.rb -->
# BINARY
#
BINARY: Encoding

# <!-- rdoc-file=lib/kconv.rb -->
# EUC-JP
#
EUC: Encoding

# <!-- rdoc-file=lib/kconv.rb -->
# ISO-2022-JP
#
JIS: Encoding

# <!-- rdoc-file=lib/kconv.rb -->
# NOCONV
#
NOCONV: nil

# <!-- rdoc-file=lib/kconv.rb -->
# Shift_JIS
#
SJIS: Encoding

# <!-- rdoc-file=lib/kconv.rb -->
# UNKNOWN
#
UNKNOWN: nil

# <!-- rdoc-file=lib/kconv.rb -->
# UTF-16
#
UTF16: Encoding

# <!-- rdoc-file=lib/kconv.rb -->
# UTF-32
#
UTF32: Encoding

# <!-- rdoc-file=lib/kconv.rb -->
# UTF-8
#
UTF8: Encoding

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.guess(str) => encoding
# -->
# Guess input encoding by NKF.guess
#
def self.guess: (String str) -> Encoding

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.iseuc(str) => true or false
# -->
# Returns whether input encoding is EUC-JP or not.
#
# **Note** don't expect this return value is MatchData.
#
def self.iseuc: (String str) -> bool

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.isjis(str) => true or false
# -->
# Returns whether input encoding is ISO-2022-JP or not.
#
def self.isjis: (String str) -> bool

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.issjis(str) => true or false
# -->
# Returns whether input encoding is Shift_JIS or not.
#
def self.issjis: (String str) -> bool

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.isutf8(str) => true or false
# -->
# Returns whether input encoding is UTF-8 or not.
#
def self.isutf8: (String str) -> bool

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.kconv(str, to_enc, from_enc=nil)
# -->
# Convert `str` to `to_enc`. `to_enc` and `from_enc` are given as constants of
# Kconv or Encoding objects.
#
def self.kconv: (String str, Encoding? out_code, ?Encoding? in_code) -> String

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.toeuc(str) => string
# -->
# Convert `str` to EUC-JP
#
def self.toeuc: (String str) -> String

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.tojis(str) => string
# -->
# Convert `str` to ISO-2022-JP
#
def self.tojis: (String str) -> String

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.tolocale => string
# -->
# Convert `self` to locale encoding
#
def self.tolocale: (String str) -> String

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.tosjis(str) => string
# -->
# Convert `str` to Shift_JIS
#
def self.tosjis: (String str) -> String

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.toutf16(str) => string
# -->
# Convert `str` to UTF-16
#
def self.toutf16: (String str) -> String

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.toutf32(str) => string
# -->
# Convert `str` to UTF-32
#
def self.toutf32: (String str) -> String

# <!--
# rdoc-file=lib/kconv.rb
# - Kconv.toutf8(str) => string
# -->
# Convert `str` to UTF-8
#
def self.toutf8: (String str) -> String
end
Loading