lutra 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/bin/lutra +7 -3
- data/lib/lutra/formatter.rb +8 -1
- data/lib/lutra/formatters/default.rb +5 -3
- data/lib/lutra/note.rb +2 -20
- data/lib/lutra/scanner.rb +3 -4
- data/lib/lutra/version.rb +1 -1
- data/spec/note_spec.rb +1 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903cc869e8442ea63148ad65bf377694f8ae5583
|
4
|
+
data.tar.gz: 2c266db60c8eb220d63efe88c8cc95e925d5870b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05669ce27f79d59dfbcb9ccd95e040b19f1c69be1cc34286227ef183742f722d2734ba64e3003f85c78bbd3a945a82c7df7f9f59528e9077e353f0945f28c2d3
|
7
|
+
data.tar.gz: ce05f0c382fc3718831b68b9a8ffa964113286d61ce605557ad32c2192c714426962ba48a8e23fd9141dc80317397d37c443afaf94564c18c11d922f3e7005ff
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Usage: lutra [OPTIONS] [PATH]
|
|
23
23
|
-t, --tags=TAG Search for custom tags
|
24
24
|
-c, --comments=COM Specify comment lines
|
25
25
|
-f, --formatter=NAME Use your own formatter
|
26
|
+
-s, --text-size=SIZE Set text size for formatter
|
26
27
|
-v, --verbose Verbose output
|
27
28
|
--hide-tags Hide tags
|
28
29
|
```
|
data/bin/lutra
CHANGED
@@ -8,8 +8,8 @@ color = STDOUT.tty?
|
|
8
8
|
usage = 'Usage: lutra [OPTIONS] [PATH]'
|
9
9
|
tags = Lutra::TAGS.dup
|
10
10
|
comments = Lutra::COMM.dup
|
11
|
-
display_tags = true
|
12
11
|
formatter_name = :default
|
12
|
+
formatter_opts = {}
|
13
13
|
|
14
14
|
ARGV.options do |o|
|
15
15
|
o.version = Lutra::VERSION
|
@@ -26,12 +26,16 @@ ARGV.options do |o|
|
|
26
26
|
formatter_name = name.to_sym
|
27
27
|
end
|
28
28
|
|
29
|
+
o.on('-s', '--text-size=SIZE', 'Set text size for formatter') do |size|
|
30
|
+
formatter_opts[:text_size] = size.to_i
|
31
|
+
end
|
32
|
+
|
29
33
|
o.on('-v', '--verbose', 'Verbose output') do
|
30
34
|
verbose = true
|
31
35
|
end
|
32
36
|
|
33
37
|
o.on('--hide-tags', 'Hide tags') do
|
34
|
-
display_tags = false
|
38
|
+
formatter_opts[:display_tags] = false
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -67,7 +71,7 @@ Find.find(*paths) do |path|
|
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
70
|
-
formatter = Lutra::Formatter.new(
|
74
|
+
formatter = Lutra::Formatter.new(formatter_opts)
|
71
75
|
formatter.set(formatter_name)
|
72
76
|
formatter.display(scanner.notes)
|
73
77
|
|
data/lib/lutra/formatter.rb
CHANGED
@@ -3,7 +3,7 @@ module Lutra
|
|
3
3
|
attr_reader :formatters, :current
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
|
-
@options = options
|
6
|
+
@options = default_options.merge(options)
|
7
7
|
@current = :default
|
8
8
|
@formatters = [
|
9
9
|
{ name: :default, short: :d, class: Lutra::Formatters::Default }
|
@@ -39,5 +39,12 @@ module Lutra
|
|
39
39
|
def formatter?(class_name)
|
40
40
|
class_name.new.respond_to?(:prepare)
|
41
41
|
end
|
42
|
+
|
43
|
+
def default_options
|
44
|
+
{
|
45
|
+
display_tags: true,
|
46
|
+
text_size: 55
|
47
|
+
}
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
@@ -14,9 +14,11 @@ module Lutra
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def prepare(note, indent)
|
17
|
-
s = "[#{note
|
18
|
-
s << "[#{note
|
19
|
-
s << note.
|
17
|
+
s = "[#{note[:line].to_s.rjust(indent)}] "
|
18
|
+
s << "[#{note[:tag]}] " if @options[:display_tags]
|
19
|
+
s << note[:text][0..@options[:text_size]].strip.chomp
|
20
|
+
s << "..." if note[:text].size > @options[:text_size]
|
21
|
+
s
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
data/lib/lutra/note.rb
CHANGED
@@ -1,23 +1,5 @@
|
|
1
1
|
module Lutra
|
2
|
-
class Note
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(data)
|
6
|
-
@tag = data[:tag]
|
7
|
-
@line = data[:line]
|
8
|
-
@file = data[:file]
|
9
|
-
@source = data[:source]
|
10
|
-
end
|
11
|
-
|
12
|
-
def text
|
13
|
-
extract[:text]
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def extract
|
19
|
-
@source =~ /(#{@tag})\s(.*)/
|
20
|
-
{ tag: $1, text: $2 }
|
21
|
-
end
|
2
|
+
class Note < Struct.new(:tag, :text, :line, :file)
|
3
|
+
# ...
|
22
4
|
end
|
23
5
|
end
|
data/lib/lutra/scanner.rb
CHANGED
@@ -24,9 +24,8 @@ module Lutra
|
|
24
24
|
def extract(source, path = nil)
|
25
25
|
rxp = regexp
|
26
26
|
source.each_with_index do |line, i|
|
27
|
-
if
|
28
|
-
|
29
|
-
@notes << Note.new(raw)
|
27
|
+
if r = rxp.match(line)
|
28
|
+
@notes << Note.new(r[:tag], r[:text], i + 1, path)
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -40,7 +39,7 @@ module Lutra
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def regexp
|
43
|
-
/(#{@comments.join('|')})\s*(?<tag>#{@tags.join('|')})\s*(?<text>.*)/
|
42
|
+
/(#{@comments.join('|')})\s*(?<tag>#{@tags.join('|')})[\s|\:]*(?<text>.*)/
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
data/lib/lutra/version.rb
CHANGED
data/spec/note_spec.rb
CHANGED
@@ -2,18 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Lutra::Note do
|
4
4
|
subject do
|
5
|
-
|
6
|
-
described_class.new(raw)
|
5
|
+
described_class.new('X', 'text', 1, 'ex.rb')
|
7
6
|
end
|
8
7
|
|
9
8
|
it "#tag" do
|
10
9
|
expect(subject.tag).to eq 'X'
|
11
10
|
end
|
12
11
|
|
13
|
-
it "#source" do
|
14
|
-
expect(subject.source).to eq 'X text'
|
15
|
-
end
|
16
|
-
|
17
12
|
it "#line" do
|
18
13
|
expect(subject.line).to eq 1
|
19
14
|
end
|