Skip to content

Commit fea8e03

Browse files
committed
Add support for format parameter in the command line
In order to call the rake task and get JSON output will be like so: ``` rake stats\[test/dummy,json\] ```
1 parent 0eb2bf1 commit fea8e03

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/rails_stats/tasks.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
desc "Report code statistics (KLOCs, etc) from the current (or given) application"
2-
task :stats, [:path] do |t, args|
2+
task :stats, [:path, :format] do |t, args|
33
Rake::Task["stats"].clear # clear out normal one if there
44
require 'rails_stats/all'
55

66
path = args[:path]
77
path = Rails.root.to_s if defined?(Rails)
8+
fmt = args[:format] || ""
89
raise "no path given for stats" unless path
910

1011
root_directory = File.absolute_path(path)
1112
puts "\nDirectory: #{root_directory}\n\n" if args[:path]
12-
RailsStats::CodeStatistics.new(root_directory).to_s
13+
RailsStats::CodeStatistics.new(root_directory, format: fmt).to_s
1314
end

0 commit comments

Comments
 (0)