decode 0.23.2 → 0.23.4
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -3
- data/agent.md +31 -0
- data/bake/decode/index.rb +1 -1
- data/lib/decode/comment/attribute.rb +1 -1
- data/lib/decode/comment/node.rb +2 -4
- data/lib/decode/comment/parameter.rb +1 -1
- data/lib/decode/comment/pragma.rb +1 -1
- data/lib/decode/comment/returns.rb +1 -1
- data/lib/decode/comment/tag.rb +1 -1
- data/lib/decode/comment/tags.rb +1 -1
- data/lib/decode/comment/text.rb +1 -1
- data/lib/decode/comment/yields.rb +1 -1
- data/lib/decode/definition.rb +1 -1
- data/lib/decode/documentation.rb +1 -1
- data/lib/decode/index.rb +1 -1
- data/lib/decode/language/generic.rb +1 -1
- data/lib/decode/language/reference.rb +1 -1
- data/lib/decode/language/ruby/alias.rb +1 -1
- data/lib/decode/language/ruby/attribute.rb +1 -1
- data/lib/decode/language/ruby/block.rb +1 -1
- data/lib/decode/language/ruby/call.rb +3 -3
- data/lib/decode/language/ruby/class.rb +2 -2
- data/lib/decode/language/ruby/code.rb +3 -3
- data/lib/decode/language/ruby/constant.rb +1 -1
- data/lib/decode/language/ruby/definition.rb +1 -1
- data/lib/decode/language/ruby/function.rb +1 -1
- data/lib/decode/language/ruby/generic.rb +1 -1
- data/lib/decode/language/ruby/method.rb +1 -1
- data/lib/decode/language/ruby/module.rb +1 -1
- data/lib/decode/language/ruby/parser.rb +38 -16
- data/lib/decode/language/ruby/reference.rb +1 -1
- data/lib/decode/language/ruby/segment.rb +1 -1
- data/lib/decode/language/ruby.rb +1 -1
- data/lib/decode/languages.rb +1 -1
- data/lib/decode/location.rb +1 -1
- data/lib/decode/segment.rb +1 -1
- data/lib/decode/source.rb +1 -1
- data/lib/decode/syntax/link.rb +1 -1
- data/lib/decode/syntax/match.rb +1 -1
- data/lib/decode/syntax/rewriter.rb +1 -1
- data/lib/decode/trie.rb +5 -3
- data/lib/decode/version.rb +2 -2
- data/license.md +1 -1
- data/readme.md +15 -1
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +3 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d918d6104a7b51fdf463bc40d3c5108dcfbae329064cb25395a988cb45c6aba
|
4
|
+
data.tar.gz: 7d303793cff2638b2b6c5a0527ab3cb0cfa3a33a0c4c1340436e03f0d7804602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fa8f8c71fb84a01414399a3f214d0870ee220225d2059ddb4416cb00bd7e4425ddf4c81c6c5a02ade8d53d9462f0be1544b4dd514b3b57d9dd3e052225fe269
|
7
|
+
data.tar.gz: 81174c0ff895f8ade0f80ad31216bcfeb13080173728c186fba4d37843ca45c551438a5401d865d32bef97e8416b5ab4bebaa5983949f43b8e22d56591d139ce
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
'� ���$��ӄ�̸��r�B���P�`ɢα.$'��j�����7�cr[X�v�]-eDRn�d<���H^P�W�s����J��8c�/��,Pxk�U�u*6ቊ�f�FVYuY9'Yr"G3��/E��
|
1
|
+
�f��nu|$>�9�mT<6��X��a��VlCS�bҘc��!)�TFJ4��9�I��4TB����61�ae �<��z<߇YE�F��Z�,���1��b�ҽ.���b9�
|
2
|
+
�[����?|��8�gLZs�=�/я&�O��S��
|
data/agent.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Agent
|
2
|
+
|
3
|
+
## Context
|
4
|
+
|
5
|
+
This section provides links to documentation from installed packages. It is automatically generated and may be updated by running `bake agent:context:install`.
|
6
|
+
|
7
|
+
**Important:** Before performing any code, documentation, or analysis tasks, always read and apply the full content of any relevant documentation referenced in the following sections. These context files contain authoritative standards and best practices for documentation, code style, and project-specific workflows. **Do not proceed with any actions until you have read and incorporated the guidance from relevant context files.**
|
8
|
+
|
9
|
+
### agent-context
|
10
|
+
|
11
|
+
Install and manage context files from Ruby gems.
|
12
|
+
|
13
|
+
#### [Usage Guide](.context/agent-context/usage.md)
|
14
|
+
|
15
|
+
`agent-context` is a tool that helps you discover and install contextual information from Ruby gems for AI agents. Gems can provide additional documentation, examples, and guidance in a `context/` ...
|
16
|
+
|
17
|
+
### sus
|
18
|
+
|
19
|
+
A fast and scalable test runner.
|
20
|
+
|
21
|
+
#### [Using Sus Testing Framework](.context/sus/usage.md)
|
22
|
+
|
23
|
+
Sus is a modern Ruby testing framework that provides a clean, BDD-style syntax for writing tests. It's designed to be fast, simple, and expressive.
|
24
|
+
|
25
|
+
#### [Mocking](.context/sus/mocking.md)
|
26
|
+
|
27
|
+
There are two types of mocking in sus: `receive` and `mock`. The `receive` matcher is a subset of full mocking and is used to set expectations on method calls, while `mock` can be used to replace m...
|
28
|
+
|
29
|
+
#### [Shared Test Behaviors and Fixtures](.context/sus/shared.md)
|
30
|
+
|
31
|
+
Sus provides shared test contexts which can be used to define common behaviours or tests that can be reused across one or more test files.
|
data/bake/decode/index.rb
CHANGED
data/lib/decode/comment/node.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
module Decode
|
7
7
|
module Comment
|
@@ -63,9 +63,7 @@ module Decode
|
|
63
63
|
# @parameter node [Node] The current node which is being traversed.
|
64
64
|
# @parameter descend [Proc | Nil] The recursive method for traversing children.
|
65
65
|
def traverse(&block)
|
66
|
-
descend = ->(node){
|
67
|
-
node.traverse(&block)
|
68
|
-
}
|
66
|
+
descend = ->(node){node.traverse(&block)}
|
69
67
|
|
70
68
|
yield(self, descend)
|
71
69
|
end
|
data/lib/decode/comment/tag.rb
CHANGED
data/lib/decode/comment/tags.rb
CHANGED
data/lib/decode/comment/text.rb
CHANGED
data/lib/decode/definition.rb
CHANGED
data/lib/decode/documentation.rb
CHANGED
data/lib/decode/index.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "definition"
|
7
7
|
|
@@ -33,8 +33,8 @@ module Decode
|
|
33
33
|
else
|
34
34
|
# For multiline calls, use the actual call name with arguments
|
35
35
|
if @node.arguments && @node.arguments.arguments.any?
|
36
|
-
|
37
|
-
"#{@node.name}(#{
|
36
|
+
argument_text = @node.arguments.arguments.map {|argument| argument.location.slice}.join(", ")
|
37
|
+
"#{@node.name}(#{argument_text})"
|
38
38
|
else
|
39
39
|
@node.name.to_s
|
40
40
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "definition"
|
7
7
|
|
@@ -54,7 +54,7 @@ module Decode
|
|
54
54
|
class Singleton < Definition
|
55
55
|
# Generate a nested name for the singleton class.
|
56
56
|
def nested_name
|
57
|
-
"
|
57
|
+
"class"
|
58
58
|
end
|
59
59
|
|
60
60
|
# A singleton class is a container for other definitions.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "definition"
|
7
7
|
require_relative "../../syntax/link"
|
@@ -58,8 +58,8 @@ module Decode
|
|
58
58
|
|
59
59
|
# Extract constants from arguments:
|
60
60
|
if node.arguments
|
61
|
-
node.arguments.arguments.each do |
|
62
|
-
traverse(
|
61
|
+
node.arguments.arguments.each do |argument_node|
|
62
|
+
traverse(argument_node, into)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
when :constant_read_node
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require "prism"
|
7
7
|
|
@@ -113,7 +113,11 @@ module Decode
|
|
113
113
|
if name = singleton_name_for(node)
|
114
114
|
definition = Singleton.new(name,
|
115
115
|
comments: comments_for(node),
|
116
|
-
parent: parent,
|
116
|
+
parent: parent,
|
117
|
+
node: node,
|
118
|
+
language: @language,
|
119
|
+
visibility: :public,
|
120
|
+
source: source
|
117
121
|
)
|
118
122
|
|
119
123
|
yield definition
|
@@ -154,17 +158,17 @@ module Decode
|
|
154
158
|
# Handle cases like "private def foo" where method definitions are arguments
|
155
159
|
if node.arguments
|
156
160
|
has_method_definitions = false
|
157
|
-
node.arguments.arguments.each do |
|
158
|
-
if
|
161
|
+
node.arguments.arguments.each do |argument_node|
|
162
|
+
if argument_node.type == :def_node
|
159
163
|
has_method_definitions = true
|
160
164
|
# Process the method definition with the specified visibility
|
161
|
-
receiver = receiver_for(
|
165
|
+
receiver = receiver_for(argument_node.receiver)
|
162
166
|
|
163
|
-
definition = Method.new(
|
167
|
+
definition = Method.new(argument_node.name,
|
164
168
|
visibility: name,
|
165
|
-
comments: comments_for(
|
169
|
+
comments: comments_for(argument_node),
|
166
170
|
parent: parent,
|
167
|
-
node:
|
171
|
+
node: argument_node,
|
168
172
|
language: @language,
|
169
173
|
receiver: receiver,
|
170
174
|
)
|
@@ -220,7 +224,7 @@ module Decode
|
|
220
224
|
else
|
221
225
|
# Check if this call should be treated as a definition
|
222
226
|
# either because it has a @name comment, @attribute comment, or a block
|
223
|
-
has_name_comment = comments_for(node).any? {
|
227
|
+
has_name_comment = comments_for(node).any? {|comment| comment.match(NAME_ATTRIBUTE)}
|
224
228
|
has_attribute_comment = kind_for(node, comments_for(node))
|
225
229
|
has_block = node.block
|
226
230
|
|
@@ -254,6 +258,24 @@ module Decode
|
|
254
258
|
)
|
255
259
|
|
256
260
|
yield definition
|
261
|
+
when :if_node
|
262
|
+
# Walk the 'if' branch (statements):
|
263
|
+
if node.statements
|
264
|
+
walk_definitions(node.statements, parent, source, &block)
|
265
|
+
end
|
266
|
+
# Walk the 'else' or 'elsif' branch (subsequent):
|
267
|
+
if node.subsequent
|
268
|
+
walk_definitions(node.subsequent, parent, source, &block)
|
269
|
+
end
|
270
|
+
when :unless_node
|
271
|
+
# Walk the 'unless' branch (statements):
|
272
|
+
if node.statements
|
273
|
+
walk_definitions(node.statements, parent, source, &block)
|
274
|
+
end
|
275
|
+
# Walk the 'else' branch (else_clause):
|
276
|
+
if node.else_clause
|
277
|
+
walk_definitions(node.else_clause, parent, source, &block)
|
278
|
+
end
|
257
279
|
else
|
258
280
|
if node.respond_to?(:statements)
|
259
281
|
walk_definitions(node.statements, parent, source, &block)
|
@@ -467,15 +489,15 @@ module Decode
|
|
467
489
|
statements = node.child_nodes
|
468
490
|
current_segment = nil
|
469
491
|
|
470
|
-
statements.each_with_index do |
|
492
|
+
statements.each_with_index do |statement, statement_index|
|
471
493
|
# Find comments that precede this statement and are not inside previous statements
|
472
494
|
preceding_comments = []
|
473
|
-
|
495
|
+
last_statement_end_line = statement_index > 0 ? statements[statement_index - 1].location.end_line : 0
|
474
496
|
|
475
497
|
comments.each do |comment|
|
476
498
|
comment_line = comment.location.start_line
|
477
499
|
# Comment must be after the previous statement and before this statement
|
478
|
-
if comment_line >
|
500
|
+
if comment_line > last_statement_end_line && comment_line < statement.location.start_line
|
479
501
|
preceding_comments << comment
|
480
502
|
end
|
481
503
|
end
|
@@ -487,19 +509,19 @@ module Decode
|
|
487
509
|
# Start a new segment with these comments
|
488
510
|
yield current_segment if current_segment
|
489
511
|
current_segment = Segment.new(
|
490
|
-
preceding_comments.map {
|
512
|
+
preceding_comments.map {|comment| comment.location.slice.sub(/^#[\s\t]?/, "")},
|
491
513
|
@language,
|
492
|
-
|
514
|
+
statement
|
493
515
|
)
|
494
516
|
elsif current_segment
|
495
517
|
# Extend current segment with this statement
|
496
|
-
current_segment.expand(
|
518
|
+
current_segment.expand(statement)
|
497
519
|
else
|
498
520
|
# Start a new segment without comments
|
499
521
|
current_segment = Segment.new(
|
500
522
|
[],
|
501
523
|
@language,
|
502
|
-
|
524
|
+
statement
|
503
525
|
)
|
504
526
|
end
|
505
527
|
end
|
data/lib/decode/language/ruby.rb
CHANGED
data/lib/decode/languages.rb
CHANGED
data/lib/decode/location.rb
CHANGED
data/lib/decode/segment.rb
CHANGED
data/lib/decode/source.rb
CHANGED
data/lib/decode/syntax/link.rb
CHANGED
data/lib/decode/syntax/match.rb
CHANGED
data/lib/decode/trie.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "source"
|
7
7
|
|
@@ -55,11 +55,13 @@ module Decode
|
|
55
55
|
# @parameter node [Node] The current node which is being traversed.
|
56
56
|
# @parameter descend [Proc] The recursive method for traversing children.
|
57
57
|
def traverse(path = [], &block)
|
58
|
-
|
58
|
+
descend = lambda do
|
59
59
|
@children.each do |name, node|
|
60
60
|
node.traverse([*path, name], &block)
|
61
61
|
end
|
62
|
-
|
62
|
+
end
|
63
|
+
|
64
|
+
yield(path, self, descend)
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
data/lib/decode/version.rb
CHANGED
data/license.md
CHANGED
data/readme.md
CHANGED
@@ -10,7 +10,21 @@ As part of my effort to build [better project documentation](https://github.com/
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
Please see the [project documentation](https://ioquatix.github.io/decode/).
|
13
|
+
Please see the [project documentation](https://ioquatix.github.io/decode/) for more details.
|
14
|
+
|
15
|
+
- [Getting Started](https://ioquatix.github.io/decode/guides/getting-started/index) - This guide explains how to use `decode` for source code analysis.
|
16
|
+
|
17
|
+
- [Code Coverage](https://ioquatix.github.io/decode/guides/code-coverage/index) - This guide explains how to compute documentation code coverage.
|
18
|
+
|
19
|
+
- [Extract Symbols](https://ioquatix.github.io/decode/guides/extract-symbols/index) - This example demonstrates how to extract symbols using the index. An instance of <code class="language-ruby">Decode::Index</code> is used for loading symbols from source code files. These symbols are available as a flat list and as a trie structure. You can look up specific symbols using a reference using <code class="language-ruby">Decode::Index\#lookup</code>.
|
20
|
+
|
21
|
+
## Releases
|
22
|
+
|
23
|
+
Please see the [project releases](https://ioquatix.github.io/decode/releases/index) for all releases.
|
24
|
+
|
25
|
+
### v0.23.4
|
26
|
+
|
27
|
+
- Fix handling of definitions nested within `if`/`unless`/`elsif`/`else` blocks.
|
14
28
|
|
15
29
|
## Contributing
|
16
30
|
|
data/releases.md
ADDED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -56,6 +56,7 @@ executables: []
|
|
56
56
|
extensions: []
|
57
57
|
extra_rdoc_files: []
|
58
58
|
files:
|
59
|
+
- agent.md
|
59
60
|
- bake/decode/index.rb
|
60
61
|
- context/coverage.md
|
61
62
|
- context/getting-started.md
|
@@ -107,6 +108,7 @@ files:
|
|
107
108
|
- lib/decode/version.rb
|
108
109
|
- license.md
|
109
110
|
- readme.md
|
111
|
+
- releases.md
|
110
112
|
homepage: https://github.com/ioquatix/decode
|
111
113
|
licenses:
|
112
114
|
- MIT
|
metadata.gz.sig
CHANGED
Binary file
|