Skip to content

Commit e1fbc4e

Browse files
committed
replace the default rake stats
1 parent cc24c1e commit e1fbc4e

File tree

6 files changed

+42
-21
lines changed

6 files changed

+42
-21
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RailsStats mainly adds the ability to be run from outside the project in questio
88
### Run it
99

1010
```bash
11+
1112
$ bundle exec rake stats[/path/to/app/]
1213

1314
Directory: /path/to/app/
@@ -35,14 +36,27 @@ Directory: /path/to/app/
3536

3637
```
3738

39+
### Within your Rails project
40+
41+
You can also include it within your Rails application to _replace_ the default `rake stats` implementation.
42+
43+
Just add rails_stats to your Gemfile.
44+
Depending on your setup, you might need to `require rails_stats` in your Rakefile.
45+
46+
Then you'll be able to just run:
47+
48+
```bash
49+
$ bundle exec rake stats
50+
```
51+
3852
### Things it knows about
3953

40-
RailsStats also adds more coverage than the default.
54+
RailsStats adds more coverage than the default.
4155

4256
* Any concepts you've added within an `app` directory
4357
* Configuration files
4458
* Library files
45-
* Gems that you've embedded in the project
59+
* Gems that you've created and embedded in the project
4660
* Engines and their code
4761
* RSpec/Unit/Cucumber Tests
4862

@@ -249,4 +263,3 @@ Directory: /users/brian/examples/spree
249263
* Add CSS but don't count towards ratios
250264
* Output other metrics like number of tables and columns
251265
* Different output formatters
252-
* replace current rake stats if included in a Rails project

Rakefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
require "rails_stats"
2-
3-
desc "Calculates the statistsics for a given Rails project"
4-
task :stats, [:path] do |t, args|
5-
root_directory = File.absolute_path(args[:path])
6-
puts "\nDirectory: #{root_directory}\n\n"
7-
RailsStats::CodeStatistics.new(root_directory).to_s
8-
end

lib/rails_stats.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,5 @@ module RailsStats
44

55
end
66

7-
require 'rails_stats/inflector'
8-
require 'rails_stats/code_statistics_calculator'
9-
require 'rails_stats/util'
10-
require 'rails_stats/app_statistics'
11-
require 'rails_stats/test_statistics'
12-
require 'rails_stats/spec_statistics'
13-
require 'rails_stats/cucumber_statistics'
14-
require 'rails_stats/root_statistics'
15-
require 'rails_stats/gem_statistics'
16-
require 'rails_stats/code_statistics'
7+
require 'rails_stats/tasks'
8+

lib/rails_stats/all.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'rails_stats/inflector'
2+
require 'rails_stats/code_statistics_calculator'
3+
require 'rails_stats/util'
4+
require 'rails_stats/app_statistics'
5+
require 'rails_stats/test_statistics'
6+
require 'rails_stats/spec_statistics'
7+
require 'rails_stats/cucumber_statistics'
8+
require 'rails_stats/root_statistics'
9+
require 'rails_stats/gem_statistics'
10+
require 'rails_stats/code_statistics'

lib/rails_stats/tasks.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
desc "Report code statistics (KLOCs, etc) from the current (or given) application"
2+
task :stats, [:path] do |t, args|
3+
Rake::Task["stats"].clear # clear out normal one if there
4+
require 'rails_stats/all'
5+
6+
path = args[:path]
7+
path = Rails.root.to_s if defined?(Rails)
8+
raise "no path given for stats" unless path
9+
10+
root_directory = File.absolute_path(path)
11+
puts "\nDirectory: #{root_directory}\n\n" if args[:path]
12+
RailsStats::CodeStatistics.new(root_directory).to_s
13+
end

lib/rails_stats/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RailsStats
2-
VERSION = "0.1.0"
2+
VERSION = "1.0.0"
33
end

0 commit comments

Comments
 (0)