rails_stats 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -7
- data/Rakefile +7 -1
- data/lib/rails_stats/code_statistics.rb +5 -2
- data/lib/rails_stats/test_statistics.rb +74 -0
- data/lib/rails_stats/version.rb +1 -1
- data/lib/rails_stats.rb +1 -3
- data/rails_stats.gemspec +2 -3
- metadata +5 -20
- data/lib/rails_stats/rake.rb +0 -37
- data/stats.thor +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49a95d6e3cccd65728bc591f5beacb216608d9a6
|
4
|
+
data.tar.gz: 14506184a365bc2af465fa3e927cf3cbdb8f8e75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c579583a0acdefaa7388cc5c60df668c39d586575396d89d2a97abe24e594533c06a196b62a8369c92e46bb5d3f86facd3fd56d7b141fa54e441dbbcc025d981
|
7
|
+
data.tar.gz: 8dca4a07de86d2be8e26ae13767a611fb1d348c1bfc744648af333fa931680e9d438f4dd5dc8ff206c445a8b7bd4871919379effeff7283279fb190103361c24
|
data/README.md
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
See stuff about a Rails app.
|
4
4
|
|
5
5
|
```bash
|
6
|
-
$ bundle exec
|
6
|
+
$ bundle exec rake:stats[/path/to/app/]
|
7
7
|
|
8
|
-
Directory:
|
8
|
+
Directory: /path/to/app/
|
9
9
|
|
10
10
|
+----------------------+-------+-------+---------+---------+-----+-------+
|
11
11
|
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
|
@@ -30,11 +30,20 @@ Directory: ~/path/to/app/
|
|
30
30
|
|
31
31
|
```
|
32
32
|
|
33
|
+
### Things it knows about
|
34
|
+
|
35
|
+
* Any concepts you've added within an `app` directory
|
36
|
+
* Configuration files
|
37
|
+
* Library files
|
38
|
+
* Gems that you've embedded in the project
|
39
|
+
* Engines and their code
|
40
|
+
* RSpec/Unit/Cucumber Tests
|
41
|
+
|
33
42
|
### TODO
|
34
43
|
|
35
|
-
*
|
44
|
+
* Option to print out by app directory (stats per engine)
|
36
45
|
* Add views (jbuilder, erb, haml) but don't count towards ratios
|
37
|
-
* Support JS for projects that have it in public
|
38
|
-
* Add
|
39
|
-
*
|
40
|
-
*
|
46
|
+
* Support JS for projects that have it in public (but not compiled)
|
47
|
+
* Add CSS but don't count towards ratios
|
48
|
+
* Output other metrics like number of tables and columns
|
49
|
+
* Different output formatters
|
data/Rakefile
CHANGED
@@ -1,2 +1,8 @@
|
|
1
|
-
require "
|
1
|
+
require "rails_stats"
|
2
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
|
@@ -69,7 +69,7 @@ module RailsStats
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def calculate_gem_projects
|
72
|
-
gems = Util.calculate_projects(@root_directory, "**", "*.gemspec")
|
72
|
+
gems = Util.calculate_projects(@root_directory, "*", "**", "*.gemspec")
|
73
73
|
gems.collect do |root_path|
|
74
74
|
GemStatistics.new(root_path)
|
75
75
|
end
|
@@ -83,7 +83,10 @@ module RailsStats
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def calculate_test_projects
|
86
|
-
|
86
|
+
specs = Util.calculate_projects(@root_directory, "**", "test", "test_helper.rb")
|
87
|
+
specs.collect do |root_path|
|
88
|
+
TestStatistics.new(root_path, @key_concepts)
|
89
|
+
end
|
87
90
|
end
|
88
91
|
|
89
92
|
def calculate_root_projects
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module RailsStats
|
2
|
+
class TestStatistics
|
3
|
+
attr_reader :statistics, :total, :test
|
4
|
+
|
5
|
+
SPEC_FOLDERS = ['controllers',
|
6
|
+
'functional',
|
7
|
+
'helpers',
|
8
|
+
'models',
|
9
|
+
'requests',
|
10
|
+
'unit',
|
11
|
+
'integrations',
|
12
|
+
'integration',
|
13
|
+
'mailers',
|
14
|
+
'lib']
|
15
|
+
|
16
|
+
def initialize(directory, key_concepts)
|
17
|
+
@test = true
|
18
|
+
@directory = directory
|
19
|
+
@key_concepts = key_concepts
|
20
|
+
@statistics = calculate_statistics
|
21
|
+
@total = calculate_total
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def calculate_total
|
27
|
+
out = CodeStatisticsCalculator.new(true)
|
28
|
+
@statistics.each do |key, stats|
|
29
|
+
out.add(stats)
|
30
|
+
end
|
31
|
+
out
|
32
|
+
end
|
33
|
+
|
34
|
+
def calculate_statistics
|
35
|
+
out = {}
|
36
|
+
categorize_files.each do |key, list|
|
37
|
+
out[key] = Util.calculate_file_statistics(list)
|
38
|
+
end
|
39
|
+
out
|
40
|
+
end
|
41
|
+
|
42
|
+
def categorize_files
|
43
|
+
out = {}
|
44
|
+
Dir[File.join(@directory, "**", "*.rb")].each do |file_path|
|
45
|
+
if file_path =~ /.*_test.rb$/
|
46
|
+
key = categorize_file(file_path)
|
47
|
+
else
|
48
|
+
key = "Test Support"
|
49
|
+
end
|
50
|
+
|
51
|
+
out[key] ||= []
|
52
|
+
out[key] << file_path
|
53
|
+
end
|
54
|
+
|
55
|
+
out
|
56
|
+
end
|
57
|
+
|
58
|
+
def categorize_file(file_path)
|
59
|
+
types = (@key_concepts + SPEC_FOLDERS).uniq
|
60
|
+
types.each do |folder|
|
61
|
+
if file_path =~ /\/#{folder}\//
|
62
|
+
folder = Inflector.humanize(folder)
|
63
|
+
folder = Inflector.titleize(folder)
|
64
|
+
folder = Inflector.singularize(folder)
|
65
|
+
return "#{folder} Tests"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# something else
|
70
|
+
return "Other Tests"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/lib/rails_stats/version.rb
CHANGED
data/lib/rails_stats.rb
CHANGED
@@ -10,11 +10,9 @@ require 'rails_stats/inflector'
|
|
10
10
|
require 'rails_stats/code_statistics_calculator'
|
11
11
|
require 'rails_stats/util'
|
12
12
|
require 'rails_stats/app_statistics'
|
13
|
+
require 'rails_stats/test_statistics'
|
13
14
|
require 'rails_stats/spec_statistics'
|
14
15
|
require 'rails_stats/cucumber_statistics'
|
15
16
|
require 'rails_stats/root_statistics'
|
16
17
|
require 'rails_stats/gem_statistics'
|
17
18
|
require 'rails_stats/code_statistics'
|
18
|
-
|
19
|
-
require "rails_stats/rake"
|
20
|
-
RailsStats.extend RailsStats::Rake
|
data/rails_stats.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["brian@bleonard.com"]
|
11
11
|
spec.summary = %q{Analyze a Rails project}
|
12
12
|
spec.description = %q{Point it to a directory and see stuff about the app}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/bleonard/rails_stats"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "
|
21
|
+
spec.add_dependency "rake"
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
-
spec.add_development_dependency "rake"
|
24
23
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Leonard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
description: Point it to a directory and see stuff about the app
|
56
42
|
email:
|
57
43
|
- brian@bleonard.com
|
@@ -71,14 +57,13 @@ files:
|
|
71
57
|
- lib/rails_stats/cucumber_statistics.rb
|
72
58
|
- lib/rails_stats/gem_statistics.rb
|
73
59
|
- lib/rails_stats/inflector.rb
|
74
|
-
- lib/rails_stats/rake.rb
|
75
60
|
- lib/rails_stats/root_statistics.rb
|
76
61
|
- lib/rails_stats/spec_statistics.rb
|
62
|
+
- lib/rails_stats/test_statistics.rb
|
77
63
|
- lib/rails_stats/util.rb
|
78
64
|
- lib/rails_stats/version.rb
|
79
65
|
- rails_stats.gemspec
|
80
|
-
|
81
|
-
homepage: ''
|
66
|
+
homepage: https://github.com/bleonard/rails_stats
|
82
67
|
licenses:
|
83
68
|
- MIT
|
84
69
|
metadata: {}
|
data/lib/rails_stats/rake.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# railties/lib/rails/tasks/statistics.rake
|
2
|
-
|
3
|
-
module RailsStats
|
4
|
-
module Rake
|
5
|
-
STATS_DIRECTORIES = [
|
6
|
-
%w(Controllers app/controllers),
|
7
|
-
%w(Helpers app/helpers),
|
8
|
-
%w(Models app/models),
|
9
|
-
%w(Mailers app/mailers),
|
10
|
-
%w(Observers app/observers),
|
11
|
-
%w(Javascripts app/assets/javascripts),
|
12
|
-
%w(Libraries lib/),
|
13
|
-
%w(APIs app/apis),
|
14
|
-
%w(Controller\ tests test/controllers),
|
15
|
-
%w(Helper\ tests test/helpers),
|
16
|
-
%w(Model\ tests test/models),
|
17
|
-
%w(Mailer\ tests test/mailers),
|
18
|
-
%w(Integration\ tests test/integration),
|
19
|
-
%w(Functional\ tests\ (old) test/functional),
|
20
|
-
%w(Unit\ tests \ (old) test/unit),
|
21
|
-
%w(Controller\ tests spec/controllers),
|
22
|
-
%w(Helper\ tests spec/helpers),
|
23
|
-
%w(Model\ tests spec/models),
|
24
|
-
%w(Mailer\ tests spec/mailers),
|
25
|
-
%w(Integration\ tests spec/integration),
|
26
|
-
%w(Integration\ tests spec/integrations),
|
27
|
-
%w(Request\ tests spec/requests),
|
28
|
-
%w(Library\ tests spec/lib),
|
29
|
-
%w(Cucumber\ tests features),
|
30
|
-
]
|
31
|
-
|
32
|
-
def calculate(root_directory)
|
33
|
-
puts "\nDirectory: #{root_directory}\n\n"
|
34
|
-
CodeStatistics.new(root_directory).to_s
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|