Class: LooseErbs::Cli
- Inherits:
-
Object
- Object
- LooseErbs::Cli
- Defined in:
- lib/loose_erbs.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Cli
Returns a new instance of Cli.
40 41 42 43 44 |
# File 'lib/loose_erbs.rb', line 40 def initialize(argv) @options = {} option_parser.parse!(into: @options) end |
Instance Method Details
#run ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/loose_erbs.rb', line 46 def run require File.("./config/environment") nodes = registry.to_graph unless [:all] used_erbs = scanner.renders.map { registry.lookup(_1) }.to_set visitor = Graph::LooseVisitor.new nodes.select { |node| # assume regular templates are good until controller parsing is added used_erbs.include?(node.identifier) || !node.partial? }.each { _1.accept(visitor) } end nodes = FilterChain.new(filters).filter(nodes) unless filters.empty? if [:trees] nodes.each(&:print_tree) true else puts "\nLoose ERBs:" unless nodes.empty? nodes.each(&:print) nodes.empty? end end |