$ cat a.rbs
class Foo
def bar: () -> void
def self.baz: () -> (Integer | String)
def qux: (untyped) -> untyped
end
This file contains hidden or 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
#! /usr/bin/env ruby | |
class Generator | |
def initialize(base_locale:, root_name:, rb_path:, rbs_path:) | |
@base_locale = base_locale.to_sym | |
@root_name = root_name | |
@rb_path = rb_path | |
@rbs_path = rbs_path | |
@stack = nil | |
@mode = nil |
This file contains hidden or 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
#! /usr/bin/env ruby | |
# $ rbs-fuzzing.rb [TypeName] [method_name] | |
# $ rbs-fuzzing.rb Integer | |
# $ rbs-fuzzing.rb Integer pow | |
require 'rbs' | |
require 'rbs/test' | |
class Fuzzing |
RBS is an easy language to generate code for because of its simple syntax and lack of dependencies between files. In addition, there are currently a large number of required type definitions, so code generation for RBS is considered to be highly important.
Various attempts have been made to generate RBS code, including generation from JSON files and analysis of static and dynamic Ruby code. However, each method has its advantages and disadvantages, and not all problems have been solved.
This file contains hidden or 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
begin | |
require "rbs_rails/rake_task" | |
require "rbs" | |
rescue LoadError | |
return | |
end | |
RbsRails::RakeTask.new | |
class AppGeneratedWriter < RBS::Writer |
This file contains hidden or 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
# inspired by https://qiita.com/kentaro/items/477c92a57c8aaf694251 | |
user = { | |
id: 123_456, | |
name: "ksss", | |
profile: { | |
real_name: "栗原勇樹", | |
image: { | |
original: "...", | |
thumbnail: "...", |
This file contains hidden or 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
if ENV['COVERAGE'] | |
require "coverage" | |
Coverage.start | |
at_exit do | |
# "great_library" is example gem name | |
cov = Coverage.result.select { |d| d.match?(%r{/great_library/lib/}) } | |
cov.transform_keys! { |key| key.dup.sub!(%r{^.*great_library/(lib/.*)$}, '\1') } | |
cov.transform_values! do |ary| | |
ary = ary.compact | |
ary.count { |l| l > 0 }.fdiv(ary.length) |
This file contains hidden or 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
/* cat init.sql | sqlite3 pokemon */ | |
drop table if exists status_list; | |
create table status_list( | |
jpname VARCHAR(255) primary key, | |
jpromaji VARCHAR(255) not null, | |
no integer not null, | |
h integer not null, | |
a integer not null, | |
b integer not null, | |
c integer not null, |
This file contains hidden or 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
#! /usr/bin/env ruby | |
require 'json' | |
require 'pp' | |
require 'optparse' | |
Option = Struct.new( | |
:symbolize | |
) | |
o = Option.new( |
This file contains hidden or 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
#! /usr/bin/env ruby | |
require 'logger' | |
case ARGV[0] | |
when "stdout" | |
log = Logger.new(STDOUT) | |
else | |
log = nil | |
end |
NewerOlder