rbname 0.0.4 → 0.0.5
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 +8 -8
- data/lib/file_line.rb +5 -5
- data/lib/file_line_presenter.rb +2 -2
- data/lib/replacement_collection.rb +4 -1
- data/lib/vim_edit.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
NThiZDcyNThhZjgwNjYxNmM4MzhmMDMyNmYxMjM1MzkyYzE3NjcwZQ==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
ZDYxNzBhYTAwZTcyMGUxNGE3MzU2MTIxMzQwNzJiNDAyNDFiNmFkNg==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
ZGE3Mzk2YTU2YjAxMTBhZTQwM2FiODA3ZTQ4YWZmMTU2ODY5YzI2YjMyNmVi
|
|
10
|
+
Y2Q1YTQxMTY5ODFmYmQ3NzQwMGVlOTQ2NzU2ZWQxYzk2OTU1MWVkZjQ4N2Nk
|
|
11
|
+
ZmFiNjhhOGRlNjhlMDAxMzViYTY5M2E5ODE0NTI4MjVkOWQxOTg=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
ODFhN2NkZTI2Y2IxNjA4MTYzYzVlMjZiZmVlYWU3OWI3YjU4ZjEyYTkyMGU3
|
|
14
|
+
YzAzOGI2NmYwOTI0NGViZWNlNGU5ZGY0ZmQyOTVmN2Q5OTc3NzI4NWE3Mzli
|
|
15
|
+
OGZiYTJhMGM3ZjU4NTlhNmI5MjNmY2NjZDU4NDc1NmY2NTkzNTc=
|
data/lib/file_line.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require 'colorize'
|
|
2
2
|
|
|
3
3
|
class FileLine
|
|
4
|
-
attr_accessor :
|
|
5
|
-
def initialize(
|
|
6
|
-
@
|
|
4
|
+
attr_accessor :line_number, :path
|
|
5
|
+
def initialize(line_number, path)
|
|
6
|
+
@line_number = line_number
|
|
7
7
|
@path = path
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -17,11 +17,11 @@ class FileLine
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def update_filesystem!(new_contents)
|
|
20
|
-
`sed -e
|
|
20
|
+
`sed -e "#{line_number} s/.*/#{new_contents}/" -i '' #{path}`
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def raw_contents
|
|
24
|
-
`sed -n
|
|
24
|
+
`sed -n #{line_number}p #{path}`.chomp
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
end
|
data/lib/file_line_presenter.rb
CHANGED
|
@@ -6,7 +6,7 @@ class FileLinePresenter
|
|
|
6
6
|
|
|
7
7
|
def self.present_contents(file_line, pattern, context = 0)
|
|
8
8
|
current_highlighted_line = with_line_number(file_line, with_highlighting(file_line, pattern))
|
|
9
|
-
line_number = file_line.
|
|
9
|
+
line_number = file_line.line_number
|
|
10
10
|
line_path = file_line.path
|
|
11
11
|
lower_limit = [line_number - context, 1].max
|
|
12
12
|
upper_limit = [line_number + context, file_length(file_line)].min
|
|
@@ -27,7 +27,7 @@ class FileLinePresenter
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def self.with_line_number(file_line, contents = file_line.raw_contents)
|
|
30
|
-
"#{file_line.
|
|
30
|
+
"#{file_line.line_number}:#{TAB}#{contents}"
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def self.with_highlighting(file_line, pattern)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
class ReplacementCollection < Array
|
|
2
2
|
def applicable_replacements(line_contents)
|
|
3
|
-
select do |replacement|
|
|
3
|
+
applicable = select do |replacement|
|
|
4
4
|
line_contents.match(Regexp.escape(replacement.removed_by_user))
|
|
5
5
|
end
|
|
6
|
+
applicable.uniq do |replacement|
|
|
7
|
+
replacement.suggest(line_contents)
|
|
8
|
+
end
|
|
6
9
|
end
|
|
7
10
|
end
|
|
8
11
|
|
data/lib/vim_edit.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class VimEdit
|
|
2
2
|
def execute!(file_line, pattern)
|
|
3
|
-
system "vim +#{file_line.
|
|
3
|
+
system "vim +#{file_line.line_number} #{file_line.path} -c '#{"/"+pattern}' -c 'normal n' -c 'normal N' -c 'normal zz'"
|
|
4
4
|
end
|
|
5
5
|
end
|