sqlsnip 0.2.0 → 0.2.1
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/exe/sqlsnip +16 -2
- data/lib/sqlsnip/version.rb +1 -1
- data/lib/sqlsnip.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eff6793c0897ff170d7113e76b9599ebba9e781a17a7c79f0e290072f51b8126
|
4
|
+
data.tar.gz: 18cb83ef312352f398989ad01f96bff419db7cf755d1c93d891bb9c8cc641c08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b28921c49c85b91418e74a5e193431187778fa84a274c5a3d894b03fc0269da4cec30955d551123eb1451f7af325cf67115b75068a604cbae38b290f71e5e09
|
7
|
+
data.tar.gz: 1836d49c1dc2f46f4889d92243b2b59452017ccabb68af0ed261ab62b2d5990ff0a0bee7627b4580a219b1a6e13e81fc5d117b6f6ad2364b0625fece9fd47fc8
|
data/exe/sqlsnip
CHANGED
@@ -44,7 +44,7 @@ SPEC = %(
|
|
44
44
|
sqlsnip can be used to create a vim macro in .vimrcc that executes the
|
45
45
|
selected text or the whole file:
|
46
46
|
|
47
|
-
function! PrepareSqlRange() range
|
47
|
+
\\function! PrepareSqlRange() range
|
48
48
|
let path = expand('%:p')
|
49
49
|
let start_line = line("'<")
|
50
50
|
let end_line = line("'>")
|
@@ -68,7 +68,21 @@ SPEC = %(
|
|
68
68
|
|
69
69
|
...or to just replace the current selected text with drop statements
|
70
70
|
|
71
|
-
|
71
|
+
\\function! ReplaceSqlRange() range " ChatGPT
|
72
|
+
let start_line = line("'<")
|
73
|
+
let end_line = line("'>")
|
74
|
+
let save_cursor = getpos('.')
|
75
|
+
let range_text = getline(start_line, end_line)
|
76
|
+
let path = expand('%:p')
|
77
|
+
let shell_output = system('bundle exec exe/sqlsnip -ds"" ' . path)
|
78
|
+
let shell_output_lines = split(shell_output, "\n")
|
79
|
+
call deletebufline('%', start_line, end_line)
|
80
|
+
call append(start_line - 1, shell_output_lines)
|
81
|
+
call setpos('.', save_cursor)
|
82
|
+
endfunction
|
83
|
+
|
84
|
+
" CTRL+I - insert drop statements
|
85
|
+
map <C-I> :call ReplaceSqlRange()<CR>
|
72
86
|
|
73
87
|
)
|
74
88
|
|
data/lib/sqlsnip/version.rb
CHANGED
data/lib/sqlsnip.rb
CHANGED
@@ -145,14 +145,14 @@ module Sqlsnip
|
|
145
145
|
IO.readlines(file).each.with_index { |line, i|
|
146
146
|
line.chomp!
|
147
147
|
i += 1
|
148
|
-
if
|
149
|
-
|
150
|
-
|
151
|
-
@search_path_stmt = line
|
148
|
+
break if !stop_line.nil? && i > stop_line
|
149
|
+
next if line =~ /^\s*$/
|
150
|
+
if @lines.empty? && @search_path.nil? && line =~ /^\s*set\s+search_path/
|
151
|
+
@search_path_stmt = line
|
152
|
+
elsif !start_line.nil? && i < start_line
|
153
|
+
;
|
152
154
|
elsif stop_line.nil? || i <= stop_line
|
153
155
|
@lines << line
|
154
|
-
else
|
155
|
-
break
|
156
156
|
end
|
157
157
|
}
|
158
158
|
end
|