Class: Tol::Codecheck

Inherits:
Object
  • Object
show all
Defined in:
lib/tol/codecheck.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#terminal_columnsObject

Returns the value of attribute terminal_columns.



9
10
11
# File 'lib/tol/codecheck.rb', line 9

def terminal_columns
  @terminal_columns
end

Instance Method Details

#check_for_binding_pryObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tol/codecheck.rb', line 19

def check_for_binding_pry    
  puts Rainbow("Checking for binding.pry").foreground(:yellow)
  result = `find . -name "*.rb" -exec grep -H "binding.pry" {} \\\;`
  if result.length > 0
    puts Rainbow("The following binding.pry's have been found").foreground(:red)
    result.split("\n").each do |res|
      puts res[0..self.terminal_columns - 2]
    end
    puts Rainbow("Please fix").foreground(:red)
  else
    puts Rainbow("No binding.pry's found").foreground(:green)
  end
end

#check_for_console_logObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tol/codecheck.rb', line 33

def check_for_console_log
  puts Rainbow("Checking for console.log").foreground(:yellow)
  result = `find . -name "*.js*" -exec grep -H "console.log" {} \\\;`
  if result.length > 0
    puts Rainbow("The following console.log's have been found").foreground(:red)
    result.split("\n").each do |res|
      puts res[0..self.terminal_columns - 2]
    end
    puts Rainbow("Please fix!").foreground(:red)
  else
    puts Rainbow("No console.log's found").foreground(:green)
  end
end

#runObject



11
12
13
14
15
16
17
# File 'lib/tol/codecheck.rb', line 11

def run
  size = HighLine::SystemExtensions.terminal_size
  self.terminal_columns = size[0]

  check_for_binding_pry
  check_for_console_log
end