Skip to content

Commit

Permalink
Refactoring for contact names and add-contact feature
Browse files Browse the repository at this point in the history
  • Loading branch information
elenagensch committed May 30, 2021
1 parent 8994e19 commit e8c4707
Show file tree
Hide file tree
Showing 45 changed files with 112 additions and 60 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ readChildFoldersMailsFrom: anEmailAccount
| anICContact |
anEmailAccount rootFolder recursiveChildFolders do: [:childFolder |
childFolder emails do: [:childFolderEmail |
anICContact := ICContact newWith: childFolderEmail senderAddressFromHeader with: childFolderEmail senderName.
anICContact := ICContact newWith: childFolderEmail senderAddressFromHeader
with: childFolderEmail senderName.
self addEmail: anICContact asString]]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ initialize
readRootFoldersMailsFrom: anEmailAccount

| anICContact |
anEmailAccount rootFolder emails
anEmailAccount rootFolder emails
do: [:rootFolderEmail |
anICContact := ICContact newWith: rootFolderEmail senderAddressFromHeader with: rootFolderEmail senderName.
anICContact := ICContact newWith: rootFolderEmail senderAddressFromHeader
with: rootFolderEmail senderName.
self addEmail: anICContact asString]
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"addEmail:" : "EG 5/22/2021 09:43",
"feedMeWithEntries:" : "EG 5/20/2021 12:25",
"find:" : "LW 6/16/2020 09:51",
"initialize" : "EG 5/20/2021 11:19",
"readChildFoldersMailsFrom:" : "EG 5/22/2021 09:34",
"readRootFoldersMailsFrom:" : "EG 5/22/2021 09:38" } }
"readChildFoldersMailsFrom:" : "EG 5/29/2021 23:35",
"readRootFoldersMailsFrom:" : "EG 5/29/2021 23:35" } }
1 change: 1 addition & 0 deletions packages/IMAPClient-Core.package/ICContact.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An ICContact is a data object holding all relevant data for an ICAddressBook entry.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
as yet unclassified
instance creation
newWith: anEmail with: aName

^ (ICContact new)
^ ICContact new
email: anEmail;
name: aName;
yourself

yourself
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
asString

