fukuzatsu 0.9.12 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3435a15f15b81c3a57c8b8f325f1c9acdd21447
4
- data.tar.gz: c1803f26411ef439239dab446743ae4231162ef3
3
+ metadata.gz: 33b9be43725bfc69fd427bc78857cb173db66586
4
+ data.tar.gz: 93eb38e086bcf10b4e38cccc9cec53e3a10bcd7b
5
5
  SHA512:
6
- metadata.gz: 672355b3c4cf948b6d4222242de5be9aa0bbb7cb35757a6adff631e4c3467a11917a1349f813e65c948628c87cb4e13d1c07d02971f57b00b524c9fcffbbfc7a
7
- data.tar.gz: 2f36f1ba855de4eb02e86b26ca72c21b3bf088723860fb26a7d9441f839e40eada29796c1a54f1c77a404e38f7efc11c13c20b516f65f64ab7b18ce86acf9b70
6
+ metadata.gz: 0f42bf703830a6e88d468b0fc64c96f3de69c9b69a79557ebe59c6a0913b3858ed68c498685daddcdf454df3bbf1fa622a042b7632e568b09602dec6828299d6
7
+ data.tar.gz: 38fa1c7d5ecbd1be0725af017d162f58ef23f5c0b2cbd43014ac224461b56ead7df38dc08c596549e4b83c33782afa300a61dddf71bce645118f8bc27a246522
data/lib/fukuzatsu/cli.rb CHANGED
@@ -12,43 +12,62 @@ module Fukuzatsu
12
12
  method_option :format, :type => :string, :default => 'text', :aliases => "-f"
13
13
  method_option :threshold, :type => :numeric, :default => 0, :aliases => "-t"
14
14
 
15
- def check(path)
15
+ def check(path="./")
16
16
 
17
17
  file_summary = []
18
18
  file_complexities = []
19
+ last_file = {}
19
20
 
20
21
  file_list(path).each do |path_to_file|
21
22
  file = ParsedFile.new(path_to_file: path_to_file)
22
- case options['format']
23
- when 'html'
24
- Formatters::Html.new(file).export
25
- when 'csv'
26
- Formatters::Csv.new(file).export
27
- else
28
- Formatters::Text.new(file).export
29
- end
30
- file_summary << {path_to_file: path_to_file, class_name: "#{file.class_name}", complexity: file.complexity}
23
+ parser = formatter(options).new(file)
24
+ parser.export
25
+ file_summary << {
26
+ results_file: "#{parser.output_path}/#{parser.filename}",
27
+ path_to_file: path_to_file,
28
+ class_name: "#{file.class_name}",
29
+ complexity: file.complexity
30
+ }
31
31
  file_complexities << file.complexity
32
32
  end
33
33
 
34
- Formatters::HtmlIndex.new(file_summary).export if options['format'] == 'html'
35
-
36
- handle_complexity(file_complexities.sort.last, options['threshold'])
34
+ last_file = handle_index(file_summary) if options['format'] == 'html'
35
+ report(last_file[:results_file], file_summary.map{|s| s[:results_file]})
36
+ handle_complexity(options, file_complexities.sort.last, options['threshold'])
37
37
 
38
38
  end
39
39
 
40
+ default_task :check
41
+
40
42
  private
41
43
 
42
- def write_index(file_list)
43
- Formatters::Html.write_index(file_list)
44
+ def formatter(options)
45
+ formatter = case options['format']
46
+ when 'html'
47
+ Formatters::Html
48
+ when 'csv'
49
+ Formatters::Csv
50
+ else
51
+ Formatters::Text
52
+ end
53
+ end
54
+
55
+ def handle_index(file_summary)
56
+ index = Formatters::HtmlIndex.new(file_summary)
57
+ index.export
58
+ {results_file: "#{index.output_path}/#{index.filename}"}
59
+ end
60
+
61
+ def report(last_file, file_list)
62
+ return if options['format'] == "text"
63
+ puts "Results written to:"
64
+ puts last_file.present? && "#{last_file}" || file_list.join("\r\n")
44
65
  end
45
66
 
46
- def handle_complexity(max, threshold)
47
- return if options['threshold'] == 0
67
+ def handle_complexity(options, highest_complexity, threshold)
68
+ return if options['threshold'].to_i == 0
48
69
  return if highest_complexity <= options['threshold']
49
- puts "=" * 40
50
70
  puts "Maximum complexity is #{highest_complexity}, which is greater than the threshold of #{options['threshold']}."
51
- puts "=" * 40
52
71
  exit 1
53
72
  end
54
73
 
@@ -62,4 +81,4 @@ module Fukuzatsu
62
81
 
63
82
  end
64
83
 
65
- end
84
+ end
@@ -18,8 +18,12 @@ module Formatters
18
18
  ["class", "method", "complexity"]
19
19
  end
20
20
 
21
+ def root_path
22
+ "doc/fukuzatsu"
23
+ end
24
+
21
25
  def output_path
22
- output_path = "doc/fukuzatsu/#{self.file.path_to_file.split('/')[0..-2].join("/")}"
26
+ output_path = "#{root_path}/#{self.file.path_to_file.split('/')[0..-2].join("/")}"
23
27
  FileUtils.mkpath(output_path)
24
28
  output_path
25
29
  end
@@ -28,6 +32,10 @@ module Formatters
28
32
  self.file.path_to_file.split('/')[-1] + file_extension
29
33
  end
30
34
 
35
+ def file_extension
36
+ ""
37
+ end
38
+
31
39
  def export
32
40
  begin
33
41
  outfile = File.open("#{output_path}/#{filename}", 'w')
@@ -4,17 +4,6 @@ module Formatters
4
4
 
5
5
  include Formatters::Base
6
6
 
7
- def self.write_index(file_list)
8
- index_template = File.read(File.dirname(__FILE__) + "/templates/index.html.haml")
9
- Haml::Engine.new(index_template).render(
10
- Object.new, {
11
- file_list: file_list,
12
- date: Time.now.strftime("%Y/%m/%d"),
13
- time: Time.now.strftime("%l:%M %P")
14
- }
15
- )
16
- end
17
-
18
7
  def header
19
8
  columns.map{|col| "<th>#{col.titleize}</th>"}.join("\r\n")
20
9
  end
@@ -15,9 +15,8 @@ module Formatters
15
15
  end
16
16
 
17
17
  def output_path
18
- output_path = "doc/fukuzatsu/"
19
- FileUtils.mkpath(output_path)
20
- output_path
18
+ FileUtils.mkpath(root_path)
19
+ root_path
21
20
  end
22
21
 
23
22
  def content
@@ -85,7 +85,8 @@
85
85
  $(document).ready(function(){
86
86
  $('.output-table').dataTable({
87
87
  bLengthChange: false,
88
- iDisplayLength: 25000
88
+ iDisplayLength: 25000,
89
+ "order": [[2, "desc"]]
89
90
  });
90
91
  });
91
92
 
@@ -72,7 +72,8 @@
72
72
  $(document).ready(function(){
73
73
  $('.output-table').dataTable({
74
74
  bLengthChange: false,
75
- iDisplayLength: 25000
75
+ iDisplayLength: 25000,
76
+ "order": [[2, "desc"]]
76
77
  });
77
78
  });
78
79
 
@@ -1,3 +1,3 @@
1
1
  module Fukuzatsu
2
- VERSION = "0.9.12"
2
+ VERSION = "0.9.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fukuzatsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bantik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-04 00:00:00.000000000 Z
11
+ date: 2014-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ephemeral