code_statistics 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,5 +1,7 @@
1
1
  Copyright (c) 2009 Devver
2
2
 
3
+ The MIT License
4
+
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
5
7
  "Software"), to deal in the Software without restriction, including
@@ -2,6 +2,14 @@
2
2
 
3
3
  This is a port of the rails 'rake stat' so it can be used on none rails projects and have it's features slowly expanded. Please feel free to contact us if you have any ideas for additional stats that should be added.
4
4
 
5
+ todos:
6
+ * make bin accept passed cmd line arguments to run
7
+ * stop relying on ENV vars
8
+ * count number of total files
9
+ * count number of of .rb or passed in filter files
10
+ * find todo, perf, bug, hack, etc comments and display them with info about them (line number etc)
11
+
12
+
5
13
  contact@devver.net
6
14
 
7
15
  == Note on Patches/Pull Requests
data/Rakefile CHANGED
@@ -11,7 +11,9 @@ begin
11
11
  gem.email = "dan@devver.net"
12
12
  gem.homepage = "http://github.com/danmayer/code_statistics"
13
13
  gem.authors = ["Dan Mayer"]
14
- gem.add_development_dependency "thoughtbot-shoulda"
14
+ gem.add_development_dependency "thoughtbot-shoulda"
15
+ gem.add_development_dependency "devver-construct"
16
+ gem.executables = ['code_statistics']
15
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
18
  end
17
19
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -0,0 +1,29 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ stats_directories = [
4
+ %w(Libraries lib/),
5
+ %w(Source source/),
6
+ %w(Src src/),
7
+ ].collect { |name, dir| [ name, "#{Dir.pwd}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
8
+
9
+ if ENV['DIRECTORIES_TO_CALCULATE']
10
+ user_defined_dirs = ENV['DIRECTORIES_TO_CALCULATE'].split(',')
11
+ user_defined_dirs.each do |dir|
12
+ if File.directory?(dir)
13
+ stats_directories << [dir.capitalize, "#{Dir.pwd}/#{dir}"]
14
+ end
15
+ end
16
+ end
17
+
18
+ if ENV['IGNORE_FILE_GLOBS']
19
+ user_ignored_dirs = ENV['IGNORE_FILE_GLOBS'].split(',')
20
+ else
21
+ user_ignored_dirs = []
22
+ end
23
+
24
+ def report_stats(stats_directories, user_ignored_dirs)
25
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'code_statistics', 'code_statistics')
26
+ puts CodeStatistics::CodeStatistics.new(stats_directories, user_ignored_dirs).to_s
27
+ end
28
+
29
+ report_stats(stats_directories, user_ignored_dirs)
@@ -5,13 +5,15 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{code_statistics}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Mayer"]
12
- s.date = %q{2009-11-18}
12
+ s.date = %q{2009-11-22}
13
+ s.default_executable = %q{code_statistics}
13
14
  s.description = %q{"This is a port of the rails 'rake stats' method so it can be made more robust and work for non rails projects. New features may eventually be added as well."}
14
15
  s.email = %q{dan@devver.net}
16
+ s.executables = ["code_statistics"]
15
17
  s.extra_rdoc_files = [
16
18
  "LICENSE",
17
19
  "README.rdoc"
@@ -23,6 +25,7 @@ Gem::Specification.new do |s|
23
25
  "README.rdoc",
24
26
  "Rakefile",
25
27
  "VERSION",
28
+ "bin/code_statistics",
26
29
  "code_statistics.gemspec",
27
30
  "lib/code_statistics.rb",
28
31
  "lib/code_statistics/code_statistics.rb",
@@ -46,10 +49,13 @@ Gem::Specification.new do |s|
46
49
 
47
50
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
51
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
52
+ s.add_development_dependency(%q<devver-construct>, [">= 0"])
49
53
  else
50
54
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
55
+ s.add_dependency(%q<devver-construct>, [">= 0"])
51
56
  end
52
57
  else
53
58
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
59
+ s.add_dependency(%q<devver-construct>, [">= 0"])
54
60
  end
55
61
  end
@@ -129,7 +129,14 @@ module CodeStatistics
129
129
 
130
130
  def print_header
131
131
  print_splitter
132
- @print_buffer << "| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |\n"
132
+ @print_buffer << "| Name".ljust(22)+" "+
133
+ "| Lines".ljust(8)+
134
+ "| LOC".ljust(8)+
135
+ "| Classes".ljust(10)+
136
+ "| Methods".ljust(10)+
137
+ "| M/C".ljust(6)+
138
+ "| LOC/M".ljust(6)+
139
+ " |\n"
133
140
  print_splitter
134
141
  end
135
142
 
@@ -147,13 +154,15 @@ module CodeStatistics
147
154
  "| #{name.ljust(20)} "
148
155
  end
149
156
 
150
- @print_buffer << start +
151
- "| #{statistics["lines"].to_s.rjust(5)} " +
152
- "| #{statistics["codelines"].to_s.rjust(5)} " +
153
- "| #{statistics["classes"].to_s.rjust(7)} " +
154
- "| #{statistics["methods"].to_s.rjust(7)} " +
155
- "| #{m_over_c.to_s.rjust(3)} " +
156
- "| #{loc_over_m.to_s.rjust(5)} |\n"
157
+ if (statistics['lines']!=0)
158
+ @print_buffer << start +
159
+ "| #{statistics["lines"].to_s.rjust(5)} " +
160
+ "| #{statistics["codelines"].to_s.rjust(5)} " +
161
+ "| #{statistics["classes"].to_s.rjust(7)} " +
162
+ "| #{statistics["methods"].to_s.rjust(7)} " +
163
+ "| #{m_over_c.to_s.rjust(3)} " +
164
+ "| #{loc_over_m.to_s.rjust(5)} |\n"
165
+ end
157
166
  end
158
167
 
159
168
  def print_code_test_stats
@@ -19,15 +19,19 @@ else
19
19
  user_ignored_dirs = []
20
20
  end
21
21
 
22
- desc "Report code statistics (KLOCs, etc) from the application"
23
- task :stats do
22
+ def report_stats(stats_directories, user_ignored_dirs)
24
23
  require File.join(File.dirname(__FILE__), '..', 'code_statistics', 'code_statistics')
25
24
  puts CodeStatistics::CodeStatistics.new(stats_directories, user_ignored_dirs).to_s
26
25
  end
27
26
 
27
+ desc "Report code statistics (KLOCs, etc) from the application"
28
+ task :stats do
29
+ report_stats(stats_directories, user_ignored_dirs)
30
+ end
31
+
28
32
  #this is for apps that already had a stats task, but want to use the newer features of this gem
29
33
  desc "Report code statistics (KLOCs, etc) from the application"
30
34
  task :code_stats do
31
- require File.join(File.dirname(__FILE__), '..', 'code_statistics', 'code_statistics')
32
- puts CodeStatistics::CodeStatistics.new(stats_directories, user_ignored_dirs).to_s
35
+ report_stats(stats_directories, user_ignored_dirs)
33
36
  end
37
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-18 00:00:00 -05:00
13
- default_executable:
12
+ date: 2009-11-22 00:00:00 -05:00
13
+ default_executable: code_statistics
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thoughtbot-shoulda
@@ -22,10 +22,20 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: devver-construct
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
25
35
  description: "\"This is a port of the rails 'rake stats' method so it can be made more robust and work for non rails projects. New features may eventually be added as well.\""
26
36
  email: dan@devver.net
27
- executables: []
28
-
37
+ executables:
38
+ - code_statistics
29
39
  extensions: []
30
40
 
31
41
  extra_rdoc_files:
@@ -38,6 +48,7 @@ files:
38
48
  - README.rdoc
39
49
  - Rakefile
40
50
  - VERSION
51
+ - bin/code_statistics
41
52
  - code_statistics.gemspec
42
53
  - lib/code_statistics.rb
43
54
  - lib/code_statistics/code_statistics.rb