memethod 0.0.1

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 +7 -0
  2. data/bin/memethod +4 -0
  3. data/lib/memethod.rb +39 -0
  4. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3dd5793370ef1eb57cc4027426031f2123e875c0
4
+ data.tar.gz: 02f276fd71a5a08e8a65c76e85241eaf0d20c400
5
+ SHA512:
6
+ metadata.gz: a9c6e18c0af0e6a937d8c4a54f309262b2ad07c7b4e9a9879f17b2649eb20d4c42cbdcf018d71015741b14468662fc2596cbaee6fd12788efb4fd938afdd9328
7
+ data.tar.gz: 263702e6bda3b26027dfb284f0820a4c6f96d6e1f50bf76250a353049b6de7e2078512d03a2d321fe772df283c82b963c76f0899651a149d2a674820e736439d
data/bin/memethod ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'memethod'
3
+ puts Memethod.new
4
+
data/lib/memethod.rb ADDED
@@ -0,0 +1,39 @@
1
+ class Memethod
2
+
3
+ def initialize(extension = '.rb')
4
+ @extension = extension
5
+ extension_file
6
+ count_method
7
+ end
8
+
9
+ def extension_file
10
+ ext = File.join("**", "*.rb")
11
+ files = Dir.glob(ext)
12
+ end
13
+
14
+ def count_method
15
+ num_files, line_count, method_count = 0, 0, 0
16
+ extension_file.each do |f|
17
+ next if f.index('vendor')
18
+ next if FileTest.directory?(f)
19
+ num_files += 1
20
+ i = 0
21
+ lines = []
22
+ File.new(f).each_line do |line|
23
+ if line.strip[0..2] == 'def'
24
+ method_count += 1
25
+ next
26
+ end
27
+ i += 1
28
+ end
29
+ line_count += i
30
+ end
31
+ display_stat(num_files, line_count, method_count)
32
+ end
33
+
34
+ def display_stat(num_files, line_count, method_count)
35
+ puts "\n------------------------------\n#{num_files.to_s} files with #{@extension} extension.\n #{method_count} methods\n#{line_count.to_f} lines of code."
36
+ end
37
+
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: memethod
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Cyrus Ghazanfar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: count the number of method in your project files
14
+ email: cghazanfar10@gmail.com
15
+ executables:
16
+ - memethod
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/memethod
21
+ - lib/memethod.rb
22
+ homepage: http://rubygems.org/gems/memethod
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.6
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: def count
46
+ test_files: []
47
+ has_rdoc: