khall-metric_fu 1.0.2.1

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.
Files changed (47) hide show
  1. data/HISTORY +119 -0
  2. data/MIT-LICENSE +22 -0
  3. data/Manifest.txt +25 -0
  4. data/README +1 -0
  5. data/Rakefile +46 -0
  6. data/TODO +14 -0
  7. data/lib/base/base_template.rb +134 -0
  8. data/lib/base/configuration.rb +187 -0
  9. data/lib/base/generator.rb +147 -0
  10. data/lib/base/md5_tracker.rb +52 -0
  11. data/lib/base/report.rb +100 -0
  12. data/lib/generators/churn.rb +86 -0
  13. data/lib/generators/flay.rb +29 -0
  14. data/lib/generators/flog.rb +127 -0
  15. data/lib/generators/rcov.rb +77 -0
  16. data/lib/generators/reek.rb +32 -0
  17. data/lib/generators/roodi.rb +24 -0
  18. data/lib/generators/saikuro.rb +212 -0
  19. data/lib/generators/stats.rb +43 -0
  20. data/lib/metric_fu.rb +20 -0
  21. data/lib/templates/standard/churn.html.erb +30 -0
  22. data/lib/templates/standard/default.css +64 -0
  23. data/lib/templates/standard/flay.html.erb +33 -0
  24. data/lib/templates/standard/flog.html.erb +52 -0
  25. data/lib/templates/standard/index.html.erb +38 -0
  26. data/lib/templates/standard/rcov.html.erb +42 -0
  27. data/lib/templates/standard/reek.html.erb +41 -0
  28. data/lib/templates/standard/roodi.html.erb +28 -0
  29. data/lib/templates/standard/saikuro.html.erb +83 -0
  30. data/lib/templates/standard/standard_template.rb +26 -0
  31. data/lib/templates/standard/stats.html.erb +54 -0
  32. data/spec/base/base_template_spec.rb +140 -0
  33. data/spec/base/configuration_spec.rb +303 -0
  34. data/spec/base/generator_spec.rb +159 -0
  35. data/spec/base/md5_tracker_spec.rb +57 -0
  36. data/spec/base/report_spec.rb +139 -0
  37. data/spec/generators/churn_spec.rb +152 -0
  38. data/spec/generators/flay_spec.rb +101 -0
  39. data/spec/generators/flog_spec.rb +200 -0
  40. data/spec/generators/reek_spec.rb +59 -0
  41. data/spec/generators/saikuro_spec.rb +53 -0
  42. data/spec/generators/stats_spec.rb +74 -0
  43. data/spec/spec_helper.rb +28 -0
  44. data/tasks/metric_fu.rake +15 -0
  45. data/tasks/railroad.rake +39 -0
  46. data/vendor/saikuro/saikuro.rb +1214 -0
  47. metadata +163 -0
