josephine 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/josephine.rb +18 -28
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfd1fd17cc33a951354d7b57e8b202dc36a8bc6a
4
- data.tar.gz: 60dba93987882a4e71b5aabfbd7a121e499dae0b
3
+ metadata.gz: 6e592484a817f1afa19732ef5b791717cfed8af6
4
+ data.tar.gz: 5348f475b3765d1a0ee9e2de35b916aec80ab1f5
5
5
  SHA512:
6
- metadata.gz: f50e241a236d90ad6295a0a2e050f5b588ff1e3961f0b07420c88073223e195262855887794df8653cd628fbc950929338c7303479a94775335ddc7de116de2e
7
- data.tar.gz: 7dec8dafcabdcda61f8a98978d2c9d8c66a44c3f91870f7c37c74bd6bd7bb345905bb9686be1c09a01349d7c5b3a83999d66a42d0ba0ee9a0891c828d04004b8
6
+ metadata.gz: 3768e2262618e65d584ae8eba1a59f94162998248c7b0f0a23aeaddbf790789c61152f20ccf549d014ba1f7dad05d419586dbb2dbc5b9ca1d1380f95c7664c15
7
+ data.tar.gz: 0e1dadb144889afa833cfc34d7083b83f58f78c339929616968ee83fe3c087337963d4b413ec59541ee360cf1949d9cdcdd041ce696b66433ec63b568626e3fa
data/lib/josephine.rb CHANGED
@@ -1,46 +1,36 @@
1
1
  class Josephine
2
2
 
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|
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|
20
11
  next if f.index('vendor')
21
12
  next if FileTest.directory?(f)
22
- l += 1
13
+ o += 1
23
14
  i = 0
24
15
  lines = []
25
16
  File.new(f).each_line do |line|
26
- lines << line unless line.strip[0] == nil || line.strip[0] == '#'
27
- if line.strip[0].nil?
28
- space += 1
17
+ if line.strip[0] == nil
18
+ n -= 1
29
19
  next
30
20
  end
31
21
  if line.strip[0] == '#'
32
- line_com += 1
22
+ m += 1
33
23
  next
34
24
  end
25
+ lines << line
35
26
  i += 1
36
27
  end
37
- line_count = lines.length
28
+ n += i
38
29
  end
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."
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."
44
34
  end
45
35
 
46
36
  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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrus Ghazanfar