File tree Expand file tree Collapse file tree 2 files changed +49
-7
lines changed Expand file tree Collapse file tree 2 files changed +49
-7
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ trap("INT") do
6
6
exit
7
7
end
8
8
9
- # resolve bin path, ignoring symlinks
10
- require "pathname"
11
- bin_file = Pathname . new ( __FILE__ ) . realpath
9
+ # resolve bin path, ignoring symlinks
10
+ require "pathname"
11
+ bin_file = Pathname . new ( __FILE__ ) . realpath
12
12
13
13
Odor . run ( *ARGV )
Original file line number Diff line number Diff line change @@ -10,10 +10,52 @@ def self.run(*args)
10
10
end
11
11
12
12
def self . check_file ( filename )
13
+ line_numbers = line_changes ( filename )
14
+ issues = %x[rails_best_practices -f text #{ filename } --silent]
15
+ issues = issues . split ( "\n " )
16
+
17
+ issues . each do |hint |
18
+ line_numbers . each do |num |
19
+ if hint . include? ( num . to_s )
20
+ puts hint
21
+ break
22
+ end
23
+ end
24
+ end
25
+ return true
26
+ end
27
+
28
+ def self . line_changes ( filename )
13
29
changes = %x[git diff -U0 #{ filename } ]
14
-
15
- puts changes . split ( "\n " )
16
- issues = %x[rails_best_practices -f text #{ filename } ]
17
- puts issues
30
+ changes = changes . split ( "\n " )
31
+ changes . shift ( 4 )
32
+ #changes = changes.map{ |c| c if !c.nil? && c.start_with?('@') }
33
+
34
+ line_changes = [ ]
35
+ changes . each do |c |
36
+ line_changes << c if !c . nil? && c . start_with? ( '@' )
37
+ end
38
+
39
+ lines = [ ]
40
+
41
+ line_changes . each do |s |
42
+ s = s . split
43
+
44
+ s . shift ( 2 )
45
+ li = s . first [ 1 , 50 ] . split ( ',' )
46
+
47
+ li . last . to_i . times do |i |
48
+ lines << li . first . to_i + i
49
+ end
50
+ end
51
+
52
+ # s = changes.first.split
53
+ # s.shift(2)
54
+ # li = s.first[1, 50].split(',')
55
+ #
56
+ # li.last.to_i.times do |i|
57
+ # lines << li.first.to_i + i
58
+ # end
59
+ return lines
18
60
end
19
61
end
You can’t perform that action at this time.
0 commit comments