^ self name, ' ', self email
^ (self name truncateTo: 30), Character tab, self email
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"class" : {
"newWith:with:" : "EG 5/20/2021 11:49" },
"newWith:with:" : "EG 5/29/2021 23:20" },
"instance" : {
"asString" : "EG 5/22/2021 09:55",
"asString" : "c.h. 5/25/2021 09:30",
"email" : "EG 5/21/2021 00:03",
"email:" : "EG 5/21/2021 00:03",
"name" : "EG 5/21/2021 00:03",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"classvars" : [
],
"commentStamp" : "",
"commentStamp" : "EG 5/29/2021 23:20",
"instvars" : [
"email",
"name" ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
senderAddressDelimeters

^ '<>'
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ accessing-header
sender

| fromCollection |
fromCollection := self from findBetweenSubStrs: '<>'.
fromCollection := self from findBetweenSubStrs: self class senderAddressDelimeters.
^ (fromCollection at: 2 ifAbsent: [fromCollection at: 1 ifAbsent: [ '' ]])
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ accessing-header
senderName

| fromCollection |
fromCollection := self from findBetweenSubStrs: '<>'.
fromCollection := self from findBetweenSubStrs: self class senderAddressDelimeters.
^ (fromCollection at: 1 ifAbsent: [ '' ])
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"class" : {
"newFromJsonStream:" : "hg 7/30/2020 09:50" },
"newFromJsonStream:" : "hg 7/30/2020 09:50",
"senderAddressDelimeters" : "EG 5/30/2021 12:19" },
"instance" : {
"=" : "hg 7/30/2020 11:06",
"asString" : "AR 7/28/2016 14:06",
Expand Down Expand Up @@ -35,9 +36,9 @@
"retrieveBody" : "JJ 8/2/2020 15:33",
"seen" : "C.G. 7/25/2018 13:49",
"seen:" : "C.G. 7/25/2018 13:49",
"sender" : "EG 5/20/2021 18:51",
"sender" : "EG 5/30/2021 12:20",
"senderAddressFromHeader" : "LW 8/2/2020 13:58",
"senderName" : "EG 5/21/2021 14:56",
"senderName" : "EG 5/30/2021 12:20",
"serializeToJson" : "hg 7/29/2020 15:25",
"subject" : "tg 7/19/2019 11:45",
"subject:" : "C.G. 7/25/2018 13:49",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
"retrieveFlagsFrom:to:" : "JJ 8/2/2020 15:33",
"rootFolder" : "ok 7/26/2019 19:05",
"sanitizeMailCollection:" : "LW 5/20/2020 09:49",
"startUpdateProcess:" : "LW 8/2/2020 14:34",
"startUpdateProcess:" : "EG 5/29/2021 20:46",
"update" : "pm 6/3/2019 18:34",
"updateAndShowProgressWith:" : "LW 6/3/2020 15:13" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
constants
emails

^ (ICEmail new
from: 'Sender <sender@address.de>') asOrderedCollection
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
addressBook: anObject

addressBook := anObject
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
addressBook

^ addressBook
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
emailAccounts: anObject

emailAccounts := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
emailAccounts

^ emailAccounts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
emailContact: anObject

emailContact := anObject
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
emailContact

^ emailContact
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ setUp
self addressBook: (ICAddressBook new: 10).

self emailContact:
(ICContact newWith: 'erika.musterfrau@rocks.de' with: 'Erika Musterfrau') asString
(ICContact newWith: 'erika.musterfrau@rocks.de' with: 'Erika Musterfrau') asString.

self emailAccounts: ICMockEndpoint new asOrderedCollection
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ testAddEntry

self addressBook addEmail: self emailContact.

self assert: self addressBook size equals: 1

self assert: self addressBook size equals: 1
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ testAddEntryDuplicated
self addressBook addEmail: self emailContact.
self addressBook addEmail: self emailContact.

self assert: self addressBook size equals: 1

self assert: self addressBook size equals: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
adding entries
testFeedWithEntries

self emailAccounts
do: [:account | account rootFolder: (ICFolder new emails: self class emails)].

self addressBook feedMeWithEntries: emailAccounts.

self assert: self addressBook size equals: 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ testFindEntry

self addressBook addEmail: self emailContact.

self assert: (self addressBook find: self emailContact) equals: self emailContact

self assert: (self addressBook find: self emailContact) equals: self emailContact
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"class" : {
},
"emails" : "EG 5/30/2021 12:10" },
"instance" : {
"addressBook" : "LW 5/13/2020 09:54",
"addressBook:" : "LW 5/13/2020 09:54",
"emailContact" : "EG 5/22/2021 14:10",
"emailContact:" : "EG 5/22/2021 14:10",
"setUp" : "EG 5/22/2021 15:08",
"testAddEntry" : "EG 5/22/2021 14:44",
"testAddEntryDuplicated" : "EG 5/22/2021 14:45",
"addressBook" : "EG 5/29/2021 23:22",
"addressBook:" : "EG 5/29/2021 23:21",
"emailAccounts" : "EG 5/30/2021 12:42",
"emailAccounts:" : "EG 5/30/2021 12:42",
"emailContact" : "EG 5/29/2021 23:21",
"emailContact:" : "EG 5/29/2021 23:21",
"setUp" : "EG 5/30/2021 12:22",
"testAddEntry" : "EG 5/27/2021 09:47",
"testAddEntryDuplicated" : "EG 5/27/2021 09:48",
"testDeleteEntry" : "EG 5/22/2021 14:45",
"testDeleteNonExistentEntryRaisesError" : "EG 5/22/2021 14:45",
"testFindEntry" : "EG 5/22/2021 14:46",
"testFindNonExistentEntryRaisesError" : "EG 5/22/2021 14:46" } }
"testDeleteNonExistentEntryRaisesError" : "EG 5/29/2021 23:23",
"testFeedWithEntries" : "EG 5/30/2021 12:09",
"testFindEntry" : "EG 5/29/2021 23:24",
"testFindNonExistentEntryRaisesError" : "EG 5/29/2021 23:24" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"commentStamp" : "LW 8/1/2020 11:39",
"instvars" : [
"addressBook",
"emailContact" ],
"emailContact",
"emailAccounts" ],
"name" : "ICAddressBookTest",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This class tests ICContact.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
expectedStringRepresentation

