Module: Mailmate::FlagCheck Private
- Defined in:
- lib/mailmate/flag_check.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Shared #flags expectation predicate, used by both the inline check in ‘mm-modify` and the batch `mm-verify`. An “expectation” is a [kind, arg] pair describing the post-action state a single eml-id’s flag list should satisfy; ‘kind` may be a Symbol (internal) or String (round-tripped through a JSON check-ticket) — both resolve the same.
Kinds:
[:seen, true|false] \Seen present / absent
[:flagged, true|false] \Flagged present / absent
[:tag_present, "name"] keyword present
[:tag_absent, "name"] keyword absent
[:no_user_tags, nil] no non-system keywords (only \… / $… remain)
Class Method Summary collapse
-
.all_met?(flags, expectations) ⇒ Boolean
private
All expectations satisfied by ‘flags`? `expectations` is an array of [kind, arg] pairs.
-
.label(kind, arg) ⇒ Object
private
Human label for an expectation, for verification messages.
- .met?(flags, kind, arg) ⇒ Boolean private
- .system_flag?(flag) ⇒ Boolean private
Class Method Details
.all_met?(flags, expectations) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
All expectations satisfied by ‘flags`? `expectations` is an array of
- kind, arg
-
pairs.
32 33 34 |
# File 'lib/mailmate/flag_check.rb', line 32 def all_met?(flags, expectations) expectations.all? { |kind, arg| met?(flags, kind, arg) } end |
.label(kind, arg) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Human label for an expectation, for verification messages.
41 42 43 44 45 46 47 48 49 |
# File 'lib/mailmate/flag_check.rb', line 41 def label(kind, arg) case kind.to_sym when :seen then arg ? "read" : "unread" when :flagged then arg ? "flagged" : "not flagged" when :tag_present then "tag #{arg.inspect}" when :tag_absent then "no tag #{arg.inspect}" when :no_user_tags then "no user tags" end end |
.met?(flags, kind, arg) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mailmate/flag_check.rb', line 19 def met?(flags, kind, arg) case kind.to_sym when :seen then flags.include?("\\Seen") == arg when :flagged then flags.include?("\\Flagged") == arg when :tag_present then flags.include?(arg) when :tag_absent then !flags.include?(arg) when :no_user_tags then flags.none? { |f| !system_flag?(f) } else raise ArgumentError, "unknown flag-check kind: #{kind.inspect}" end end |
.system_flag?(flag) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/mailmate/flag_check.rb', line 36 def system_flag?(flag) flag.start_with?("\\", "$") end |