data/HISTORY ADDED
@@ -0,0 +1,119 @@
1
+ === MetricFu 1.0.2 / 2009-5-11
2
+
3
+ * Fixing problems with Reek new line character (thanks to all who pointed this out)
4
+ * Flog now recognizes namespaces in method names thanks to Daniel Guettler
5
+ * Saikuro now looks at multiple directories, again.
6
+
7
+ === MetricFu 1.0.1 / 2009-5-3
8
+
9
+ * metrics:all task no longer requires a MetricFu::Configuration.run {} if you want to accept the defaults
10
+ * rcov task now reports total coverage percent
11
+
12
+ === MetricFu 1.0.0 / 2009-4-30
13
+
14
+ * Merged in Grant McInnes' work on creating yaml output for all metrics to aid harvesting by other tools
15
+ * Supporting Flog 2.1.0
16
+ * Supporting Reek 1.0.0
17
+ * Removed dependency on Rails Env for 3.months.ago (for churn report), now using chronic gem ("3 months ago").
18
+ * Almost all code is out of Rakefiles now and so is more easily testable
19
+ * Metrics inherit from a refactored Generator now. New metrics generators just have to implement "emit", "analyze", "to_h" and inherit from Generator. They also must have a template. See the flay generator and template for a simple implementation.
20
+ * You now define the metrics you wish to run in the configuration and then run "metrics:all". No other metrics task is exposed by default.
21
+
22
+ === MetricFu 0.9.0 / 2009-1-25
23
+
24
+ * Adding line numbers to the views so that people viewing it on cc.rb can figure out where the problems are
25
+ * Merging in changes from Jay Zeschin having to do with the railroad task -- I still have no idea how to use it (lemme know if you figure it out)
26
+ * Added totals to Flog results
27
+ * Moved rcov options to configuration
28
+
29
+ === MetricFu 0.8.9 / 2009-1-20
30
+
31
+ * Thanks to Andre Arko and Petrik de Heus for adding the following features:
32
+ * The source control type is auto-detected for Churn
33
+ * Moved all presentation to templates
34
+ * Wrote specs for all classes
35
+ * Added flay, Reek and Roodi metrics
36
+ * There's now a configuration class (see README for details)
37
+ * Unification of metrics reports
38
+ * Metrics can be generated using one command
39
+ * Adding new metrics reports has been standardized
40
+
41
+ === MetricFu 0.8.0 / 2008-10-06
42
+
43
+ * Source Control Churn now supports git (thanks to Erik St Martin)
44
+ * Flog Results are sorted by Highest Flog Score
45
+ * Fix for a bunch of 'already initialized constant' warnings that metric_fu caused
46
+ * Fixing bug so the flog reporter can handle methods with digits in the name (thanks to Andy Gregorowicz)
47
+ * Internal Rake task now allows metric_fu to flog/churn itself
48
+
49
+ === MetricFu 0.7.6 / 2008-09-15
50
+
51
+ * CHURN_OPTIONS has become MetricFu::CHURN_OPTIONS
52
+ * SAIKURO_OPTIONS has become MetricFu::SAIKURO_OPTIONS
53
+ * Rcov now looks at test and specs
54
+ * Exclude gems and Library ruby code from rcov
55
+ * Fixed bug with churn start_date functionality (bad path)
56
+
57
+ === MetricFu 0.7.5 / 2008-09-12
58
+
59
+ * Flog can now flog any set of directories you like (see README).
60
+ * Saikuro can now look at any set of directories you like (see README).
61
+
62
+ === MetricFu 0.7.1 / 2008-09-12
63
+
64
+ * Fixed filename bugs pointed out by Bastien
65
+
66
+ === MetricFu 0.7.0 / 2008-09-11
67
+
68
+ * Merged in Sean Soper's changes to metric_fu.
69
+ * Metric_fu is now a gem.
70
+ * Flogging now uses a MD5 hash to figure out if it should re-flog a file (if it's changed)
71
+ * Flogging also has a cool new output screen(s)
72
+ * Thanks Sean!
73
+
74
+ === Metricks 0.4.2 / 2008-07-01
75
+
76
+ * Changed rcov output directory so that it is no longer 'coverage/unit' but just 'coverage' for better integration with CC.rb
77
+
78
+ === Metricks 0.4.1 / 2008-06-13
79
+
80
+ * Rcov tests now extend beyond one level depth directory by using RcovTask instead of the shell
81
+
82
+ === Metricks 0.4.0 / 2008-06-13
83
+
84
+ * Implementing functionality for use as a gem
85
+ * Added Rakefile to facilitate testing
86
+
87
+ === Metricks 0.3.0 / 2008-06-11
88
+
89
+ * Generated reports now open on darwin automatically
90
+ * Generated reports reside under tmp/metricks unless otherwise specified by ENV['CC_BUILD_ARTIFACTS']
91
+ * MD5Tracker works with Flog reports for speed optimization
92
+
93
+ === Metricks 0.2.0 / 2008-06-11
94
+
95
+ * Integrated use of base directory constant
96
+ * Have all reports automatically open in a browser if platform is darwin
97
+ * Namespaced under Metricks
98
+ * Dropped use of shell md5 command in favor of Ruby's Digest::MD5 libraries
99
+
100
+ === Metricks 0.1.0 / 2008-06-10
101
+
102
+ * Initial integration of metric_fu and my enhancements to flog
103
+ * Metrics are generated but are all over the place
104
+
105
+ === MetricFu 0.6.0 / 2008-05-11
106
+
107
+ * Add source control churn report
108
+
109
+ === MetricFu 0.5.1 / 2008-04-25
110
+
111
+ * Fixed bug with Saikuro report generation
112
+
113
+ === MetricFu 0.5.0 / 2008-04-25
114
+
115
+ * create MetricFu as a Rails Plugin
116
+ * Add Flog Report
117
+ * Add Coverage Report
118
+ * Add Saikuro Report
119
+ * Add Stats Report
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008,2009 Jake Scruggs
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,25 @@
1
+ History.txt
2
+ Manifest.txt
3
+ metric_fu-0.7.gem
4
+ metric_fu.gemspec
5
+ MIT-LICENSE
6
+ Rakefile
7
+ README
8
+ TODO.txt
9
+ lib/metric_fu.rb
10
+ lib/metric_fu/base.rb
11
+ lib/metric_fu/churn.rb
12
+ lib/metric_fu/flay_reporter.rb
13
+ lib/metric_fu/flog_reporter.rb
14
+ lib/metric_fu/md5_tracker.rb
15
+ lib/metric_fu/saikuro/saikuro.rb
16
+ lib/metric_fu/saikuro/SAIKURO_README
17
+ lib/tasks/churn.rake
18
+ lib/tasks/coverage.rake
19
+ lib/tasks/flog.rake
20
+ lib/tasks/metric_fu.rake
21
+ lib/tasks/metric_fu.rb
22
+ lib/tasks/saikuro.rake
23
+ lib/tasks/stats.rake
24
+ test/test_helper.rb
25
+ test/test_md5_tracker.rb
data/README ADDED
@@ -0,0 +1 @@
1
+ See http://metric-fu.rubyforge.org/ for documentation, or the HISTORY file for a change log.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'rake/rdoctask'
3
+ require 'spec/rake/spectask'
4
+ require 'lib/metric_fu'
5
+
6
+ desc "Run all specs in spec directory"
7
+ Spec::Rake::SpecTask.new(:spec) do |t|
8
+ t.spec_files = FileList['spec/**/*_spec.rb']
9
+ t.rcov = true
10
+ t.rcov_opts = ['--exclude', 'spec,config,Library,usr/lib/ruby']
11
+ t.rcov_dir = File.join(File.dirname(__FILE__), "tmp")
12
+ end
13
+
14
+ MetricFu::Configuration.run do |config|
15
+ end
16
+
17
+ namespace :metrics do
18
+ desc "Generate all reports"
19
+ task :all do
20
+ MetricFu.metrics.each {|metric| MetricFu.report.add(metric) }
21
+ MetricFu.report.save_output(MetricFu.report.to_yaml,
22
+ MetricFu.base_directory,
23
+ 'report.yml')
24
+ MetricFu.report.save_templatized_report
25
+ if MetricFu.report.open_in_browser?
26
+ MetricFu.report.show_in_browser(MetricFu.output_directory)
27
+ end
28
+ end
29
+
30
+ MetricFu.metrics.each do |metric|
31
+ desc "Generate report for #{metric}"
32
+ task metric do
33
+
34
+ MetricFu.report.add(metric)
35
+ MetricFu.report.save_output(MetricFu.report.to_yaml,
36
+ MetricFu.base_directory,
37
+ 'report.yml')
38
+ MetricFu.report.save_templatized_report
39
+ if MetricFu.report.open_in_browser?
40
+ MetricFu.report.show_in_browser(MetricFu.output_directory)
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ task :default => [:"metrics:all"]
data/TODO ADDED
@@ -0,0 +1,14 @@
1
+ == TODO list
2
+
3
+ * Color code flog results with scale from: http://jakescruggs.blogspot.com/2008/08/whats-good-flog-score.html
4
+ * Extract functionality from rake files and put under test
5
+ * Integrate Flog, Saikuro, and Coverage into one report so you can see methods that have high complexity and low coverage (this is a big one)
6
+ * Integrate MD5 hashing with remainder of reports
7
+ * Move HTML out of code and into templates/
8
+ * Replace #generate_report with #new on each metric class
9
+ * Make each class descend from MetricFu::CodeMetric
10
+ * Generate metrics:* rake tasks for each of CodeMetric's descendants
11
+ * Update flog specs so that they actually run flog
12
+ * Add flay specs that run flay
13
+ * Convert readme to markdown and rename to README.mkdn so github will render it
14
+ * Saikuro.rb falls over if tries to parse an empty file. Fair enough. We shouldn't feed it empty files
@@ -0,0 +1,134 @@
1
+ module MetricFu
2
+
3
+ # The Template class is intended as an abstract class for concrete
4
+ # template classes to subclass. It provides a variety of utility
5
+ # methods to make templating a bit easier. However, classes do not
6
+ # have to inherit from here in order to provide a template. The only
7
+ # requirement for a template class is that it provides a #write method
8
+ # to actually write out the template. See StandardTemplate for an
9
+ # example.
10
+ class Template
11
+ attr_accessor :report
12
+
13
+ private
14
+ # Creates a new erb evaluated result from the passed in section.
15
+ #
16
+ # @param section String
17
+ # The section name of
18
+ #
19
+ # @return String
20
+ # The erb evaluated string
21
+ def erbify(section)
22
+ require 'erb'
23
+ erb_doc = File.read(template(section))
24
+ ERB.new(erb_doc).result(binding)
25
+ end
26
+
27
+ # Determines whether a template file exists for a given section
28
+ # of the full template.
29
+ #
30
+ # @param section String
31
+ # The section of the template to check against
32
+ #
33
+ # @return Boolean
34
+ # Does a template file exist for this section or not?
35
+ def template_exists?(section)
36
+ File.exist?(template(section))
37
+ end
38
+
39
+ # Copies an instance variable mimicing the name of the section
40
+ # we are trying to render, with a value equal to the passed in
41
+ # constant. Allows the concrete template classes to refer to
42
+ # that instance variable from their ERB rendering
43
+ #
44
+ # @param section String
45
+ # The name of the instance variable to create
46
+ #
47
+ # @param contents Object
48
+ # The value to set as the value of the created instance
49
+ # variable
50
+ def create_instance_var(section, contents)
51
+ instance_variable_set("@#{section}", contents)
52
+ end
53
+
54
+ # Generates the filename of the template file to load and
55
+ # evaluate. In this case, the path to the template directory +
56
+ # the section name + .html.erb
57
+ #
58
+ # @param section String
59
+ # A section of the template to render
60
+ #
61
+ # @return String
62
+ # A file path
63
+ def template(section)
64
+ File.join(this_directory, section.to_s + ".html.erb")
65
+ end
66
+
67
+ # Returns the filename that the template will render into for
68
+ # a given section. In this case, the section name + '.html'
69
+ #
70
+ # @param section String
71
+ # A section of the template to render
72
+ #
73
+ # @return String
74
+ # The output filename
75
+ def output_filename(section)
76
+ section.to_s + ".html"
77
+ end
78
+
79
+ # Returns the contents of a given css file in order to
80
+ # render it inline into a template.
81
+ #
82
+ # @param css String
83
+ # The name of a css file to open
84
+ #
85
+ # @return String
86
+ # The contents of the css file
87
+ def inline_css(css)
88
+ open(File.join(this_directory, css)) { |f| f.read }
89
+ end
90
+
91
+ # Provides a link to open a file through the textmate protocol
92
+ # on Darwin, or otherwise, a simple file link.
93
+ #
94
+ # @param name String
95
+ #
96
+ # @param line Integer
97
+ # The line number to link to, if textmate is available. Defaults
98
+ # to nil
99
+ #
100
+ # @return String
101
+ # An anchor link to a textmate reference or a file reference
102
+ def link_to_filename(name, line = nil)
103
+ filename = File.expand_path(name)
104
+ if MetricFu.configuration.platform.include?('darwin')
105
+ "<a href='txmt://open/?url=file://" \
106
+ +"#{filename}&line=#{line}'>#{name}:#{line}</a>"
107
+ else
108
+ "<a href='file://#{filename}'>#{name}:#{line}</a>"
109
+ end
110
+ end
111
+
112
+
113
+ # Provides a brain dead way to cycle between two values during
114
+ # an iteration of some sort. Pass in the first_value, the second_value,
115
+ # and the cardinality of the iteration.
116
+ #
117
+ # @param first_value Object
118
+ #
119
+ # @param second_value Object
120
+ #
121
+ # @param iteration Integer
122
+ # The number of times through the iteration.
123
+ #
124
+ # @return Object
125
+ # The first_value if iteration is even. The second_value if
126
+ # iteration is odd.
127
+ def cycle(first_value, second_value, iteration)
128
+ return first_value if iteration % 2 == 0
129
+ return second_value
130
+ end
131
+
132
+
133
+ end
134
+ end
@@ -0,0 +1,187 @@
1
+ module MetricFu
2
+
3
+ # A list of metrics which are available in the MetricFu system.
4
+ #
5
+ # These are metrics which have been developed for the system. Of
6
+ # course, in order to use these metrics, their respective gems must
7
+ # be installed on the system.
8
+ AVAILABLE_METRICS = [:churn, :flog, :flay, :reek,
9
+ :roodi, :saikuro, :rcov]
10
+
11
+
12
+ # The @@configuration class variable holds a global type configuration
13
+ # object for any parts of the system to use.
14
+ def self.configuration
15
+ @@configuration ||= Configuration.new
16
+ end
17
+
18
+ # = Configuration
19
+ #
20
+ # The Configuration class, as it sounds, provides methods for
21
+ # configuring the behaviour of MetricFu.
22
+ #
23
+ # == Customization for Rails
24
+ #
25
+ # The Configuration class checks for the presence of a
26
+ # 'config/environment.rb' file. If the file is present, it assumes
27
+ # it is running in a Rails project. If it is, it will:
28
+ #
29
+ # * Add 'app' to the @code_dirs directory to include the
30
+ # code in the app directory in the processing
31
+ # * Add :stats to the list of metrics to run to get the Rails stats
32
+ # task
33
+ #
34
+ # == Customization for CruiseControl.rb
35
+ #
36
+ # The Configuration class checks for the presence of a
37
+ # 'CC_BUILD_ARTIFACTS' environment variable. If it's found
38
+ # it will change the default output directory from the default
39
+ # "tmp/metric_fu to the directory represented by 'CC_BUILD_ARTIFACTS'
40
+ #
41
+ # == Deprications
42
+ #
43
+ # The Configuration class checks for several deprecated constants
44
+ # that were previously used to configure MetricFu. These include
45
+ # CHURN_OPTIONS, DIRECTORIES_TO_FLOG, SAIKURO_OPTIONS,
46
+ # and MetricFu::SAIKURO_OPTIONS.
47
+ #
48
+ # These have been replaced by config.churn, config.flog and
49
+ # config.saikuro respectively.
50
+ class Configuration
51
+
52
+ def initialize #:nodoc:#
53
+ warn_about_deprecated_config_options
54
+ reset
55
+ add_attr_accessors_to_self
56
+ add_class_methods_to_metric_fu
57
+ end
58
+
59
+ # Searches through the instance variables of the class and
60
+ # creates a class method on the MetricFu module to read the value
61
+ # of the instance variable from the Configuration class.
62
+ def add_class_methods_to_metric_fu
63
+ instance_variables.each do |name|
64
+ method_name = name[1..-1].to_sym
65
+ method = <<-EOF
66
+ def self.#{method_name}
67
+ configuration.send(:#{method_name})
68
+ end
69
+ EOF
70
+ MetricFu.module_eval(method)
71
+ end
72
+ end
73
+
74
+ # Searches through the instance variables of the class and creates
75
+ # an attribute accessor on this instance of the Configuration
76
+ # class for each instance variable.
77
+ def add_attr_accessors_to_self
78
+ instance_variables.each do |name|
79
+ method_name = name[1..-1].to_sym
80
+ MetricFu::Configuration.send(:attr_accessor, method_name)
81
+ end
82
+ end
83
+
84
+ # Check if certain constants that are deprecated have been
85
+ # assigned. If so, warn the user about them, and the
86
+ # fact that they will have no effect.
87
+ def warn_about_deprecated_config_options
88
+ if defined?(::MetricFu::CHURN_OPTIONS)
89
+ raise("Use config.churn instead of MetricFu::CHURN_OPTIONS")
90
+ end
91
+ if defined?(::MetricFu::DIRECTORIES_TO_FLOG)
92
+ raise("Use config.flog[:dirs_to_flog] "+
93
+ "instead of MetricFu::DIRECTORIES_TO_FLOG")
94
+ end
95
+ if defined?(::MetricFu::SAIKURO_OPTIONS)
96
+ raise("Use config.saikuro instead of MetricFu::SAIKURO_OPTIONS")
97
+ end
98
+ if defined?(SAIKURO_OPTIONS)
99
+ raise("Use config.saikuro instead of SAIKURO_OPTIONS")
100
+ end
101
+ end
102
+
103
+ # This allows us to have a nice syntax like:
104
+ #
105
+ # MetricFu.run do |config|
106
+ # config.base_directory = 'tmp/metric_fu'
107
+ # end
108
+ #
109
+ # See the README for more information on configuration options.
110
+ def self.run
111
+ yield MetricFu.configuration
112
+ end
113
+
114
+ # This does the real work of the Configuration class, by setting
115
+ # up a bunch of instance variables to represent the configuration
116
+ # of the MetricFu app.
117
+ def reset
118
+ @base_directory = ENV['CC_BUILD_ARTIFACTS'] || 'tmp/metric_fu'
119
+ @scratch_directory = File.join(@base_directory, 'scratch')
120
+ @output_directory = File.join(@base_directory, 'output')
121
+ @metric_fu_root_directory = File.join(File.dirname(__FILE__),
122
+ '..', '..')
123
+ @template_directory = File.join(@metric_fu_root_directory,
124
+ 'lib', 'templates')
125
+ @template_class = StandardTemplate
126
+ set_metrics
127
+ set_code_dirs
128
+ @flay = { :dirs_to_flay => @code_dirs }
129
+ @flog = { :dirs_to_flog => @code_dirs }
130
+ @reek = { :dirs_to_reek => @code_dirs }
131
+ @roodi = { :dirs_to_roodi => @code_dirs }
132
+ @saikuro = { :output_directory => @scratch_directory + '/saikuro',
133
+ :input_directory => @code_dirs,
134
+ :cyclo => "",
135
+ :filter_cyclo => "0",
136
+ :warn_cyclo => "5",
137
+ :error_cyclo => "7",
138
+ :formater => "text"}
139
+ @churn = {}
140
+ @stats = {}
141
+ @rcov = { :test_files => ['test/**/*_test.rb',
142
+ 'spec/**/*_spec.rb'],
143
+ :rcov_opts => ["--sort coverage",
144
+ "--no-html",
145
+ "--text-coverage",
146
+ "--no-color",
147
+ "--profile",
148
+ "--rails",
149
+ "--exclude /gems/,/Library/,/usr/,spec"]}
150
+ end
151
+
152
+ # Perform a simple check to try and guess if we're running
153
+ # against a rails app.
154
+ #
155
+ # @todo This should probably be made a bit more robust.
156
+ def rails?
157
+ @rails = File.exist?("config/environment.rb")
158
+ end
159
+
160
+ # Add the :stats task to the AVAILABLE_METRICS constant if we're
161
+ # running within rails.
162
+ def set_metrics
163
+ if rails?
164
+ @metrics = MetricFu::AVAILABLE_METRICS + [:stats]
165
+ else
166
+ @metrics = MetricFu::AVAILABLE_METRICS
167
+ end
168
+ end
169
+
170
+ # Add the 'app' directory if we're running within rails.
171
+ def set_code_dirs
172
+ if rails?
173
+ @code_dirs = ['app', 'lib']
174
+ else
175
+ @code_dirs = ['lib']
176
+ end
177
+ end
178
+
179
+ def platform #:nodoc:
180
+ return PLATFORM
181
+ end
182
+
183
+ def is_cruise_control_rb?
184
+ !!ENV['CC_BUILD_ARTIFACTS']
185
+ end
186
+ end
187
+ end