^ 'Erika Musterfrau erika.musterfrau@rocks.de'
^ 'Erika Musterfrau', Character tab, 'erika.musterfrau@rocks.de'
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
running
setUp

self contact: (ICContact new
email: 'erika.musterfrau@rocks.de';
name: 'Erika Musterfrau';
yourself)
self contact: (ICContact newWith: 'erika.musterfrau@rocks.de' with: 'Erika Musterfrau')
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test - converting
testAsString

self assert: self contact asString equals: (ICContactTest expectedStringRepresentation)
self assert: self contact asString equals: self class expectedStringRepresentation
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"class" : {
"expectedStringRepresentation" : "EG 5/22/2021 14:55" },
"expectedStringRepresentation" : "c.h. 5/25/2021 09:37" },
"instance" : {
"contact" : "EG 5/22/2021 14:16",
"contact:" : "EG 5/22/2021 14:16",
"setUp" : "EG 5/22/2021 14:28",
"testAsString" : "EG 5/22/2021 14:55" } }
"setUp" : "EG 5/27/2021 09:45",
"testAsString" : "EG 5/30/2021 12:52" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"classvars" : [
],
"commentStamp" : "",
"commentStamp" : "EG 5/27/2021 09:35",
"instvars" : [
"contact" ],
"name" : "ICContactTest",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
expectedSender

^ 'sender@address.de'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
expectedSenderName

^ 'Sender '
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expectedStringRepresentation
^ 'contentTransferEncoding: base64', String cr,
'contentType: text/plain; charset=ISO-8859-1', String cr,
'date: Fri, 10 Jun 2016 12:51:42 +0200', String cr,
'from: sender', String cr,
'from: Sender <sender@address.de>', String cr,
'subject: subject text', String cr,
'to: receiver', String cr,
String cr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ setUp
self email: (ICEmail new
body: 'body text';
subject: 'subject text';
from: 'sender';
from: 'Sender <sender@address.de>';
to: 'receiver';
contentType: 'text/plain; charset=ISO-8859-1';
contentTransferEncoding: 'base64';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
testSender

self assert: self email sender equals: self class expectedSender
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
testSenderName

self assert: self email senderName equals: self class expectedSenderName
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@
"expectedMinimalHeaderAsString" : "hg 7/31/2020 22:32",
"expectedParsedMESZDate" : "tg 7/19/2019 10:36",
"expectedParsedUTCDate" : "tg 7/19/2019 10:36",
"expectedSender" : "EG 5/29/2021 20:56",
"expectedSenderName" : "EG 5/29/2021 23:16",
"expectedSqueakEpochSeconds" : "tg 7/19/2019 09:29",
"expectedStringRepresentation" : "hg 7/31/2020 22:33",
"expectedStringRepresentation" : "EG 5/29/2021 23:16",
"givenJsonObject" : "hg 7/30/2020 11:40" },
"instance" : {
"email" : "EG 5/20/2021 11:50",
"email:" : "EG 5/20/2021 11:50",
"setUp" : "EG 5/20/2021 11:50",
"setUp" : "EG 5/30/2021 12:43",
"testAsString" : "EG 5/20/2021 11:50",
"testDateFormatted" : "EG 5/20/2021 11:50",
"testDateInSecondsSince1980" : "EG 5/20/2021 11:50",
"testDateInSecondsSinceSqueakEpoch" : "EG 5/20/2021 11:50",
"testDeserialization" : "hg 7/30/2020 11:01",
"testRetrieveBody" : "EG 5/20/2021 11:50",
"testSender" : "EG 5/29/2021 21:00",
"testSenderName" : "EG 5/29/2021 21:00",
"testSerialization" : "hg 7/30/2020 10:57" } }
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ buildAddressBookEntryList: builder
color: (Color white);
columns: {
[:listMorph | (listMorph filteredItems collect: [:item |
item preferredWidthOfColumn: 1]) max].}
item preferredWidthOfColumn: 1]) max].
[:listMorph | (listMorph filteredItems collect: [:item |
item preferredWidthOfColumn: 2]) max].}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ buildWith: builder
model: self;
label: self dialogTitle;
children: OrderedCollection new;
extent: 350 @ 200;
extent: 550 @ 400;
children: {self buildAddressBookEntryList: builder.
self buildAddressBookPanel: builder})
Loading

0 comments on commit e8c4707

Please sign in to comment.