Sha256: e8b4aa2a3e74432747fa7fdddccc550b57dfd7ba969892cbf0c57c54385700d1

Contents?: true

Size: 1.38 KB

Versions: 19

Compression:

Stored size: 1.38 KB

Contents

require 'code_statistics'
require 'rbosa'

module Autotest::Shame
  @@chat_app = :adium

  def self.chat_app= o
    @@chat_app = o
  end

  # Until the rails team learns how to write modular code... I must steal :/
  STATS_DIRECTORIES = [
                       %w(Controllers        app/controllers),
                       %w(Helpers            app/helpers),
                       %w(Models             app/models),
                       %w(Libraries          lib/),
                       %w(APIs               app/apis),
                       %w(Components         components),
                       %w(Integration\ tests test/integration),
                       %w(Functional\ tests  test/functional),
                       %w(Unit\ tests        test/unit),
                      ].select { |name, dir| File.directory?(dir) }

  def self.shame
    stats = CodeStatistics.new(*STATS_DIRECTORIES)
    code  = stats.send :calculate_code
    tests = stats.send :calculate_tests
    msg = "Code To Test Ratio: 1:#{sprintf("%.2f", tests.to_f/code)}"
    $-w = ! $-w
    case @@chat_app
    when :adium then
      OSA.app('Adium').adium_controller.my_status_message = msg
    when :ichat then
      OSA.app('ichat').status_message = msg
    else
      raise "huh?"
    end
    $-w = ! $-w
    $stderr.puts "Status set to: #{msg.inspect}"
  end

  Autotest.add_hook(:all_good) do |autotest|
    shame
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
grosser-autotest-4.0.3 lib/autotest/shame.rb
grosser-autotest-4.0.4 lib/autotest/shame.rb
ryanbriones-ZenTest-3.11.1 lib/autotest/shame.rb
ZenTest-3.5.1 lib/autotest/shame.rb
ZenTest-3.5.2 lib/autotest/shame.rb
ZenTest-3.6.0 lib/autotest/shame.rb
ZenTest-3.6.1 lib/autotest/shame.rb
ZenTest-3.7.0 lib/autotest/shame.rb
ZenTest-3.7.1 lib/autotest/shame.rb
ZenTest-3.7.2 lib/autotest/shame.rb
ZenTest-3.8.0 lib/autotest/shame.rb
ZenTest-3.9.0 lib/autotest/shame.rb
ZenTest-3.9.1 lib/autotest/shame.rb
ZenTest-3.9.2 lib/autotest/shame.rb
ZenTest-3.9.3 lib/autotest/shame.rb
ZenTest-3.10.0 lib/autotest/shame.rb
ZenTest-3.11.0 lib/autotest/shame.rb
ZenTest-3.11.1 lib/autotest/shame.rb
ZenTest-4.0.0 lib/autotest/shame.rb