Skip to content

Instantly share code, notes, and snippets.

View tk0miya's full-sized avatar

Takeshi KOMIYA tk0miya

View GitHub Profile
# frozen_string_literal: true
require 'pathname'
require 'rbs'
require 'rbs/prototype/rb'
module RBS
module Prototype
class RB
alias process_orig process
# frozen_string_literal: true
#
# RBS::Location を marshal 可能にする試み。
# ダンプサイズを減らし、load 後のメモリ使用量を抑える目的で、RBS::Buffer はそのままダンプせず、
# ロード時に .rbs ファイルを再読み込みするようにしている。
#
# marhsal キャッシュ導入前:
# 3.80s, 3.58s, 3.65s
#
# frozen_string_literal: true
#
# RBS loading optimizer
#
# Usage: require 'rbs_optimizer' in your .irbrc
#
require 'rbs'
require 'rbs/cli'
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|
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
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
# リテラルスタイルのアンカーを作る
#
# 使い方:
# * :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
# リテラルスタイルのアンカーを作る
#
# 使い方: :codehref:`blah blah blah <http://path.to/anywhere>`
#
from docutils import nodes
from sphinx.util.docutils import ReferenceRole
class CodeHref(ReferenceRole):
def run(self):
# 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
# frozen_string_literal: true
module Ransack
module Nullable
# Ransack で NULL を含む IN クエリを組み立てるためのヘルパ
#
# 利用方法:
# Ransack::Nullable.build(User, params[:q], nullable: %i[user_id])
#
# 注意点: