imsg-grep 0.1.8-darwin → 0.1.9-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: f76e2f8bd190242f5894404a9a7e06d27a326f9c9ac53a554b0737de814368de
4
- data.tar.gz: 0e132c730b11b689ea2c49dc54d169e6cdd8e04224069ead6ef76c1bb047e08e
3
+ metadata.gz: 3f325277a5246f7b7c573ef53fe51dd0c59d54785cfaae5d14fc92f29080c660
4
+ data.tar.gz: a2fb623ebd5fd37bbbcebba44d38c0601427c7205fc9e8c8b3b9306f470a1ea9
5
5
  SHA512:
6
- metadata.gz: 195e09aba5f3dff9d9ccf557a76daf28052cc3960762cf9f31455b853363df0ce889be7a1b3f3e109b2e7b34a51ad9a4499bccc598f6b43b15676b08feceee7d
7
- data.tar.gz: 0c0fd316926a265389611ea3aee83c867829a22059117534b7a949395d0ef81d15295ea09d8fc885d4d03ba215845c4556d3d3f804dcfbfd1f5bfb0684abb66e
6
+ metadata.gz: f4f948a11ef66632c8f864642ed10e8898158e615703b0aa294bacd5907f34c41f10e1731e405622c67904865df94797251c86e8b5a8819f35c1c36a8ecad555
7
+ data.tar.gz: 1da625d8798d2c7063d3fb47376f11965ba1a494a978dd478994c0aca081be210b3b72ec118adf236dcd12d24de691dd5b9ea07b8c82208588b9790f15fdc301
data/bin/imsg-grep CHANGED
@@ -45,8 +45,9 @@ end
45
45
  def consume(ivarname) = instance_variable_get(ivarname).tap{ instance_variable_set(ivarname, nil) }
46
46
 
47
47
  # wrap and indent text, respecting SGR sequences; only if tty
48
- def wrap(s, indent=0, maxw = IO.console.winsize[1] - 2, disable: (!$stdout.tty?||@no_wrap), wrap_all: false)
48
+ def wrap(s, indent=0, maxw = nil, disable: (!$stdout.tty?||@no_wrap), wrap_all: false)
49
49
  return s if disable
50
+ maxw ||= IO.console.winsize[1] - 2
50
51
  sgr = /\e\[[\d;]*m/
51
52
  pad = "\e[#{indent}C"
52
53
 
@@ -359,6 +360,10 @@ begin
359
360
 
360
361
  def match(x, r) = "#{x} REGEXP '#{SQLite3::Database.quote r.to_s}'"
361
362
  def match_searchable(x, r) = "EXISTS (SELECT 1 FROM json_each(#{x}) WHERE #{match(:value, r)})"
363
+ def match_any(xs, r) = xs.map{ match(it, r) }.join(" OR ").then{ "(#{it})" }
364
+ def match_url(r) = match_any(%w[ link->>'url' link->>'original_url' ], r)
365
+
366
+ @link_meta = @conditions.positive(:links).any? # with link filters, msg patterns also match link title/summary
362
367
 
363
368
  groups = @conditions.slice_before{ !(Symbol === it.bin_op) }
364
369
 
@@ -405,16 +410,16 @@ begin
405
410
  in :until, _ then date_cmp(:<=, term)
406
411
  in :from_me, _ then "is_from_me IS #{term}"
407
412
  in :links, true then "link IS NOT NULL"
408
- in :links, :youtube then match(:link, %r["https?://((www\.)?youtube\.com|youtu\.be)/]i) # matching inside json, " acts as \A sort of
409
- in :links, :soundcloud then match(:link, %r["https?://(on\.)?soundcloud\.com/]i)
410
- in :links, :twitter then match(:link, %r["https?://(pic\.)?(twitter|x)\.com/]i)
411
- in :links, Regexp then match(:link, term)
413
+ in :links, :youtube then match_url(%r[\Ahttps?://((www\.)?youtube\.com|youtu\.be)/]i)
414
+ in :links, :soundcloud then match_url(%r[\Ahttps?://(on\.)?soundcloud\.com/]i)
415
+ in :links, :twitter then match_url(%r[\Ahttps?://(pic\.)?(twitter|x)\.com/]i)
416
+ in :links, Regexp then match_url(term)
412
417
  in :from, Regexp then match_searchable(:sender_searchable, term)
413
418
  in :to, Regexp then match_searchable(:recipients_searchable, term)
414
419
  in :with, Regexp then match_searchable(:members_searchable, term)
415
420
  in :chat, Regexp then match(:chat_name, term)
416
421
  in :chat, (true | false) then "(is_group_chat IS #{'NOT' unless term} TRUE)" # so nulls also match -vc
417
- in :message, Regexp then match(:text, term)
422
+ in :message, Regexp then @link_meta ? match_any(%w[ text link->>'title' link->>'summary' ], term) : match(:text, term)
418
423
  in :service, Regexp then match(:service, term)
419
424
  in :files, :any then "(has_attachments AND has_files IS TRUE)" # has_attachments first should be a faster check
420
425
  in :files, :images then "(has_attachments AND has_images IS TRUE)"
@@ -551,6 +556,7 @@ begin
551
556
  l_conds = @conditions.positive(:links).map(&:term).select{ Regexp===it } + m_conds
552
557
  rx_highlight = /#{m_conds*?|}/ if m_conds.any?
553
558
  rx_link_highlight = /#{l_conds*?|}/ if l_conds.any?
559
+ rx_meta_highlight = rx_highlight if @link_meta
554
560
 
555
561
  def highlight(s, r, a, b)
556
562
  return unless s
@@ -674,7 +680,7 @@ begin
674
680
  if @no_meta # oneline included, already onelined above
675
681
  puts text
676
682
  elsif @one_line
677
- text << " #{c.link_summary(oneline[title])}" if title
683
+ text << " #{highlight(oneline[title], rx_meta_highlight, :link_summary, :match!)}" if title
678
684
  to = chat_name.to_s.empty? ? to*', ' : chat_name
679
685
  buf = "#{c.l_time time} [#{c.l_from from} -> #{c.l_to to}]: #{text}"
680
686
  buf.prepend "#{guid} " if @debug
@@ -696,8 +702,8 @@ begin
696
702
 
697
703
  buf = +""
698
704
  buf << wrap(text, pad, wrap_all: !!link_image_result) << nn unless text.empty?
699
- buf << c.link_title(wrap(title, pad, wrap_all: !!link_image_result)) << nn if title
700
- buf << c.link_summary(wrap(summary, pad, wrap_all: !!link_image_result)) << nn if summary
705
+ buf << wrap(highlight(title, rx_meta_highlight, :link_title, :match!), pad, wrap_all: !!link_image_result) << nn if title
706
+ buf << wrap(highlight(summary, rx_meta_highlight, :link_summary, :match!), pad, wrap_all: !!link_image_result) << nn if summary
701
707
 
702
708
  if link_image_result
703
709
  buf_rows = buf.strip.count(?\n) + 1
data/doc/HELP CHANGED
@@ -29,6 +29,8 @@ Link filtering:
29
29
  -Y, --youtube Find youtube links
30
30
  -S, --soundcloud Find soundcloud links
31
31
  -X, --twitter Find twitter links
32
+ With any of these, message patterns also match
33
+ link title and summary
32
34
 
33
35
  Pattern modifiers:
34
36
  -C, --smart-case Case-sensitive only when pattern has uppercase
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
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.8
4
+ version: 0.1.9
5
5
  platform: darwin
6
6
  authors:
7
7
  - Caio Chassot
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  requirements: []
214
- rubygems_version: 4.0.3
214
+ rubygems_version: 4.0.21
215
215
  specification_version: 4
216
216
  summary: iMessage database search
217
217
  test_files: []