todo_scanner 1.0.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 (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/todo_scanner.rb +37 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: db4e637e3026bfa13c429a676a5fa800a448cc743ab2f889c2b4a8c37c67d0ab
4
+ data.tar.gz: 282599e10e2cc28c0efc405087836d9a53353c5c5fd44abce747ae13678eba19
5
+ SHA512:
6
+ metadata.gz: d86bf84cf35f038bfeb00fecf20b167914d385a07d6f42078c7244071dd19b7bbaa9d68b63281f30fb092dd6dd1d56a3970854efc1da50abaad1c9c057498ed4
7
+ data.tar.gz: 9f92feaed608512476f02faa762a532b3f75ab27199fef0284085c54299a2fcebce161ba13f0f520c841e984379f874a5bb2374e321e872b8fcc188af9e8e914
@@ -0,0 +1,37 @@
1
+ module TodoScanner
2
+ class Todo
3
+ def self.scan
4
+ files = Dir["**/*.rb"]
5
+ config['Exclude'].each { |excluded_file| files.reject! { |f| f[excluded_file] } } if config.present?
6
+
7
+ todos_found = []
8
+ files.each do |file|
9
+ line_number = File.foreach(file).with_index(1) do | line, index |
10
+ todos_found << "#{line.strip} - #{file}:#{index}" if found_todo?(line)
11
+ end
12
+ end
13
+
14
+ puts "TODOs Found : #{todos_found.count}"
15
+ todos_found.each do |todo|
16
+ puts todo
17
+ end if todos_found.count > 0
18
+ end
19
+
20
+ private
21
+
22
+ def self.found_todo?(line)
23
+ if line.strip.include? '# TODO :'
24
+ true
25
+ elsif line.strip.include? '# TODO:'
26
+ true
27
+ else
28
+ false
29
+ end
30
+ end
31
+
32
+ def self.config
33
+ config_file = '.todo_scanner.yml'
34
+ return YAML.load_file('.todo_scanner.yml') if File.exists? config_file
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: todo_scanner
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yagi Anggar Prahara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: yagi.anggar@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/todo_scanner.rb
20
+ homepage:
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubyforge_project:
39
+ rubygems_version: 2.6.13
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Simple todos scanner
43
+ test_files: []