https://github.com/siman-man/ripper_tree
RipperTree is like tree command for Ripper#sexp.
https://github.com/siman-man/ripper_tree
gem ruby
Last synced: 10 months ago
JSON representation
RipperTree is like tree command for Ripper#sexp.
- Host: GitHub
- URL: https://github.com/siman-man/ripper_tree
- Owner: siman-man
- License: mit
- Created: 2017-02-20T11:58:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-26T14:07:07.000Z (over 9 years ago)
- Last Synced: 2024-08-30T16:19:16.018Z (almost 2 years ago)
- Topics: gem, ruby
- Language: Ruby
- Homepage:
- Size: 21.5 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# RipperTree
[](https://travis-ci.org/siman-man/ripper_tree)
RipperTree is like `tree` command for Ripper#sexp.
## Installation
```
$ gem install ripper_tree
```
## Usage
You can use `rtree` command.
sample.rb
```ruby
1 + 1
```
exec `rtree` command.
```
$ rtree sample.rb
```
result
```ruby
:program
└──── :binary
├──── :@int ["1"] 1:0
├──── :+
└──── :@int ["1"] 1:4
```
if use in ruby code.
```rb
require 'ripper_tree'
require 'pp'
code =<<-CODE
puts "hello world"
CODE
pp Ripper.sexp(code)
puts
puts RipperTree.create(code)
```
result
```ruby
[: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
```ruby
: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](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).