jstats 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2157c81989d4f26444aa31e2fc75b3501cfb500a
4
- data.tar.gz: 9c12506d470828733ad04362fe435a9e7e9fa446
3
+ metadata.gz: 7a92a291a3cee27f72d3ae80f530f6c0010518ce
4
+ data.tar.gz: 982cf5a583fb7e351699df5b85ad0f2ecce18392
5
5
  SHA512:
6
- metadata.gz: 674eec177fac1ec1b6cc6de6cb08460fc7820467f12009c60b10ca258380ab4b8cf72ebb3f0bb8e75347b0efb9f509a8da17867adfafe7b93d3f4ac309484c20
7
- data.tar.gz: 37ca540d77c307680f3def61aa9cb24232f01f3c20c131215caf66120e6879264000df858137930e51994df6149b952b0edb2a1c74fd0d3df71582e4af129346
6
+ metadata.gz: 193fe61cc4e19d569e8570516814bbcf59db7e1e0b4dc68bf8f7c1b3ee8726506f8a2451814dd0c8f0a61a58352864fdcae660703fbd025d43d853a29073931a
7
+ data.tar.gz: 3c322251fc7c64fda5d76c1734656d39ff478994a82a1456fa6a8cfc02f9ab17a32b15177d768343e871445cc07eddf0cd061ed303ad958c38b3f719d88ed0e7
data/lib/jstats/loc.rb ADDED
@@ -0,0 +1,46 @@
1
+ module Jstats
2
+
3
+ class Loc
4
+
5
+ attr_reader :tables
6
+
7
+ def initialize(directories)
8
+ @java_files = JavaParse::JavaFiles.new(directories)
9
+ @distrib = {(0...100) => 0, (100...200) => 0, (200...300) => 0, (300...400) => 0, (400...500) => 0, (500...600) => 0,
10
+ (600...700) => 0, (700...800) => 0, (800...900) => 0, (900...1000) => 0, (1000...5000) => 0 }
11
+ run_distrib
12
+ @tables = [total_lines_table, distribution_table]
13
+ end
14
+
15
+ private
16
+
17
+ def run_distrib
18
+ @distrib_rows = []
19
+ @java_files.each { |unit|
20
+ @distrib.each_key { |range|
21
+ @distrib[range] = @distrib[range] + 1 if range.include? unit.all_lines
22
+ }
23
+ }
24
+
25
+ @distrib.to_a.each { |d| @distrib_rows << d}
26
+
27
+ @distrib_rows.each { |row|
28
+ row.push(sprintf('%.1f', (row[1] * 100) / (@java_files.count).to_f) + ' %')
29
+ }
30
+ end
31
+
32
+ def distribution_table
33
+ Terminal::Table.new :title => "Files size distribution",
34
+ :headings => ['Lines range', 'Files in range', ' % ' ],
35
+ :rows => @distrib_rows
36
+ end
37
+
38
+ def total_lines_table
39
+ Terminal::Table.new :title => "Processing #{@java_files.count} Java Files",
40
+ :headings => ['All lines', 'Lines of code', 'Lines of comments', 'Blank lines' ],
41
+ :rows => [[@java_files.count(:all_lines), @java_files.count(:loc), @java_files.count(:cloc), @java_files.count(:bloc)]]
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -1,3 +1,3 @@
1
1
  module Jstats
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Caplette
@@ -91,6 +91,7 @@ extra_rdoc_files:
91
91
  files:
92
92
  - bin/jstats
93
93
  - lib/jstats_version.rb
94
+ - lib/jstats/loc.rb
94
95
  - README.rdoc
95
96
  - jstats.rdoc
96
97
  homepage: https://github.com/simcap/jstats