exclude files in stats

67 views
Skip to first unread message

Chris Ian Fiel

unread,
Oct 5, 2013, 5:49:16 AM10/5/13
to metr...@googlegroups.com


Hello I am using metric_fu in command line. How can I exclude files in stats report? Any Ideas?

Benjamin Fleischer

unread,
Oct 5, 2013, 8:55:14 AM10/5/13
to metr...@googlegroups.com
You could add to your .metrics file something like:

configure_metrics(:stats) do |stats|
  stats.additional_test_directories = [{glob_pattern: whatever, file_pattern: 'whatever'}]
  stats.additional_app_directories = [{glob_pattern: whatever, file_pattern: 'whatever'}]
end

Does that help?  I admit the code could be a bit more flexible.

The directories are currently added as below:


    # collects non empty directories and names the metric by the folder name
    # parent? or dirname? or basename?
    def collect_directories(glob_pattern, file_pattern='')
      Pathname.glob(glob_pattern).select{|f| f.basename.to_s.include?(file_pattern) }.map(&:dirname).uniq.map(&:realpath)
    end



    def default_run_options
      {
        # returns a list of directories that contains the glob of files that have the file_pattern in the file names
        :additional_test_directories => [{glob_pattern: File.join('.','spec','**','*_spec.rb'), file_pattern: 'spec'}],
        :additional_app_directories => [{glob_pattern: File.join('.','engines','**','*.rb'), file_pattern: ''}],
      }
    end






    # @return [Array<[ 'Acceptance specs', 'spec/acceptance' ]>]
    def dirs
      require 'code_metrics/stats_directories'
      require 'code_metrics/statistics'
      stats_dirs = CodeMetrics::StatsDirectories.new
      options.fetch(:additional_test_directories).each do |option|
        stats_dirs.add_test_directories(option.fetch(:glob_pattern), option.fetch(:file_pattern))
      end
      options.fetch(:additional_app_directories).each do |option|
        stats_dirs.add_directories(option.fetch(:glob_pattern), option.fetch(:file_pattern))
      end
      stats_dirs.directories
    end
Reply all
Reply to author
Forward
0 new messages