Skip to content
Browse files

Removed result output duplication

Now both the roodi executable and the rake task have pretty colours.

Solving issue #20
  • Loading branch information...
1 parent dc17b2c commit a1acc5fd38a09510c0b6ce5958d869d467e3c64b @evjan evjan committed
Showing with 16 additions and 22 deletions.
  1. +0 −6 bin/roodi
  2. +16 −0 lib/roodi/core/runner.rb
  3. +0 −16 lib/roodi_task.rb
View
6 bin/roodi
@@ -10,12 +10,6 @@ config_param = ARGV.detect {|arg| arg =~ /-config=.*/}
runner.config = config_param.split("=")[1] if config_param
ARGV.delete config_param
-puts "\nRunning Roodi checks"
-
runner.start(ARGV)
-runner.errors.each {|error| puts error}
-
-puts "\nChecked #{runner.files_checked} files"
-puts "Found #{runner.errors.size} errors"
exit runner.errors.size
View
16 lib/roodi/core/runner.rb
@@ -19,12 +19,28 @@ def initialize(*checks)
end
def start(paths)
+ puts "\nRunning Roodi checks"
+
paths = ['.'] if paths == []
all_files = collect_files(paths)
@files_checked = all_files.count
all_files.each do |path|
check_file(path)
end
+
+ output_result(errors, @files_checked)
+ end
+
+ def output_result(errors, files_checked)
+ errors.each {|error| puts "\e[31m#{error}\e[0m"}
+
+ puts "\nChecked #{files_checked} files"
+ result = "Found #{errors.size} errors."
+ if errors.empty?
+ puts "\e[32m#{result}\e[0m"
+ else
+ raise "\e[31m#{result}\e[0m"
+ end
end
def collect_files(paths)
View
16 lib/roodi_task.rb
@@ -21,28 +21,12 @@ def initialize name = :roodi, patterns = nil, config = nil
def define
desc "Run Roodi against all source files"
task name do
- puts "\nRunning Roodi checks"
-
runner = Roodi::Core::Runner.new
runner.config = config if config
runner.start(@patterns)
-
- output_result(runner.errors, runner.files_checked)
end
self
end
-
- def output_result(errors, files_checked)
- errors.each {|error| puts "\e[31m#{error}\e[0m"}
-
- puts "\nChecked #{files_checked} files"
- result = "Found #{errors.size} errors."
- if errors.empty?
- puts "\e[32m#{result}\e[0m"
- else
- raise "\e[31m#{result}\e[0m"
- end
- end
end

0 comments on commit a1acc5f

Please sign in to comment.
Something went wrong with that request. Please try again.