ast_transform 2.0.0 → 2.1.1
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
- data/.claude/CLAUDE.md +2 -0
- data/.cursor/rules/base.mdc +35 -0
- data/.cursor/rules/best-practices.mdc +27 -0
- data/.github/workflows/ci.yml +1 -1
- data/Gemfile.lock +2 -1
- data/README.md +1 -1
- data/ast_transform.gemspec +1 -0
- data/lib/ast_transform/source_map.rb +2 -2
- data/lib/ast_transform/transformer.rb +5 -4
- data/lib/ast_transform/version.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc4f949d11b3c6ae864a5c773e6df3f286f88da246499eca57d13069e87c7376
|
|
4
|
+
data.tar.gz: ba829cf5e50d1c23c4fad2aed2dcd0bd5cbb2ffa15bbc4a9aab0d2abbf09df1e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 037e381eade462b8c9259ef14620ca55d1da3576a1028321b698dfa34cafb063fbfb8c41920aa60d56ec793bbe05842309568b5c2282006b2ce7e952bce5f4e7
|
|
7
|
+
data.tar.gz: d4284341fa943f57666c3ca5ace2038708ed1e2e284b26c82b17c241db6b2487b638990f2a55703561f116693438a30ee4f1a556a83f31037ff44e7f5b554a50
|
data/.claude/CLAUDE.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Principal Engineer persona and code guidelines (stack-agnostic)
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
As a Principal Engineer, the highest ranking engineer at our company, you are tasked with creating clear, readable code. You use the latest version of the stack's technologies and follow their best practices and conventions, as well as this repo's and our org's best practices. Follow Shopify-style development philosophy and industry best practices where applicable.
|
|
7
|
+
|
|
8
|
+
When responding to questions, follow the Chain of Thought method. First, outline a detailed plan step by step in great detail, then outline that plan in pseudocode, then confirm it, then write the code, and rewrite the code for concision and readability.
|
|
9
|
+
|
|
10
|
+
You carefully provide accurate, factual, thoughtful answers, and are a genius at reasoning; but you always admit when you don't know the answer.
|
|
11
|
+
|
|
12
|
+
Remember the following important mindset when providing code, in the following order:
|
|
13
|
+
- Adherence to conventions and patterns in the rest of the codebase
|
|
14
|
+
- Simplicity
|
|
15
|
+
- Readability
|
|
16
|
+
- Testability
|
|
17
|
+
- Explicitness
|
|
18
|
+
- Beginner-friendly
|
|
19
|
+
|
|
20
|
+
Adhere to the following guidelines in your code:
|
|
21
|
+
- Follow the user's requirements carefully and to the letter.
|
|
22
|
+
- Fully implement all requested functionality.
|
|
23
|
+
- Leave no TODOs, FIXMEs, placeholders or missing pieces.
|
|
24
|
+
- Always consider the experience of a developer who will be reading your code.
|
|
25
|
+
- Use comments to explain why you are doing something in a certain way, if it is not obvious. If unsure, leave a comment.
|
|
26
|
+
- Employ descriptive, human-readable variable and function/const names.
|
|
27
|
+
- Prefer writing in a functional style where it fits, producing pure functions that do not cause side effects when practical.
|
|
28
|
+
- The codebase is strictly linted; follow the existing code style to ensure consistency.
|
|
29
|
+
- If the generated code would fail a lint check, refactor the code until it no longer fails the lint check.
|
|
30
|
+
- Search hard to find an existing function or pattern in the codebase where possible.
|
|
31
|
+
- Be sure to reference file names when relevant.
|
|
32
|
+
- Be concise. Minimize any prose other than code.
|
|
33
|
+
- If you think there might not be a correct answer, say so. If you do not know the answer, say so instead of guessing.
|
|
34
|
+
- In tests, always avoid mocking the filesystem. Use real files and directories, in temporary directories if needed.
|
|
35
|
+
- In tests, prefer to have as little shared state between tests as possible. Avoid beforeAll and afterAll.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Our best practices (snapshot we own and evolve; often org-wide across repos)
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
# Best practices (d3mlabs snapshot)
|
|
7
|
+
|
|
8
|
+
We own this snapshot and evolve it as the org diverges. In practice these practices are often shared org-wide across repos for consistency.
|
|
9
|
+
|
|
10
|
+
## Priorities
|
|
11
|
+
|
|
12
|
+
- **Conventions over configuration**: Follow existing patterns and tooling before introducing new ones.
|
|
13
|
+
- **Clarity and maintainability**: Code should be easy to read and change; prefer explicit over clever.
|
|
14
|
+
- **Testability**: Design so that behavior can be tested with real inputs and minimal mocks.
|
|
15
|
+
- **Explicitness**: Prefer clear, named steps and obvious control flow over brevity that hides intent.
|
|
16
|
+
|
|
17
|
+
## Code and tests
|
|
18
|
+
|
|
19
|
+
- No TODOs, FIXMEs, or placeholders in committed code; finish or track elsewhere.
|
|
20
|
+
- In tests: use real files and temporary directories; avoid filesystem mocks.
|
|
21
|
+
- Minimal shared state between tests; avoid beforeAll/afterAll and global fixtures.
|
|
22
|
+
- Strict lint and existing code style; refactor until lint passes.
|
|
23
|
+
- Prefer existing helpers and patterns in the codebase; search before adding new abstractions.
|
|
24
|
+
|
|
25
|
+
## Further reading
|
|
26
|
+
|
|
27
|
+
- [Shopify Engineering](https://shopify.engineering) — blog and engineering culture.
|
data/.github/workflows/ci.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[](https://github.com/rspockframework/ast-transform/actions/workflows/ci.yml)
|
|
2
|
-
[](https://codecov.io/gh/rspockframework/ast-transform)
|
|
3
3
|
|
|
4
4
|
# ASTTransform
|
|
5
5
|
|
data/ast_transform.gemspec
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require 'parser
|
|
2
|
+
require 'parser'
|
|
3
3
|
|
|
4
4
|
module ASTTransform
|
|
5
5
|
class SourceMap
|
|
@@ -66,7 +66,7 @@ module ASTTransform
|
|
|
66
66
|
#
|
|
67
67
|
# @return [Integer] The line count.
|
|
68
68
|
def line_count
|
|
69
|
-
@transformed_ranges_ast&.loc&.expression
|
|
69
|
+
@transformed_ranges_ast&.loc&.expression&.last_line || 0
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
private
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require '
|
|
2
|
+
require 'prism'
|
|
3
|
+
require 'prism/translation/parser'
|
|
3
4
|
require 'unparser'
|
|
4
5
|
require 'ast_transform/source_map'
|
|
5
6
|
|
|
@@ -8,8 +9,8 @@ module ASTTransform
|
|
|
8
9
|
# Constructs a new Transformer instance.
|
|
9
10
|
#
|
|
10
11
|
# @param transformations [Array<ASTTransform::AbstractTransformation>] The transformations to be run.
|
|
11
|
-
# @param builder [Parser::
|
|
12
|
-
def initialize(*transformations, builder: Parser::
|
|
12
|
+
# @param builder [Prism::Translation::Parser::Builder] The AST Node builder.
|
|
13
|
+
def initialize(*transformations, builder: Prism::Translation::Parser::Builder.new)
|
|
13
14
|
@transformations = transformations
|
|
14
15
|
@builder = builder
|
|
15
16
|
end
|
|
@@ -99,7 +100,7 @@ module ASTTransform
|
|
|
99
100
|
|
|
100
101
|
def parser
|
|
101
102
|
@parser&.reset
|
|
102
|
-
@parser ||= Parser
|
|
103
|
+
@parser ||= Prism::Translation::Parser.new(@builder)
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
def register_source_map(source_file_path, transformed_file_path, transformed_ast, transformed_source)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ast_transform
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jean-Philippe Duchesne
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '3.0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: prism
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '1.5'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '1.5'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: unparser
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -129,6 +143,9 @@ executables: []
|
|
|
129
143
|
extensions: []
|
|
130
144
|
extra_rdoc_files: []
|
|
131
145
|
files:
|
|
146
|
+
- ".claude/CLAUDE.md"
|
|
147
|
+
- ".cursor/rules/base.mdc"
|
|
148
|
+
- ".cursor/rules/best-practices.mdc"
|
|
132
149
|
- ".github/workflows/ci.yml"
|
|
133
150
|
- ".github/workflows/release.yml"
|
|
134
151
|
- ".gitignore"
|