Sha256: d3991518cabcb7693842262d263454b192cc59bf5ef726721fb5416807d15e4d
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
module RailsStats class SpecStatistics attr_reader :statistics, :total, :test SPEC_FOLDERS = ['controllers', 'features', 'helpers', 'models', 'requests', 'routing', 'integrations', 'integration', 'mailers', 'lib', 'acceptance', 'factories'] def initialize(directory, key_concepts) @test = true @directory = directory @key_concepts = key_concepts @statistics = calculate_statistics @total = calculate_total end private def calculate_total out = CodeStatisticsCalculator.new(true) @statistics.each do |key, stats| out.add(stats) end out end def calculate_statistics out = {} categorize_files.each do |key, list| out[key] = Util.calculate_file_statistics(list) end out end def categorize_files out = {} Dir[File.join(@directory, "**", "*.rb")].each do |file_path| if file_path =~ /.*_spec.rb$/ key = categorize_file(file_path) else key = "Spec Support" end out[key] ||= [] out[key] << file_path end out end def categorize_file(file_path) types = (@key_concepts + SPEC_FOLDERS).uniq types.each do |folder| if file_path =~ /\/#{folder}\// folder = Inflector.humanize(folder) folder = Inflector.titleize(folder) folder = Inflector.singularize(folder) return "#{folder} Tests" end end # something else return "Other Tests" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_stats-2.0.1 | lib/rails_stats/spec_statistics.rb |
rails_stats-2.0.0 | lib/rails_stats/spec_statistics.rb |