sqlsnip 0.2.0 → 0.2.1

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: eff6793c0897ff170d7113e76b9599ebba9e781a17a7c79f0e290072f51b8126
4
+ data.tar.gz: 18cb83ef312352f398989ad01f96bff419db7cf755d1c93d891bb9c8cc641c08
5
5
  SHA512:
6
- metadata.gz: d803dd650b36880b6b574d98271846a87000c4dc7baaa26b8cfb3309dc12e981dd7c78794073457272624207591ab020166f72765f1ce388594172668f8dbbff
7
- data.tar.gz: a41b647dcfcb71e3653099158e037042ac8c65f20089ac719cdb665d86dafeccf5f502cd9bd2569da848115fdb3b90eeb6c1aff0994003980c026146ed2a8267
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
- 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('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
 
@@ -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.1"
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen