diff --git a/README.md b/README.md index dff8a0d..c228e5d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Rexx Address Book ```oorexx -/*************************************************************************** -* Rexx Address Book * -* * -* A simple application for storing, maintaining, and browsing contact * -* information. * -* * -* Backend: Object Rexx with unix system, and sqlite extensions. * -* Frontend: Object Rexx with ncurses extensions. * - **************************************************************************/ + /***************************************************************************\ + * Rexx Address Book * + * * + * A simple application for storing, maintaining, and browsing contact * + * information. * + * * + * Backend: Object Rexx with unix, and sqlite extensions. * + * Frontend: Object Rexx with ncurses extensions. * + \***************************************************************************/ ``` diff --git a/addbook.rex b/addbook.rex index 5f746bf..3bf4d52 100755 --- a/addbook.rex +++ b/addbook.rex @@ -58,6 +58,7 @@ Exit .environment~projectRoot = .home||"/Projects/rexx-address-book" .environment~pkgPath = .projectRoot||"/app" .environment~dbPath = .projectRoot||"/db" + .environment~dbFile = .dbPath||"/contacts.sqlite" .environment["REXX_PATH"] = .projectRoot||";"||.pkgPath||";"||.dbPath||";" diff --git a/app/appdb.cls b/app/appdb.cls index c789d3b..3ada79c 100644 --- a/app/appdb.cls +++ b/app/appdb.cls @@ -9,14 +9,14 @@ expose db /* Create database directory if it doesn't exist */ - if SysFileExists(.dbPath) == .false then DO + if SysFileExists(.dbFile) == .false then DO SAY "Initializing new address book" - db = .ooSQLiteConnection~new(.dbPath) + db = .ooSQLiteConnection~new(.dbFile) self~createTables END Else Do Say "Initializing existing address book" - db = .ooSQLiteConnection~new(.dbPath,.ooSQLite~OPEN_READWRITE) + db = .ooSQLiteConnection~new(.dbFile,.ooSQLite~OPEN_READWRITE) End return diff --git a/db/test_contacts.sqlite b/db/test_contacts.sqlite index ae27f9f..109e788 100644 Binary files a/db/test_contacts.sqlite and b/db/test_contacts.sqlite differ diff --git a/tests/test_appdb.rexx b/tests/test_appdb.rexx index 7fc9c72..5ca19a5 100755 --- a/tests/test_appdb.rexx +++ b/tests/test_appdb.rexx @@ -8,11 +8,7 @@ ***************************************************************************/ /* Setup environment */ -.local~home = SysGetpwnam("gmgauthier", "d") -.local~projectRoot = .home||"/Projects/rexx-address-book" -.local~appPkg = .projectRoot||"/app" -.local~dbPath = .projectRoot||"/db/test_contacts.sqlite" /* Use a test database */ - +call setEnv tests = .TestSuite~new() @@ -36,11 +32,20 @@ tests~tearDown exit 0 +::ROUTINE setEnv + .environment~home = SysGetpwnam("gmgauthier", "d") + .environment~projectRoot = .home||"/Projects/rexx-address-book" + .environment~pkgPath = .projectRoot||"/app" + .environment~dbPath = .projectRoot||"/db" + .environment~dbFile = .dbPath||"/test_contacts.sqlite" + .environment["REXX_PATH"] = .projectRoot||";"||.pkgPath||";"||.dbPath||";" + + ::requires 'app/appdb.cls' +::requires 'app/utils.rex' ::requires 'ooSQLite.cls' ::requires "rxunixsys" LIBRARY ::requires 'ncurses.cls' -::requires 'app/utils.rex' ::CLASS TestSuite @@ -49,11 +54,11 @@ exit 0 ::METHOD setUp expose db contactDict - if SysFileExists(.dbPath) then do - call SysFileDelete .dbPath + if SysFileExists(.dbFile) then do + call SysFileDelete .dbFile say "Deleted existing test database." end - say "Initializing test database at:" .dbPath + say "Initializing test database at:" .dbFile db = .AddressBookDB~new() self~setupFixtureData()