imsg-grep 0.1.4-darwin → 0.1.5-darwin

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e9003c398da31639dbfde03aaec593b2f165940563851b5e6941d4a55a3ac7d
4
- data.tar.gz: 98155da94f986fc1a3455f368d40c2b418d2e077980d9fbb536d375f1e3fffd4
3
+ metadata.gz: 57ddef6878c4ff5a7359f79d3482c5b0e9c391ed5170623bb06c7c4e5ddebb83
4
+ data.tar.gz: b2b548bf55ba13909a0e006b3dbfb27cdb633e575028e64bb358b525cdd35ae9
5
5
  SHA512:
6
- metadata.gz: 4992137950786e7a8e3040f50378a8d8b285d6894913ae7aa8ec6c7b539048bf11be519cd5db8f3cd10fd888438a2707d1ba2b77f2de5ed387c788b317c76a4e
7
- data.tar.gz: 319ef0da83aa8c21b8bc71f934744604def1b6b8e28b2ff361cdb34710e4d8a04787f9cc14a63fa1270fda60bc0f30adfbc96fef2fe2e489da5b8b3f0c64e5cf
6
+ metadata.gz: 5d6ea1f60dd4b4b132375c662156df78ab3de53e2def55d56763bba30a1c88bf7abec7246be24fe5cecab5c39b11bae098114dd28509d5ea4972aba5de27522b
7
+ data.tar.gz: 397b91312c94deb494289c14a038ddbb199707a6a65c4c652b5790697090816bcb17029eb3b76be037bf1c03ac30dc1fbf784162cb06e8b992a7688158f947f9
data/bin/imsg-grep CHANGED
@@ -373,9 +373,13 @@ begin
373
373
 
374
374
  begin
375
375
  Messages.init_fs
376
- rescue Errno::EPERM, Errno::EACCES
377
- $stderr.print "You must grant #{ENV['TERM_PROGRAM']} Full Disk Access so #{PROG} can access the chat database. Open System Settings pane? [y/N] "
378
- $stdin.gets.to_s.strip.downcase == "y" and system 'open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"'
376
+ rescue Errno::EPERM, Errno::EACCES => e
377
+ if $stdout.tty? && $stdin.tty?
378
+ $stderr.print "You must grant #{ENV['TERM_PROGRAM']} Full Disk Access so #{PROG} can access the chat database. Open System Settings pane? [y/N] "
379
+ $stdin.gets.to_s.strip.downcase == ?y and system 'open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"'
380
+ else
381
+ err! "full disk access required (#{e.message})"
382
+ end
379
383
  exit 1
380
384
  rescue => e
381
385
  err! e.message
@@ -578,7 +582,9 @@ begin
578
582
  @link_images[link] = Concurrent::Promises.future_on(POOL, msg) do |msg|
579
583
  ix = link[:image_idx] or next
580
584
  file = msg.dig(:files, ix) or next
581
- path = File.expand_path file[:filename]
585
+ path = file[:filename] or next
586
+ path = File.expand_path path
587
+ File.exist?(path) or next
582
588
  img = Imaginator::Image.new(path).load or next
583
589
  fit, fits = img.fit @link_preview_cols, @link_preview_min_rows
584
590
  png = img.png_transform w:fit.w, h:fit.h, pad_w:fits[:cfit].pad_w
@@ -592,7 +598,9 @@ begin
592
598
  msg[:images] = msg[:files].select{ it[:mime_type]&.start_with?('image/') }
593
599
  preview?(:images) and msg[:images].each do |im|
594
600
  @images[im] = Concurrent::Promises.future_on(POOL, im) do |im|
595
- path = File.expand_path im[:filename]
601
+ path = im[:filename] or next
602
+ path = File.expand_path path
603
+ File.exist?(path) or next
596
604
  img = Imaginator::Image.new(path).load or next
597
605
  fit, = img.fit 25, @img_rows
598
606
  png = img.png_transform w:fit.w, h:fit.h
@@ -694,7 +702,7 @@ begin
694
702
  if img_rows != @link_preview_min_rows
695
703
  img = Imaginator::Image.new(img).load if img.is_a? String # it's a path, original img released
696
704
  fit1, fits = img.fit @link_preview_cols, img_rows
697
- # if the backround render image is different from what we need now that we know the text size, do it again
705
+ # if the promise-rendered image is different from what we need now that we know the text size, do it again
698
706
  if fit1 != fit
699
707
  fit = fit1
700
708
  png = img.png_transform w:fit.w, h:fit.h, pad_w:fits[:cfit].pad_w
@@ -704,7 +712,7 @@ begin
704
712
  print " "
705
713
  Imaginator.print_image(data: png, c: @link_preview_cols)
706
714
  puts
707
- print "\e[#{fit.r}A" # go up by image rows
715
+ print "\e[#{fit.r}A" # go up by image rows to print padded buf next to it
708
716
  end
709
717
 
710
718
  print buf
@@ -712,7 +720,7 @@ begin
712
720
 
713
721
  if @list_files
714
722
  for file in files.reject{ it[:mime_type].nil? }
715
- path, _, name = file[:filename].rpartition %r_(?<=/)_
723
+ path, _, name = file[:filename].to_s.rpartition %r_(?<=/)_
716
724
  p, q, r = path.rpartition %r_/\KTemporaryItems(?=/)_
717
725
  path = c.file_path(p) + c.file_path_bad(q) + c.file_path(r)
718
726
  puts " " + path + c.file_name(name) + ?\n
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -189,7 +189,7 @@ module Messages
189
189
  summary = rich_link&.dig "summary"
190
190
  image = rich_link&.dig "imageMetadata", "URL"
191
191
  image_idx = rich_link&.dig "image", "richLinkImageAttachmentSubstituteIndex"
192
- ci_idx = rich_link&.dig("contentImages")&.at(0)&.dig("richLinkImageAttachmentSubstituteIndex")
192
+ ci_idx = rich_link&.dig "contentImages", 0, "richLinkImageAttachmentSubstituteIndex"
193
193
  image_idx = ci_idx if ci_idx
194
194
  url = rich_url || orig_url || found_url
195
195
  # i'm not sure the mapping richLinkImageAttachmentSubstituteIndex to
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imsg-grep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: darwin
6
6
  authors:
7
7
  - Caio Chassot
@@ -117,7 +117,6 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - LICENSE
119
119
  - README.md
120
- - bin/img2png
121
120
  - bin/imsg-grep
122
121
  - bin/msg-info
123
122
  - bin/sql-shell
data/bin/img2png DELETED
Binary file