pointme 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
- # pointme 0.1.0 (11-09-2011)
1
+ # pointme 1.0.1 (28 Dec 2011)
2
+
3
+ + Make it look in files with proper MIME type (not extension like before).
4
+
5
+ # pointme 1.0.0 (28 Dec 2011)
6
+
7
+ + It's basicly working.
8
+
9
+ # pointme 0.1.0 (11 Sep 2011)
2
10
 
3
11
  + Birthday!
data/README.md CHANGED
@@ -37,11 +37,23 @@ Pointme can handle several language comments like:
37
37
  + ; TODO: content
38
38
  + <!-- TODO: content -->
39
39
 
40
+ ## Supported MIME types
41
+
42
+ + text/plain
43
+ + text/x-ruby
44
+ + text/x-python
45
+ + text/x-c
46
+ + text/x-c++
47
+ + text/x-shellscript
48
+ + text/x-java
49
+ + text/x-php
50
+ + text/html
51
+
40
52
  ## Dependencies
41
53
 
42
54
  + ruby (working just great on 1.9.2, haven't tried it on other versions yet)
43
55
  + rubygems (the newest the better [for sure works under 1.8.5])
44
- + a UNIX tool called `cat` (but you probably have it, right?)
56
+ + a UNIX tools called `cat` and `file` (but you have them, right?)
45
57
 
46
58
  ## Beware, beware! A bug!
47
59
 
data/lib/pointme/cli.rb CHANGED
@@ -1,36 +1,36 @@
1
1
  require "trollop"
2
2
 
3
3
  module Pointme
4
-
5
- # Command Line Interface class
6
- #
7
- # === Usage
8
- #
9
- # module Pointme
10
- # Cli.new.run!
11
- # end
12
- #
13
- # or
14
- #
15
- # Pointme::Cli.new.run!
16
- #
17
- # === Exit statuses
18
- #
19
- # - *0* Everything went just fine :)
20
- # - *1* User said ^C :]
21
- # - *2* User wanted to look for UnknownToken
22
- #
23
- class Cli
24
-
25
- # run! the Cli!
26
- def run!
27
-
28
- # Nice, cool 'n' AWESOME --options parsing with Trollop[http://trollop.rubyforge.org/]!
29
- #
30
- # @return [Hash] array full of options
31
- $opts = Trollop::options do
32
- version "pointme version #{Version::STRING}"
33
- banner <<-EOB
4
+
5
+ # Command Line Interface class
6
+ #
7
+ # === Usage
8
+ #
9
+ # module Pointme
10
+ # Cli.new.run!
11
+ # end
12
+ #
13
+ # or
14
+ #
15
+ # Pointme::Cli.new.run!
16
+ #
17
+ # === Exit statuses
18
+ #
19
+ # - *0* Everything went just fine :)
20
+ # - *1* User said ^C :]
21
+ # - *2* User wanted to look for UnknownToken
22
+ #
23
+ class Cli
24
+
25
+ # run! the Cli!
26
+ def run!
27
+
28
+ # Nice, cool 'n' AWESOME --options parsing with Trollop[http://trollop.rubyforge.org/]!
29
+ #
30
+ # @return [Hash] array full of options
31
+ $opts = Trollop::options do
32
+ version "pointme version #{Version::STRING}"
33
+ banner <<-EOB
34
34
  usage: pointme <token> [options]
35
35
 
36
36
  tokens are:
@@ -40,30 +40,30 @@ tokens are:
40
40
  options are:
41
41
  EOB
42
42
  # TODO: Looking in directories with no recursion.
43
- # opt :no_recurse, "don't look in directories recursively"
44
- opt :in, "specify where to look for", :default => Dir.pwd
45
- opt :version, "show version and exit"
46
- opt :help, "show help and exit"
47
- end
48
-
49
- # Let's see what to look for
50
- token = ARGV.shift.downcase
43
+ # opt :no_recurse, "don't look in directories recursively"
44
+ opt :in, "specify where to look for", :default => Dir.pwd
45
+ opt :version, "show version and exit"
46
+ opt :help, "show help and exit"
47
+ end
48
+
49
+ # Let's see what to look for
50
+ token = ARGV.shift.downcase
51
51
  unless token == "todos" || token == "fixmes"
52
52
  raise Look::UnknownToken, "Unknown token: '#{token}'"
53
53
  end
54
- # Let's see where to look for
55
- where = $opts[:in] || Dir.pwd
56
-
57
- begin
58
- Look.for_the token, where
59
- exit 0
60
- rescue Interrupt
61
- puts "\n\n!# interrupted"
62
- exit 1
63
- rescue Look::UnknownToken => e
64
- puts e.message
65
- exit 2
66
- end
67
- end
68
- end
54
+ # Let's see where to look for
55
+ where = $opts[:in] || Dir.pwd
56
+
57
+ begin
58
+ Look.for_the token, where
59
+ exit 0
60
+ rescue Interrupt
61
+ puts "\n\n!# interrupted"
62
+ exit 1
63
+ rescue Look::UnknownToken => e
64
+ puts e.message
65
+ exit 2
66
+ end
67
+ end
68
+ end
69
69
  end
data/lib/pointme/look.rb CHANGED
@@ -1,91 +1,91 @@
1
1
  require "find"
2
2
 
3
3
  module Pointme
4
- module Look
5
-
6
- # Kinda self explanatory
7
- class UnknownToken < RuntimeError; end
8
-
9
- # @files holds all the specified files that Look should search in.
10
- # @lines keeps all the found TODO, FIXME and so-on lines.
11
- attr_accessor :files, :lines
12
-
13
- def self.get_file_list
14
- @where.split(":").each do |e|
4
+ module Look
5
+
6
+ # Kinda self explanatory
7
+ class UnknownToken < RuntimeError; end
8
+
9
+ # @files holds all the specified files that Look should search in.
10
+ # @lines keeps all the found TODO, FIXME and so-on lines.
11
+ attr_accessor :files, :lines
12
+
13
+ def self.get_file_list
14
+ @where.split(":").each do |e|
15
15
  if e == '.' then e = Dir.pwd end
16
- @dirs << e unless @dirs.include? e
17
- Find.find(e) do |path|
18
- if File.directory? path
19
- if File.basename(path)[0] == ?.
20
- Find.prune # don't look any further into this directory.
21
- else
22
- next
23
- end
24
- else
25
- ext = File.extname(path)[1..-1]
26
- # TODO: Make it look in files with proper MIME type not extension.
27
- # Don't look into files with that extensions
28
- unless (ext == "class" ||
29
- ext == "jar"
30
- ext == "rar"
31
- ext == "bz"
32
- ext == "bz2"
33
- ext == "gz"
34
- ext == "tgz"
35
- ext == "zip")
36
- @files << path
16
+ @dirs << e unless @dirs.include? e
17
+ Find.find(e) do |path|
18
+ if File.directory? path
19
+ if File.basename(path)[0] == ?.
20
+ Find.prune # don't look any further into this directory.
21
+ else
22
+ next
37
23
  end
38
- end
39
- end
40
- end
41
- end
42
-
43
- def self.search_for_tokens
44
- @files.each do |file|
45
- @lines[file] = []
46
- `cat -n #{file}`.split("\n").each do |line|
47
- if /\s*(?<n>[0-9]+)\s+(.*)?(#|\/\/|;|<!--)\s(?<token>TODO|FIXME):?\s(?<content>.*)(-->)?/ =~ line
48
- @lines[file] << [n, token, content] if @token == token
49
- end
50
- end
51
-
52
- if @lines[file].empty?
53
- @lines.delete file
54
- end
55
- end
56
- end
57
-
58
- def self.print_output
59
- if @lines.empty?
60
- puts "[pointme] there are no #{@token}s in a specified path/s"
61
- else
62
- @lines.each do |e|
63
- name = nil
64
- if @dirs.size == 1
65
- name = e[0].sub @where, ""
66
- else
67
- name = e[0]
68
- end
69
- puts "\e[1;34m" + name + ":\e[0;0m"
70
- e[1].each do |i|
71
- @count += 1
72
- puts " at \e[1;32m#{i[0]}\e[0;0m: #{i[1]} -> #{i[2]}"
73
- end
74
- puts
75
- end
76
- puts "\n \e[1;33mtotal:\e[0;0m #{@count}\n\n"
77
- end
78
- end
79
-
80
- def self.for_the token, where
81
- @files = []
82
- @lines = {}
83
- @token = token.upcase[0..-2]
84
- @where = where
85
- @count = 0
86
- @dirs = []
87
-
88
- get_file_list and search_for_tokens and print_output
89
- end
90
- end
24
+ else
25
+ mime = `file --mime -b #{path}`.chomp!.split(";")[0]
26
+ # Get into files only with that MIME types.
27
+ if (mime == "text/plain" ||
28
+ mime == "text/x-ruby" ||
29
+ mime == "text/x-python" ||
30
+ mime == "text/x-c" ||
31
+ mime == "text/x-c++" ||
32
+ mime == "text/x-shellscript" ||
33
+ mime == "text/x-java" ||
34
+ mime == "text/x-php" ||
35
+ mime == "text/html")
36
+ @files << path
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def self.search_for_tokens
44
+ @files.each do |file|
45
+ @lines[file] = []
46
+ `cat -n #{file}`.split("\n").each do |line|
47
+ if /\s*(?<n>[0-9]+)\s+(.*)?(#|\/\/|;|<!--)\s(?<token>TODO|FIXME):?\s(?<content>.*)(-->)?/ =~ line
48
+ @lines[file] << [n, token, content] if @token == token
49
+ end
50
+ end
51
+
52
+ if @lines[file].empty?
53
+ @lines.delete file
54
+ end
55
+ end
56
+ end
57
+
58
+ def self.print_output
59
+ if @lines.empty?
60
+ puts "[pointme] there are no #{@token}s in a specified path/s"
61
+ else
62
+ @lines.each do |e|
63
+ name = nil
64
+ if @dirs.size == 1
65
+ name = e[0].sub @where, ""
66
+ else
67
+ name = e[0]
68
+ end
69
+ puts "\e[1;34m" + name + ":\e[0;0m"
70
+ e[1].each do |i|
71
+ @count += 1
72
+ puts " at \e[1;32m#{i[0]}\e[0;0m: #{i[1]} -> #{i[2]}"
73
+ end
74
+ puts
75
+ end
76
+ puts "\n \e[1;33mtotal:\e[0;0m #{@count}\n\n"
77
+ end
78
+ end
79
+
80
+ def self.for_the token, where
81
+ @files = []
82
+ @lines = {}
83
+ @token = token.upcase[0..-2]
84
+ @where = where
85
+ @count = 0
86
+ @dirs = []
87
+
88
+ get_file_list and search_for_tokens and print_output
89
+ end
90
+ end
91
91
  end
@@ -1,10 +1,10 @@
1
1
  module Pointme
2
- module Version
3
- MAJOR = 1
4
- MINOR = 0
5
- PATCH = 0
6
- BUILD = nil
7
-
8
- STRING = [MAJOR, MINOR, PATCH, BUILD]. compact.join "."
9
- end
2
+ module Version
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 1
6
+ BUILD = nil
7
+
8
+ STRING = [MAJOR, MINOR, PATCH, BUILD]. compact.join "."
9
+ end
10
10
  end
data/lib/pointme.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pointme
2
- ROOT = File.expand_path(File.dirname(__FILE__))
3
-
4
- autoload :Look, "#{ROOT}/pointme/look"
5
- autoload :Version, "#{ROOT}/pointme/version"
2
+ ROOT = File.expand_path(File.dirname(__FILE__))
3
+
4
+ autoload :Look, "#{ROOT}/pointme/look"
5
+ autoload :Version, "#{ROOT}/pointme/version"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pointme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: