Module: Hashira::Coupling::Words
- Defined in:
- lib/hashira/coupling/words.rb
Constant Summary collapse
- PATTERN =
/\A[a-z][a-z_]*\z/
Class Method Summary collapse
Class Method Details
.entries(node) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/hashira/coupling/words.rb', line 14 def entries(node) case node when Prism::ArrayNode then node.elements.map { word(it) } when Prism::HashNode then keys(node) else [] end end |
.keys(node) ⇒ Object
22 |
# File 'lib/hashira/coupling/words.rb', line 22 def keys(node) = node.elements.grep(Prism::AssocNode).map { word(it.key) } |
.list(tree) ⇒ Object
10 11 12 |
# File 'lib/hashira/coupling/words.rb', line 10 def list(tree) Hashira::Analysis::NodeWalk.collect(tree).flat_map { entries(it) }.compact.grep(PATTERN).to_set end |
.word(node) ⇒ Object
24 25 26 27 28 |
# File 'lib/hashira/coupling/words.rb', line 24 def word(node) case node when Prism::SymbolNode, Prism::StringNode then node.unescaped end end |