josephine 0.0.3 → 0.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.
- checksums.yaml +4 -4
- data/bin/josephine +1 -1
- data/lib/josephine.rb +28 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc42715de0cca20be19842e70a4b9e24ca6f4687
|
4
|
+
data.tar.gz: bdfdc4f4d09179f96fbb9523f1c7b2ad6fb6b9b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e5e1beadd9cc76a4f93ed5491e8499b26d7b32f09ec82a2ddf2fe913415d442a455fda6bad88f2b667c732228c760214c408b8d391c9eb10841880860147b23
|
7
|
+
data.tar.gz: 7d3cf46c7387e6d3c9635b041f8cae78d1371b7c7c6b4dcacbb552db0fd25f7c6683d4e9937334f68a20c2ceaa8d9279306317ad623de1b7ad5d0c9e564115cd
|
data/bin/josephine
CHANGED
data/lib/josephine.rb
CHANGED
@@ -1,36 +1,46 @@
|
|
1
1
|
class Josephine
|
2
2
|
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
def initialize(extension)
|
4
|
+
@extension = extension
|
5
|
+
extension_file
|
6
|
+
count_lines
|
7
|
+
end
|
8
|
+
|
9
|
+
def extension_file
|
10
|
+
ext = File.join("**", "*#{@extension}")
|
11
|
+
files = Dir.glob(ext)
|
12
|
+
end
|
13
|
+
|
14
|
+
def count_lines
|
15
|
+
l = 0 # Number of files
|
16
|
+
line_count = 0 # Number of lines of code
|
17
|
+
line_com = 0 # Number of lines of comments
|
18
|
+
space = 0
|
19
|
+
extension_file.each do |f|
|
11
20
|
next if f.index('vendor')
|
12
21
|
next if FileTest.directory?(f)
|
13
|
-
|
22
|
+
l += 1
|
14
23
|
i = 0
|
15
24
|
lines = []
|
16
25
|
File.new(f).each_line do |line|
|
17
|
-
|
18
|
-
|
26
|
+
lines << line unless line.strip[0] == nil || line.strip[0] == '#'
|
27
|
+
if line.strip[0].nil?
|
28
|
+
space += 1
|
19
29
|
next
|
20
30
|
end
|
21
31
|
if line.strip[0] == '#'
|
22
|
-
|
32
|
+
line_com += 1
|
23
33
|
next
|
24
34
|
end
|
25
|
-
lines << line
|
26
35
|
i += 1
|
27
36
|
end
|
28
|
-
|
37
|
+
line_count = lines.length
|
29
38
|
end
|
30
|
-
puts "#{
|
31
|
-
puts "#{
|
32
|
-
puts "#{(
|
33
|
-
puts "#{
|
39
|
+
puts "#{l.to_s} files."
|
40
|
+
puts "#{line_count.to_s} lines of code."
|
41
|
+
puts "#{(line_count.to_f/l.to_f).round(2)} LOC/file."
|
42
|
+
puts "#{line_com.to_s} lines of comments."
|
43
|
+
puts "#{space.to_s} line spacing."
|
34
44
|
end
|
35
45
|
|
36
46
|
end
|