diff options
-rw-r--r-- | fake-service/Rakefile | 5 | ||||
-rw-r--r-- | fake-service/config.ru | 4 | ||||
-rw-r--r-- | fake-service/features/compose_save_draft_and_send.feature | 5 | ||||
-rw-r--r-- | fake-service/lib/generator.rb | 8 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service.rb | 27 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/all.rb (renamed from fake-service/lib/smail/all.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/combined_observer.rb (renamed from fake-service/lib/smail/combined_observer.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/contact.rb (renamed from fake-service/lib/smail/contact.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/contacts.rb (renamed from fake-service/lib/smail/contacts.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/contacts_observer.rb (renamed from fake-service/lib/smail/contacts_observer.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/contacts_search.rb (renamed from fake-service/lib/smail/contacts_search.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/contacts_sorter.rb (renamed from fake-service/lib/smail/contacts_sorter.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/fake.rb (renamed from fake-service/lib/smail/fake.rb) | 44 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/mail.rb (renamed from fake-service/lib/smail/mail.rb) | 6 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/mail_scope_filter.rb (renamed from fake-service/lib/smail/mail_scope_filter.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/mail_service.rb (renamed from fake-service/lib/smail/mail_service.rb) | 14 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/mailset.rb (renamed from fake-service/lib/smail/mailset.rb) | 4 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/paginate.rb (renamed from fake-service/lib/smail/paginate.rb) | 4 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/paginated_enumerable.rb (renamed from fake-service/lib/smail/paginated_enumerable.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/persona.rb (renamed from fake-service/lib/smail/persona.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/search.rb (renamed from fake-service/lib/smail/search.rb) | 18 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/search/and_match.rb (renamed from fake-service/lib/smail/search/and_match.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/search/negate_match.rb (renamed from fake-service/lib/smail/search/negate_match.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/search/or_match.rb (renamed from fake-service/lib/smail/search/or_match.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/search/scope_match.rb (renamed from fake-service/lib/smail/search/scope_match.rb) | 12 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/search/string_match.rb (renamed from fake-service/lib/smail/search/string_match.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/search/true_match.rb (renamed from fake-service/lib/smail/search/true_match.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/security_casing.rb (renamed from fake-service/lib/smail/security_casing.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/security_casing_examples.rb (renamed from fake-service/lib/smail/security_casing_examples.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/server.rb (renamed from fake-service/lib/smail/server.rb) | 4 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/sorted_mail.rb (renamed from fake-service/lib/smail/sorted_mail.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/stats.rb (renamed from fake-service/lib/smail/stats.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/stats_observer.rb (renamed from fake-service/lib/smail/stats_observer.rb) | 2 | ||||
-rw-r--r-- | fake-service/lib/pixelated_service/tags.rb (renamed from fake-service/lib/smail/tags.rb) | 6 | ||||
-rw-r--r-- | fake-service/lib/smail.rb | 27 | ||||
-rw-r--r-- | fake-service/spec/smail/mail_spec.rb | 10 | ||||
-rw-r--r-- | fake-service/spec/spec_helper.rb | 2 |
37 files changed, 119 insertions, 121 deletions
diff --git a/fake-service/Rakefile b/fake-service/Rakefile index 3c936d1f..8b76359c 100644 --- a/fake-service/Rakefile +++ b/fake-service/Rakefile @@ -2,7 +2,7 @@ $: << "lib" require 'rubygems' require 'rakeup' -require 'smail' +require 'pixelated_service' require 'rake/packagetask' RakeUp::ServerTask.new do |t| @@ -38,7 +38,7 @@ namespace :mailset do num = (args[:num] || "10").to_i tagging = args[:with_tagging] == "true" - ms = Smail::Mailset.create name, num, tagging + ms = PixelatedService::Mailset.create name, num, tagging ms.save! end end @@ -49,4 +49,3 @@ Rake::PackageTask.new("archive", :noversion) do |p| p.package_dir = "artifacts" p.package_files.include("**/*") end - diff --git a/fake-service/config.ru b/fake-service/config.ru index cadabecc..3d9b7c4d 100644 --- a/fake-service/config.ru +++ b/fake-service/config.ru @@ -1,4 +1,4 @@ $: << "lib" -require 'smail' -run Smail::Server +require 'pixelated_service' +run PixelatedService::Server diff --git a/fake-service/features/compose_save_draft_and_send.feature b/fake-service/features/compose_save_draft_and_send.feature index d05db837..fcff4a95 100644 --- a/fake-service/features/compose_save_draft_and_send.feature +++ b/fake-service/features/compose_save_draft_and_send.feature @@ -4,12 +4,11 @@ Feature: compose mail, save draft and send mail Scenario: user composes and email, save the draft, later sends the draft and checks the sent message Given I compose a message with | subject | body | - | Smail rocks! | You should definitely use it. Cheers, User. | + | Pixelated rocks! | You should definitely use it. Cheers, User. | And for the 'To' field I type 'ab' and chose the first contact that shows And I save the draft When I open the saved draft and send it Then I see that mail under the 'sent' tag When I open that mail - Then I see that the subject reads 'Smail rocks!' + Then I see that the subject reads 'Pixelated rocks!' And I see that the body reads 'You should definitely use it. Cheers, User.' - diff --git a/fake-service/lib/generator.rb b/fake-service/lib/generator.rb index 35518844..83c1b2b2 100644 --- a/fake-service/lib/generator.rb +++ b/fake-service/lib/generator.rb @@ -59,7 +59,7 @@ module Generator def random_mail hdr = Mail.random_header bd = Mail.random_body - Smail::Mail.new( + PixelatedService::Mail.new( from: hdr[:from], to: hdr[:to], subject: hdr[:subject], @@ -71,10 +71,10 @@ module Generator hdr = Mail.random_header bd = Mail.random_body tgs = choose(ladder_distribution(1, 5)).times.map { tagset.sample }.uniq - special_tag = ([nil, nil, nil, nil, nil, nil] + Smail::Tags::SPECIAL).sample + special_tag = ([nil, nil, nil, nil, nil, nil] + PixelatedService::Tags::SPECIAL).sample status = [] status << :read if special_tag == 'sent' - mail = Smail::Mail.new( + mail = PixelatedService::Mail.new( from: hdr[:from], to: hdr[:to], subject: hdr[:subject], @@ -86,7 +86,7 @@ module Generator end def random_persona - Smail::Persona.new(Faker::Number.number(10), + PixelatedService::Persona.new(Faker::Number.number(10), Faker::Name.name, Faker::Lorem.sentence, Faker::Internet.email) diff --git a/fake-service/lib/pixelated_service.rb b/fake-service/lib/pixelated_service.rb new file mode 100644 index 00000000..e63649d9 --- /dev/null +++ b/fake-service/lib/pixelated_service.rb @@ -0,0 +1,27 @@ + +module PixelatedService +end + +require 'generator' +require 'pixelated_service/security_casing' +require 'pixelated_service/security_casing_examples' +require 'pixelated_service/stats' +require 'pixelated_service/stats_observer' +require 'pixelated_service/sorted_mail' +require 'pixelated_service/mail' +require 'pixelated_service/persona' +require 'pixelated_service/mail_service' +require 'pixelated_service/fake' +require 'pixelated_service/mailset' +require 'pixelated_service/server' +require 'pixelated_service/paginate' +require 'pixelated_service/all' +require 'pixelated_service/search' +require 'pixelated_service/tags' +require 'pixelated_service/combined_observer' +require 'pixelated_service/contacts_observer' +require 'pixelated_service/contact' +require 'pixelated_service/contacts' +require 'pixelated_service/contacts_sorter' +require 'pixelated_service/contacts_search' +require 'pixelated_service/mail_scope_filter' diff --git a/fake-service/lib/smail/all.rb b/fake-service/lib/pixelated_service/all.rb index 76da1f8b..c2e97528 100644 --- a/fake-service/lib/smail/all.rb +++ b/fake-service/lib/pixelated_service/all.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService class All def restrict(input) input diff --git a/fake-service/lib/smail/combined_observer.rb b/fake-service/lib/pixelated_service/combined_observer.rb index a3e920ca..a300f6e6 100644 --- a/fake-service/lib/smail/combined_observer.rb +++ b/fake-service/lib/pixelated_service/combined_observer.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class CombinedObserver def initialize(*observers) @observers = observers diff --git a/fake-service/lib/smail/contact.rb b/fake-service/lib/pixelated_service/contact.rb index a07f0f84..e1c86779 100644 --- a/fake-service/lib/smail/contact.rb +++ b/fake-service/lib/pixelated_service/contact.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService class Contact < Struct.new(:ident, :name, :addresses, :mails_received, :mails_sent, :last_received, :last_sent, :prev, :next) include Comparable diff --git a/fake-service/lib/smail/contacts.rb b/fake-service/lib/pixelated_service/contacts.rb index af523a69..2f57387d 100644 --- a/fake-service/lib/smail/contacts.rb +++ b/fake-service/lib/pixelated_service/contacts.rb @@ -1,7 +1,7 @@ require 'mail' require 'set' -module Smail +module PixelatedService class Contacts include Enumerable diff --git a/fake-service/lib/smail/contacts_observer.rb b/fake-service/lib/pixelated_service/contacts_observer.rb index 04c1670b..8f60ac81 100644 --- a/fake-service/lib/smail/contacts_observer.rb +++ b/fake-service/lib/pixelated_service/contacts_observer.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class ContactsObserver def initialize(contacts) @contacts = contacts diff --git a/fake-service/lib/smail/contacts_search.rb b/fake-service/lib/pixelated_service/contacts_search.rb index 76ee6aa2..f7b24ca3 100644 --- a/fake-service/lib/smail/contacts_search.rb +++ b/fake-service/lib/pixelated_service/contacts_search.rb @@ -2,7 +2,7 @@ # Very simple search for contacts. The search string will be something that will be prefix matched # using a boundary before but not after. If you put in more than one word, those two will be searched # and ANDed together. You can use double quotes or single quotes to do the obvious thing instead -module Smail +module PixelatedService class ContactsSearch def initialize(q) @qtree = ContactsSearch.compile(q) diff --git a/fake-service/lib/smail/contacts_sorter.rb b/fake-service/lib/pixelated_service/contacts_sorter.rb index ca78177f..e559205d 100644 --- a/fake-service/lib/smail/contacts_sorter.rb +++ b/fake-service/lib/pixelated_service/contacts_sorter.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService class ContactsSorter def restrict(input) input.sort diff --git a/fake-service/lib/smail/fake.rb b/fake-service/lib/pixelated_service/fake.rb index b1b468ac..48709096 100644 --- a/fake-service/lib/smail/fake.rb +++ b/fake-service/lib/pixelated_service/fake.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class << self def mail_service @mail_service ||= MailService.new @@ -20,111 +20,111 @@ module Smail def mails(query, page_number, window_size) with_timing do - stats, mails = Smail.mail_service.mails(query, page_number, window_size) + stats, mails = PixelatedService.mail_service.mails(query, page_number, window_size) { stats: stats, mails: mails.to_a } end end def contacts(query, page_number, window_size) with_timing do - contacts = Smail.mail_service.contacts(query, page_number, window_size) + contacts = PixelatedService.mail_service.contacts(query, page_number, window_size) { contacts: contacts.to_a } end end def contact(ix) - Smail.mail_service.contact(ix) + PixelatedService.mail_service.contact(ix) end def delete_mails(query, page_number, window_size, mails_idents) idents = mails_idents.gsub(/[\[\]]/, '').split(',').collect {|x| x.to_i} - Smail.mail_service.delete_mails(query, page_number, window_size, idents) + PixelatedService.mail_service.delete_mails(query, page_number, window_size, idents) [] end def mail(i) - Smail.mail_service.mail(i) + PixelatedService.mail_service.mail(i) end def send_mail(data) - Smail.mail_service.send_mail(data) + PixelatedService.mail_service.send_mail(data) end def update_mail(data) - Smail.mail_service.update_mail(data) + PixelatedService.mail_service.update_mail(data) end def delete_mail(i) - Smail.mail_service.delete_mail(i) + PixelatedService.mail_service.delete_mail(i) end def draft_reply_for(i) - Smail.mail_service.draft_reply_for(i) + PixelatedService.mail_service.draft_reply_for(i) end def tags(i) - Smail.mail_service.mail(i).tag_names + PixelatedService.mail_service.mail(i).tag_names end def create_tag(tag_json) - Smail.mail_service.create_tag tag_json + PixelatedService.mail_service.create_tag tag_json end def all_tags(q) - Smail.mail_service.tags(q) + PixelatedService.mail_service.tags(q) end def settags(i, body) - m = Smail.mail_service.mail(i) + m = PixelatedService.mail_service.mail(i) m.tag_names = body["newtags"] m.tag_names end def starmail(i, val) - m = Smail.mail_service.mail(i) + m = PixelatedService.mail_service.mail(i) m.starred = val if m "" end def repliedmail(i, val) - m = Smail.mail_service.mail(i) + m = PixelatedService.mail_service.mail(i) m.replied = val if m "" end def readmail(i, val) - m = Smail.mail_service.mail(i) + m = PixelatedService.mail_service.mail(i) m.read = val if m "" end def readmails(mail_idents, val) idents = mail_idents.gsub(/[\[\]]/, '').split(',').collect {|x| x.to_i} - Smail.mail_service.each { |k,v| readmail(k.ident, val) if idents.include?(k.ident) } + PixelatedService.mail_service.each { |k,v| readmail(k.ident, val) if idents.include?(k.ident) } [] end def control_create_mail - Smail.mail_service.create + PixelatedService.mail_service.create "" end def control_delete_mails - Smail.mail_service.clean + PixelatedService.mail_service.clean "" end def control_mailset_load(name) with_timing do { - stats: Smail.mail_service.load_mailset(name), + stats: PixelatedService.mail_service.load_mailset(name), loaded: name } end end def stats - Smail.mail_service.stats_report + PixelatedService.mail_service.stats_report end def with_timing diff --git a/fake-service/lib/smail/mail.rb b/fake-service/lib/pixelated_service/mail.rb index 8d1c8806..29ae5067 100644 --- a/fake-service/lib/smail/mail.rb +++ b/fake-service/lib/pixelated_service/mail.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Mail attr_reader :to, :cc, :bcc, :from, :subject, :body, :headers, :status, :draft_reply_for attr_accessor :ident, :security_casing @@ -80,7 +80,7 @@ module Smail unless self.status?(n) @status = @status + [n] @tags.added_status(n) - Smail.mail_service.stats_status_added(n, self) + PixelatedService.mail_service.stats_status_added(n, self) end end @@ -88,7 +88,7 @@ module Smail if self.status?(n) @status = @status - [n] @tags.removed_status(n) - Smail.mail_service.stats_status_removed(n, self) + PixelatedService.mail_service.stats_status_removed(n, self) end end diff --git a/fake-service/lib/smail/mail_scope_filter.rb b/fake-service/lib/pixelated_service/mail_scope_filter.rb index c8a5e042..dae6d99e 100644 --- a/fake-service/lib/smail/mail_scope_filter.rb +++ b/fake-service/lib/pixelated_service/mail_scope_filter.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService module MailScopeFilter include Enumerable diff --git a/fake-service/lib/smail/mail_service.rb b/fake-service/lib/pixelated_service/mail_service.rb index 314feaf5..02e36835 100644 --- a/fake-service/lib/smail/mail_service.rb +++ b/fake-service/lib/pixelated_service/mail_service.rb @@ -1,9 +1,9 @@ require 'set' -module Smail +module PixelatedService class MailService include Enumerable - include Smail::Stats + include PixelatedService::Stats def each @mails.each do |mo| @@ -24,7 +24,7 @@ module Smail end def clean - Smail::Tags.clean + PixelatedService::Tags.clean @next_ident = 0 @reply_drafts = {} @mails = SortedMail.new @@ -43,7 +43,7 @@ module Smail end def create_tag(tag_json) - Smail::Tags.create_tag tag_json['tag'] + PixelatedService::Tags.create_tag tag_json['tag'] end def mail(ix) @@ -87,11 +87,11 @@ module Smail def tags(q) if q && !q.strip.empty? query = /\b#{Regexp.new(Regexp.quote(q), Regexp::IGNORECASE)}/ - Smail::Tags.all_tags.select do |tt| + PixelatedService::Tags.all_tags.select do |tt| query =~ tt.name end else - Smail::Tags.all_tags + PixelatedService::Tags.all_tags end end @@ -114,7 +114,7 @@ module Smail def load_mailset(name) self.clean - ms = Smail::Mailset.load(name, @observers) + ms = PixelatedService::Mailset.load(name, @observers) raise "couldn't find mailset #{name}" unless ms @mails.add_all ms.mails self.stats diff --git a/fake-service/lib/smail/mailset.rb b/fake-service/lib/pixelated_service/mailset.rb index 0626dad8..595571e8 100644 --- a/fake-service/lib/smail/mailset.rb +++ b/fake-service/lib/pixelated_service/mailset.rb @@ -1,6 +1,6 @@ require 'set' -module Smail +module PixelatedService class Mailset DIR = File.expand_path File.join(File.dirname(__FILE__), "..", "..", "data", "mail-sets") @@ -70,7 +70,7 @@ module Smail @ix = 0 Dir["#{dir}/mbox*"].each do |f| File.open(f) do |fio| - res = Smail::Mail.read fio, @ix + res = PixelatedService::Mail.read fio, @ix res.read = true if (res.tag_names.include?('sent') || res.tag_names.include?('drafts')) @mails[res.ident] = res @observers.mail_added res diff --git a/fake-service/lib/smail/paginate.rb b/fake-service/lib/pixelated_service/paginate.rb index 85d09196..59d263d8 100644 --- a/fake-service/lib/smail/paginate.rb +++ b/fake-service/lib/pixelated_service/paginate.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService class Paginate def initialize(page, window_size) @start = page * window_size @@ -12,4 +12,4 @@ module Smail end end -require 'smail/paginated_enumerable' +require 'pixelated_service/paginated_enumerable' diff --git a/fake-service/lib/smail/paginated_enumerable.rb b/fake-service/lib/pixelated_service/paginated_enumerable.rb index 41c7f7bd..b1045e2f 100644 --- a/fake-service/lib/smail/paginated_enumerable.rb +++ b/fake-service/lib/pixelated_service/paginated_enumerable.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService class Paginate class PaginatedEnumerable include Enumerable diff --git a/fake-service/lib/smail/persona.rb b/fake-service/lib/pixelated_service/persona.rb index 47fe42dd..c51974ed 100644 --- a/fake-service/lib/smail/persona.rb +++ b/fake-service/lib/pixelated_service/persona.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Persona < Struct.new :ident, :name, :signature, :address def to_json { diff --git a/fake-service/lib/smail/search.rb b/fake-service/lib/pixelated_service/search.rb index 6c6b109e..e8f9d9fd 100644 --- a/fake-service/lib/smail/search.rb +++ b/fake-service/lib/pixelated_service/search.rb @@ -9,13 +9,13 @@ # if you use parenthesis, you can group together terms # search in:_default_, in:all, in:trash, in:sent, in:drafts will only work for the WHOLE search. You can do a negation on a scoped search if it's in:trash, in:sent or in:drafts, but not for in:all -module Smail +module PixelatedService class Search def initialize(q) if q @qtree, @search_scope = Search.compile(q) else - @qtree, @search_scope = TrueMatch.new, Smail::MailScopeFilter::Default + @qtree, @search_scope = TrueMatch.new, PixelatedService::MailScopeFilter::Default end end @@ -46,7 +46,7 @@ module Smail def self.compile(q, qs = StringScanner.new(q)) qtree = AndMatch.new - search_scope = Smail::MailScopeFilter::Default + search_scope = PixelatedService::MailScopeFilter::Default until qs.eos? if qs.check(/\)/) qs.scan(/\)/) @@ -125,9 +125,9 @@ module Smail end end -require 'smail/search/string_match' -require 'smail/search/scope_match' -require 'smail/search/negate_match' -require 'smail/search/and_match' -require 'smail/search/or_match' -require 'smail/search/true_match' +require 'pixelated_service/search/string_match' +require 'pixelated_service/search/scope_match' +require 'pixelated_service/search/negate_match' +require 'pixelated_service/search/and_match' +require 'pixelated_service/search/or_match' +require 'pixelated_service/search/true_match' diff --git a/fake-service/lib/smail/search/and_match.rb b/fake-service/lib/pixelated_service/search/and_match.rb index 2bc53f0d..dfd0f287 100644 --- a/fake-service/lib/smail/search/and_match.rb +++ b/fake-service/lib/pixelated_service/search/and_match.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Search class AndMatch attr_reader :data diff --git a/fake-service/lib/smail/search/negate_match.rb b/fake-service/lib/pixelated_service/search/negate_match.rb index f8bb59d4..77d880e8 100644 --- a/fake-service/lib/smail/search/negate_match.rb +++ b/fake-service/lib/pixelated_service/search/negate_match.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Search class NegateMatch attr_reader :data diff --git a/fake-service/lib/smail/search/or_match.rb b/fake-service/lib/pixelated_service/search/or_match.rb index 455923bf..2c3e50ef 100644 --- a/fake-service/lib/smail/search/or_match.rb +++ b/fake-service/lib/pixelated_service/search/or_match.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Search class OrMatch attr_reader :left, :right diff --git a/fake-service/lib/smail/search/scope_match.rb b/fake-service/lib/pixelated_service/search/scope_match.rb index 4402674d..170c54cf 100644 --- a/fake-service/lib/smail/search/scope_match.rb +++ b/fake-service/lib/pixelated_service/search/scope_match.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService class Search class ScopeMatch def initialize(scope, data) @@ -19,15 +19,15 @@ module Smail def search_scope case @data.match_string.downcase when '_default_' - Smail::MailScopeFilter::Default + PixelatedService::MailScopeFilter::Default when 'all' - Smail::MailScopeFilter::All + PixelatedService::MailScopeFilter::All when 'trash' - Smail::MailScopeFilter::Trash + PixelatedService::MailScopeFilter::Trash when 'sent' - Smail::MailScopeFilter::Sent + PixelatedService::MailScopeFilter::Sent when 'drafts' - Smail::MailScopeFilter::Drafts + PixelatedService::MailScopeFilter::Drafts end end diff --git a/fake-service/lib/smail/search/string_match.rb b/fake-service/lib/pixelated_service/search/string_match.rb index fc17ab59..f9b32376 100644 --- a/fake-service/lib/smail/search/string_match.rb +++ b/fake-service/lib/pixelated_service/search/string_match.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Search class StringMatch attr_reader :str diff --git a/fake-service/lib/smail/search/true_match.rb b/fake-service/lib/pixelated_service/search/true_match.rb index 7ac14923..fd615f16 100644 --- a/fake-service/lib/smail/search/true_match.rb +++ b/fake-service/lib/pixelated_service/search/true_match.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Search class TrueMatch def match?(mail) diff --git a/fake-service/lib/smail/security_casing.rb b/fake-service/lib/pixelated_service/security_casing.rb index fe8ae42b..6e2a77e5 100644 --- a/fake-service/lib/smail/security_casing.rb +++ b/fake-service/lib/pixelated_service/security_casing.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService class SecurityCasing < Struct.new(:imprints, :locks) def to_json(*args) { imprints: self.imprints, locks: self.locks }.to_json(*args) diff --git a/fake-service/lib/smail/security_casing_examples.rb b/fake-service/lib/pixelated_service/security_casing_examples.rb index 91bf80bb..e194de02 100644 --- a/fake-service/lib/smail/security_casing_examples.rb +++ b/fake-service/lib/pixelated_service/security_casing_examples.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService module SecurityCasingExamples module Key VALID_U_U = SecurityCasing::Key.new("295C746984AF7F0C", "698E2885C1DE74E32CD503AD295C746984AF7F0C", ["Ola Bini <ola@bini.ec>", diff --git a/fake-service/lib/smail/server.rb b/fake-service/lib/pixelated_service/server.rb index a5db8e03..d825a5e2 100644 --- a/fake-service/lib/smail/server.rb +++ b/fake-service/lib/pixelated_service/server.rb @@ -3,7 +3,7 @@ require 'sinatra/json' require 'json' require 'net/http' -module Smail +module PixelatedService class Server < Sinatra::Base set :root, File.join(File.dirname(__FILE__), '../../') @@ -77,6 +77,6 @@ module Smail end - include Smail::Fake + include PixelatedService::Fake end end diff --git a/fake-service/lib/smail/sorted_mail.rb b/fake-service/lib/pixelated_service/sorted_mail.rb index 803a8348..555d4bd4 100644 --- a/fake-service/lib/smail/sorted_mail.rb +++ b/fake-service/lib/pixelated_service/sorted_mail.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class SortedMail include Enumerable diff --git a/fake-service/lib/smail/stats.rb b/fake-service/lib/pixelated_service/stats.rb index 4e0393a4..3e79b226 100644 --- a/fake-service/lib/smail/stats.rb +++ b/fake-service/lib/pixelated_service/stats.rb @@ -1,5 +1,5 @@ -module Smail +module PixelatedService module Stats class StatsCollector include Stats diff --git a/fake-service/lib/smail/stats_observer.rb b/fake-service/lib/pixelated_service/stats_observer.rb index f4f9b1cd..f4e2831b 100644 --- a/fake-service/lib/smail/stats_observer.rb +++ b/fake-service/lib/pixelated_service/stats_observer.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class StatsObserver def initialize(stats) @stats = stats diff --git a/fake-service/lib/smail/tags.rb b/fake-service/lib/pixelated_service/tags.rb index 0973fc3d..d2eccc51 100644 --- a/fake-service/lib/smail/tags.rb +++ b/fake-service/lib/pixelated_service/tags.rb @@ -1,4 +1,4 @@ -module Smail +module PixelatedService class Tag < Struct.new(:name, :total_count, :read, :starred, :replied, :default) def to_json(*args) { @@ -135,14 +135,14 @@ module Smail end def create_tag(name) - Smail::Tag.new(name, 0, 0, 0, 0, false).tap do |t| + PixelatedService::Tag.new(name, 0, 0, 0, 0, false).tap do |t| self.tags[normalized(name)] = t end end def create_default_tags() SPECIAL.each do |name| - self.tags[normalized(name)] = Smail::Tag.new(name, 0, 0, 0, 0, true) + self.tags[normalized(name)] = PixelatedService::Tag.new(name, 0, 0, 0, 0, true) end end end diff --git a/fake-service/lib/smail.rb b/fake-service/lib/smail.rb deleted file mode 100644 index 6710f752..00000000 --- a/fake-service/lib/smail.rb +++ /dev/null @@ -1,27 +0,0 @@ - -module Smail -end - -require 'generator' -require 'smail/security_casing' -require 'smail/security_casing_examples' -require 'smail/stats' -require 'smail/stats_observer' -require 'smail/sorted_mail' -require 'smail/mail' -require 'smail/persona' -require 'smail/mail_service' -require 'smail/fake' -require 'smail/mailset' -require 'smail/server' -require 'smail/paginate' -require 'smail/all' -require 'smail/search' -require 'smail/tags' -require 'smail/combined_observer' -require 'smail/contacts_observer' -require 'smail/contact' -require 'smail/contacts' -require 'smail/contacts_sorter' -require 'smail/contacts_search' -require 'smail/mail_scope_filter' diff --git a/fake-service/spec/smail/mail_spec.rb b/fake-service/spec/smail/mail_spec.rb index b75ceff5..96b3bb31 100644 --- a/fake-service/spec/smail/mail_spec.rb +++ b/fake-service/spec/smail/mail_spec.rb @@ -2,10 +2,10 @@ fixture1 = File.read(File.join(File.dirname(__FILE__), "..", "fixtures", "mail1")) fixture2 = File.read(File.join(File.dirname(__FILE__), "..", "fixtures", "mail2")) -describe Smail::Mail do +describe PixelatedService::Mail do describe "#read" do context("simple email") do - subject(:mail) { Smail::Mail.read(fixture1) } + subject(:mail) { PixelatedService::Mail.read(fixture1) } it "reads the subject correctly" do expect(mail.subject).to eq("Doloremque aliquid a facilis et sit numquam libero.") @@ -39,7 +39,7 @@ BODY end context("with multiple recipients") do - subject(:mail) { Smail::Mail.read(fixture2) } + subject(:mail) { PixelatedService::Mail.read(fixture2) } it "reads multiple recipients correctly" do expect(mail.to).to eq(%w(cmurphy@thoughtworks.com cgorslin@thoughtworks.com cmitchel@thoughtworks.com dnorth@thoughtworks.com dpgoodwi@thoughtworks.com dbodart@thoughtworks.com dsmith@thoughtworks.com djrice@thoughtworks.com dwhalley@thoughtworks.com)) @@ -53,7 +53,7 @@ BODY describe ".to_s" do context("simple email") do - subject(:mail) { Smail::Mail.read(fixture1) } + subject(:mail) { PixelatedService::Mail.read(fixture1) } it "writes correct output" do expect(mail.to_s).to eq(<<MAIL) @@ -76,7 +76,7 @@ MAIL end end context("with multiple recipients") do - subject(:mail) { Smail::Mail.read(fixture2) } + subject(:mail) { PixelatedService::Mail.read(fixture2) } it "writes correct output" do expect(mail.to_s).to eq(<<MAIL) diff --git a/fake-service/spec/spec_helper.rb b/fake-service/spec/spec_helper.rb index d25e8240..4b2cd2ad 100644 --- a/fake-service/spec/spec_helper.rb +++ b/fake-service/spec/spec_helper.rb @@ -1 +1 @@ -require 'smail' +require 'pixelated_service' |