ast_transform 1.0.0 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f056c80996873150457b81b9e56d21764ea29dccfaf3b1bb61624202ae08f82
4
- data.tar.gz: 82e2697b952bea94b22d3537f06f0985dd1f28811926768471a63c7055b8e1b5
3
+ metadata.gz: 11aae5afaee14319577bb90868a9409f8b6eb7525731fcc9c61e64b7d638d5ff
4
+ data.tar.gz: de05ce9d6d76f090dbe4530976b8614269084c8ea5196a6bc648a56b0e2280b9
5
5
  SHA512:
6
- metadata.gz: 76e893ba2f979700b04d05d4a5a2ed45ef61363db6517fc8a191e5b53b932721cf170f6d3d83f6f0ae05da32f1d45f254a451e3b228ffd260efde8dc9f0256b0
7
- data.tar.gz: 61737eb9d28efa2c0ae71be5fd2b95750a97a8c25ec3f116c7643bccdd5c53af8f18a592066fd080196822e09296761ea88f9ad7603b7ea78352ed6e22c9d2cc
6
+ metadata.gz: e60d5134197b6ce4c4c84bebb7d095c84dc7a369ec0d08d44a429a1b6e3df2e79895023f5780867896534808bcf1ffddba563d30751e92074f26acd7a2c40e4e
7
+ data.tar.gz: 1d5ecf0ecaeab6b12ff8ffae425711d187693261c747bb1da2e0672b9ad0b12515318c7e3237b01b6efa4580f4d61d4acba046b2e538f7176a70fe88b9883dc1
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ['3.2', '3.3', '4.0']
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache: true
22
+ - run: bundle exec rake test
23
+ - name: Upload coverage to Codecov
24
+ if: matrix.ruby == '3.3'
25
+ uses: codecov/codecov-action@v5
26
+ with:
27
+ token: ${{ secrets.CODECOV_TOKEN }}
28
+ files: coverage/coverage.json
29
+ fail_ci_if_error: false
@@ -0,0 +1,30 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ['v*']
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ id-token: write
12
+ contents: read
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: '3.3'
18
+ - name: Verify version matches tag
19
+ run: |
20
+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
21
+ GEM_VERSION=$(ruby -e "require './lib/ast_transform/version'; puts ASTTransform::VERSION")
22
+ if [ "$TAG_VERSION" != "$GEM_VERSION" ]; then
23
+ echo "::error::Tag ($TAG_VERSION) does not match gem version ($GEM_VERSION)"
24
+ exit 1
25
+ fi
26
+ - uses: rubygems/configure-rubygems-credentials@main
27
+ - name: Build and publish gem
28
+ run: |
29
+ gem build ast_transform.gemspec
30
+ gem push ast_transform-*.gem
data/Gemfile.lock CHANGED
@@ -1,89 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ast_transform (1.0.0)
5
- parser (~> 2.5)
6
- unparser (~> 0.4)
4
+ ast_transform (2.1.0)
5
+ parser (>= 3.0)
6
+ prism (>= 1.5)
7
+ unparser (>= 0.6)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- abstract_type (0.0.7)
12
- adamantium (0.2.0)
13
- ice_nine (~> 0.11.0)
14
- memoizable (~> 0.4.0)
15
12
  ansi (1.5.0)
16
- ast (2.4.1)
17
- builder (3.2.4)
18
- byebug (11.1.3)
13
+ ast (2.4.3)
14
+ builder (3.3.0)
19
15
  coderay (1.1.3)
20
- concord (0.1.5)
21
- adamantium (~> 0.2.0)
22
- equalizer (~> 0.0.9)
23
- coveralls (0.8.23)
24
- json (>= 1.8, < 3)
25
- simplecov (~> 0.16.1)
26
- term-ansicolor (~> 1.3)
27
- thor (>= 0.19.4, < 2.0)
28
- tins (~> 1.6)
29
- diff-lcs (1.4.4)
30
- docile (1.3.2)
31
- equalizer (0.0.11)
32
- ice_nine (0.11.2)
33
- json (2.3.1)
34
- memoizable (0.4.2)
35
- thread_safe (~> 0.3, >= 0.3.1)
36
- method_source (1.0.0)
37
- minitest (5.14.1)
38
- minitest-reporters (1.4.2)
16
+ diff-lcs (1.6.2)
17
+ docile (1.4.1)
18
+ io-console (0.8.2)
19
+ method_source (1.1.0)
20
+ minitest (5.27.0)
21
+ minitest-reporters (1.7.1)
39
22
  ansi
40
23
  builder
41
24
  minitest (>= 5.0)
42
25
  ruby-progressbar
43
- parser (2.7.1.4)
26
+ parser (3.3.10.2)
44
27
  ast (~> 2.4.1)
45
- procto (0.0.3)
46
- pry (0.13.1)
28
+ racc
29
+ prism (1.9.0)
30
+ pry (0.16.0)
47
31
  coderay (~> 1.1)
48
32
  method_source (~> 1.0)
49
- pry-byebug (3.9.0)
50
- byebug (~> 11.0)
51
- pry (~> 0.13.0)
52
- rake (13.0.1)
53
- ruby-progressbar (1.10.1)
54
- simplecov (0.16.1)
33
+ reline (>= 0.6.0)
34
+ racc (1.8.1)
35
+ rake (13.3.1)
36
+ reline (0.6.3)
37
+ io-console (~> 0.5)
38
+ ruby-progressbar (1.13.0)
39
+ simplecov (0.22.0)
55
40
  docile (~> 1.1)
56
- json (>= 1.8, < 3)
57
- simplecov-html (~> 0.10.0)
58
- simplecov-html (0.10.2)
59
- sync (0.5.0)
60
- term-ansicolor (1.7.1)
61
- tins (~> 1.0)
62
- thor (1.0.1)
63
- thread_safe (0.3.6)
64
- tins (1.25.0)
65
- sync
66
- unparser (0.4.7)
67
- abstract_type (~> 0.0.7)
68
- adamantium (~> 0.2.0)
69
- concord (~> 0.1.5)
70
- diff-lcs (~> 1.3)
71
- equalizer (~> 0.0.9)
72
- parser (>= 2.6.5)
73
- procto (~> 0.0.2)
41
+ simplecov-html (~> 0.11)
42
+ simplecov_json_formatter (~> 0.1)
43
+ simplecov-html (0.13.2)
44
+ simplecov_json_formatter (0.1.4)
45
+ unparser (0.8.1)
46
+ diff-lcs (~> 1.6)
47
+ parser (>= 3.3.0)
48
+ prism (>= 1.5.1)
74
49
 
75
50
  PLATFORMS
51
+ arm64-darwin-24
76
52
  ruby
77
53
 
78
54
  DEPENDENCIES
79
55
  ast_transform!
80
- bundler (~> 2.1)
81
- coveralls (~> 0.8)
56
+ bundler (>= 2.1)
82
57
  minitest (~> 5.14)
83
58
  minitest-reporters (~> 1.4)
84
- pry (~> 0.13)
85
- pry-byebug (~> 3.9)
59
+ pry (>= 0.14)
86
60
  rake (~> 13.0)
61
+ simplecov (~> 0.22)
87
62
 
88
63
  BUNDLED WITH
89
- 2.1.4
64
+ 2.5.22
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Build Status](https://travis-ci.org/rspockframework/ast-transform.svg?branch=master)](https://travis-ci.org/rspockframework/ast-transform)
2
- [![Coverage Status](https://coveralls.io/repos/github/rspockframework/ast-transform/badge.svg?branch=master)](https://coveralls.io/github/rspockframework/ast-transform?branch=master)
1
+ [![CI](https://github.com/rspockframework/ast-transform/actions/workflows/ci.yml/badge.svg)](https://github.com/rspockframework/ast-transform/actions/workflows/ci.yml)
2
+ [![codecov](https://codecov.io/gh/rspockframework/ast-transform/branch/master/graph/badge.svg)](https://codecov.io/gh/rspockframework/ast-transform)
3
3
 
4
4
  # ASTTransform
5
5
 
@@ -183,4 +183,32 @@ end
183
183
 
184
184
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
185
185
 
186
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
186
+ To install this gem onto your local machine, run `bundle exec rake install`.
187
+
188
+ ## Releasing a New Version
189
+
190
+ There are two ways to create a release. Both require that `version.rb` has already been updated and merged to main.
191
+
192
+ ### Via GitHub UI
193
+
194
+ 1. Update `VERSION` in `lib/ast_transform/version.rb`, commit, open a PR, and merge to main
195
+ 2. Go to the repo on GitHub → **Releases** → **Draft a new release**
196
+ 3. Enter a new tag (e.g. `v2.0.0`), select `main` as the target branch
197
+ 4. Add a title and release notes (GitHub can auto-generate these from merged PRs)
198
+ 5. Click **Publish release**
199
+
200
+ ### Via CLI
201
+
202
+ 1. Update `VERSION` in `lib/ast_transform/version.rb`, commit, open a PR, and merge to main
203
+ 2. Tag and push:
204
+ ```
205
+ git checkout main && git pull
206
+ git tag v2.0.0
207
+ git push origin v2.0.0
208
+ ```
209
+
210
+ In both cases, the [release workflow](.github/workflows/release.yml) validates that the tag matches `version.rb`, builds the gem, and publishes it to [rubygems.org](https://rubygems.org) via [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) (no API key needed). If there's a mismatch, the workflow fails before publishing.
211
+
212
+ ### One-time setup
213
+
214
+ Configure the gem as a trusted publisher on rubygems.org so that the release workflow can publish automatically. See the [Trusted Publishing guide](https://guides.rubygems.org/trusted-publishing/pushing-a-new-gem-with-a-trusted-publisher/) for details.
@@ -19,26 +19,18 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = "exe"
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
- spec.required_ruby_version = '~> 2.5'
23
-
24
- if ENV['TRAVIS']
25
- if ENV['TRAVIS_TAG'].nil? || ENV['TRAVIS_TAG'].empty?
26
- spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}"
27
- elsif ENV['TRAVIS_TAG'] != spec.version.to_s
28
- raise "Tag name (#{ENV['TRAVIS_TAG']}) and Gem version (#{spec.version}) are different"
29
- end
30
- end
22
+ spec.required_ruby_version = '>= 3.2'
31
23
 
32
24
  # Development dependencies
33
- spec.add_development_dependency "bundler", "~> 2.1"
25
+ spec.add_development_dependency "bundler", ">= 2.1"
34
26
  spec.add_development_dependency "rake", "~> 13.0"
35
27
  spec.add_development_dependency "minitest", "~> 5.14"
36
28
  spec.add_development_dependency "minitest-reporters", "~> 1.4"
37
- spec.add_development_dependency "pry", "~> 0.13"
38
- spec.add_development_dependency "pry-byebug", "~> 3.9"
39
- spec.add_development_dependency "coveralls", "~> 0.8"
29
+ spec.add_development_dependency "pry", ">= 0.14"
30
+ spec.add_development_dependency "simplecov", "~> 0.22"
40
31
 
41
32
  # Runtime dependencies
42
- spec.add_runtime_dependency "parser", "~> 2.5"
43
- spec.add_runtime_dependency "unparser", "~> 0.4"
33
+ spec.add_runtime_dependency "parser", ">= 3.0"
34
+ spec.add_runtime_dependency "prism", ">= 1.5"
35
+ spec.add_runtime_dependency "unparser", ">= 0.6"
44
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'parser/current'
2
+ require 'parser'
3
3
 
4
4
  module ASTTransform
5
5
  class SourceMap
@@ -16,11 +16,19 @@ module ASTTransform
16
16
  process_node_helper(child_node, previous_sibling)
17
17
  end
18
18
 
19
+ count_before_reject = children.size
20
+
19
21
  children.reject!.with_index { |child_node, index|
20
22
  transform_node?(child_node) && transformable_node?(next_child(node, index))
21
23
  }
22
24
 
23
- node.updated(nil, process_all(children))
25
+ processed = process_all(children)
26
+
27
+ if node.type == :begin && processed.size == 1 && children.size < count_before_reject
28
+ processed.first
29
+ else
30
+ node.updated(nil, processed)
31
+ end
24
32
  end
25
33
 
26
34
  def previous_child(node, index)
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'parser/current'
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::Builders::Default] The AST Node builder.
12
- def initialize(*transformations, builder: Parser::Builders::Default.new)
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::CurrentRuby.new(@builder)
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)
@@ -1,3 +1,3 @@
1
1
  module ASTTransform
2
- VERSION = "1.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ast_transform
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Philippe Duchesne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-09 00:00:00.000000000 Z
11
+ date: 2026-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
@@ -70,72 +70,72 @@ dependencies:
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0.13'
75
+ version: '0.14'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0.13'
82
+ version: '0.14'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry-byebug
84
+ name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.9'
89
+ version: '0.22'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.9'
96
+ version: '0.22'
97
97
  - !ruby/object:Gem::Dependency
98
- name: coveralls
98
+ name: parser
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '0.8'
104
- type: :development
103
+ version: '3.0'
104
+ type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '0.8'
110
+ version: '3.0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: parser
112
+ name: prism
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '2.5'
117
+ version: '1.5'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '2.5'
124
+ version: '1.5'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: unparser
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '0.4'
131
+ version: '0.6'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '0.4'
138
+ version: '0.6'
139
139
  description: An AST transformation framework.
140
140
  email:
141
141
  - jpduchesne89@gmail.com
@@ -143,8 +143,9 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
+ - ".github/workflows/ci.yml"
147
+ - ".github/workflows/release.yml"
146
148
  - ".gitignore"
147
- - ".travis.yml"
148
149
  - CHANGELOG.md
149
150
  - Gemfile
150
151
  - Gemfile.lock
@@ -169,24 +170,23 @@ homepage: https://github.com/rspockframework/ast-transform
169
170
  licenses:
170
171
  - MIT
171
172
  metadata: {}
172
- post_install_message:
173
+ post_install_message:
173
174
  rdoc_options: []
174
175
  require_paths:
175
176
  - lib
176
177
  required_ruby_version: !ruby/object:Gem::Requirement
177
178
  requirements:
178
- - - "~>"
179
+ - - ">="
179
180
  - !ruby/object:Gem::Version
180
- version: '2.5'
181
+ version: '3.2'
181
182
  required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  requirements:
183
184
  - - ">="
184
185
  - !ruby/object:Gem::Version
185
186
  version: '0'
186
187
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.7.7
189
- signing_key:
188
+ rubygems_version: 3.5.22
189
+ signing_key:
190
190
  specification_version: 4
191
191
  summary: An AST transformation framework.
192
192
  test_files: []
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.5
5
- - 2.6
6
- - 2.7
7
-
8
- install: ./bin/setup
9
-
10
- jobs:
11
- include:
12
- - stage: deploy
13
- rvm: 2.7
14
- install: ./bin/setup
15
- script:
16
- - echo Deploy
17
- - echo $TRAVIS_PULL_REQUEST
18
- - echo $TRAVIS_BRANCH
19
- - echo $TRAVIS_TAG
20
- deploy:
21
- provider: rubygems
22
- gemspec: ast_transform.gemspec
23
- gem: ast_transform
24
- on:
25
- all_branches: true
26
- condition: '"$TRAVIS_PULL_REQUEST" = "false" && ( "$TRAVIS_BRANCH" = "master" || "$TRAVIS_BRANCH" = "$TRAVIS_TAG" )'
27
- api_key:
28
- secure: a+D7+wUWmgdk39C+oDFAqjLDAE9s8uaN08xPgf0/IaxFy3PGeuxKSi+3ZFaB0f6zI203mMe7m0sNVD77PxyPqKToKal5K9240+m9yZGoS4seMOJExcBmhiMXk8KOj9upw5Fk0PY91LY5lU13m6u40MtHT9r8da8AysO21PGhkrDkYZNGZ/0nCpV3hnux6DOlNguUhHuuKIKCY6xN9tldwUhVZJvDjSKLe0aRMbP0PZhM3JzMz9BfosirkdE9u666ryI5kIFfHgzDCekiU1sbEugOKyHyu90kaVhgRAXA81LHirj6U9pA0cfJOq84EAE2di6A0xswlbM8GBXdJpRIh706A6sZ7ByYG2SlxyF9vHogqhpg8aU5IMk+sNbrg6++qyTW8zSTksoJN/kMAHcEvMloK4Ja2rRPqhIJkawcQRd5unxHnt4jc6ED2ryDbXhAaBWX4G80jpg5lSeHIQH/S9v+PWcG9UB8Rv08oiJadEid+26r4rWsRA0f/hBP6K+KMq3rACa2Xapgo9ZbSE4xBBu+Yc+4ooiKQ42y+10A5TlTI6iSxKUDcmbH/qVZIchzlDv4MFYoE50BHVn9p0J6dbf8q+WQXsRi1ojEcVy95hd00wdmeMGItE7VuW8zDObJ5W8LNaKuKD358o+4v5CrammfNNz/MynRXhfmPCwyy8s=