Skip to content

Commit 9395229

Browse files
committed
Simplify running outside of an app
1 parent 00ccb50 commit 9395229

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

@@ -22,4 +22,4 @@
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)

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff 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

1921
Then you can call it:
2022

2123
```bash
22-
$ rake stats\[/path/to/app/\]
24+
$ rails_stats /path/to/app/
2325

2426
Directory: /path/to/app/
2527

exe/rails_stats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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

lib/rails_stats/console_formatter.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
module 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

rails_stats.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)