lutra 0.0.2 → 0.0.3
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 +4 -4
- data/bin/lutra +10 -9
- data/lib/lutra/formatters/default.rb +7 -1
- data/lib/lutra/note.rb +1 -3
- data/lib/lutra/scanner.rb +6 -10
- data/lib/lutra/version.rb +1 -1
- data/spec/scanner_spec.rb +5 -15
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59d911ed406e63282be41712f2613b7225d13dd6
|
4
|
+
data.tar.gz: e6c90ff275373cbba0eafd9cdd53ab413cd6c226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a815072f42e68d1705c0812ad8207dffdef13eae9e29375f6fe2f845734d5ff9721c0d77f7038a0cc46567cd4beffc9b76a559a20421a1a1be3ab74461088d3d
|
7
|
+
data.tar.gz: 950dd6dc571266a999899157e985f4f3cd6a84aad890dcfdc72ba049fa36701e0d8c5694f0e72ef99df059e17e2433ca42fc7e3b9248024e7ba17dc9b37a7550
|
data/bin/lutra
CHANGED
@@ -6,20 +6,21 @@ require 'lutra'
|
|
6
6
|
verbose = false
|
7
7
|
color = STDOUT.tty?
|
8
8
|
usage = 'Usage: lutra [OPTIONS] [PATH]'
|
9
|
-
tags = Lutra::TAGS
|
10
|
-
comments = Lutra::COMM
|
9
|
+
tags = Lutra::TAGS
|
10
|
+
comments = Lutra::COMM
|
11
11
|
formatter_name = :default
|
12
12
|
formatter_opts = {}
|
13
13
|
|
14
14
|
ARGV.options do |o|
|
15
15
|
o.version = Lutra::VERSION
|
16
16
|
o.banner = usage
|
17
|
+
|
17
18
|
o.on('-t', '--tags=TAG', 'Search for custom tags') do |tag|
|
18
|
-
tags
|
19
|
+
tags = tag.split(',').map(&:strip)
|
19
20
|
end
|
20
21
|
|
21
22
|
o.on('-c', '--comments=COM', 'Specify comment lines') do |com|
|
22
|
-
comments
|
23
|
+
comments = com.split(',').map(&:strip)
|
23
24
|
end
|
24
25
|
|
25
26
|
o.on('-f', '--formatter=NAME', 'Use your own formatter') do |name|
|
@@ -41,19 +42,19 @@ end
|
|
41
42
|
|
42
43
|
begin
|
43
44
|
ARGV.options.parse!
|
44
|
-
if ARGV.empty?
|
45
|
-
|
45
|
+
paths = if ARGV.empty?
|
46
|
+
'.'
|
46
47
|
else
|
47
|
-
|
48
|
+
ARGV.select { |path| File.exist?(path) }
|
48
49
|
end
|
49
50
|
rescue => e
|
50
|
-
STDERR.puts "
|
51
|
+
STDERR.puts "Error: #{e.message}"
|
51
52
|
STDERR.puts usage
|
52
53
|
STDERR.puts "Try 'lutra --help' for more information"
|
53
54
|
exit 1
|
54
55
|
end
|
55
56
|
|
56
|
-
scanner = Lutra::Scanner.new(tags
|
57
|
+
scanner = Lutra::Scanner.new(tags, comments)
|
57
58
|
|
58
59
|
Find.find(*paths) do |path|
|
59
60
|
unless paths.include?(path)
|
@@ -5,7 +5,7 @@ module Lutra
|
|
5
5
|
indent = notes.map(&:line).flatten.max.to_s.size
|
6
6
|
|
7
7
|
notes.group_by { |n| n.file }.each do |file, notes|
|
8
|
-
puts "#{file
|
8
|
+
puts "#{format_path(file)}:"
|
9
9
|
notes.each do |note|
|
10
10
|
puts " * #{prepare(note, indent)}"
|
11
11
|
end
|
@@ -20,6 +20,12 @@ module Lutra
|
|
20
20
|
s << "..." if note[:text].size > @options[:text_size]
|
21
21
|
s
|
22
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def format_path(file)
|
27
|
+
file.gsub('../', '').gsub('./', '')
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
data/lib/lutra/note.rb
CHANGED
data/lib/lutra/scanner.rb
CHANGED
@@ -3,25 +3,21 @@ module Lutra
|
|
3
3
|
attr_accessor :tags, :comments
|
4
4
|
attr_reader :notes
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@tags
|
8
|
-
@comments =
|
9
|
-
@notes
|
10
|
-
end
|
6
|
+
def initialize(tags = nil, comments = nil)
|
7
|
+
@tags = tags || Lutra::TAGS
|
8
|
+
@comments = comments || Lutra::COMM
|
9
|
+
@notes = []
|
11
10
|
|
12
|
-
def scan(source)
|
13
11
|
check_tags and check_comments
|
14
|
-
extract(source.split("\n")) and self
|
15
12
|
end
|
16
13
|
|
17
14
|
def scan_file(path)
|
18
|
-
|
19
|
-
extract(File.open(path), path) and self
|
15
|
+
extract(File.open(path), path)
|
20
16
|
end
|
21
17
|
|
22
18
|
private
|
23
19
|
|
24
|
-
def extract(source, path
|
20
|
+
def extract(source, path)
|
25
21
|
rxp = regexp
|
26
22
|
source.each_with_index do |line, i|
|
27
23
|
if r = rxp.match(line)
|
data/lib/lutra/version.rb
CHANGED
data/spec/scanner_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Lutra::Scanner do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "with custom tags" do
|
12
|
-
expect(subject.new(
|
12
|
+
expect(subject.new(['X']).tags).to eq ['X']
|
13
13
|
end
|
14
14
|
|
15
15
|
it "with default comments" do
|
@@ -17,29 +17,19 @@ describe Lutra::Scanner do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "with custom comments" do
|
20
|
-
expect(subject.new(
|
20
|
+
expect(subject.new(['X'], ['#']).comments).to eq ["#"]
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
context "#scan_file" do
|
25
25
|
let(:notes) do
|
26
|
-
subject.new
|
26
|
+
scanner = subject.new
|
27
|
+
scanner.scan_file("#{File.dirname(__FILE__)}/example")
|
28
|
+
scanner.notes
|
27
29
|
end
|
28
30
|
|
29
31
|
it "have todo, fixme and optimize" do
|
30
32
|
expect(notes.map(&:tag)).to eq ['TODO', 'FIXME', 'OPTIMIZE']
|
31
33
|
end
|
32
34
|
end
|
33
|
-
|
34
|
-
context "#scan" do
|
35
|
-
let(:notes) { subject.new.scan(example_data).notes }
|
36
|
-
|
37
|
-
it "have todo, fixme and optimize" do
|
38
|
-
expect(notes.map(&:tag)).to eq ['TODO', 'FIXME', 'OPTIMIZE']
|
39
|
-
end
|
40
|
-
|
41
|
-
it "have only 3 items" do
|
42
|
-
expect(notes.size).to eq 3
|
43
|
-
end
|
44
|
-
end
|
45
35
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuri Artemev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.1'
|
41
41
|
description: Parse tags (todo, fixme, optimize) in your source code
|
@@ -46,16 +46,17 @@ executables:
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- README.md
|
50
49
|
- LICENSE
|
51
|
-
-
|
50
|
+
- README.md
|
51
|
+
- bin/lutra
|
52
|
+
- lib/lutra.rb
|
52
53
|
- lib/lutra/formatter.rb
|
53
54
|
- lib/lutra/formatters/base.rb
|
54
55
|
- lib/lutra/formatters/default.rb
|
55
56
|
- lib/lutra/note.rb
|
56
57
|
- lib/lutra/scanner.rb
|
57
58
|
- lib/lutra/version.rb
|
58
|
-
-
|
59
|
+
- lutra.gemspec
|
59
60
|
- spec/example
|
60
61
|
- spec/formatter_spec.rb
|
61
62
|
- spec/formatters/base_spec.rb
|
@@ -64,7 +65,6 @@ files:
|
|
64
65
|
- spec/note_spec.rb
|
65
66
|
- spec/scanner_spec.rb
|
66
67
|
- spec/spec_helper.rb
|
67
|
-
- bin/lutra
|
68
68
|
homepage: http://github.com/artemeff/lutra
|
69
69
|
licenses:
|
70
70
|
- MIT
|
@@ -75,17 +75,17 @@ require_paths:
|
|
75
75
|
- lib
|
76
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
88
|
+
rubygems_version: 2.4.5
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: In source annotaions parser
|
@@ -98,3 +98,4 @@ test_files:
|
|
98
98
|
- spec/note_spec.rb
|
99
99
|
- spec/scanner_spec.rb
|
100
100
|
- spec/spec_helper.rb
|
101
|
+
has_rdoc:
|