0.0
No commit activity in last 3 years
No release in over 3 years
RipperTree is like tree command for Ripper#sexp.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0
~> 3.0

Runtime

 Project Readme

RipperTree

Build Status

RipperTree is like tree command for Ripper#sexp.

Installation

$ gem install ripper_tree

Usage

You can use rtree command.

sample.rb

1 + 1

exec rtree command.

$ rtree sample.rb

result

:program
 └──── :binary
         ├──── :@int ["1"] 1:0
         ├──── :+
         └──── :@int ["1"] 1:4

if use in ruby code.

require 'ripper_tree'
require 'pp'

code =<<-CODE
puts "hello world"
CODE

pp Ripper.sexp(code)
puts
puts RipperTree.create(code)

result

[:program,
 [[:command,
   [:@ident, "puts", [1, 0]],
   [:args_add_block,
    [[:string_literal,
      [:string_content, [:@tstring_content, "hello world", [1, 6]]]]],
    false]]]]

:program
 └──── :command
         ├──── :@ident ["puts"] 1:0
         └──── :args_add_block
                 ├──── :string_literal
                        └──── :string_content
                                └──── :@tstring_content ["hello world"] 1:6
                 └──── false

and can use -e "command" option

$ rtree -e "1+2*3"

result

:program
 └──── :binary
         ├──── :@int ["1"] 1:0
         ├──── :+
         └──── :binary
                 ├──── :@int ["2"] 1:2
                 ├──── :*
                 └──── :@int ["3"] 1:4

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/siman-man/ripper_tree. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.