ast_transform 1.0.0 → 2.0.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: b792a2cc3409c9ce158a9f663a2850a5bdb80abc644679f37a21898811735e43
4
+ data.tar.gz: 0d8474390beb970135f2672af42ec592e680f20487673bbe02c585e93475ab5c
5
5
  SHA512:
6
- metadata.gz: 76e893ba2f979700b04d05d4a5a2ed45ef61363db6517fc8a191e5b53b932721cf170f6d3d83f6f0ae05da32f1d45f254a451e3b228ffd260efde8dc9f0256b0
7
- data.tar.gz: 61737eb9d28efa2c0ae71be5fd2b95750a97a8c25ec3f116c7643bccdd5c53af8f18a592066fd080196822e09296761ea88f9ad7603b7ea78352ed6e22c9d2cc
6
+ metadata.gz: cc84118cec0034ca2ab7061985a65964467367bb8ee91008773b7cf54c2e48e106ab2789786344637a46db6ecfbd9e633f737d6e089d9435b15f75837d78c43f
7
+ data.tar.gz: 8ba0240933c0e8bb133d5f2bba3abd884ec73476927c913c5434abadfaca1cd1f23c3dc7acbf696c69e3a294b0e354709aa95b9b58f4d3af91e1962440539c60
@@ -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']
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,63 @@
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.0.0)
5
+ parser (>= 3.0)
6
+ unparser (>= 0.6)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- abstract_type (0.0.7)
12
- adamantium (0.2.0)
13
- ice_nine (~> 0.11.0)
14
- memoizable (~> 0.4.0)
15
11
  ansi (1.5.0)
16
- ast (2.4.1)
17
- builder (3.2.4)
18
- byebug (11.1.3)
12
+ ast (2.4.3)
13
+ builder (3.3.0)
19
14
  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)
15
+ diff-lcs (1.6.2)
16
+ docile (1.4.1)
17
+ io-console (0.8.2)
18
+ method_source (1.1.0)
19
+ minitest (5.27.0)
20
+ minitest-reporters (1.7.1)
39
21
  ansi
40
22
  builder
41
23
  minitest (>= 5.0)
42
24
  ruby-progressbar
43
- parser (2.7.1.4)
25
+ parser (3.3.10.2)
44
26
  ast (~> 2.4.1)
45
- procto (0.0.3)
46
- pry (0.13.1)
27
+ racc
28
+ prism (1.9.0)
29
+ pry (0.16.0)
47
30
  coderay (~> 1.1)
48
31
  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)
32
+ reline (>= 0.6.0)
33
+ racc (1.8.1)
34
+ rake (13.3.1)
35
+ reline (0.6.3)
36
+ io-console (~> 0.5)
37
+ ruby-progressbar (1.13.0)
38
+ simplecov (0.22.0)
55
39
  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)
40
+ simplecov-html (~> 0.11)
41
+ simplecov_json_formatter (~> 0.1)
42
+ simplecov-html (0.13.2)
43
+ simplecov_json_formatter (0.1.4)
44
+ unparser (0.8.1)
45
+ diff-lcs (~> 1.6)
46
+ parser (>= 3.3.0)
47
+ prism (>= 1.5.1)
74
48
 
75
49
  PLATFORMS
50
+ arm64-darwin-24
76
51
  ruby
77
52
 
78
53
  DEPENDENCIES
79
54
  ast_transform!
80
- bundler (~> 2.1)
81
- coveralls (~> 0.8)
55
+ bundler (>= 2.1)
82
56
  minitest (~> 5.14)
83
57
  minitest-reporters (~> 1.4)
84
- pry (~> 0.13)
85
- pry-byebug (~> 3.9)
58
+ pry (>= 0.14)
86
59
  rake (~> 13.0)
60
+ simplecov (~> 0.22)
87
61
 
88
62
  BUNDLED WITH
89
- 2.1.4
63
+ 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/main/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,17 @@ 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 "unparser", ">= 0.6"
44
35
  end
@@ -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,3 +1,3 @@
1
1
  module ASTTransform
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.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.0.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,58 @@ dependencies:
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.13'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.13'
83
- - !ruby/object:Gem::Dependency
84
- name: pry-byebug
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
73
+ - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: '3.9'
75
+ version: '0.14'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: '3.9'
82
+ version: '0.14'
97
83
  - !ruby/object:Gem::Dependency
98
- name: coveralls
84
+ name: simplecov
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0.8'
89
+ version: '0.22'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0.8'
96
+ version: '0.22'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: parser
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - "~>"
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: '2.5'
103
+ version: '3.0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - "~>"
108
+ - - ">="
123
109
  - !ruby/object:Gem::Version
124
- version: '2.5'
110
+ version: '3.0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: unparser
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - "~>"
115
+ - - ">="
130
116
  - !ruby/object:Gem::Version
131
- version: '0.4'
117
+ version: '0.6'
132
118
  type: :runtime
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
- - - "~>"
122
+ - - ">="
137
123
  - !ruby/object:Gem::Version
138
- version: '0.4'
124
+ version: '0.6'
139
125
  description: An AST transformation framework.
140
126
  email:
141
127
  - jpduchesne89@gmail.com
@@ -143,8 +129,9 @@ executables: []
143
129
  extensions: []
144
130
  extra_rdoc_files: []
145
131
  files:
132
+ - ".github/workflows/ci.yml"
133
+ - ".github/workflows/release.yml"
146
134
  - ".gitignore"
147
- - ".travis.yml"
148
135
  - CHANGELOG.md
149
136
  - Gemfile
150
137
  - Gemfile.lock
@@ -169,24 +156,23 @@ homepage: https://github.com/rspockframework/ast-transform
169
156
  licenses:
170
157
  - MIT
171
158
  metadata: {}
172
- post_install_message:
159
+ post_install_message:
173
160
  rdoc_options: []
174
161
  require_paths:
175
162
  - lib
176
163
  required_ruby_version: !ruby/object:Gem::Requirement
177
164
  requirements:
178
- - - "~>"
165
+ - - ">="
179
166
  - !ruby/object:Gem::Version
180
- version: '2.5'
167
+ version: '3.2'
181
168
  required_rubygems_version: !ruby/object:Gem::Requirement
182
169
  requirements:
183
170
  - - ">="
184
171
  - !ruby/object:Gem::Version
185
172
  version: '0'
186
173
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.7.7
189
- signing_key:
174
+ rubygems_version: 3.5.22
175
+ signing_key:
190
176
  specification_version: 4
191
177
  summary: An AST transformation framework.
192
178
  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=