Permalink
Browse files

pry module + files_modified will be fetched only once

  • Loading branch information...
rindek committed Apr 19, 2012
1 parent 3ea2fa4 commit 9daf70f81b966255992edfcf66e84d456f811074
Showing with 42 additions and 2 deletions.
  1. +1 −1 lib/checker.rb
  2. +40 −0 lib/checker/modules/pry.rb
  3. +1 −1 lib/checker/utils.rb
View
@@ -4,4 +4,4 @@
require "checker/modules/all"
require "checker/modules/ruby"
require "checker/modules/haml"
-
+require "checker/modules/pry"
View
@@ -0,0 +1,40 @@
+module Checker
+ module Modules
+ class Pry
+ def self.check
+ puts ">> PRY <<"
+
+ files = Utils.files_modified
+
+ files.map! do |f|
+ print "Checking #{f} -> "
+ [Pry.check_for_binding_pry(f), Pry.check_for_binding_remote_pry].all_true?
+ end
+
+ files.all_true?
+ end
+
+ def self.check_for_binding_pry(file)
+ result = `grep -n "binding.pry" #{file}`.chomp
+
+ unless result.empty?
+ puts "FAIL #{file} found occurence of 'binding.pry'"
+ puts result
+ end
+
+ result.empty?
+ end
+
+ def self.check_for_binding_remote_pry(file)
+ result = `grep -n "binding.remote_pry" #{file}`.chomp
+
+ unless result.empty?
+ puts "FAIL #{file} -> found occurence of 'binding.remote_pry'"
+ puts result
+ end
+
+ result.empty?
+ end
+ end
+ end
+end
View
@@ -1,6 +1,6 @@
class Utils
def self.files_modified
- `git status --porcelain | egrep "^(A |M |R ).*" | awk ' { if ($3 == "->") print $4; else print $2 } '`.split
+ $files_modified ||= `git status --porcelain | egrep "^(A |M |R ).*" | awk ' { if ($3 == "->") print $4; else print $2 } '`.split
end
def self.use_rvm?

0 comments on commit 9daf70f

Please sign in to comment.