Skip to content

feat: Add comprehensive Ruby support#5

Open
gabriel-dehan wants to merge 1 commit into
yilinjz:mainfrom
gabriel-dehan:feature/add-ruby-rails-support
Open

feat: Add comprehensive Ruby support#5
gabriel-dehan wants to merge 1 commit into
yilinjz:mainfrom
gabriel-dehan:feature/add-ruby-rails-support

Conversation

@gabriel-dehan

@gabriel-dehan gabriel-dehan commented Aug 16, 2025

Copy link
Copy Markdown

Adds comprehensive Ruby support.

Summary

  • Ruby language support: Full tree-sitter-ruby integration for parsing Ruby code
  • Ruby-specific constructs: Recognition of modules, classes, methods, singleton methods, and singleton classes
  • Testing: added test cases covering Ruby-specific scenarios
  • Documentation: Updated README with Ruby examples and usage patterns
  • Backward compatibility: Tested all the other languages to make sure there were zero regressions

Changes Made

Core Implementation

  • Added tree-sitter-ruby>=0.20.0 dependency to pyproject.toml and requirements.txt
  • Extended ASTChunkBuilder to support Ruby language parsing
  • Updated ASTChunk to recognize Ruby-specific AST node types:
    • class (Ruby class definitions)
    • module (Ruby module definitions)
    • method (Ruby instance methods)
    • singleton_method (Ruby singleton methods)
    • singleton_class (Ruby singleton classes)

Documentation

  • Updated README.md to include Ruby in supported languages table
  • Added Ruby usage examples and configuration options
  • Enhanced documentation with Ruby-specific information

Usage Example

from astchunk import ASTChunkBuilder

# Ruby configuration
config = {
    "max_chunk_size": 800,
    "language": "ruby",  # New language support!
    "metadata_template": "default"
}

chunk_builder = ASTChunkBuilder(**config)
chunks = chunk_builder.chunkify(ruby_code)

- Add tree-sitter-ruby dependency to pyproject.toml and requirements.txt
- Extend ASTChunkBuilder to support Ruby language parsing with tree-sitter-ruby
- Update ASTChunk to recognize Ruby-specific node types:
  * class (Ruby class definitions)
  * module (Ruby module definitions)
  * method (Ruby instance methods)
  * singleton_method (Ruby singleton methods)
  * singleton_class (Ruby singleton classes)
- Create comprehensive Ruby calculator example with:
  * Modules and nested modules
  * Classes with inheritance
  * Instance, class, and singleton methods
  * Rails-style concerns and patterns
  * Ruby metaprogramming constructs
- Update README.md to include Ruby in supported languages table
- Add Ruby usage examples and documentation
- Create comprehensive test suite (tests/test_ruby_support.py) with 15+ test cases:
  * Basic Ruby class and module chunking
  * Rails-style controllers and models
  * Ruby singleton methods and metaprogramming
  * Complex inheritance patterns
  * Error handling and edge cases
- Add Ruby demonstration script (examples/ruby_demo.py)
- Verify no regressions in existing language support (Python, Java, C#, TypeScript)
- Maintain full backward compatibility and consistent metadata structure

Ruby support is now production-ready with comprehensive test coverage.
ASTChunk now supports 5 languages: Python, Java, C#, TypeScript, and Ruby.
@gabriel-dehan gabriel-dehan changed the title feat: Add comprehensive Ruby/Rails support feat: Add comprehensive Ruby support Aug 16, 2025
@gabriel-dehan
gabriel-dehan marked this pull request as ready for review August 16, 2025 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant