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 +4 -4
- data/lib/fukuzatsu/cli.rb +39 -20
- data/lib/fukuzatsu/formatters/base.rb +9 -1
- data/lib/fukuzatsu/formatters/html.rb +0 -11
- data/lib/fukuzatsu/formatters/html_index.rb +2 -3
- data/lib/fukuzatsu/formatters/templates/index.html.haml +2 -1
- data/lib/fukuzatsu/formatters/templates/output.html.haml +2 -1
- data/lib/fukuzatsu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33b9be43725bfc69fd427bc78857cb173db66586
|
4
|
+
data.tar.gz: 93eb38e086bcf10b4e38cccc9cec53e3a10bcd7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
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
|
43
|
-
|
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(
|
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 = "
|
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
|
data/lib/fukuzatsu/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2014-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ephemeral
|