josephine 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/josephine +1 -1
  3. data/lib/josephine.rb +28 -18
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61fdeff4365d68430e558777b3380eff180bda98
4
- data.tar.gz: be6e129c64c074be4d8ac5893b0630705c435a2b
3
+ metadata.gz: cc42715de0cca20be19842e70a4b9e24ca6f4687
4
+ data.tar.gz: bdfdc4f4d09179f96fbb9523f1c7b2ad6fb6b9b4
5
5
  SHA512:
6
- metadata.gz: 04b27ba5246ccde7189e6cad98cd315c22f6f00da1f572bfe03021576eb5b6e87cb72d1ce5357670958bed20afc8bc9bc58b85adf24121c8853b588db99c39a3
7
- data.tar.gz: 48f9b40023dafc0d4af80cadeb1469e4c0bb1b759e511ebfd36a450b653979e141db4acd27e3d68b8e34ece2730f507e77f9393660d626cef67a4758fd158540
6
+ metadata.gz: 6e5e1beadd9cc76a4f93ed5491e8499b26d7b32f09ec82a2ddf2fe913415d442a455fda6bad88f2b667c732228c760214c408b8d391c9eb10841880860147b23
7
+ data.tar.gz: 7d3cf46c7387e6d3c9635b041f8cae78d1371b7c7c6b4dcacbb552db0fd25f7c6683d4e9937334f68a20c2ceaa8d9279306317ad623de1b7ad5d0c9e564115cd
data/bin/josephine CHANGED
@@ -2,5 +2,5 @@
2
2
  require 'fileutils'
3
3
  require 'tempfile'
4
4
  require 'josephine'
5
- puts Josephine.new.count_lines(ARGV[0])
5
+ puts Josephine.new.(ARGV[0])
6
6
 
data/lib/josephine.rb CHANGED
@@ -1,36 +1,46 @@
1
1
  class Josephine
2
2
 
3
- def count_lines(ext)
4
- o = 0 # Number of files
5
- n = 0 # Number of lines of code
6
- m = 0 # Number of lines of comments
7
- # files = Dir.glob('./**/*.' + ext)
8
- rubyfile = File.join("**", "*#{ext}")
9
- files = Dir.glob(rubyfile)
10
- files.each do |f|
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
- o += 1
22
+ l += 1
14
23
  i = 0
15
24
  lines = []
16
25
  File.new(f).each_line do |line|
17
- if line.strip[0] == nil
18
- n -= 1
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
- m += 1
32
+ line_com += 1
23
33
  next
24
34
  end
25
- lines << line
26
35
  i += 1
27
36
  end
28
- n += i
37
+ line_count = lines.length
29
38
  end
30
- puts "#{o.to_s} files."
31
- puts "#{n.to_s} lines of code."
32
- puts "#{(n.to_f/o.to_f).round(2)} LOC/file."
33
- puts "#{m.to_s} lines of comments."
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: josephine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrus Ghazanfar