lutra 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 903cc869e8442ea63148ad65bf377694f8ae5583
4
- data.tar.gz: 2c266db60c8eb220d63efe88c8cc95e925d5870b
3
+ metadata.gz: 59d911ed406e63282be41712f2613b7225d13dd6
4
+ data.tar.gz: e6c90ff275373cbba0eafd9cdd53ab413cd6c226
5
5
  SHA512:
6
- metadata.gz: 05669ce27f79d59dfbcb9ccd95e040b19f1c69be1cc34286227ef183742f722d2734ba64e3003f85c78bbd3a945a82c7df7f9f59528e9077e353f0945f28c2d3
7
- data.tar.gz: ce05f0c382fc3718831b68b9a8ffa964113286d61ce605557ad32c2192c714426962ba48a8e23fd9141dc80317397d37c443afaf94564c18c11d922f3e7005ff
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.dup
10
- comments = Lutra::COMM.dup
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 |= [tag]
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 |= [com]
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
- paths = '.'
45
+ paths = if ARGV.empty?
46
+ '.'
46
47
  else
47
- paths = ARGV.map { |p| File.exist? p or raise Errno::ENOENT, p ; p }
48
+ ARGV.select { |path| File.exist?(path) }
48
49
  end
49
50
  rescue => e
50
- STDERR.puts "lutra: #{e.message}"
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: tags, comments: comments)
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[2..-1]}:"
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
@@ -1,5 +1,3 @@
1
1
  module Lutra
2
- class Note < Struct.new(:tag, :text, :line, :file)
3
- # ...
4
- end
2
+ Note = Struct.new(:tag, :text, :line, :file)
5
3
  end
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(options = {})
7
- @tags = options[:tags] || TAGS.dup
8
- @comments = options[:comments] || COMM.dup
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
- check_tags and check_comments
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 = nil)
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
@@ -1,3 +1,3 @@
1
1
  module Lutra
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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(tags: ['X']).tags).to eq ['X']
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(comments: ['#']).comments).to eq ["#"]
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.scan_file("#{File.dirname(__FILE__)}/example").notes
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.2
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: 2013-10-08 00:00:00.000000000 Z
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
- - lutra.gemspec
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
- - lib/lutra.rb
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.1.4
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: