Class: RedminePluginSupport::StatsTask

Inherits:
GeneralTask
  • Object
show all
Defined in:
lib/redmine_plugin_support/stats_task.rb

Constant Summary collapse

STATS_DIRECTORIES =
[
%w(Controllers        app/controllers),
%w(Helpers            app/helpers), 
%w(Models             app/models),
%w(Libraries          lib/),
%w(APIs               app/apis),
%w(Integration\ tests test/integration),
%w(Functional\ tests  test/functional),
%w(Unit\ tests        test/unit)

Instance Attribute Summary

Attributes inherited from GeneralTask

#name

Instance Method Summary collapse

Methods inherited from GeneralTask

#initialize

Constructor Details

This class inherits a constructor from RedminePluginSupport::GeneralTask

Instance Method Details

#defineObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/redmine_plugin_support/stats_task.rb', line 19

def define
  # TODO: Need to get rspec stats to work
  
  namespace :spec do
    task :statsetup do
      require 'code_statistics'
      STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?("#{RedmineHelper.plugin_root}/spec/models")
      STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?("#{RedmineHelper.plugin_root}/spec/views")
      STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?("#{RedmineHelper.plugin_root}/spec/controllers")
      STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?("#{RedmineHelper.plugin_root}/spec/helpers")
      STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?("#{RedmineHelper.plugin_root}/spec/lib")
      STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?("#{RedmineHelper.plugin_root}/spec/routing")
      STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?("#{RedmineHelper.plugin_root}/spec/integration")
      ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?("#{RedmineHelper.plugin_root}/spec/models")
      ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?("#{RedmineHelper.plugin_root}/spec/views")
      ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?("#{RedmineHelper.plugin_root}/spec/controllers")
      ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?("#{RedmineHelper.plugin_root}/spec/helpers")
      ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?("#{RedmineHelper.plugin_root}/spec/lib")
      ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?("#{RedmineHelper.plugin_root}/spec/routing")
      ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?("#{RedmineHelper.plugin_root}/spec/integration")
    end
  end



  desc "Report code statistics (KLOCs, etc) from the application"
  task :stats do
    require 'code_statistics'
    CodeStatistics.new(*stats_directories).to_s
  end
  
  self
end

#stats_directoriesObject



15
16
17
# File 'lib/redmine_plugin_support/stats_task.rb', line 15

def stats_directories
  STATS_DIRECTORIES.collect { |name, dir| [ name, "#{RedmineHelper.plugin_root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
end