Method: CodeStats.analyze_and_report

Defined in:
lib/code_stats/code_stats.rb

.analyze_and_report(*args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/code_stats/code_stats.rb', line 30

def analyze_and_report *args
  # parsing options
  options = args.extract_options!
  paths = args

  options.validate_options! *(FileSet::AVAILIABLE_OPTIONS + Project::AVAILIABLE_OPTIONS)
  project_options = options.select{|k, v| Project::AVAILIABLE_OPTIONS.include? k}
  lang_options = options.select{|k, v| FileSet::AVAILIABLE_OPTIONS.include? k}

  # analyzing & reporting
  projects = analyze *(paths << project_options)
  report = Report.new(*(projects << lang_options)).render

  report_file = "./projects_statistics.html".to_file
  report_file.write report

  info "done, statistics are in #{report_file}"

  Kernel.exec "open #{report_file}"
end