notes-cli 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/notes CHANGED
@@ -4,6 +4,8 @@ require 'notes-cli'
4
4
 
5
5
  if ARGV.any? { |arg| ["-h", "--help"].include?(arg) }
6
6
  puts %Q{\
7
+ Recursively search source files for annotations. Default annotations are TODO, OPTIMIZE, and FIXME.
8
+
7
9
  Usage: notes [DIRECTORY=.] [-f FILES] [-e EXCLUDES]
8
10
 
9
11
  Options:
@@ -77,20 +77,34 @@ class Notes
77
77
  counter = 1
78
78
  tasks = []
79
79
 
80
- File.read(filename).each_line do |line|
81
- if @options[:flags].any? { |flag| line.include?(flag) || line.include?(flag.downcase) }
82
- tasks << {
83
- :line_num => counter,
84
- :line => line.strip
85
- }
80
+ begin
81
+ File.read(filename).each_line do |line|
82
+ if @options[:flags].any? { |flag| line =~ /#{flag}/i }
83
+ tasks << {
84
+ :line_num => counter,
85
+ :line => line.strip
86
+ }
87
+ end
88
+ counter += 1
86
89
  end
87
- counter += 1
90
+ rescue
91
+ # Error occurred reading the file (ex. invalid byte sequence in UTF-8)
92
+ # Move on quietly
88
93
  end
89
94
 
90
95
  if !tasks.empty?
91
96
  name.slice!(0) if name.start_with?("/")
92
97
  puts "#{name}:"
93
- tasks.each { |task| puts " ln #{task[:line_num]}: #{task[:line]}" }
98
+
99
+ tasks.each do |task|
100
+ flag_regex = Regexp.new(@options[:flags].join('|'), true)
101
+ color = 33 # yellow
102
+ line = task[:line].gsub(flag_regex) do |flag|
103
+ "\e[#{color};1m#{flag}\033[0m"
104
+ end
105
+ puts " ln #{task[:line_num]}: #{line}"
106
+ end
107
+
94
108
  puts ""
95
109
  end
96
110
  end
@@ -1,3 +1,3 @@
1
1
  class Notes
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notes-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: