sqlsnip 0.2.0 → 0.2.2

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
  SHA256:
3
- metadata.gz: 1c25a3eafcf25530a813f9b4c36b16e52d567f9ae945baed3f823642f5177555
4
- data.tar.gz: 680fc3ba40fcbfcd945909ee9c994c267a2dbecea3baeb7c097b1e55e42bbe69
3
+ metadata.gz: 540b170ccb1ae5a38045089f209f9b373ab46695e2c96dbb3eb40450789cb36f
4
+ data.tar.gz: ccebd8ecef866998db72f924a1c7ad06677d86eaf1d013b3eca6d86459dd9973
5
5
  SHA512:
6
- metadata.gz: d803dd650b36880b6b574d98271846a87000c4dc7baaa26b8cfb3309dc12e981dd7c78794073457272624207591ab020166f72765f1ce388594172668f8dbbff
7
- data.tar.gz: a41b647dcfcb71e3653099158e037042ac8c65f20089ac719cdb665d86dafeccf5f502cd9bd2569da848115fdb3b90eeb6c1aff0994003980c026146ed2a8267
6
+ metadata.gz: 1e3ffd644aedf35c9ab808b0f1184b77e1c27b86f8c5b7cd3566da050959e250af8cad0ae7330090dff1b790269205afbe90dcf7bcf35fba91aa444d6ca28fce
7
+ data.tar.gz: fa073d37e19ce9cbcc3835777fa94dacac2c9426a3a4ed864cf5958b4ae0209ceddf0fab47e55e7fba53a3162d247d2f256520f162479bf1969033d591824307
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
- TODO
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('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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sqlsnip
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
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 start_line.nil?
149
- @lines << line
150
- elsif i < start_line
151
- @search_path_stmt = line if @search_path.nil? && line =~ /^\s*set\s+search_path/
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlsnip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen