View test.rb
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
# frozen_string_literal: true | |
require 'pathname' | |
require 'rbs' | |
require 'rbs/prototype/rb' | |
module RBS | |
module Prototype | |
class RB | |
alias process_orig process |
View rbs_marshalable.rb
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
# frozen_string_literal: true | |
# | |
# RBS::Location を marshal 可能にする試み。 | |
# ダンプサイズを減らし、load 後のメモリ使用量を抑える目的で、RBS::Buffer はそのままダンプせず、 | |
# ロード時に .rbs ファイルを再読み込みするようにしている。 | |
# | |
# marhsal キャッシュ導入前: | |
# 3.80s, 3.58s, 3.65s | |
# |
View rbs_optimizer.rb
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
# frozen_string_literal: true | |
# | |
# RBS loading optimizer | |
# | |
# Usage: require 'rbs_optimizer' in your .irbrc | |
# | |
require 'rbs' | |
require 'rbs/cli' |
View gist:785c3bc17c7b6d8e6e68fdb865fcea8c
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
diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb | |
index 646ed909..628e9878 100644 | |
--- a/lib/rbs/prototype/rb.rb | |
+++ b/lib/rbs/prototype/rb.rb | |
@@ -109,8 +109,26 @@ module RBS | |
# Give up detect super class e.g. `class Foo < Struct.new(:bar)` | |
nil | |
end | |
+ | |
+ const_to_name!(class_name).namespace.ascend.reject(&:empty?).reverse_each do |module_name| |
View gist:2f271a3478fcd8b82c85c7fde96a3057
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
diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb | |
index 646ed909..3667d7dc 100644 | |
--- a/lib/rbs/prototype/rb.rb | |
+++ b/lib/rbs/prototype/rb.rb | |
@@ -5,11 +5,11 @@ module RBS | |
class RB | |
include Helpers | |
- Context = _ = Struct.new(:module_function, :singleton, :namespace, keyword_init: true) do | |
+ Context = _ = Struct.new(:module_function, :singleton, :namespace, :in_block, keyword_init: true) do |
View gist:83fcacaa5f7e125d2ba309143e84d2d3
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
diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb | |
index 646ed909..cbbf4b80 100644 | |
--- a/lib/rbs/prototype/rb.rb | |
+++ b/lib/rbs/prototype/rb.rb | |
@@ -347,10 +347,33 @@ module RBS | |
end | |
when :ITER | |
- method_name = node.children.first.children.first | |
- case method_name |
View ext.py
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
# リテラルスタイルのアンカーを作る | |
# | |
# 使い方: | |
# * :codehref:`blah blah blah <http://path.to/anywhere>` | |
# * :codehref:`blah \`\`blah\`\` blah <http://path.to/anywhere>` | |
# | |
from docutils import nodes | |
from sphinx.util.docutils import ReferenceRole | |
View ext.py
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
# リテラルスタイルのアンカーを作る | |
# | |
# 使い方: :codehref:`blah blah blah <http://path.to/anywhere>` | |
# | |
from docutils import nodes | |
from sphinx.util.docutils import ReferenceRole | |
class CodeHref(ReferenceRole): | |
def run(self): |
View ext.py
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
# extension testbed | |
import re | |
from docutils import nodes | |
from docutils.nodes import Element, Node | |
from sphinx.util.docutils import SphinxDirective | |
from sphinx.writers.html5 import HTML5Translator | |
View nullable.rb
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
# frozen_string_literal: true | |
module Ransack | |
module Nullable | |
# Ransack で NULL を含む IN クエリを組み立てるためのヘルパ | |
# | |
# 利用方法: | |
# Ransack::Nullable.build(User, params[:q], nullable: %i[user_id]) | |
# | |
# 注意点: |
NewerOlder