code_hunter 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,4 +3,4 @@
3
3
  $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
4
  require "code_hunter"
5
5
 
6
- CodeHunter::Runner.run(ARGV)
6
+ puts CodeHunter::Runner.run(ARGV)
@@ -1,6 +1,7 @@
1
1
  require "active_support/all"
2
2
 
3
3
  require "code_hunter/version"
4
+ require "code_hunter/config"
4
5
  require "code_hunter/method_logger"
5
6
  require "code_hunter/option_parser"
6
7
  require "code_hunter/runner"
@@ -0,0 +1,13 @@
1
+ module CodeHunter
2
+ module Config
3
+ class << self
4
+ attr_accessor :enable_logger
5
+
6
+ def reset
7
+ self.enable_logger = true
8
+ end
9
+ end
10
+
11
+ reset
12
+ end
13
+ end
@@ -2,7 +2,7 @@ module CodeHunter
2
2
  module MethodLogger
3
3
  def log(method_name)
4
4
  define_method("#{method_name}_with_log") do |*args, &block|
5
- warn("#{Time.now} #{self.class}##{method_name}")
5
+ warn("#{Time.now} #{self.class}##{method_name}") if Config.enable_logger
6
6
  __send__("#{method_name}_without_log", *args, &block)
7
7
  end
8
8
  alias_method_chain method_name, :log
@@ -11,16 +11,15 @@ module CodeHunter
11
11
  end
12
12
 
13
13
  def run
14
- warnings = collect_warnings
15
- warnings = warnings.select(&:has_git_metadata?)
16
- warnings = warnings.reject(&:ignore?)
17
- puts Renderer.render(warnings.map(&:to_hash), :format => options[:format])
14
+ Renderer.render(result, :format => options[:format])
18
15
  end
19
16
 
20
- def collect_warnings
21
- services.map(&:run).compact.inject([], :+).map do |attributes|
22
- Warning.new(attributes)
23
- end
17
+ def result
18
+ results = services.map(&:run).compact
19
+ warnings = results.inject([], :+).map {|attributes| Warning.new(attributes) }
20
+ warnings = warnings.select(&:has_git_metadata?)
21
+ warnings = warnings.reject(&:ignore?)
22
+ warnings.map(&:to_hash)
24
23
  end
25
24
 
26
25
  private
@@ -1,3 +1,3 @@
1
1
  module CodeHunter
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -6,3 +6,5 @@ RSpec.configure do |config|
6
6
  config.run_all_when_everything_filtered = true
7
7
  config.filter_run :focus
8
8
  end
9
+
10
+ CodeHunter::Config.enable_logger = false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_hunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -142,6 +142,7 @@ files:
142
142
  - lib/code_hunter/brakeman.rb
143
143
  - lib/code_hunter/brakeman/invoker.rb
144
144
  - lib/code_hunter/brakeman/summarizer.rb
145
+ - lib/code_hunter/config.rb
145
146
  - lib/code_hunter/git_blamer.rb
146
147
  - lib/code_hunter/method_logger.rb
147
148
  - lib/code_hunter/option_parser.rb
@@ -186,3 +187,4 @@ test_files:
186
187
  - spec/code_hunter/renderer_spec.rb
187
188
  - spec/code_hunter/runner_spec.rb
188
189
  - spec/spec_helper.rb
190
+ has_rdoc: