Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tree_stump

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree_stump

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

TreeStump

RSpec

tree-sitter binding for Ruby written by Rust.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add tree_stump

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install tree_stump

Usage

require "tree_stump"
require "rouge"

TreeStump.register_lang("ruby", "./libtree-sitter-ruby.so")

parser = TreeStump::Parser.new
parser.set_language("ruby")

source = File.read("./sample.rb")

formatter = Rouge::Formatters::Terminal256.new
lexer = Rouge::Lexers::Ruby.new

puts "== Source =="
puts formatter.format(lexer.lex(source))

puts "\n"

puts "==  Tree  =="
tree = parser.parse(source)

puts tree.root_node.to_sexp
(program (class name: (constant) superclass: (superclass (constant)) body: (body_statement (call method: (identifier) arguments: (argument_list (simple_symbol) (pair key: (hash_key_symbol) value: (true)))) (singleton_method object: (self) name: (identifier) parameters: (method_parameters (identifier)) body: (body_statement (call receiver: (constant) method: (identifier) arguments: (argument_list (pair key: (hash_key_symbol) value: (identifier)))))))) (call receiver: (constant) method: (identifier) arguments: (argument_list (string (string_content)))))

Development

Requirements

  • Rust Toolchain
  • tree-sitter-ruby
  1. Download source of tree-sitter-ruby from GitHub Repository.
  2. Extract tree-sitter-ruby source
  3. mv tree-sitter-ruby-v{version_num} to tree_stump/tree-sitter-ruby
  4. Execute make in tree-sitter-ruby directory

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/joker1007/tree_stump.

FAQs

Package last updated on 03 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc