metric_fu 2.1.3.7.19 → 2.1.4.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/.rspec +2 -0
  2. data/.travis.yml +12 -0
  3. data/Gemfile +2 -2
  4. data/HISTORY.md +15 -2
  5. data/README.md +19 -12
  6. data/TODO.md +121 -7
  7. data/bin/metric_fu +134 -2
  8. data/lib/metric_fu.rb +8 -1
  9. data/lib/metric_fu/configuration.rb +192 -0
  10. data/lib/{data_structures → metric_fu/data_structures}/careful_array.rb +0 -0
  11. data/lib/{data_structures → metric_fu/data_structures}/line_numbers.rb +0 -0
  12. data/lib/{data_structures → metric_fu/data_structures}/location.rb +0 -0
  13. data/lib/{errors → metric_fu/errors}/analysis_error.rb +0 -0
  14. data/lib/{initial_requires.rb → metric_fu/initial_requires.rb} +1 -0
  15. data/lib/{load_files.rb → metric_fu/load_files.rb} +0 -8
  16. data/lib/{logging → metric_fu/logging}/mf_debugger.rb +0 -0
  17. data/lib/{metrics → metric_fu/metrics}/base_template.rb +0 -0
  18. data/lib/metric_fu/metrics/churn/churn.rb +64 -0
  19. data/lib/{metrics → metric_fu/metrics}/churn/churn_hotspot.rb +0 -0
  20. data/lib/metric_fu/metrics/churn/init.rb +5 -0
  21. data/lib/{metrics → metric_fu/metrics}/churn/template_awesome/churn.html.erb +0 -0
  22. data/lib/{metrics → metric_fu/metrics}/churn/template_standard/churn.html.erb +0 -0
  23. data/lib/{metrics → metric_fu/metrics}/flay/flay.rb +3 -1
  24. data/lib/{metrics → metric_fu/metrics}/flay/flay_grapher.rb +0 -0
  25. data/lib/{metrics → metric_fu/metrics}/flay/flay_hotspot.rb +0 -0
  26. data/lib/metric_fu/metrics/flay/init.rb +9 -0
  27. data/lib/{metrics → metric_fu/metrics}/flay/template_awesome/flay.html.erb +0 -0
  28. data/lib/{metrics → metric_fu/metrics}/flay/template_standard/flay.html.erb +0 -0
  29. data/lib/{metrics → metric_fu/metrics}/flog/flog.rb +0 -0
  30. data/lib/{metrics → metric_fu/metrics}/flog/flog_grapher.rb +0 -0
  31. data/lib/{metrics → metric_fu/metrics}/flog/flog_hotspot.rb +0 -0
  32. data/lib/metric_fu/metrics/flog/init.rb +7 -0
  33. data/lib/{metrics → metric_fu/metrics}/flog/template_awesome/flog.html.erb +0 -0
  34. data/lib/{metrics → metric_fu/metrics}/flog/template_standard/flog.html.erb +0 -0
  35. data/lib/{metrics → metric_fu/metrics}/generator.rb +3 -4
  36. data/lib/{metrics → metric_fu/metrics}/graph.rb +0 -0
  37. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/code_issue.rb +0 -0
  38. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/grouping.rb +0 -0
  39. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/ranking.rb +0 -0
  40. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/record.rb +0 -0
  41. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/scoring_strategies.rb +0 -0
  42. data/lib/{metrics → metric_fu/metrics}/hotspots/analysis/table.rb +0 -0
  43. data/lib/{metrics → metric_fu/metrics}/hotspots/hotspot_analyzer.rb +0 -0
  44. data/lib/{metrics → metric_fu/metrics}/hotspots/hotspots.rb +0 -0
  45. data/lib/metric_fu/metrics/hotspots/init.rb +5 -0
  46. data/lib/{metrics → metric_fu/metrics}/hotspots/template_awesome/hotspots.html.erb +0 -0
  47. data/lib/{metrics → metric_fu/metrics}/hotspots/template_standard/hotspots.html.erb +0 -0
  48. data/lib/metric_fu/metrics/rails_best_practices/init.rb +7 -0
  49. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/rails_best_practices.rb +4 -2
  50. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/rails_best_practices_grapher.rb +0 -0
  51. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/template_awesome/rails_best_practices.html.erb +0 -0
  52. data/lib/{metrics → metric_fu/metrics}/rails_best_practices/template_standard/rails_best_practices.html.erb +0 -0
  53. data/lib/metric_fu/metrics/rcov/init.rb +18 -0
  54. data/lib/{metrics → metric_fu/metrics}/rcov/rcov.rb +22 -7
  55. data/lib/{metrics → metric_fu/metrics}/rcov/rcov_grapher.rb +0 -0
  56. data/lib/{metrics → metric_fu/metrics}/rcov/rcov_hotspot.rb +0 -0
  57. data/lib/{metrics → metric_fu/metrics}/rcov/template_awesome/rcov.html.erb +0 -0
  58. data/lib/{metrics → metric_fu/metrics}/rcov/template_standard/rcov.html.erb +0 -0
  59. data/lib/metric_fu/metrics/reek/init.rb +7 -0
  60. data/lib/{metrics → metric_fu/metrics}/reek/reek.rb +3 -1
  61. data/lib/{metrics → metric_fu/metrics}/reek/reek_grapher.rb +0 -0
  62. data/lib/{metrics → metric_fu/metrics}/reek/reek_hotspot.rb +0 -0
  63. data/lib/{metrics → metric_fu/metrics}/reek/template_awesome/reek.html.erb +0 -0
  64. data/lib/{metrics → metric_fu/metrics}/reek/template_standard/reek.html.erb +0 -0
  65. data/lib/metric_fu/metrics/roodi/init.rb +7 -0
  66. data/lib/{metrics → metric_fu/metrics}/roodi/roodi.rb +3 -1
  67. data/lib/{metrics → metric_fu/metrics}/roodi/roodi_grapher.rb +0 -0
  68. data/lib/{metrics → metric_fu/metrics}/roodi/roodi_hotspot.rb +0 -0
  69. data/lib/{metrics → metric_fu/metrics}/roodi/template_awesome/roodi.html.erb +0 -0
  70. data/lib/{metrics → metric_fu/metrics}/roodi/template_standard/roodi.html.erb +0 -0
  71. data/lib/metric_fu/metrics/saikuro/init.rb +11 -0
  72. data/lib/{metrics → metric_fu/metrics}/saikuro/saikuro.rb +0 -0
  73. data/lib/{metrics → metric_fu/metrics}/saikuro/saikuro_hotspot.rb +0 -0
  74. data/lib/{metrics → metric_fu/metrics}/saikuro/template_awesome/saikuro.html.erb +0 -0
  75. data/lib/{metrics → metric_fu/metrics}/saikuro/template_standard/saikuro.html.erb +0 -0
  76. data/lib/metric_fu/metrics/stats/init.rb +7 -0
  77. data/lib/{metrics → metric_fu/metrics}/stats/stats.rb +3 -1
  78. data/lib/{metrics → metric_fu/metrics}/stats/stats_grapher.rb +0 -0
  79. data/lib/{metrics → metric_fu/metrics}/stats/stats_hotspot.rb +0 -0
  80. data/lib/{metrics → metric_fu/metrics}/stats/template_awesome/stats.html.erb +0 -0
  81. data/lib/{metrics → metric_fu/metrics}/stats/template_standard/stats.html.erb +0 -0
  82. data/lib/{reporting → metric_fu/reporting}/graphs/engines/bluff.rb +0 -0
  83. data/lib/{reporting → metric_fu/reporting}/graphs/engines/gchart.rb +0 -0
  84. data/lib/metric_fu/reporting/graphs/engines/init.rb +5 -0
  85. data/lib/{reporting → metric_fu/reporting}/graphs/grapher.rb +0 -0
  86. data/lib/{reporting → metric_fu/reporting}/report.rb +3 -2
  87. data/lib/{reporting → metric_fu/reporting}/templates/awesome/awesome_template.rb +0 -0
  88. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/buttons.css +0 -0
  89. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/default.css +0 -0
  90. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/integrity.css +0 -0
  91. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/reset.css +0 -0
  92. data/lib/{reporting → metric_fu/reporting}/templates/awesome/css/syntax.css +0 -0
  93. data/lib/{reporting → metric_fu/reporting}/templates/awesome/index.html.erb +0 -0
  94. data/lib/{reporting → metric_fu/reporting}/templates/awesome/layout.html.erb +0 -0
  95. data/lib/{reporting → metric_fu/reporting}/templates/javascripts/bluff-min.js +0 -0
  96. data/lib/{reporting → metric_fu/reporting}/templates/javascripts/excanvas.js +0 -0
  97. data/lib/{reporting → metric_fu/reporting}/templates/javascripts/js-class.js +0 -0
  98. data/lib/{reporting → metric_fu/reporting}/templates/standard/default.css +0 -0
  99. data/lib/{reporting → metric_fu/reporting}/templates/standard/index.html.erb +0 -0
  100. data/lib/{reporting → metric_fu/reporting}/templates/standard/standard_template.rb +0 -0
  101. data/lib/{run.rb → metric_fu/run.rb} +12 -11
  102. data/lib/{tasks → metric_fu/tasks}/metric_fu.rake +0 -0
  103. data/lib/metric_fu/version.rb +3 -0
  104. data/metric_fu.gemspec +13 -21
  105. data/spec/metric_fu/configuration_spec.rb +298 -0
  106. data/spec/{base → metric_fu/data_structures}/line_numbers_spec.rb +11 -11
  107. data/spec/{base → metric_fu/data_structures}/location_spec.rb +1 -1
  108. data/spec/{base → metric_fu/metrics}/base_template_spec.rb +1 -1
  109. data/spec/metric_fu/metrics/churn/churn_spec.rb +85 -0
  110. data/spec/{graphs → metric_fu/metrics/flay}/flay_grapher_spec.rb +3 -3
  111. data/spec/{generators → metric_fu/metrics/flay}/flay_spec.rb +1 -1
  112. data/spec/{graphs → metric_fu/metrics/flog}/flog_grapher_spec.rb +4 -4
  113. data/spec/{generators → metric_fu/metrics/flog}/flog_spec.rb +1 -1
  114. data/spec/{base → metric_fu/metrics}/generator_spec.rb +4 -3
  115. data/spec/{base → metric_fu/metrics}/graph_spec.rb +1 -1
  116. data/spec/{base → metric_fu/metrics/hotspots/analysis}/ranking_spec.rb +1 -1
  117. data/spec/{base → metric_fu/metrics/hotspots/analysis}/table_spec.rb +1 -1
  118. data/spec/{base → metric_fu/metrics/hotspots}/hotspot_analyzer_spec.rb +1 -1
  119. data/spec/{generators → metric_fu/metrics/hotspots}/hotspots_spec.rb +1 -1
  120. data/spec/{graphs → metric_fu/metrics/rails_best_practices}/rails_best_practices_grapher_spec.rb +3 -3
  121. data/spec/{generators → metric_fu/metrics/rails_best_practices}/rails_best_practices_spec.rb +1 -1
  122. data/spec/{graphs → metric_fu/metrics/rcov}/rcov_grapher_spec.rb +3 -3
  123. data/spec/{generators → metric_fu/metrics/rcov}/rcov_spec.rb +1 -1
  124. data/spec/{graphs → metric_fu/metrics/reek}/reek_grapher_spec.rb +3 -3
  125. data/spec/{generators → metric_fu/metrics/reek}/reek_spec.rb +1 -1
  126. data/spec/{graphs → metric_fu/metrics/roodi}/roodi_grapher_spec.rb +3 -3
  127. data/spec/{generators → metric_fu/metrics/roodi}/roodi_spec.rb +1 -1
  128. data/spec/{generators → metric_fu/metrics/saikuro}/saikuro_spec.rb +4 -4
  129. data/spec/{graphs → metric_fu/metrics/stats}/stats_grapher_spec.rb +3 -3
  130. data/spec/{generators → metric_fu/metrics/stats}/stats_spec.rb +7 -4
  131. data/spec/{graphs → metric_fu/reporting/graphs}/engines/bluff_spec.rb +3 -3
  132. data/spec/{graphs → metric_fu/reporting/graphs}/engines/gchart_spec.rb +2 -1
  133. data/spec/{base → metric_fu/reporting}/report_spec.rb +5 -3
  134. data/spec/spec_helper.rb +17 -5
  135. data/spec/support/suite.rb +16 -0
  136. metadata +195 -183
  137. data/lib/configuration.rb +0 -227
  138. data/lib/metrics/churn/churn.rb +0 -28
  139. data/lib/version.rb +0 -3
  140. data/spec/base/configuration_spec.rb +0 -277
  141. data/spec/generators/churn_spec.rb +0 -41
  142. data/spec/spec.opts +0 -6
data/lib/configuration.rb DELETED
@@ -1,227 +0,0 @@
1
- require 'fileutils'
2
- MetricFu.reporting_require { 'templates/awesome/awesome_template' }
3
- module MetricFu
4
-
5
- # A list of metrics which are available in the MetricFu system.
6
- #
7
- # These are metrics which have been developed for the system. Of
8
- # course, in order to use these metrics, their respective gems must
9
- # be installed on the system.
10
- AVAILABLE_METRICS = [:churn,
11
- :flog,
12
- :flay,
13
- :reek,
14
- :roodi,
15
- :rcov,
16
- :hotspots,
17
- :saikuro
18
- ]
19
-
20
- AVAILABLE_GRAPHS = [
21
- :flog,
22
- :flay,
23
- :reek,
24
- :roodi,
25
- :rcov,
26
- :rails_best_practices
27
- ]
28
- AVAILABLE_GRAPH_ENGINES = [:gchart, :bluff]
29
-
30
- # The @@configuration class variable holds a global type configuration
31
- # object for any parts of the system to use.
32
- def self.configuration
33
- @@configuration ||= Configuration.new
34
- end
35
-
36
- # = Configuration
37
- #
38
- # The Configuration class, as it sounds, provides methods for
39
- # configuring the behaviour of MetricFu.
40
- #
41
- # == Customization for Rails
42
- #
43
- # The Configuration class checks for the presence of a
44
- # 'config/environment.rb' file. If the file is present, it assumes
45
- # it is running in a Rails project. If it is, it will:
46
- #
47
- # * Add 'app' to the @code_dirs directory to include the
48
- # code in the app directory in the processing
49
- # * Add :stats to the list of metrics to run to get the Rails stats
50
- # task
51
- #
52
- # == Customization for CruiseControl.rb
53
- #
54
- # The Configuration class checks for the presence of a
55
- # 'CC_BUILD_ARTIFACTS' environment variable. If it's found
56
- # it will change the default output directory from the default
57
- # "tmp/metric_fu to the directory represented by 'CC_BUILD_ARTIFACTS'
58
- #
59
- # == Deprications
60
- #
61
- # The Configuration class checks for several deprecated constants
62
- # that were previously used to configure MetricFu. These include
63
- # CHURN_OPTIONS, DIRECTORIES_TO_FLOG, SAIKURO_OPTIONS,
64
- # and MetricFu::SAIKURO_OPTIONS.
65
- #
66
- # These have been replaced by config.churn, config.flog and
67
- # config.saikuro respectively.
68
- class Configuration
69
-
70
- def initialize #:nodoc:#
71
- reset
72
- add_attr_accessors_to_self
73
- add_class_methods_to_metric_fu
74
- end
75
-
76
- # Searches through the instance variables of the class and
77
- # creates a class method on the MetricFu module to read the value
78
- # of the instance variable from the Configuration class.
79
- def add_class_methods_to_metric_fu
80
- instance_variables.each do |name|
81
- method_name = name[1..-1].to_sym
82
- method = <<-EOF
83
- def self.#{method_name}
84
- configuration.send(:#{method_name})
85
- end
86
- EOF
87
- MetricFu.module_eval(method)
88
- end
89
- end
90
-
91
- # Searches through the instance variables of the class and creates
92
- # an attribute accessor on this instance of the Configuration
93
- # class for each instance variable.
94
- def add_attr_accessors_to_self
95
- instance_variables.each do |name|
96
- method_name = name[1..-1].to_sym
97
- MetricFu::Configuration.send(:attr_accessor, method_name)
98
- end
99
- end
100
-
101
- # This allows us to have a nice syntax like:
102
- #
103
- # MetricFu.run do |config|
104
- # config.base_directory = 'tmp/metric_fu'
105
- # end
106
- #
107
- # See the README for more information on configuration options.
108
- def self.run
109
- yield MetricFu.configuration
110
- end
111
-
112
- # This does the real work of the Configuration class, by setting
113
- # up a bunch of instance variables to represent the configuration
114
- # of the MetricFu app.
115
- # TODO review if these code is functionally duplicated in the
116
- # base generator initialize
117
- def reset
118
- @base_directory = MetricFu.artifact_dir
119
- @scratch_directory = MetricFu.scratch_dir
120
- @output_directory = MetricFu.output_dir
121
- @data_directory = MetricFu.data_dir
122
- # due to behavior differences between ruby 1.8.7 and 1.9.3
123
- # this is good enough for now
124
- [@base_directory, @scratch_directory, @output_directory].each do |dir|
125
- FileUtils.mkdir_p dir
126
- end
127
- @metric_fu_root_directory = MetricFu.root_dir
128
- @template_directory = File.join(@metric_fu_root_directory,
129
- 'lib', 'templates')
130
- @template_class = AwesomeTemplate
131
- set_metrics
132
- set_graphs
133
- set_code_dirs
134
- @flay = { :dirs_to_flay => @code_dirs,
135
- :minimum_score => 100,
136
- :filetypes => ['rb'] }
137
- @flog = { :dirs_to_flog => @code_dirs }
138
- @reek = { :dirs_to_reek => @code_dirs,
139
- :config_file_pattern => nil}
140
- @roodi = { :dirs_to_roodi => @code_dirs,
141
- :roodi_config => nil }
142
- @saikuro = { :output_directory => "#{@scratch_directory}/saikuro",
143
- :input_directory => @code_dirs,
144
- :cyclo => "",
145
- :filter_cyclo => "0",
146
- :warn_cyclo => "5",
147
- :error_cyclo => "7",
148
- :formater => "text"}
149
- @churn = {}
150
- @stats = {}
151
- @rcov = { :environment => 'test',
152
- :test_files => ['test/**/*_test.rb',
153
- 'spec/spec_helper.rb', # NOTE: ensure it is loaded before the specs
154
- 'spec/**/*_spec.rb'],
155
- :rcov_opts => ["--sort coverage",
156
- "--no-html",
157
- "--text-coverage",
158
- "--no-color",
159
- "--profile",
160
- "--rails",
161
- "--exclude /gems/,/Library/,/usr/,spec"],
162
- :external => nil
163
- }
164
- @rails_best_practices = {}
165
- @hotspots = {}
166
- @file_globs_to_ignore = []
167
- @link_prefix = nil
168
-
169
-
170
- @verbose = false
171
-
172
- @graph_engine = :bluff # can be :bluff or :gchart
173
-
174
- @darwin_txmt_protocol_no_thanks = true
175
- # uses the CodeRay gem (was syntax gem)
176
- @syntax_highlighting = true #Can be set to false to avoid UTF-8 issues with Ruby 1.9.2 and Syntax 1.0
177
- end
178
-
179
- # Perform a simple check to try and guess if we're running
180
- # against a rails app.
181
- #
182
- # @todo This should probably be made a bit more robust.
183
- def rails?
184
- @rails = File.exist?("config/environment.rb")
185
- end
186
-
187
- # Add the :stats task to the AVAILABLE_METRICS constant if we're
188
- # running within rails.
189
- def set_metrics
190
- if rails?
191
- @metrics = MetricFu::AVAILABLE_METRICS + [
192
- :stats,
193
- :rails_best_practices
194
- ]
195
- else
196
- @metrics = MetricFu::AVAILABLE_METRICS
197
- end
198
- end
199
-
200
- def set_graphs
201
- if rails?
202
- @graphs = MetricFu::AVAILABLE_GRAPHS + [
203
- :stats
204
- ]
205
- else
206
- @graphs = MetricFu::AVAILABLE_GRAPHS
207
- end
208
- end
209
-
210
- # Add the 'app' directory if we're running within rails.
211
- def set_code_dirs
212
- if rails?
213
- @code_dirs = ['app', 'lib']
214
- else
215
- @code_dirs = ['lib']
216
- end
217
- end
218
-
219
- def platform #:nodoc:
220
- return RUBY_PLATFORM
221
- end
222
-
223
- def is_cruise_control_rb?
224
- !!ENV['CC_BUILD_ARTIFACTS']
225
- end
226
- end
227
- end
@@ -1,28 +0,0 @@
1
- module MetricFu
2
-
3
- class Churn < Generator
4
-
5
- def initialize(options={})
6
- super
7
- end
8
-
9
- def emit
10
- @output = `churn --yaml`
11
- yaml_start = @output.index("---")
12
- @output = @output[yaml_start...@output.length] if yaml_start
13
- end
14
-
15
- def analyze
16
- if @output.match(/Churning requires a subversion or git repo/)
17
- @churn = [:churn => {}]
18
- else
19
- @churn = YAML::load(@output)
20
- end
21
- end
22
-
23
- def to_h
24
- {:churn => @churn[:churn]}
25
- end
26
- end
27
-
28
- end
data/lib/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module MetricFu
2
- VERSION = "2.1.3.7.19"
3
- end
@@ -1,277 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
-
3
- describe MetricFu::Configuration do
4
-
5
- def get_new_config
6
- @config = Configuration.new
7
- end
8
-
9
- def base_directory
10
- @config.instance_variable_get(:@base_directory)
11
- end
12
-
13
- def output_directory
14
- @config.instance_variable_get(:@output_directory)
15
- end
16
-
17
- def scratch_directory
18
- @config.instance_variable_get(:@scratch_directory)
19
- end
20
-
21
- def template_directory
22
- @config.instance_variable_get(:@template_directory)
23
- end
24
-
25
- def template_class
26
- @config.instance_variable_get(:@template_class)
27
- end
28
-
29
- def metric_fu_root
30
- @config.instance_variable_get(:@metric_fu_root_directory)
31
- end
32
-
33
- describe "#reset" do
34
-
35
- before(:each) { get_new_config }
36
-
37
- describe 'when there is a CC_BUILD_ARTIFACTS environment variable' do
38
- before(:each) { ENV['CC_BUILD_ARTIFACTS'] = 'foo' }
39
-
40
- it 'should return the CC_BUILD_ARTIFACTS environment variable' do
41
- get_new_config
42
- compare_paths(base_directory, ENV['CC_BUILD_ARTIFACTS'])
43
- end
44
- end
45
-
46
- describe 'when there is no CC_BUILD_ARTIFACTS environment variable' do
47
- before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
48
-
49
- it 'should return "tmp/metric_fu"' do
50
- get_new_config
51
- base_directory.should == "tmp/metric_fu"
52
- end
53
- end
54
-
55
- it 'should set @metric_fu_root_directory to the base of the '+
56
- 'metric_fu application' do
57
- app_root = File.join(File.dirname(__FILE__), '..', '..')
58
- app_root_absolute_path = File.expand_path(app_root)
59
- metric_fu_absolute_path = File.expand_path(metric_fu_root)
60
- metric_fu_absolute_path.should == app_root_absolute_path
61
- end
62
-
63
- it 'should set @template_directory to the lib/templates relative '+
64
- 'to @metric_fu_root_directory' do
65
- template_dir = File.join(File.dirname(__FILE__),
66
- '..', '..', 'lib','templates')
67
- template_dir_abs_path = File.expand_path(template_dir)
68
- calc_template_dir_abs_path = File.expand_path(template_directory)
69
- calc_template_dir_abs_path.should == template_dir_abs_path
70
- end
71
-
72
- it 'should set @scratch_directory to scratch relative '+
73
- 'to @base_directory' do
74
- scratch_dir = MetricFu.scratch_dir
75
- scratch_directory.should == scratch_dir
76
- end
77
-
78
- it 'should set @output_directory to output relative '+
79
- 'to @base_directory' do
80
- output_dir = MetricFu.output_dir
81
- output_directory.should == output_dir
82
- end
83
-
84
- it 'should set @template_class to AwesomeTemplate' do
85
- template_class.should == AwesomeTemplate
86
- end
87
-
88
- it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
89
- @config.instance_variable_get(:@flay).
90
- should == {:dirs_to_flay => ['lib'], :filetypes=>["rb"], :minimum_score => 100}
91
- end
92
-
93
- it 'should set @flog to {:dirs_to_flog => @code_dirs}' do
94
- @config.instance_variable_get(:@flog).
95
- should == {:dirs_to_flog => ['lib']}
96
- end
97
-
98
- it 'should set @reek to {:dirs_to_reek => @code_dirs}' do
99
- @config.instance_variable_get(:@reek).
100
- should == {:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
101
- end
102
-
103
- it 'should set @roodi to {:dirs_to_roodi => @code_dirs}' do
104
- @config.instance_variable_get(:@roodi).
105
- should == {:roodi_config=>nil, :dirs_to_roodi => ['lib']}
106
- end
107
-
108
- it 'should set @churn to {}' do
109
- @config.instance_variable_get(:@churn).
110
- should == {}
111
- end
112
-
113
- it 'should set @stats to {}' do
114
- @config.instance_variable_get(:@stats).
115
- should == {}
116
- end
117
-
118
- it 'should set @rails_best_practices to {}' do
119
- @config.instance_variable_get(:@rails_best_practices).
120
- should == {}
121
- end
122
-
123
- it 'should set @rcov to { :test_files => ["test/**/*_test.rb",
124
- "spec/**/*_spec.rb"]
125
- :rcov_opts => ["--sort coverage",
126
- "--no-html",
127
- "--text-coverage",
128
- "--no-color",
129
- "--profile",
130
- "--rails",
131
- "--exclude /gems/,/Library/,/usr/,spec"]}' do
132
- @config.instance_variable_get(:@rcov).
133
- should == { :environment => 'test',
134
- :test_files => ['test/**/*_test.rb',
135
- 'spec/spec_helper.rb',
136
- 'spec/**/*_spec.rb'],
137
- :rcov_opts => ["--sort coverage",
138
- "--no-html",
139
- "--text-coverage",
140
- "--no-color",
141
- "--profile",
142
- "--rails",
143
- "--exclude /gems/,/Library/,/usr/,spec"],
144
- :external => nil}
145
- end
146
-
147
- it 'should set @saikuro to { :output_directory => @scratch_directory + "/saikuro",
148
- :input_directory => @code_dirs,
149
- :cyclo => "",
150
- :filter_cyclo => "0",
151
- :warn_cyclo => "5",
152
- :error_cyclo => "7",
153
- :formater => "text" }' do
154
- @config.instance_variable_get(:@saikuro).
155
- should == { :output_directory => "#{scratch_directory}/saikuro",
156
- :input_directory => ['lib'],
157
- :cyclo => "",
158
- :filter_cyclo => "0",
159
- :warn_cyclo => "5",
160
- :error_cyclo => "7",
161
- :formater => "text"}
162
- end
163
-
164
- describe 'if #rails? is true ' do
165
- before(:each) do
166
- @config.stub!(:rails?).and_return(true)
167
- end
168
-
169
- describe '#set_metrics ' do
170
- it 'should set the @metrics instance var to AVAILABLE_METRICS + '\
171
- +'[:stats]' do
172
- @config.instance_variable_get(:@metrics).
173
- should == MetricFu::AVAILABLE_METRICS << [:stats]
174
- end
175
- end
176
-
177
- describe '#set_graphs ' do
178
- it 'should set the @graphs instance var to AVAILABLE_GRAPHS' do
179
- @config.instance_variable_get(:@graphs).
180
- should == MetricFu::AVAILABLE_GRAPHS
181
- end
182
- end
183
-
184
- describe '#set_code_dirs ' do
185
- it 'should set the @code_dirs instance var to ["app", "lib"]' do
186
- # This is hard to spec properly because the @code_dirs variable
187
- # is set during the reset process.
188
- #@config.instance_variable_get(:@code_dirs).
189
- # should == ['app','lib']
190
- end
191
- end
192
- end
193
-
194
- describe 'if #rails? is false ' do
195
- before(:each) do
196
- @config.stub!(:rails?).and_return(false)
197
- end
198
-
199
- describe '#set_metrics ' do
200
- it 'should set the @metrics instance var to AVAILABLE_METRICS' do
201
- @config.instance_variable_get(:@metrics).
202
- should == MetricFu::AVAILABLE_METRICS
203
- end
204
- end
205
-
206
- describe '#set_code_dirs ' do
207
- it 'should set the @code_dirs instance var to ["lib"]' do
208
- @config.instance_variable_get(:@code_dirs).should == ['lib']
209
- end
210
- end
211
- end
212
- end
213
-
214
- describe '#add_attr_accessors_to_self' do
215
-
216
- before(:each) { get_new_config }
217
-
218
- MetricFu::AVAILABLE_METRICS.each do |metric|
219
- it "should have a reader for #{metric}" do
220
- @config.respond_to?(metric).should be_true
221
- end
222
-
223
- it "should have a writer for #{metric}=" do
224
- @config.respond_to?((metric.to_s + '=').to_sym).should be_true
225
- end
226
- end
227
- end
228
-
229
- describe '#add_class_methods_to_metric_fu' do
230
-
231
- before(:each) { get_new_config }
232
-
233
- MetricFu::AVAILABLE_METRICS.each do |metric|
234
- it "should add a #{metric} class method to the MetricFu module " do
235
- MetricFu.should respond_to(metric)
236
- end
237
- end
238
-
239
- MetricFu::AVAILABLE_GRAPHS.each do |graph|
240
- it "should add a #{graph} class metrhod to the MetricFu module" do
241
- MetricFu.should respond_to(graph)
242
- end
243
- end
244
- end
245
-
246
- describe '#platform' do
247
-
248
- before(:each) { get_new_config }
249
-
250
- it 'should return the value of the PLATFORM constant' do
251
- this_platform = RUBY_PLATFORM
252
- @config.platform.should == this_platform
253
- end
254
- end
255
-
256
- describe '#is_cruise_control_rb? ' do
257
-
258
- before(:each) { get_new_config }
259
- describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
260
-
261
- before(:each) { ENV['CC_BUILD_ARTIFACTS'] = 'is set' }
262
-
263
- it 'should return true' do
264
- @config.is_cruise_control_rb?.should be_true
265
- end
266
-
267
- end
268
-
269
- describe "when the CC_BUILD_ARTIFACTS env var is nil" do
270
- before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
271
-
272
- it 'should return false' do
273
- @config.is_cruise_control_rb?.should be_false
274
- end
275
- end
276
- end
277
- end