Ruby ffast: Difference between revisions
From wikinotes
(→Usage) |
(→Usage) |
||
Line 29: | Line 29: | ||
'(send (const {nil _} :Foo) :new (hash ... (pair (sym :two)) ))' | '(send (const {nil _} :Foo) :new (hash ... (pair (sym :two)) ))' | ||
Foo.new(one: "abc", two: "def", three: "ghi") | Foo.new(one: "abc", two: "def", three: "ghi") | ||
# assignment of 'two' in a specific method call | |||
fast --ast '(send {nil _} :sayhi {nil ...} (str "two") {nil ...})' foo.rb | |||
sayhi("one", "two", "three") | |||
</source> | </source> | ||
</blockquote><!-- usage --> | </blockquote><!-- usage --> |
Revision as of 16:15, 1 February 2024
A library and cli tool for searching/matching nodes within ruby's AST.
Documentation
github https://github.com/jonatas/fast
Install
gem install ffast
Usage
fast --ast some/file.rb # show ast fast '(const _ _)' some/file.rb # find matching in some/file.rbsample patterns
# an object 'Foo' initialized with the keyword-argument 'two' '(send (const {nil _} :Foo) :new (hash ... (pair (sym :two)) ))' Foo.new(one: "abc", two: "def", three: "ghi") # assignment of 'two' in a specific method call fast --ast '(send {nil _} :sayhi {nil ...} (str "two") {nil ...})' foo.rb sayhi("one", "two", "three")