Class: Chuggle
- Inherits:
-
Object
- Object
- Chuggle
- Defined in:
- lib/chuggle.rb,
lib/chuggle/version.rb,
lib/chuggle/scatter_plot_generator.rb
Defined Under Namespace
Classes: Reporter, ScatterPlotGenerator
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
Instance Method Summary collapse
- #churn ⇒ Object
- #complexity ⇒ Object
-
#initialize(dir) ⇒ Chuggle
constructor
A new instance of Chuggle.
- #metrics_for(filename) ⇒ Object
Constructor Details
#initialize(dir) ⇒ Chuggle
Returns a new instance of Chuggle.
13 14 15 16 17 18 19 20 21 |
# File 'lib/chuggle.rb', line 13 def initialize(dir) @dir = dir @metrics = {} Dir.chdir(dir) do @ruby_files = Dir["**/*\.rb"] churn complexity end end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
11 12 13 |
# File 'lib/chuggle.rb', line 11 def dir @dir end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
12 13 14 |
# File 'lib/chuggle.rb', line 12 def metrics @metrics end |
Instance Method Details
#churn ⇒ Object
23 24 25 26 27 28 |
# File 'lib/chuggle.rb', line 23 def churn changes_by_ruby_file.each do |count, filename| print "." metrics_for(filename)[:churn] = Integer(count) end end |
#complexity ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chuggle.rb', line 30 def complexity flogger = Flog.new @ruby_files.each do |filename| print "." begin flogger.flog filename reporter = Reporter.new flogger.report(reporter) metrics_for(filename)[:complexity] = reporter.average rescue SyntaxError => e puts "\nError flogging: #{filename}\n" end end end |
#metrics_for(filename) ⇒ Object
46 47 48 |
# File 'lib/chuggle.rb', line 46 def metrics_for(filename) @metrics[filename] ||= {} end |