rbtr-lang-ruby 2026.9.0.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alejandro Giacometti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: rbtr-lang-ruby
3
+ Version: 2026.9.0.dev1
4
+ Summary: rbtr — Ruby language plugin
5
+ Keywords: code-search,code-index,tree-sitter,static-analysis,semantic-search,developer-tools,ruby
6
+ Author: Alejandro Giacometti
7
+ Author-email: Alejandro Giacometti <alejandro.giacometti@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Ruby
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Classifier: Topic :: Text Processing :: Indexing
17
+ Classifier: Typing :: Typed
18
+ Requires-Dist: rbtr==2026.9.0.dev1
19
+ Requires-Dist: tree-sitter-ruby
20
+ Requires-Python: >=3.13
21
+ Project-URL: Homepage, https://github.com/janrito/rbtr
22
+ Project-URL: Repository, https://github.com/janrito/rbtr
23
+ Project-URL: Documentation, https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-ruby#readme
24
+ Project-URL: Issues, https://github.com/janrito/rbtr/issues
25
+ Project-URL: Changelog, https://github.com/janrito/rbtr/releases
26
+ Description-Content-Type: text/markdown
27
+
28
+ # rbtr-lang-ruby
29
+
30
+ Ruby support for [rbtr]. Optional plugin — install with
31
+ `pip install rbtr[ruby]`.
32
+
33
+ [rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
34
+
35
+ ## What it ingests
36
+
37
+ - **Functions & methods** — `def` (a method inside a class/module is scoped
38
+ to it; top-level `def` is a function).
39
+ - **Classes** — `class` and `module` definitions (a module also scopes its
40
+ members).
41
+ - **Variables** — constants and module-level assignments.
42
+ - **Imports** — `require` and `require_relative`, for cross-file edges.
43
+
44
+ Leading `#` doc comments fold into the symbol's content.
45
+
46
+ ## Chunks produced
47
+
48
+ ```ruby
49
+ def greet(name); …; end # function "greet"
50
+ class User # class "User"
51
+ def save; …; end # method "save", scope "User"
52
+ end
53
+ MAX = 100 # variable "MAX"
54
+ require_relative "config" # import, metadata {module: config}
55
+ ```
56
+
57
+ ## Embedded / injected chunks
58
+
59
+ None. Ruby does not embed other languages.
60
+
61
+ ## Grammar & dependencies
62
+
63
+ Uses the `tree-sitter-ruby` grammar. No dependency on other language plugins.
@@ -0,0 +1,36 @@
1
+ # rbtr-lang-ruby
2
+
3
+ Ruby support for [rbtr]. Optional plugin — install with
4
+ `pip install rbtr[ruby]`.
5
+
6
+ [rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
7
+
8
+ ## What it ingests
9
+
10
+ - **Functions & methods** — `def` (a method inside a class/module is scoped
11
+ to it; top-level `def` is a function).
12
+ - **Classes** — `class` and `module` definitions (a module also scopes its
13
+ members).
14
+ - **Variables** — constants and module-level assignments.
15
+ - **Imports** — `require` and `require_relative`, for cross-file edges.
16
+
17
+ Leading `#` doc comments fold into the symbol's content.
18
+
19
+ ## Chunks produced
20
+
21
+ ```ruby
22
+ def greet(name); …; end # function "greet"
23
+ class User # class "User"
24
+ def save; …; end # method "save", scope "User"
25
+ end
26
+ MAX = 100 # variable "MAX"
27
+ require_relative "config" # import, metadata {module: config}
28
+ ```
29
+
30
+ ## Embedded / injected chunks
31
+
32
+ None. Ruby does not embed other languages.
33
+
34
+ ## Grammar & dependencies
35
+
36
+ Uses the `tree-sitter-ruby` grammar. No dependency on other language plugins.
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.11.26,<1"]
3
+ build-backend = "uv_build"
4
+
5
+ [tool.uv.build-backend]
6
+ module-name = "rbtr_lang_ruby"
7
+
8
+ [tool.uv.sources.rbtr]
9
+ workspace = true
10
+
11
+ [project]
12
+ name = "rbtr-lang-ruby"
13
+ version = "2026.9.0-dev1"
14
+ description = "rbtr — Ruby language plugin"
15
+ readme = "README.md"
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
18
+ keywords = [
19
+ "code-search",
20
+ "code-index",
21
+ "tree-sitter",
22
+ "static-analysis",
23
+ "semantic-search",
24
+ "developer-tools",
25
+ "ruby",
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 4 - Beta",
29
+ "Intended Audience :: Developers",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Programming Language :: Ruby",
33
+ "Topic :: Software Development :: Libraries",
34
+ "Topic :: Text Processing :: Indexing",
35
+ "Typing :: Typed",
36
+ ]
37
+ requires-python = ">=3.13"
38
+ dependencies = [
39
+ "rbtr==2026.9.0-dev1",
40
+ "tree-sitter-ruby",
41
+ ]
42
+
43
+ [[project.authors]]
44
+ name = "Alejandro Giacometti"
45
+ email = "alejandro.giacometti@gmail.com"
46
+
47
+ [project.urls]
48
+ Homepage = "https://github.com/janrito/rbtr"
49
+ Repository = "https://github.com/janrito/rbtr"
50
+ Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-ruby#readme"
51
+ Issues = "https://github.com/janrito/rbtr/issues"
52
+ Changelog = "https://github.com/janrito/rbtr/releases"
53
+
54
+ [project.entry-points."rbtr.languages"]
55
+ ruby = "rbtr_lang_ruby.plugin:ruby"
56
+
57
+ [dependency-groups]
58
+ dev = ["rbtr[test]"]
@@ -0,0 +1,62 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.11.26,<1"]
3
+ build-backend = "uv_build"
4
+
5
+ [tool.uv.build-backend]
6
+ module-name = "rbtr_lang_ruby"
7
+ # No source-exclude: the plugin's tests, samples, and snapshots ship with
8
+ # the wheel (they are the language's golden record), and ruby.scm ships as
9
+ # package data.
10
+
11
+ [project]
12
+ name = "rbtr-lang-ruby"
13
+ version = "2026.9.0-dev1"
14
+ description = "rbtr — Ruby language plugin"
15
+ readme = "README.md"
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
18
+ authors = [
19
+ { name = "Alejandro Giacometti", email = "alejandro.giacometti@gmail.com" },
20
+ ]
21
+ keywords = [
22
+ "code-search",
23
+ "code-index",
24
+ "tree-sitter",
25
+ "static-analysis",
26
+ "semantic-search",
27
+ "developer-tools",
28
+ "ruby",
29
+ ]
30
+ classifiers = [
31
+ "Development Status :: 4 - Beta",
32
+ "Intended Audience :: Developers",
33
+ "Programming Language :: Python :: 3 :: Only",
34
+ "Programming Language :: Python :: 3.13",
35
+ "Programming Language :: Ruby",
36
+ "Topic :: Software Development :: Libraries",
37
+ "Topic :: Text Processing :: Indexing",
38
+ "Typing :: Typed",
39
+ ]
40
+ requires-python = ">=3.13"
41
+ dependencies = [
42
+ "rbtr==2026.9.0-dev1",
43
+ "tree-sitter-ruby",
44
+ ]
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/janrito/rbtr"
48
+ Repository = "https://github.com/janrito/rbtr"
49
+ Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-ruby#readme"
50
+ Issues = "https://github.com/janrito/rbtr/issues"
51
+ Changelog = "https://github.com/janrito/rbtr/releases"
52
+
53
+ [project.entry-points."rbtr.languages"]
54
+ # The value resolves to the language's `LanguageRegistration` (named by its
55
+ # id) — see the rbtr ARCHITECTURE "External plugins" note.
56
+ ruby = "rbtr_lang_ruby.plugin:ruby"
57
+
58
+ [tool.uv.sources]
59
+ rbtr = { workspace = true }
60
+
61
+ [dependency-groups]
62
+ dev = ["rbtr[test]"]
@@ -0,0 +1 @@
1
+ """Ruby language plugin package."""
@@ -0,0 +1,97 @@
1
+ """Ruby language plugin.
2
+
3
+ Provides symbol extraction (methods, classes, modules, constants,
4
+ and the RSpec `describe`/`context`/`it` DSL) and structured import
5
+ metadata from `require` / `require_relative`. Constants scope to
6
+ their enclosing class/module. RSpec groups (`describe`/`context`/
7
+ `feature`) are classes and examples (`it`/`specify`/`example`) are
8
+ functions, named by their description string.
9
+
10
+ Extracted chunks::
11
+
12
+ def greet ... end → function "greet", scope ""
13
+ class Shape ... end → class "Shape", scope ""
14
+ module Utils ... end → class "Utils", scope ""
15
+ class Foo
16
+ def bar ... end → method "bar", scope "Foo"
17
+ end
18
+
19
+ require "json"
20
+ → import, metadata {module: "json"}
21
+ require_relative "helpers"
22
+ → import, metadata {module: "helpers", dots: "1"}
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ from typing import TYPE_CHECKING
28
+
29
+ from rbtr.domain.models import ImportMeta
30
+ from rbtr.languages.registration import (
31
+ ImportResolver,
32
+ LanguageRegistration,
33
+ QueryExtraction,
34
+ load_query,
35
+ parse_path_relative,
36
+ )
37
+
38
+ if TYPE_CHECKING:
39
+ from tree_sitter import Node
40
+
41
+ # ── Query ────────────────────────────────────────────────────────────
42
+
43
+
44
+ # ── Import extractor ─────────────────────────────────────────────────
45
+
46
+
47
+ def extract_import_meta(
48
+ resolver: ImportResolver, node: Node, captures: dict[str, list[Node]]
49
+ ) -> ImportMeta:
50
+ """Extract import data from a Ruby `require` / `require_relative` node.
51
+
52
+ Reads `@_import_module` from captures (the query captures
53
+ the string argument), then sets `dots` for
54
+ `require_relative` (always relative to the current file).
55
+
56
+ Examples:
57
+
58
+ `require "json"`:
59
+ module="json"
60
+
61
+ `require_relative "helpers"`:
62
+ module="helpers", dots="1"
63
+
64
+ `require_relative "./config"`:
65
+ module="config", dots="1"
66
+
67
+ `require_relative "../lib/utils"`:
68
+ module="lib/utils", dots="2"
69
+ """
70
+ meta = resolver(node, captures)
71
+ method = node.child_by_field_name("method")
72
+ if method and method.text == b"require_relative":
73
+ # `require_relative` is always relative to the current file. Strip any
74
+ # `./`/`../` prefix into `dots` (a bare path is the current dir, dots=1)
75
+ # so the resolver doesn't see a leftover `./` it can't match.
76
+ dots, cleaned = parse_path_relative(meta.module)
77
+ meta.module = cleaned
78
+ meta.dots = str(dots or 1)
79
+ return meta
80
+
81
+
82
+ # ── Plugin ───────────────────────────────────────────────────────────
83
+
84
+
85
+ ruby = LanguageRegistration(
86
+ id="ruby",
87
+ extensions=frozenset({".rb"}),
88
+ grammar_module="tree_sitter_ruby",
89
+ extraction=QueryExtraction(
90
+ query=load_query(__package__, "ruby"),
91
+ scope_types=frozenset({"class", "module"}),
92
+ ),
93
+ source_roots=("", "lib"),
94
+ extraction_serial=5,
95
+ )
96
+
97
+ ruby.import_extractor(extract_import_meta)
@@ -0,0 +1,51 @@
1
+
2
+ ; Comments (Ruby: `#` line and `=begin`/`=end` block, both `comment`).
3
+ (comment) @comment
4
+
5
+ (method
6
+ name: (identifier) @_fn_name) @function
7
+
8
+ (singleton_method
9
+ name: (identifier) @_fn_name) @function
10
+
11
+ (class
12
+ name: (constant) @_cls_name) @class
13
+
14
+ (module
15
+ name: (constant) @_cls_name) @class
16
+
17
+ (call
18
+ method: (identifier) @_call_name
19
+ arguments: (argument_list
20
+ (string) @_import_module)
21
+ (#eq? @_call_name "require")) @import
22
+
23
+ (call
24
+ method: (identifier) @_call_name
25
+ arguments: (argument_list
26
+ (string) @_import_module)
27
+ (#eq? @_call_name "require_relative")) @import
28
+
29
+ (assignment
30
+ left: (constant) @_var_name) @variable
31
+
32
+ (assignment
33
+ left: (left_assignment_list (constant) @_var_name)) @variable
34
+
35
+ (assignment
36
+ left: (left_assignment_list (rest_assignment (constant) @_var_name))) @variable
37
+
38
+ (call
39
+ method: (identifier) @_call_name
40
+ arguments: (argument_list . (string (string_content) @_cls_name))
41
+ (#any-of? @_call_name "describe" "context" "feature" "shared_examples" "shared_context")) @class
42
+
43
+ (call
44
+ method: (identifier) @_call_name
45
+ arguments: (argument_list . (constant) @_cls_name)
46
+ (#any-of? @_call_name "describe" "context" "feature")) @class
47
+
48
+ (call
49
+ method: (identifier) @_call_name
50
+ arguments: (argument_list . (string (string_content) @_fn_name))
51
+ (#any-of? @_call_name "it" "specify" "example" "scenario")) @function
@@ -0,0 +1,3 @@
1
+ [
2
+ "ruby.rb::require_relative \"./config\" -> config.rb::DEFAULT_LOCALE [imports]"
3
+ ]