File tree Expand file tree Collapse file tree 5 files changed +22
-13
lines changed Expand file tree Collapse file tree 5 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 11# main ([ unreleased] ( https://github.com/fastruby/rails_stats/compare/v1.0.2...main ) )
22
3- *
3+ * [ FEATURE: Simplify running outside of an app ] ( https://github.com/fastruby/rails_stats/pull/34 )
44
55# v2.0.1 ([ commits] ( https://github.com/fastruby/rails_stats/compare/v2.0.0...v2.0.1 ) )
66
2222# v1.0.1 / 2018-10-8
2323
2424* [ FEATURE: add more aggregate stats] ( https://github.com/fastruby/rails_stats/pull/5 )
25- * [ FEATURE: More detailed introspection of app] ( https://github.com/fastruby/rails_stats/pull/1 )
25+ * [ FEATURE: More detailed introspection of app] ( https://github.com/fastruby/rails_stats/pull/1 )
Original file line number Diff line number Diff line change @@ -8,18 +8,20 @@ RailsStats mainly adds the ability to be run from outside the project in questio
88
99### Run it outside Rails project
1010
11- You will need a ` Rakefile ` in the directory where you call ` rake ` and you will
12- need to require ` rails_stats ` :
11+ Install the gem globally with:
1312
14- ``` ruby
15- # Rakefile
16- require " rails_stats"
17- ```
13+ ` gem install rails_stats `
14+
15+ You can then run:
16+
17+ ` rails_stats PATH_TO_APP [FORMAT] `
18+
19+ (the format is optional and defaults to the console formatter).
1820
1921Then you can call it:
2022
2123``` bash
22- $ rake stats \[ /path/to/app/\]
24+ $ rails_stats /path/to/app/
2325
2426Directory: /path/to/app/
2527
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+
3+ $LOAD_PATH. unshift File . expand_path ( "../lib" , __dir__ )
4+ require "rails_stats/all"
5+
6+ root_directory = ARGV [ 0 ]
7+ fmt = ARGV [ 1 ] || ""
8+
9+ RailsStats ::CodeStatistics . new ( root_directory , { format : fmt } ) . to_s
Original file line number Diff line number Diff line change 33module RailsStats
44 class ConsoleFormatter < StatsFormatter
55 def to_s
6- Bundler ::Stats ::CLI . start
7-
86 print_header
97 sorted_keys = @statistics . keys . sort
108 sorted_keys . each { |key | print_line ( key , @statistics [ key ] ) }
@@ -54,4 +52,4 @@ def print_code_test_stats
5452 puts ""
5553 end
5654 end
57- end
55+ end
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
1414 spec . license = "MIT"
1515
1616 spec . files = `git ls-files -z` . split ( "\x0 " )
17- spec . executables = spec . files . grep ( %r{^bin /} ) { |f | File . basename ( f ) }
17+ spec . executables = spec . files . grep ( %r{^exe /} ) { |f | File . basename ( f ) }
1818 spec . test_files = spec . files . grep ( %r{^(test|spec|features)/} )
1919 spec . require_paths = [ "lib" ]
2020
You can’t perform that action at this time.
0 commit comments