what_now 0.0.2

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 +7 -0
  2. data/bin/wnow +25 -0
  3. data/lib/what_now.rb +33 -0
  4. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7bda060f1e69ee13c7863be908c04c2989b9953f
4
+ data.tar.gz: 684fab111d73886ed178aaf1a0f28d84d9854250
5
+ SHA512:
6
+ metadata.gz: f969b650b7a3b9fe07e207d731cefc7182122b67a165b09e4385bf7e56701588d92455aec1fb4009f958cbc38d699fb81c90a29566d3527011ab223b81b6152f
7
+ data.tar.gz: 18818e1895703b3274cc474751149245bc557d00ffed62626360342320fecac3f78da537aaf3c1a336221c6de75aa349c11cc02d8ab68ffdd8e3669e71cbb300
data/bin/wnow ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+ require 'colorize'
4
+ require 'what_now'
5
+
6
+ class Wnow < Thor
7
+ default_task :find
8
+
9
+ desc 'find', 'search files in directory for todo elements (default command)'
10
+ option :dir, aliases: '-d'
11
+ option :ext, aliases: '-e'
12
+ def find
13
+ dir = options[:dir] || Dir.pwd
14
+ ext = options[:ext] ? "/**/*.#{options[:ext]}" : '/**/*.*'
15
+ todos = WhatNow.search_directory(dir + ext)
16
+ todos.each do |t|
17
+ printable_path = options[:dir] ? t.path : t.path[Dir.pwd.length+1..t.path.length]
18
+ puts t.text.red.bold
19
+ puts "at line #{t.line.to_s.blue} in #{printable_path.blue.underline}"
20
+ puts
21
+ end
22
+ end
23
+ end
24
+
25
+ Wnow.start(ARGV)
data/lib/what_now.rb ADDED
@@ -0,0 +1,33 @@
1
+ # What_now definitions
2
+
3
+ require 'ptools'
4
+
5
+ Todo = Struct.new :text, :path, :line
6
+
7
+ module WhatNow
8
+ class << self
9
+ def search_line(line, line_number, path)
10
+ text = /TODO[:\s]*\s(.+)$/.match(line)
11
+ Todo.new(text[1], line_number, path) if text
12
+ end
13
+
14
+ def search_file(path)
15
+ todos = []
16
+ unless File.binary?(path)
17
+ File.open(path).each_with_index do |line, i|
18
+ result = search_line(line, path, i+1)
19
+ todos << result if result
20
+ end
21
+ end
22
+ todos
23
+ end
24
+
25
+ def search_directory(pattern)
26
+ todos = []
27
+ Dir[pattern].each do |file|
28
+ todos = todos + search_file(file)
29
+ end
30
+ todos
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: what_now
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Edgar Cabrera
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Executable for finding todo comments on directories
14
+ email: edgar@cafeinacode.com
15
+ executables:
16
+ - wnow
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/what_now.rb
21
+ - bin/wnow
22
+ homepage: https://github.com/aleandros/what_now
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.0.6
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Find todo comments in your code
46
+ test_files: []
47
+ has_rdoc: