gravitext-devtools 1.0.1 → 1.1.0
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.
- data/History.rdoc +4 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +2 -5
- data/Rakefile +1 -1
- data/bin/gt-cleanws +1 -1
- data/bin/gt-count +22 -0
- data/bin/gt-header +1 -1
- data/bin/gt-manifest +1 -1
- data/lib/gravitext-devtools/base.rb +2 -2
- data/lib/gravitext-devtools/header_writer.rb +6 -7
- data/lib/gravitext-devtools/line_counter.rb +100 -0
- data/lib/gravitext-devtools/manifest_writer.rb +1 -1
- data/lib/gravitext-devtools.rb +12 -4
- metadata +11 -7
data/History.rdoc
CHANGED
data/Manifest.txt
CHANGED
@@ -3,11 +3,13 @@ Manifest.txt
|
|
3
3
|
README.rdoc
|
4
4
|
Rakefile
|
5
5
|
bin/gt-cleanws
|
6
|
+
bin/gt-count
|
6
7
|
bin/gt-header
|
7
8
|
bin/gt-manifest
|
8
9
|
lib/gravitext-devtools/base.rb
|
9
10
|
lib/gravitext-devtools.rb
|
10
11
|
lib/gravitext-devtools/header_writer.rb
|
12
|
+
lib/gravitext-devtools/line_counter.rb
|
11
13
|
lib/gravitext-devtools/manifest_writer.rb
|
12
14
|
templates/format/format.java
|
13
15
|
templates/format/format.rb
|
data/README.rdoc
CHANGED
@@ -9,14 +9,11 @@ A collection of development support tools.
|
|
9
9
|
gt-manifest:: Maintain manifest from git ls-files minus exclusions.
|
10
10
|
gt-cleanws:: Cleanup whitespace in files.
|
11
11
|
gt-header:: Add and maintain file license headers.
|
12
|
-
|
13
|
-
== Synopsis
|
14
|
-
|
15
|
-
[TBD]
|
12
|
+
gt-count:: Count lines of code by type.
|
16
13
|
|
17
14
|
== License
|
18
15
|
|
19
|
-
Copyright (c) 2008-
|
16
|
+
Copyright (c) 2008-2011 David Kellum
|
20
17
|
|
21
18
|
Licensed under the Apache License, Version 2.0 (the "License"); you
|
22
19
|
may not use this file except in compliance with the License. You
|
data/Rakefile
CHANGED
data/bin/gt-cleanws
CHANGED
data/bin/gt-count
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2008-2011 David Kellum
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
6
|
+
# may not use this file except in compliance with the License. You may
|
7
|
+
# obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
14
|
+
# implied. See the License for the specific language governing
|
15
|
+
# permissions and limitations under the License.
|
16
|
+
#++
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift File.join( File.dirname( __FILE__ ), "..", "lib" )
|
19
|
+
|
20
|
+
require 'gravitext-devtools/line_counter'
|
21
|
+
|
22
|
+
Gravitext::DevTools::LineCounter.new.run
|
data/bin/gt-header
CHANGED
data/bin/gt-manifest
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2008-
|
2
|
+
# Copyright (c) 2008-2011 David Kellum
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
5
|
# may not use this file except in compliance with the License. You may
|
@@ -16,6 +16,6 @@
|
|
16
16
|
|
17
17
|
module Gravitext
|
18
18
|
module DevTools
|
19
|
-
VERSION = "1.0
|
19
|
+
VERSION = "1.1.0"
|
20
20
|
end
|
21
21
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2008-
|
2
|
+
# Copyright (c) 2008-2011 David Kellum
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
5
|
# may not use this file except in compliance with the License. You may
|
@@ -39,6 +39,7 @@ module Gravitext
|
|
39
39
|
attr_accessor :inception
|
40
40
|
attr_accessor :license
|
41
41
|
attr_accessor :exclusions
|
42
|
+
attr_accessor :inclusions
|
42
43
|
|
43
44
|
class << self
|
44
45
|
attr_accessor :instance
|
@@ -52,6 +53,7 @@ module Gravitext
|
|
52
53
|
|
53
54
|
@git_lister = GitFileLister.new
|
54
55
|
|
56
|
+
@inclusions = []
|
55
57
|
@exclusions = [ '**/.gitignore',
|
56
58
|
'**/.gt-config',
|
57
59
|
'**/History.rdoc',
|
@@ -90,14 +92,11 @@ module Gravitext
|
|
90
92
|
|
91
93
|
Gravitext::DevTools.load_config_from_pwd
|
92
94
|
|
95
|
+
@git_lister.inclusions = @inclusions
|
93
96
|
@git_lister.exclusions = @exclusions
|
94
|
-
# puts @exclusions.inspect
|
95
97
|
|
96
98
|
files = @git_lister.files
|
97
99
|
|
98
|
-
# puts cached_header( :rb )
|
99
|
-
# exit
|
100
|
-
|
101
100
|
files.each do |fname|
|
102
101
|
HeaderProcessor.new( fname, @do_write ).process
|
103
102
|
end
|
@@ -159,9 +158,9 @@ module Gravitext
|
|
159
158
|
@do_write = do_write
|
160
159
|
@fname = fname
|
161
160
|
@format = case fname
|
162
|
-
when /\.java$/
|
161
|
+
when /\.(java|c|h)$/
|
163
162
|
:java
|
164
|
-
when /\.xml$/
|
163
|
+
when /\.(xml|htm(l?))$/
|
165
164
|
:xml
|
166
165
|
when /\.rb$/
|
167
166
|
:rb
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2008-2011 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'gravitext-devtools'
|
18
|
+
require 'fileutils'
|
19
|
+
|
20
|
+
module Gravitext
|
21
|
+
module DevTools
|
22
|
+
|
23
|
+
class LineCounter
|
24
|
+
include FileUtils
|
25
|
+
include Gravitext::DevTools
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@verbose = false
|
29
|
+
@git_lister = GitFileLister.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse_options( args = ARGV )
|
33
|
+
|
34
|
+
@git_lister.parse_options( args ) do |opts|
|
35
|
+
opts.banner = "Usage: gt-count [dir|file] ..."
|
36
|
+
opts.on( "-v", "--verbose",
|
37
|
+
"Output per file counts" ) do
|
38
|
+
@verbose = true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def run( args = ARGV )
|
44
|
+
|
45
|
+
parse_options( args )
|
46
|
+
|
47
|
+
@git_lister.exclusions = []
|
48
|
+
git_files = @git_lister.files
|
49
|
+
|
50
|
+
show_count_line( "LANG/FILE", "LINES", "CODE" )
|
51
|
+
total_lines = total_code = 0
|
52
|
+
|
53
|
+
map = [ [ 'JAVA', [ '**/*.java' ] ],
|
54
|
+
[ 'RUBY', [ '**/*.rb', '**/bin/*', '**/init/*'] ] ]
|
55
|
+
|
56
|
+
map.each do | lang, fpats |
|
57
|
+
files = git_files.select { |f| @git_lister.match?( fpats, f ) }
|
58
|
+
lines, codelines = count_files( files )
|
59
|
+
show_count_line( lang, lines, codelines )
|
60
|
+
total_lines += lines
|
61
|
+
total_code += codelines
|
62
|
+
end
|
63
|
+
show_count_line( "TOTAL", total_lines, total_code)
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def count_lines( filename )
|
68
|
+
lines = codelines = 0
|
69
|
+
is_java = ( filename =~ /\.java$/ )
|
70
|
+
|
71
|
+
open( filename, 'r' ) { |f|
|
72
|
+
f.each do |line|
|
73
|
+
lines += 1
|
74
|
+
next if line =~ /^\s*$/
|
75
|
+
next if line =~ ( is_java ? %r{\s*[/*]} : /^\s*#/ )
|
76
|
+
codelines += 1
|
77
|
+
end
|
78
|
+
}
|
79
|
+
[ lines, codelines ]
|
80
|
+
end
|
81
|
+
|
82
|
+
def show_count_line(msg, lines, code)
|
83
|
+
printf( "%6s %6s %s\n", lines.to_s, code.to_s, msg )
|
84
|
+
end
|
85
|
+
|
86
|
+
def count_files( files )
|
87
|
+
total_lines = total_code = 0
|
88
|
+
files.each do |fn|
|
89
|
+
lines, codelines = count_lines( fn )
|
90
|
+
show_count_line( fn, lines, codelines ) if @verbose
|
91
|
+
total_lines += lines
|
92
|
+
total_code += codelines
|
93
|
+
end
|
94
|
+
[ total_lines, total_code ]
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
data/lib/gravitext-devtools.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2008-
|
2
|
+
# Copyright (c) 2008-2011 David Kellum
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
5
|
# may not use this file except in compliance with the License. You may
|
@@ -55,6 +55,10 @@ module Gravitext
|
|
55
55
|
|
56
56
|
class GitFileLister
|
57
57
|
|
58
|
+
# Inclusions to the list expressed in various ways
|
59
|
+
# Array<Regexp|Proc|String>
|
60
|
+
attr_accessor :inclusions
|
61
|
+
|
58
62
|
# Exclusions to the list expressed in various ways
|
59
63
|
# Array<Regexp|Proc|String>
|
60
64
|
attr_accessor :exclusions
|
@@ -75,6 +79,7 @@ module Gravitext
|
|
75
79
|
%r{(^|/)src(/|$)}, # gt-manifest
|
76
80
|
'lib/**/*.jar', # all
|
77
81
|
'Manifest.static' ] # gt-manifest, gt-header
|
82
|
+
@inclusions = []
|
78
83
|
@git_flags = []
|
79
84
|
@extra_files = []
|
80
85
|
end
|
@@ -107,11 +112,14 @@ module Gravitext
|
|
107
112
|
|
108
113
|
files.map! { |f| f.strip }
|
109
114
|
files.uniq!
|
110
|
-
|
115
|
+
unless @inclusions.empty?
|
116
|
+
files = files.select { |f| match?( @inclusions, f ) }
|
117
|
+
end
|
118
|
+
files.reject { |f| match?( @exclusions, f ) }
|
111
119
|
end
|
112
120
|
|
113
|
-
def
|
114
|
-
|
121
|
+
def match?( list, fname )
|
122
|
+
list.any? do |ex|
|
115
123
|
case ex
|
116
124
|
when Proc
|
117
125
|
ex.call( fname )
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gravitext-devtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Kellum
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-13 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -44,9 +44,9 @@ dependencies:
|
|
44
44
|
hash: 27
|
45
45
|
segments:
|
46
46
|
- 1
|
47
|
-
-
|
48
|
-
-
|
49
|
-
version: 1.
|
47
|
+
- 3
|
48
|
+
- 0
|
49
|
+
version: 1.3.0
|
50
50
|
type: :development
|
51
51
|
version_requirements: *id002
|
52
52
|
description: |-
|
@@ -55,10 +55,12 @@ description: |-
|
|
55
55
|
gt-manifest:: Maintain manifest from git ls-files minus exclusions.
|
56
56
|
gt-cleanws:: Cleanup whitespace in files.
|
57
57
|
gt-header:: Add and maintain file license headers.
|
58
|
+
gt-count:: Count lines of code by type.
|
58
59
|
email:
|
59
60
|
- dek-oss@gravitext.com
|
60
61
|
executables:
|
61
62
|
- gt-cleanws
|
63
|
+
- gt-count
|
62
64
|
- gt-header
|
63
65
|
- gt-manifest
|
64
66
|
extensions: []
|
@@ -74,11 +76,13 @@ files:
|
|
74
76
|
- README.rdoc
|
75
77
|
- Rakefile
|
76
78
|
- bin/gt-cleanws
|
79
|
+
- bin/gt-count
|
77
80
|
- bin/gt-header
|
78
81
|
- bin/gt-manifest
|
79
82
|
- lib/gravitext-devtools/base.rb
|
80
83
|
- lib/gravitext-devtools.rb
|
81
84
|
- lib/gravitext-devtools/header_writer.rb
|
85
|
+
- lib/gravitext-devtools/line_counter.rb
|
82
86
|
- lib/gravitext-devtools/manifest_writer.rb
|
83
87
|
- templates/format/format.java
|
84
88
|
- templates/format/format.rb
|