saikuro_treemap 0.1.2 → 0.2.0

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.
@@ -4,39 +4,69 @@ require 'erb'
4
4
  require 'rake'
5
5
  require 'base64'
6
6
 
7
+ require 'saikuro'
7
8
  require 'saikuro_treemap/version'
8
9
  require 'saikuro_treemap/parser'
9
10
  require 'saikuro_treemap/ccn_node'
10
11
 
11
12
  module SaikuroTreemap
12
13
 
14
+ class SaikuroRake
15
+ include ResultIndexGenerator
16
+
17
+ def run(options)
18
+
19
+ rm_rf options[:output_directory]
20
+
21
+ state_filter = Filter.new(5)
22
+ token_filter = Filter.new(10, 25, 50)
23
+
24
+ state_filter.limit = options[:filter_cyclo] if options[:filter_cyclo]
25
+ state_filter.warn = options[:warn_cyclo] if options[:warn_cyclo]
26
+ state_filter.error = options[:error_cyclo] if options[:error_cyclo]
27
+
28
+ token_filter.limit = options[:filter_token] if options[:filter_token]
29
+ token_filter.warn = options[:warn_token] if options[:warn_token]
30
+ token_filter.error = options[:error_token] if options[:error_token]
31
+
32
+ state_formater = ParseStateFormater.new(STDOUT, state_filter)
33
+ token_count_formater = TokenCounterFormater.new(STDOUT, token_filter)
34
+
35
+ idx_states, idx_tokens = Saikuro.analyze(
36
+ files_in_dirs(options[:code_dirs]),
37
+ state_formater,
38
+ token_count_formater,
39
+ options[:output_directory]
40
+ )
41
+
42
+ write_cyclo_index(idx_states, options[:output_directory])
43
+ write_token_index(idx_tokens, options[:output_directory])
44
+ end
45
+
46
+ def files_in_dirs(code_dirs)
47
+ code_dirs = [code_dirs].flatten
48
+ code_dirs.collect {|dir| Dir["#{dir}/**/*.rb"]}.flatten
49
+ end
50
+
51
+ end
52
+
53
+
13
54
  DEFAULT_CONFIG = {
14
- :code_dirs => ['app/controllers', 'app/models', 'app/helpers' 'lib'],
55
+ :code_dirs => ['app/controllers', 'app/models', 'app/helpers', 'lib'],
15
56
  :output_file => 'reports/saikuro_treemap.html',
16
- :saikuro_args => [
17
- "--warn_cyclo 5",
18
- "--error_cyclo 7",
19
- "--formater text",
20
- "--cyclo --filter_cyclo 0"]
57
+ :warn_cyclo => 5,
58
+ :error_cyclo => 7,
59
+ :filter_cyclo => 0
21
60
  }
22
61
 
23
- def self.generate_treemap(config={})
62
+ def self.generate_treemap(config={})
24
63
  temp_dir = 'tmp/saikuro'
25
64
 
26
65
  config = DEFAULT_CONFIG.merge(config)
27
66
 
28
- config[:saikuro_args] << "--output_directory #{temp_dir}"
29
-
30
- options_string = config[:saikuro_args] + config[:code_dirs].collect { |dir| "--input_directory '#{dir}'" }
31
-
32
-
33
- rm_rf temp_dir
34
- sh %{saikuro #{options_string.join(' ')}} do |ok, response|
35
- unless ok
36
- puts "Saikuro failed with exit status: #{response.exitstatus}"
37
- exit 1
38
- end
39
- end
67
+ config[:output_directory] = temp_dir
68
+
69
+ SaikuroRake.new.run(config)
40
70
 
41
71
  saikuro_files = Parser.parse(temp_dir)
42
72
 
@@ -1,5 +1,5 @@
1
1
  module SaikuroTreemap
2
2
  class Version
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saikuro_treemap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - ThoughtWorks Studios
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-17 00:00:00 -07:00
18
+ date: 2010-07-22 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency