Class: SpringRoutes::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/spring_routes/cli.rb

Instance Method Summary collapse

Instance Method Details

#parse_print(file_name = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/spring_routes/cli.rb', line 7

def parse_print(file_name = nil)
  file = file_name ? File.open(file_name) : STDIN
  matched = false
  over = false
  file.each do |line|
    line.chomp!
    matched = true if line =~ /JsonResponseRequestMappingHandlerMapping - /
    over = true if  line !~ /JsonResponseRequestMappingHandlerMapping - / && matched

    break if over

    if matched
      line.sub!(/^.*JsonResponseRequestMappingHandlerMapping - /, '')
      line.gsub!(/([a-z0-9]+\.)+([A-Z])/, '\2') if options[:compact]
      line.sub!(/onto public/, ' ====> ')
      puts line if line =~ /^Mapped/
    end
  end
end