snibbets 2.0.33 → 2.0.34

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: a04adb0bcd4439b3cd445b65bbfb4dc8494237cccca55fb6cc1a42c696e45864
4
- data.tar.gz: 25099f85f797910222a321dbebd3e0db84098071b964f6d93e0d6ba19ef456c5
3
+ metadata.gz: 4bfb107dedc2d689ec1ed371dcaf1ef7fb240218af43831856acb552789a0ce2
4
+ data.tar.gz: 482355a0c4a27d707d92633c47adeb2be0db027a37311412cb903f7d47cdb0b6
5
5
  SHA512:
6
- metadata.gz: 7d06a635679db42ad3a53eb21b235e21d4057f189c77760edc373306909da795e306cb7c7992e564cc517831487620904485f2007f0631a6e55ba7c434606b95
7
- data.tar.gz: 6b0f69d918b04ead612de23ba5d7c0b0044a137da79efc24b3037caa26f0f4d63055270499a6716c3c52e3a6bebbe3b12875db4dafbb7a7de8003559d58765ec
6
+ metadata.gz: 40afbc2d33dc562db0e5e21ec7fe40fc10872f279c1bc95b67deb6aac9cff90e663abc0100e49c2a08ea4500e0e2eb4f442bcf34259a54b0b901cf53c883c7ce
7
+ data.tar.gz: 072cccc7e2c90dc557f4af25b9338a7cec21b00c0545b5155b07f413d6560b7d964008a8919a638b0c0b67089ccd12d568951c314c75c29d896694a3de45e19e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 2.0.34
2
+
3
+ 2023-06-17 09:17
4
+
5
+ #### IMPROVED
6
+
7
+ - If a section of a snippet contains no code blocks, output the whole thing
8
+
9
+ #### FIXED
10
+
11
+ - Correct error if searching name only and no results are returned
12
+
1
13
  ### 2.0.33
2
14
 
3
15
  2023-04-26 10:23
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snibbets (2.0.33)
4
+ snibbets (2.0.34)
5
5
  mdless (~> 1.0, >= 1.0.32)
6
6
  tty-reader (~> 0.9, >= 0.9.0)
7
7
  tty-which (~> 0.5, >= 0.5.0)
@@ -17,47 +17,50 @@ GEM
17
17
  gem-release (2.2.2)
18
18
  json (2.6.3)
19
19
  language_server-protocol (3.17.0.3)
20
- mdless (1.0.32)
20
+ lint_roller (1.0.0)
21
+ mdless (1.0.33)
21
22
  multi_json (1.15.0)
22
- parallel (1.22.1)
23
+ parallel (1.23.0)
23
24
  parse_gemspec (1.0.0)
24
25
  parse_gemspec-cli (1.0.0)
25
26
  multi_json
26
27
  parse_gemspec
27
28
  thor
28
- parser (3.2.2.0)
29
+ parser (3.2.2.3)
29
30
  ast (~> 2.4.1)
31
+ racc
32
+ racc (1.7.1)
30
33
  rainbow (3.1.1)
31
34
  rake (13.0.6)
32
35
  rdoc (6.3.3)
33
- regexp_parser (2.7.0)
36
+ regexp_parser (2.8.1)
34
37
  rexml (3.2.5)
35
38
  rspec (3.12.0)
36
39
  rspec-core (~> 3.12.0)
37
40
  rspec-expectations (~> 3.12.0)
38
41
  rspec-mocks (~> 3.12.0)
39
- rspec-core (3.12.1)
42
+ rspec-core (3.12.2)
40
43
  rspec-support (~> 3.12.0)
41
- rspec-expectations (3.12.2)
44
+ rspec-expectations (3.12.3)
42
45
  diff-lcs (>= 1.2.0, < 2.0)
43
46
  rspec-support (~> 3.12.0)
44
47
  rspec-mocks (3.12.5)
45
48
  diff-lcs (>= 1.2.0, < 2.0)
46
49
  rspec-support (~> 3.12.0)
47
50
  rspec-support (3.12.0)
48
- rubocop (1.48.1)
51
+ rubocop (1.52.1)
49
52
  json (~> 2.3)
50
53
  parallel (~> 1.10)
51
- parser (>= 3.2.0.0)
54
+ parser (>= 3.2.2.3)
52
55
  rainbow (>= 2.2.2, < 4.0)
53
56
  regexp_parser (>= 1.8, < 3.0)
54
57
  rexml (>= 3.2.5, < 4.0)
55
- rubocop-ast (>= 1.26.0, < 2.0)
58
+ rubocop-ast (>= 1.28.0, < 2.0)
56
59
  ruby-progressbar (~> 1.7)
57
60
  unicode-display_width (>= 2.4.0, < 3.0)
58
- rubocop-ast (1.28.0)
61
+ rubocop-ast (1.29.0)
59
62
  parser (>= 3.2.1.0)
60
- rubocop-performance (1.16.0)
63
+ rubocop-performance (1.18.0)
61
64
  rubocop (>= 1.7.0, < 2.0)
62
65
  rubocop-ast (>= 0.4.0)
63
66
  ruby-progressbar (1.13.0)
@@ -71,13 +74,20 @@ GEM
71
74
  terminal-table
72
75
  simplecov-html (0.12.3)
73
76
  simplecov_json_formatter (0.1.4)
74
- standard (1.26.0)
77
+ standard (1.29.0)
75
78
  language_server-protocol (~> 3.17.0.2)
76
- rubocop (~> 1.48.1)
77
- rubocop-performance (~> 1.16.0)
79
+ lint_roller (~> 1.0)
80
+ rubocop (~> 1.52.0)
81
+ standard-custom (~> 1.0.0)
82
+ standard-performance (~> 1.1.0)
83
+ standard-custom (1.0.1)
84
+ lint_roller (~> 1.0)
85
+ standard-performance (1.1.0)
86
+ lint_roller (~> 1.0)
87
+ rubocop-performance (~> 1.18.0)
78
88
  terminal-table (3.0.2)
79
89
  unicode-display_width (>= 1.1.1, < 3)
80
- thor (1.2.1)
90
+ thor (1.2.2)
81
91
  tty-cursor (0.7.1)
82
92
  tty-reader (0.9.0)
83
93
  tty-cursor (~> 0.7)
data/README.md CHANGED
@@ -159,7 +159,7 @@ Snibbet's implementation of Skylighting has limited but better-looking themes, a
159
159
  ### Usage
160
160
 
161
161
  ```
162
- Snibbets v2.0.33
162
+ Snibbets v2.0.34
163
163
 
164
164
  Usage: snibbets [options] query
165
165
  -a, --all If a file contains multiple snippets, output all of them (no menu)
@@ -169,7 +169,7 @@ module Snibbets
169
169
 
170
170
  next if lines.blocks.zero? && !notes
171
171
 
172
- title = if lines.count > 1 && lines[0] !~ /<block\d+>/ && lines[0] =~ /^ +/
172
+ title = if lines.count > 1 && lines[0] !~ /<block\d+>/
173
173
  lines.shift.strip.sub(/[.:]$/, '')
174
174
  else
175
175
  'Default snippet'
@@ -208,18 +208,27 @@ module Snibbets
208
208
  # becomes the title, code is gleaned from text between that and the
209
209
  # next ATX header (or end)
210
210
  sans_blocks, code_blocks = content.replace_blocks
211
-
212
- parts = if Snibbets.options[:all_notes]
213
- sans_blocks.split(/^#+/)
214
- elsif sans_blocks =~ /<block\d+>/
215
- sans_blocks.split(/\n/).each_with_object([]) do |line, arr|
216
- arr << line if line =~ /^#/ || line =~ /<block\d+>/
217
- end.join("\n").split(/^#+/)
218
- else
219
- sans_blocks.gsub(/\n{2,}/, "\n\n").split(/^#+/)
220
- end
221
-
222
- # parts.shift if parts.count > 1
211
+ parts = sans_blocks.gsub(/\n{2,}/, "\n\n").split(/^#+/)
212
+
213
+ unless Snibbets.options[:all_notes]
214
+ parts.map! do |part|
215
+ if part =~ /<block\d+>/
216
+ lines = part.split(/\n/)
217
+ title = lines.shift
218
+ out = [title.gsub(/(^#+|#+$)/, '').strip]
219
+ out.concat(lines.each_with_object([]) do |line, arr|
220
+ arr << line.gsub(/(^#+|#+$)/, '').strip if line =~ /^#/ || line =~ /<block\d+>/
221
+ end)
222
+ out.join("\n")
223
+ else
224
+ lines = part.split(/\n/)
225
+ title = lines.shift
226
+ out = title.nil? ? [] : [title.gsub(/(^#+|#+$)/, '').strip]
227
+ out.concat(lines)
228
+ out.join("\n")
229
+ end
230
+ end
231
+ end
223
232
 
224
233
  restore_blocks(parts, code_blocks)
225
234
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snibbets
4
- VERSION = '2.0.33'
4
+ VERSION = '2.0.34'
5
5
  end
data/lib/snibbets.rb CHANGED
@@ -61,9 +61,7 @@ module Snibbets
61
61
  ag = TTY::Which.which('ag')
62
62
  ack = TTY::Which.which('ack')
63
63
  grep = TTY::Which.which('grep')
64
- if Snibbets.options[:name_only]
65
- nil
66
- elsif !rg.empty?
64
+ if !rg.empty?
67
65
  %(#{rg} -li --color=never --glob='*.#{ext}' '#{@query.rx}' "#{folder}")
68
66
  elsif !ag.empty?
69
67
  %(#{ag} -li --nocolor -G '.*.#{ext}' '#{@query.rx}' "#{folder}")
@@ -84,9 +82,14 @@ module Snibbets
84
82
  end
85
83
  end
86
84
 
87
- if try == 2 && cmd.nil?
88
- puts "{br}No search method available on this system. Please install ripgrep, silver surfer, ack, or grep.".x
89
- Process.exit 1
85
+ if try == 2
86
+ if Snibbets.options[:name_only]
87
+ puts '{br}No name matches found'.x
88
+ Process.exit 1
89
+ elsif cmd.nil?
90
+ puts '{br}No search method available on this system. Please install ripgrep, silver surfer, ack, or grep.'.x
91
+ Process.exit 1
92
+ end
90
93
  end
91
94
 
92
95
  res = cmd.nil? ? '' : `#{cmd}`.strip
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snibbets
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.33
4
+ version: 2.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-26 00:00:00.000000000 Z
11
+ date: 2023-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler