lutra 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8280ec08022d92e00986f7ac57545b6d07a38f8
4
- data.tar.gz: 83530ac917e962aa083b6d71886d4738d53b7cbc
3
+ metadata.gz: 903cc869e8442ea63148ad65bf377694f8ae5583
4
+ data.tar.gz: 2c266db60c8eb220d63efe88c8cc95e925d5870b
5
5
  SHA512:
6
- metadata.gz: 9e8003a4e8026dd896dab97c941220c1d07c540e1ae0b9e3e7c1f998624054b17ee938c17d4144c8e35553aa9fa589363ba26ecf806bde636b90751679e2ecb6
7
- data.tar.gz: b0abd8259bccd4425c3c035caf2a469dd89753c799f16e9cd662f518e61332a3fe5c4e47389c83f8d252b016cbfa87fd9aa06cc18114d539863f41d8da176293
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(display_tags: display_tags)
74
+ formatter = Lutra::Formatter.new(formatter_opts)
71
75
  formatter.set(formatter_name)
72
76
  formatter.display(scanner.notes)
73
77
 
@@ -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.line.to_s.rjust(indent)}] "
18
- s << "[#{note.tag}] " if @options[:display_tags]
19
- s << note.text
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
- attr_reader :tag, :source, :line, :file
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 rxp =~ line
28
- raw = { tag: $1, source: line, line: i + 1, file: path }
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
@@ -1,3 +1,3 @@
1
1
  module Lutra
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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
- raw = { tag: 'X', source: 'X text', line: 1, file: 'ex.rb' }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Artemev