kanayago 0.6.0 → 0.7.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: 70152c7596a4203fee587c54a35ab9c959346881525adceaff93a00ebc13c8c8
4
- data.tar.gz: c2da754698c773ed1d0e23fa3566c96feb204cf63123d3c561c750ef8c0db75c
3
+ metadata.gz: a8deb4e7508cf59d82a37d9c94bb429b37aaaab9c466b534fc049a69a45ed820
4
+ data.tar.gz: f60b93282c1a18e8c647d60da81eac465ee7f2a1c0059d06a5978c0281ff141e
5
5
  SHA512:
6
- metadata.gz: 497bfbc8020190f5c356728c6f36769978a93a288be653fc929269b619ac1b3e0575b5d3cfeda9f9fe750c0b59edd4a21e86c9ffe1b89fca1847f55b38e28ec4
7
- data.tar.gz: 368c35402d3575d61c81893b834866d96ccd8c99162193ae212636984b049f8ab443e6a639a0e9d160a58083514477babf0d334f4f08a134569f531343eae1fc
6
+ metadata.gz: 70ae466e835ed7cabd422aebcdad09afc4d16238a4f26ca415f24780e8e31dfbc1e3c00cec50f25ae68da432b9604a933d75d0508d8b6dd472f6b4403b04d630
7
+ data.tar.gz: a271a9cc5175ea5774db57c634fab8b8c8587041a8c3faf2b76d7cd0221c76c2a2b3fea74ab275c1992f5e84de3c02269a717afe952f4f8ae296f00f71eed82a
data/.rubocop.yml CHANGED
@@ -20,7 +20,7 @@ RBS:
20
20
  Style/Documentation:
21
21
  Enabled: false
22
22
 
23
- require:
23
+ plugins:
24
24
  - rubocop-minitest
25
25
  - rubocop-on-rbs
26
26
  - rubocop-rake
data/.rubocop_todo.yml CHANGED
@@ -1,23 +1,34 @@
1
- # Offense count: 4
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-12-18 13:44:08 UTC using RuboCop version 1.81.7.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: DebuggerMethods, DebuggerRequires.
11
+ Lint/Debugger:
12
+ Exclude:
13
+ - 'test.rb'
14
+
15
+ # Offense count: 8
2
16
  # Configuration parameters: CountComments, CountAsOne.
3
17
  Metrics/ClassLength:
4
- Max: 318
18
+ Max: 179
5
19
 
6
- # Offense count: 40
20
+ # Offense count: 80
7
21
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
8
22
  Metrics/MethodLength:
9
- Max: 49
23
+ Max: 42
10
24
 
11
- # Offense count: 2
12
- # Configuration parameters: AllowedConstants.
13
- Style/Documentation:
14
- Exclude:
15
- - 'spec/**/*'
16
- - 'test/**/*'
25
+ # Offense count: 1
26
+ # Configuration parameters: CountComments, CountAsOne.
27
+ Metrics/ModuleLength:
28
+ Max: 105
17
29
 
18
30
  # Offense count: 4
19
31
  # Configuration parameters: AllowedVariables.
20
32
  Style/GlobalVars:
21
33
  Exclude:
22
34
  - 'ext/kanayago/extconf.rb'
23
-
data/CHANGELOG.md CHANGED
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.0] - 2026-01-01
11
+
12
+ ### Fixed
13
+ - Fix segmentation fault on macOS caused by unexported Ruby C APIs
14
+ - Several Ruby C APIs (`rb_reg_compile`, `rb_enc_literal_str`, etc.) are not exported on macOS
15
+ - Add macOS-specific patch (`patch/head/macos.patch`) that replaces unexported APIs with compatible public APIs
16
+ - Use own parser config in `kanayago.c` to avoid unexported APIs
17
+
18
+ ### Added
19
+ - Add support Ruby 4.0.0
20
+ - Add macOS support
21
+ - Add macOS CI workflow (`.github/workflows/macos.yml`)
22
+ - Add `apply_macos_patch` function in `script/setup_parser.rb`
23
+ - Add support for each Ruby 3.4.x patch versions (3.4.0 - 3.4.8)
24
+ - Add individual patch files and `copy_target.rb` for each version
25
+ - Update Ubuntu CI to test multiple Ruby versions
26
+ - Add integration tests for parsing real-world Rails codebases
27
+ - Add `test/integration/rails_parsing_test.rb` for testing Rails, Discourse, Mastodon, and GitLab codebases
28
+ - Add `rake integration:setup` task to automatically clone test repositories
29
+ - Add `rake integration:test` task to run integration tests
30
+ - Add `rake integration:clean` task to remove cloned repositories
31
+ - Add `rake integration:update` task to update cloned repositories
32
+ - Integration tests verify 99.67% parse success rate across 24,000+ Ruby files
33
+ - Regular unit tests now exclude integration tests for faster execution
34
+
35
+ ## [0.6.1]
36
+
37
+ ### Fixed
38
+ - Fix segmentation fault when parsing large Ruby files (e.g., Rails schema.rb)
39
+ - Add `RB_GC_GUARD` for `vast` and `vparser` to prevent garbage collection during AST traversal
40
+ - The AST data is owned by `vast`, so it must remain alive until traversal is complete
41
+
10
42
  ## [0.6.0]
11
43
 
12
44
  ### Added
data/README.md CHANGED
@@ -31,11 +31,38 @@ Finally, build `Kanayago` gem and install it.
31
31
 
32
32
  ```console
33
33
  bundle exec rake build
34
- gem install pkg/kanayago-0.6.0.gem
34
+ gem install pkg/kanayago-0.6.1.gem
35
35
  ```
36
36
 
37
37
  ## Usage
38
38
 
39
+ ### Ruby API
40
+
41
+ ```ruby
42
+ require 'kanayago/kanayago'
43
+
44
+ result = Kanayago.parse('117 + 117')
45
+ # => #<Kanayago::ParseResult:0x00007f522199c5a8>
46
+
47
+ p result.ast
48
+ # => #<Kanayago::ScopeNode:0x00007f522199c5a8>
49
+
50
+ p result.ast.body
51
+ # => #<Kanayago::OperatorCallNode:0x00007f5221b06358>
52
+
53
+ p result.ast.body.recv
54
+ p result.ast.body.recv.val
55
+ # => #<Kanayago::IntegerNode:0x00007f5221b06330>
56
+ # => 117
57
+
58
+ # Check for syntax errors
59
+ result = Kanayago.parse('def foo')
60
+ p result.valid?
61
+ # => false
62
+ p result.error
63
+ # => #<SyntaxError: syntax error, unexpected end-of-input>
64
+ ```
65
+
39
66
  ### Language Server Protocol (LSP) Mode
40
67
 
41
68
  Kanayago provides LSP server support for real-time syntax checking in your editor:
@@ -216,38 +243,30 @@ Syntax valid
216
243
 
217
244
  The CLI exits with code 0 for valid syntax and code 1 for invalid syntax or errors.
218
245
 
219
- ### Ruby API
220
-
221
- ```ruby
222
- require 'kanayago/kanayago'
246
+ ## Development
223
247
 
224
- result = Kanayago.parse('117 + 117')
225
- # => #<Kanayago::ParseResult:0x00007f522199c5a8>
248
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
226
249
 
227
- p result.ast
228
- # => #<Kanayago::ScopeNode:0x00007f522199c5a8>
250
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
229
251
 
230
- p result.ast.body
231
- # => #<Kanayago::OperatorCallNode:0x00007f5221b06358>
252
+ ### Running Tests
232
253
 
233
- p result.ast.body.recv
234
- p result.ast.body.recv.val
235
- # => #<Kanayago::IntegerNode:0x00007f5221b06330>
236
- # => 117
254
+ ```bash
255
+ # Run unit tests (excludes integration tests)
256
+ bundle exec rake test
237
257
 
238
- # Check for syntax errors
239
- result = Kanayago.parse('def foo')
240
- p result.valid?
241
- # => false
242
- p result.error
243
- # => #<SyntaxError: syntax error, unexpected end-of-input>
244
- ```
258
+ # Run integration tests (requires repository setup)
259
+ bundle exec rake integration:setup # Clone test repositories (Rails, Discourse, Mastodon, GitLab)
260
+ bundle exec rake integration:test # Run integration tests
245
261
 
246
- ## Development
262
+ # Clean up cloned repositories
263
+ bundle exec rake integration:clean
247
264
 
248
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
265
+ # Update cloned repositories to latest
266
+ bundle exec rake integration:update
267
+ ```
249
268
 
250
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
269
+ The integration tests verify that Kanayago can successfully parse real-world Rails codebases including Rails itself, Discourse, Mastodon, and GitLab. These tests help ensure compatibility with production Ruby code patterns.
251
270
 
252
271
  ## Contributing
253
272
 
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'English'
3
4
  require 'bundler/gem_tasks'
4
5
  require 'rake/extensiontask'
5
6
  require 'rake/testtask'
@@ -10,7 +11,7 @@ require 'fileutils'
10
11
  if RUBY_DESCRIPTION.include?('dev')
11
12
  require_relative 'patch/head/copy_target'
12
13
  else
13
- require_relative "patch/#{RUBY_VERSION[0..2]}/copy_target"
14
+ require_relative "patch/#{RUBY_VERSION}/copy_target"
14
15
  end
15
16
 
16
17
  namespace :ruby_parser do
@@ -58,7 +59,101 @@ end
58
59
  Rake::TestTask.new(:test) do |t|
59
60
  t.libs << 'test'
60
61
  t.libs << 'lib'
61
- t.test_files = FileList['test/**/*_test.rb']
62
+ t.test_files = FileList['test/**/*_test.rb'].exclude('test/integration/**/*_test.rb')
63
+ end
64
+
65
+ INTEGRATION_TEST_TARGET_REPOS_DIR = File.expand_path('tmp/integration_repos', __dir__)
66
+ INTEGRATION_TEST_TARGET_REPOSITORIES = {
67
+ 'rails' => {
68
+ url: 'https://github.com/rails/rails.git',
69
+ branch: 'main',
70
+ depth: 1
71
+ },
72
+ 'discourse' => {
73
+ url: 'https://github.com/discourse/discourse.git',
74
+ branch: 'main',
75
+ depth: 1
76
+ },
77
+ 'mastodon' => {
78
+ url: 'https://github.com/mastodon/mastodon.git',
79
+ branch: 'main',
80
+ depth: 1
81
+ },
82
+ 'gitlab' => {
83
+ url: 'https://gitlab.com/gitlab-org/gitlab.git',
84
+ branch: 'master',
85
+ depth: 1
86
+ }
87
+ }.freeze
88
+
89
+ namespace :integration do
90
+ desc 'Setup integration test repositories'
91
+ task :setup do
92
+ FileUtils.mkdir_p(INTEGRATION_TEST_TARGET_REPOS_DIR)
93
+
94
+ INTEGRATION_TEST_TARGET_REPOSITORIES.each do |name, config|
95
+ repo_path = File.join(INTEGRATION_TEST_TARGET_REPOS_DIR, name)
96
+
97
+ if File.directory?(repo_path)
98
+ puts "Repository #{name} already exists at #{repo_path}"
99
+ next
100
+ end
101
+
102
+ puts "Cloning #{name} from #{config[:url]}..."
103
+ system("git clone --depth #{config[:depth]} --branch #{config[:branch]} #{config[:url]} #{repo_path}")
104
+
105
+ if $CHILD_STATUS.success?
106
+ puts "Successfully cloned #{name}"
107
+ else
108
+ puts "Failed to clone #{name}"
109
+ end
110
+ end
111
+
112
+ puts "\nIntegration test repositories setup complete!"
113
+ end
114
+
115
+ desc 'Clean integration test repositories'
116
+ task :clean do
117
+ if File.directory?(INTEGRATION_TEST_TARGET_REPOS_DIR)
118
+ puts "Removing integration test repositories at #{INTEGRATION_TEST_TARGET_REPOS_DIR}..."
119
+ FileUtils.rm_rf(INTEGRATION_TEST_TARGET_REPOS_DIR)
120
+ puts 'Done!'
121
+ else
122
+ puts 'No integration test repositories found'
123
+ end
124
+ end
125
+
126
+ desc 'Update integration test repositories'
127
+ task :update do
128
+ unless File.directory?(INTEGRATION_TEST_TARGET_REPOS_DIR)
129
+ puts "No repositories found. Run 'rake integration:setup' first."
130
+ next
131
+ end
132
+
133
+ INTEGRATION_TEST_TARGET_REPOSITORIES.each_key do |name|
134
+ repo_path = File.join(INTEGRATION_TEST_TARGET_REPOS_DIR, name)
135
+
136
+ unless File.directory?(repo_path)
137
+ puts "Repository #{name} not found, skipping..."
138
+ next
139
+ end
140
+
141
+ puts "Updating #{name}..."
142
+ Dir.chdir(repo_path) do
143
+ system('git pull')
144
+ end
145
+ end
146
+
147
+ puts "\nIntegration test repositories updated!"
148
+ end
149
+
150
+ desc 'Run integration tests'
151
+ Rake::TestTask.new(:test) do |t|
152
+ t.libs << 'test'
153
+ t.libs << 'lib'
154
+ t.test_files = FileList['test/integration/**/*_test.rb']
155
+ t.verbose = true
156
+ end
62
157
  end
63
158
 
64
159
  namespace :sample do