jstats 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.rdoc +54 -0
  2. data/bin/jstats +102 -0
  3. data/jstats.rdoc +5 -0
  4. data/lib/jstats_version.rb +3 -0
  5. metadata +137 -0
@@ -0,0 +1,54 @@
1
+ = jstats
2
+
3
+ == Description
4
+
5
+ jstats is a command line tool that outputs - in a friendly format - statistics about your Java projects
6
+
7
+ == Installation
8
+
9
+ $ gem install jstats
10
+
11
+ To uninstall
12
+
13
+ $ gem uninstall jstats
14
+
15
+ == Usage
16
+
17
+ === Help
18
+
19
+ To use the help
20
+
21
+ $ jstats help
22
+
23
+ === Loc
24
+
25
+ To use the Line Of Code command
26
+
27
+ $ jstats loc ~/projects/my-pet-app
28
+
29
+ This will ouput figures about the lines of codes for your project
30
+
31
+ +-----------+---------------+-------------------+-------------+
32
+ | Processing 151 Java Files |
33
+ +-----------+---------------+-------------------+-------------+
34
+ | All lines | Lines of code | Lines of comments | Blank lines |
35
+ +-----------+---------------+-------------------+-------------+
36
+ | 43728 | 21811 | 18100 | 3817 |
37
+ +-----------+---------------+-------------------+-------------+
38
+ +-------------+----------------+--------+
39
+ | Files size distribution |
40
+ +-------------+----------------+--------+
41
+ | Lines range | Files in range | % |
42
+ +-------------+----------------+--------+
43
+ | 0...100 | 48 | 31.8 % |
44
+ | 100...200 | 33 | 21.9 % |
45
+ | 200...300 | 25 | 16.6 % |
46
+ | 300...400 | 12 | 7.9 % |
47
+ | 400...500 | 10 | 6.6 % |
48
+ | 500...600 | 6 | 4.0 % |
49
+ | 600...700 | 4 | 2.6 % |
50
+ | 700...800 | 2 | 1.3 % |
51
+ | 800...900 | 3 | 2.0 % |
52
+ | 900...1000 | 0 | 0.0 % |
53
+ | 1000...5000 | 8 | 5.3 % |
54
+ +-------------+----------------+--------+
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+ # 1.9 adds realpath to resolve symlinks; 1.8 doesn't
3
+ # have this method, so we add it so we get resolved symlinks
4
+ # and compatibility
5
+ unless File.respond_to? :realpath
6
+ class File #:nodoc:
7
+ def self.realpath path
8
+ return realpath(File.readlink(path)) if symlink?(path)
9
+ path
10
+ end
11
+ end
12
+ end
13
+ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
14
+
15
+ require 'rubygems'
16
+ require 'terminal-table'
17
+ require 'gli'
18
+ require 'javaparse'
19
+ require 'jstats_version'
20
+
21
+ include GLI
22
+
23
+ program_desc 'Ouputs from the command line stats about your Java projects'
24
+
25
+ version Jstats::VERSION
26
+
27
+ #desc 'Describe some switch here'
28
+ #switch [:s,:switch]
29
+
30
+ #desc 'Describe some flag here'
31
+ #default_value 'the default'
32
+ #arg_name 'The name of the argument'
33
+ #flag [:f,:flagname]
34
+
35
+ desc 'Overall lines lines count (code, comments, blank) and print a distribution of your files sizes'
36
+ arg_name 'Location of your Java source files'
37
+ command :loc do |c|
38
+ #c.desc 'Describe a switch to loc'
39
+ #c.switch :s
40
+
41
+ #c.desc 'Describe a flag to loc'
42
+ #c.default_value 'default'
43
+ #c.flag :f
44
+ c.action do |global_options,options,args|
45
+ java_files = JavaParse::JavaFiles.new(*args)
46
+ files_count = java_files.count(:files)
47
+ distrib = {(0...100) => 0, (100...200) => 0, (200...300) => 0, (300...400) => 0, (400...500) => 0,
48
+ (500...600) => 0, (600...700) => 0, (700...800) => 0, (800...900) => 0, (900...1000) => 0, (1000...5000) => 0 }
49
+ java_files.java_units.each { |unit|
50
+ file_line_count = unit.all_lines
51
+ distrib.each_key { |range|
52
+ distrib[range] = distrib[range] + 1 if range.include? file_line_count
53
+ }
54
+ }
55
+
56
+ rows = []
57
+ rows << [java_files.count(:all_lines), java_files.count(:loc), java_files.count(:cloc), java_files.count(:bloc)]
58
+ table = Terminal::Table.new :title => "Processing #{java_files.count} Java Files", :headings => ['All lines', 'Lines of code', 'Lines of comments', 'Blank lines' ], :rows => rows
59
+
60
+ distrib_rows = []
61
+ distrib.to_a.each { |d| distrib_rows << d}
62
+
63
+ distrib_rows.each { |row|
64
+ row.push(sprintf('%.1f', (row[1] * 100) / files_count.to_f) + ' %')
65
+ }
66
+
67
+ distrib_table = Terminal::Table.new :title => "Files size distribution", :headings => ['Lines range', 'Files in range', ' % ' ], :rows => distrib_rows
68
+
69
+ puts table
70
+ puts distrib_table
71
+ end
72
+ end
73
+
74
+ desc 'Stats about methods sizes'
75
+ arg_name 'TODO'
76
+ command :methods do |c|
77
+ c.action do |global_options,options,args|
78
+ end
79
+ end
80
+
81
+ pre do |global,command,options,args|
82
+ # Pre logic here
83
+ # Return true to proceed; false to abort and not call the
84
+ # chosen command
85
+ # Use skips_pre before a command to skip this block
86
+ # on that command only
87
+ true
88
+ end
89
+
90
+ post do |global,command,options,args|
91
+ # Post logic here
92
+ # Use skips_post before a command to skip this
93
+ # block on that command only
94
+ end
95
+
96
+ on_error do |exception|
97
+ # Error logic here
98
+ # return false to skip default error handling
99
+ true
100
+ end
101
+
102
+ exit GLI.run(ARGV)
@@ -0,0 +1,5 @@
1
+ = jstats
2
+
3
+ Generate this with
4
+ jstats rdoc
5
+ After you have described your command line interface
@@ -0,0 +1,3 @@
1
+ module Jstats
2
+ VERSION = '0.0.4'
3
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jstats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Simon Caplette
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: gli
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: javaparse
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: terminal-table
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description:
95
+ email:
96
+ executables:
97
+ - jstats
98
+ extensions: []
99
+ extra_rdoc_files:
100
+ - README.rdoc
101
+ - jstats.rdoc
102
+ files:
103
+ - bin/jstats
104
+ - lib/jstats_version.rb
105
+ - README.rdoc
106
+ - jstats.rdoc
107
+ homepage: https://github.com/simcap/jstats
108
+ licenses: []
109
+ post_install_message:
110
+ rdoc_options:
111
+ - --title
112
+ - jstats
113
+ - --main
114
+ - README.rdoc
115
+ - -ri
116
+ require_paths:
117
+ - lib
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 1.8.24
134
+ signing_key:
135
+ specification_version: 3
136
+ summary: Outputs Java projects statistics from the command line
137
+ test_files: []