josephine 0.1.3 → 0.2.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/josephine +1 -1
  3. data/lib/josephine.rb +28 -17
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b0c30dbf69ab661396f131400fa48543857aff2
4
- data.tar.gz: bf2ac294870b72e2ba32c31716264bc6d15760f5
3
+ metadata.gz: c8b569bed9ecb093d679a47268f118c72fadf3e5
4
+ data.tar.gz: 83fbd82a63efde8514abae2183657cf6a5d7b494
5
5
  SHA512:
6
- metadata.gz: 4a948252115a344d17e8d85d782a4cf9260b87344425cc68b8789070e662b5fee6f95fcd385e3325e6f0261dcb1e4038b2752029d0771d2f553b8a253d788b6f
7
- data.tar.gz: 52950472c00a31b909131f1a9975f709cc1cb439fe45924622f02ed0204eba939e27669c361d2881fa279e36007d1a67074eeaff2d444f951e13066a0efe259a
6
+ metadata.gz: e432ba549cb8435e3ee66f639b3b762bfa039cca89e2e949a2638649df27d5eb547af6e8a71209f96442efbc8ad5cb3d08c1a44488b6c57ecad769be64f26855
7
+ data.tar.gz: 2c7640e0a3d32dd27ce801d9b0c4dc2e2658c1fc8ebf022c87dcafa1af8da6f20d89f0984339f1c10bab3358f4ab7247c365a31babe5791c7657e6a437eda992
@@ -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
 
@@ -1,36 +1,47 @@
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
26
  if line.strip[0] == nil
18
- n -= 1
27
+ space += 1
19
28
  next
20
29
  end
21
30
  if line.strip[0] == '#'
22
- m += 1
31
+ line_com += 1
23
32
  next
24
33
  end
25
- lines << line
34
+
26
35
  i += 1
27
36
  end
28
- n += i
37
+
38
+ line_count += i
29
39
  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."
40
+ puts "#{l.to_s} files."
41
+ puts "#{line_count.to_s} lines of code."
42
+ puts "#{(line_count.to_f/l.to_f).round(2)} LOC/file."
43
+ puts "#{line_com.to_s} lines of comments."
44
+ puts "#{space.to_s} line spacing."
34
45
  end
35
46
 
36
47
  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.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrus Ghazanfar