PageRenderTime 30ms CodeModel.GetById 18ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/demo/src/my_configuration.ads

http://github.com/ThomasLocke/yolk
Ada | 104 lines | 73 code | 10 blank | 21 comment | 0 complexity | 21ad6b228d94b3e86c64d1ea05be204c MD5 | raw file
Possible License(s): AGPL-1.0
  1-------------------------------------------------------------------------------
  2--                                                                           --
  3--                   Copyright (C) 2010-, Thomas Løcke                   --
  4--                                                                           --
  5--  This is free software;  you can redistribute it and/or modify it         --
  6--  under terms of the  GNU General Public License  as published by the      --
  7--  Free Software  Foundation;  either version 3,  or (at your  option) any  --
  8--  later version. This library is distributed in the hope that it will be   --
  9--  useful, but WITHOUT ANY WARRANTY;  without even the implied warranty of  --
 10--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
 11--  You should have received a copy of the GNU General Public License and    --
 12--  a copy of the GCC Runtime Library Exception along with this program;     --
 13--  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
 14--  <http://www.gnu.org/licenses/>.                                          --
 15--                                                                           --
 16-------------------------------------------------------------------------------
 17
 18--  Application specific configuration.
 19
 20with Ada.Strings.Unbounded;
 21with Yolk.Config_File_Parser;
 22
 23package My_Configuration is
 24
 25   use Ada.Strings.Unbounded;
 26
 27   function U
 28     (S : in String)
 29      return Unbounded_String
 30      renames To_Unbounded_String;
 31
 32   type Keys is (DB_Host,
 33                 DB_Name,
 34                 DB_User,
 35                 DB_Password,
 36                 Handler_DB_Test,
 37                 Handler_Dir,
 38                 Handler_Email,
 39                 Handler_Index,
 40                 Handler_Session_Test,
 41                 Handler_Syndication,
 42                 Handler_Websocket,
 43                 SQLite_Database,
 44                 SMTP_Host,
 45                 SMTP_Port,
 46                 Template_DB_Test,
 47                 Template_Email,
 48                 Template_Index,
 49                 Template_Session_Test,
 50                 Template_Websocket);
 51   --  The valid configuration keys.
 52
 53   type Defaults_Array is array (Keys) of Unbounded_String;
 54
 55   Default_Values : constant Defaults_Array :=
 56                      (DB_Host
 57                       => U ("localhost"),
 58                       DB_Name
 59                       => U ("yolk"),
 60                       DB_User
 61                       => U ("adauser"),
 62                       DB_Password
 63                       => U ("secret"),
 64                       Handler_DB_Test
 65                       => U ("/dbtest"),
 66                       Handler_Dir
 67                       => U ("^/dir/.*"),
 68                       Handler_Email
 69                       => U ("/email"),
 70                       Handler_Index
 71                       => U ("/"),
 72                       Handler_Session_Test
 73                       => U ("/sessiontest"),
 74                       Handler_Syndication
 75                       => U ("/syndication"),
 76                       Handler_Websocket
 77                       => U ("/websocket"),
 78                       SQLite_Database
 79                       => U ("yolk.db"),
 80                       SMTP_Host
 81                       => U ("localhost"),
 82                       SMTP_Port
 83                       => U ("25"),
 84                       Template_DB_Test
 85                       => U ("templates/website/database.tmpl"),
 86                       Template_Email
 87                       => U ("templates/website/email.tmpl"),
 88                       Template_Index
 89                       => U ("templates/website/index.tmpl"),
 90                       Template_Session_Test
 91                       => U ("templates/website/session_test.tmpl"),
 92                      Template_Websocket
 93                       => U ("templates/website/websocket.tmpl"));
 94   --  Default values for the configuration Keys. These values can be over-
 95   --  written by the configuration file given when instantiating the
 96   --  Yolk.Config_File_Parser generic.
 97
 98   package Config is new Yolk.Config_File_Parser
 99     (Key_Type => Keys,
100      Defaults_Array_Type => Defaults_Array,
101      Defaults => Default_Values,
102      Config_File => "configuration/my_config.ini");
103
104end My_Configuration;