diff options
Diffstat (limited to 'fake-service/lib/pixelated_service/search')
6 files changed, 0 insertions, 201 deletions
diff --git a/fake-service/lib/pixelated_service/search/and_match.rb b/fake-service/lib/pixelated_service/search/and_match.rb deleted file mode 100644 index dfd0f287..00000000 --- a/fake-service/lib/pixelated_service/search/and_match.rb +++ /dev/null @@ -1,25 +0,0 @@ -module PixelatedService - class Search - class AndMatch - attr_reader :data - def initialize(data = []) - @data = data - end - def <<(node) - @data << node - end - - def to_s - "And(#{@data.join(", ")})" - end - - def match?(mail) - self.data.all? { |mm| mm.match?(mail) } - end - - def match_string?(str) - self.data.all? { |mm| mm.match_string?(str) } - end - end - end -end diff --git a/fake-service/lib/pixelated_service/search/negate_match.rb b/fake-service/lib/pixelated_service/search/negate_match.rb deleted file mode 100644 index 77d880e8..00000000 --- a/fake-service/lib/pixelated_service/search/negate_match.rb +++ /dev/null @@ -1,22 +0,0 @@ -module PixelatedService - class Search - class NegateMatch - attr_reader :data - def initialize(data) - @data = data - end - - def to_s - "Negate(#@data)" - end - - def match?(mail) - !self.data.match?(mail) - end - - def match_string?(str) - !self.data.match_string?(str) - end - end - end -end diff --git a/fake-service/lib/pixelated_service/search/or_match.rb b/fake-service/lib/pixelated_service/search/or_match.rb deleted file mode 100644 index 2c3e50ef..00000000 --- a/fake-service/lib/pixelated_service/search/or_match.rb +++ /dev/null @@ -1,25 +0,0 @@ -module PixelatedService - class Search - class OrMatch - attr_reader :left, :right - def initialize(left, right) - @left = left - @right = right - end - def <<(node) - @right << node - end - def to_s - "Or(#@left, #@right)" - end - - def match?(mail) - [@left, @right].any? { |mm| mm.match?(mail) } - end - - def match_string?(str) - [@left, @right].any? { |mm| mm.match_string?(str) } - end - end - end -end diff --git a/fake-service/lib/pixelated_service/search/scope_match.rb b/fake-service/lib/pixelated_service/search/scope_match.rb deleted file mode 100644 index 170c54cf..00000000 --- a/fake-service/lib/pixelated_service/search/scope_match.rb +++ /dev/null @@ -1,79 +0,0 @@ - -module PixelatedService - class Search - class ScopeMatch - def initialize(scope, data) - @scope = scope.downcase.gsub(/-/, '_').to_sym - @data = data - end - - def to_s - "Scope(#@scope, #@data)" - end - - def is_search_scope? - [:in, :tag, :is].include?(@scope) && - %w(_default_ trash all sent drafts).include?(@data.match_string.downcase) - end - - def search_scope - case @data.match_string.downcase - when '_default_' - PixelatedService::MailScopeFilter::Default - when 'all' - PixelatedService::MailScopeFilter::All - when 'trash' - PixelatedService::MailScopeFilter::Trash - when 'sent' - PixelatedService::MailScopeFilter::Sent - when 'drafts' - PixelatedService::MailScopeFilter::Drafts - end - end - - def match?(mail) - strs = - case @scope - when :to - mail.to - when :from, :sender - mail.from - when :cc - mail.headers[:cc] - when :bcc - mail.headers[:bcc] - when :subject - mail.subject - when :rcpt, :rcpts, :recipient, :recipients - [mail.to, mail.headers[:cc], mail.headers[:bcc]].flatten.compact - when :body - mail.body - when :tag, :tags, :in - return @data.match_exact_string?(mail.tag_names) - # has:seal, has:imprint, has:lock - when :is - case @data.str - when "starred" - return mail.starred? - when "read" - return mail.read? - when "replied" - return mail.replied? - # sealed, imprinted, signed, locked, encrypted, - else - raise "NOT IMPLEMENTED: is:#{@data}" - end - when :before - raise "NOT IMPLEMENTED" - when :after - raise "NOT IMPLEMENTED" - when :att, :attachment - raise "NOT IMPLEMENTED" - else - mail.headers[@scope] || (return false) - end - @data.match_string? strs - end - end - end -end diff --git a/fake-service/lib/pixelated_service/search/string_match.rb b/fake-service/lib/pixelated_service/search/string_match.rb deleted file mode 100644 index f9b32376..00000000 --- a/fake-service/lib/pixelated_service/search/string_match.rb +++ /dev/null @@ -1,37 +0,0 @@ -module PixelatedService - class Search - class StringMatch - attr_reader :str - def initialize(data, quoted=false) - @str = data - @quoted = quoted - @data = Regexp.new(Regexp.quote(self.match_string), Regexp::IGNORECASE) - @exact_match = /^#{@data}$/ - end - - def match_string - if @quoted - @str[1..-2] - else - @str - end - end - - def to_s - "String(#@data)" - end - - def match_string?(str) - Array(str).any? { |ff| !!(ff[@data]) } - end - - def match_exact_string?(str) - Array(str).any? { |ff| @exact_match.match ff } - end - - def match?(mail) - match_string? [mail.to, mail.from, mail.subject, mail.body] - end - end - end -end diff --git a/fake-service/lib/pixelated_service/search/true_match.rb b/fake-service/lib/pixelated_service/search/true_match.rb deleted file mode 100644 index fd615f16..00000000 --- a/fake-service/lib/pixelated_service/search/true_match.rb +++ /dev/null @@ -1,13 +0,0 @@ -module PixelatedService - class Search - class TrueMatch - def match?(mail) - true - end - - def match_string?(str) - true - end - end - end -end |