1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
| with Ada.Wide_Text_Io;
with Ada.Calendar;
with Ada.Calendar.Time_Zones;
with Ada.Calendar.Formatting;
with Ada.Strings.Fixed;
with Ada.Characters.Handling;
separate (Ex_Digit)
procedure Chaos(Demain : out Version_Type;
Major : in Major_Type;
Minor : in Minor_Type;
Revision : in Revision_Type;
Release : in Release_Type) is
Hier : Version_Type := Initial_Version;
Date : String(1..Release.Date'Length) := (others => '*');
begin
OS.Au_Jour ( jour => Hier );
Ada.Strings.Fixed.Move
(
Ada.Calendar.Formatting.Image(Ada.Calendar.Clock, False, Ada.Calendar.Time_Zones.Utc_Time_offset(Ada.Calendar.Clock)),
Date,
Ada.Strings.Error,
Ada.Strings.Left,
' '
);
if Date /= Hier.Release.Date then
Demain := Hier;
if Revision /= Hier.Revision then
case Revision is
when Machinal =>
if Major = Hier.Major then
Demain.Major := Major_Type'Val(Boolean'Pos(not Boolean'Val(abs(Major_type'Pos(Hier.Major)-2)-1)));
else
Demain.Major := Major;
end if;
if Minor = Hier.Minor then
Demain.Minor := Minor_Type'Val(Boolean'Pos(not Boolean'Val(abs(Minor_type'Pos(Hier.Minor)-2)-1)));
else
Demain.Minor := Minor;
end if;
Demain.Revision := manual;
when others =>
if Major = Hier.Major then
Demain.Major := Major_Type'Val(Boolean'Pos(not Boolean'Val(abs(Major_type'Pos(Hier.Major)-2)-1)));
else
Demain.Major := Major;
end if;
if Minor = Hier.Minor then
Demain.Minor := Minor_Type'Val(Boolean'Pos(not Boolean'Val(abs(Minor_type'Pos(Hier.Minor)-2)-1)));
else
Demain.Minor := Minor;
end if;
Demain.Revision :=machinal;
end case;
else
Demain.Major := Major;
Demain.Minor := Minor;
Demain.Revision := Manual;
end if;
Demain.Release := Release;
Ada.Strings.Fixed.Move
(
Date,
Demain.Release.Date,
Ada.Strings.Error,
Ada.Strings.Left,
' '
);
OS.Mise_Au_Jour ( Version => Demain );
Ada.Text_Io.New_Line;
Ada.Text_Io.Put_Line("Au jour de " & Demain.Release.date);
end if;
end Chaos;
generic
Premier_Jour : Version_Type := Initial_Version;
package Ex_Machina.Zeux is
pragma Shared_Passive ( Ex_Machina.Zeux);
procedure Mise_Au_Jour (Version : in Version_Type);
--
procedure Au_Jour (Jour : out Version_Type);
--
private
Dernier_Jour : Version_Type := Initial_Version;
end Ex_Machina.Zeux;
package body Ex_Machina.Zeux is
procedure Mise_Au_Jour (Version : in Version_Type) is
begin
Dernier_Jour.major := Version.Major;
Dernier_Jour.Minor := Version.Minor;
Dernier_Jour.Revision := Version.Revision;
Dernier_Jour.Release.Author := Version.Release.Author;
Dernier_Jour.Release.Lang := Version.Release.Lang;
Dernier_Jour.Release.Copyright := Version.Release.Copyright;
Dernier_Jour.Release.Date := Version.Release.Date;
Dernier_Jour.Release.License := Version.Release.License;
end Mise_Au_Jour;
procedure Au_Jour (Jour : out Version_Type) is
begin
Jour.major := Dernier_Jour.Major;
Jour.Minor := Dernier_Jour.Minor;
Jour.Revision := Dernier_Jour.Revision;
Jour.Release.Author := Dernier_Jour.Release.Author;
Jour.Release.Lang := Dernier_Jour.Release.Lang;
Jour.Release.Copyright := Dernier_Jour.Release.Copyright;
Jour.Release.Date := Dernier_Jour.Release.Date;
Jour.Release.License := Dernier_Jour.Release.License;
end Au_Jour;
end Ex_Machina.Zeux;
package Ex_Machina is
pragma Pure (Ex_Machina);
type Version_Flags is (Major, Minor, Rev, Release);
-- the flags of version.
type Major_Type is (Alpha, Terra, Omega);
-- alpha : initialization ;
-- Terra : adjustement ;
-- omega : finalization.
type Minor_Type is (Debug, Real, Test);
-- Debug : development ;
-- Release : publication ;
-- Test : testing.
type Revision_Type is (Manual, Machinal);
-- Manual : human development ;
-- Machinal : A.I. development.
Line_First : constant Positive := 1;
Line_Last : constant Positive := 256;
subtype Line_Length_Max_Type is Positive range Line_first..Line_Last;
subtype Line_Type is String(1..32);
type Release_Type is
record
Author : Line_Type := "Ada ";
Lang : Line_Type := "fr ";
Copyright : Line_Type := "Copyleft (L) The matrix 2014 ";
Date : Line_Type := "mercredi 26 novembre 2014 ";
License : Line_Type := "Gnu General Public License ";
Program : Line_Type := "Chaos Ex Digit ";
end record;
Ada_Release : constant Release_Type := (Author => "Ada ",
Lang => "fr ",
Copyright => "Copyleft (L) The matrix 2014 ",
Date => "mercredi 26 novembre 2014 ",
License => "Gnu General Public License ",
Program => "Chaos Ex Digit ");
type Version_Type is
record
Major : Major_Type := Alpha;
Minor : Minor_Type := Debug;
Revision : Revision_Type := Manual;
Release : Release_Type;
end record;
Initial_Version : constant Version_Type :=
(
Alpha, Debug, Manual,
(
Author => "Ada ",
Lang => "fr ",
Copyright => "Copyleft (L) The matrix 2014 ",
Date => "mercredi 26 novembre 2014 ",
License => "Gnu General Public License ",
Program => "Chaos Ex Digit "
)
);
end Ex_Machina;
-- Ex Digit is Small dated version manger.
-- Coryright (C) The matrix 2014.
with Ada.Text_Io;
with Text_Io;
use Text_Io;
with Ex_Machina.Zeux;
use Ex_Machina;
procedure Ex_Digit is
package OS is new Ex_Machina.Zeux(Premier_Jour => Initial_Version);
use Os;
procedure Chaos(Demain : out Version_Type;
Major : in Major_Type;
Minor : in Minor_Type;
Revision : in Revision_Type;
Release : in Release_Type) is separate;
procedure Afficher_Version (Jour : in Version_Type) is
begin
Text_Io.Put_Line("Major : " & Major_Type'Image(Jour.Major));
Text_Io.Put_Line("Minor : " & Minor_Type'Image(Jour.Minor));
Text_Io.Put_Line("Revision : " & Revision_Type'Image(Jour.Revision));
Text_Io.New_Line;
Ada.Text_Io.Put_Line("Author : " & Jour.Release.Author);
Ada.Text_Io.Put_Line("Language : " & Jour.Release.Lang);
Ada.Text_Io.Put_Line("Copyright : " & Jour.Release.Copyright);
Ada.Text_Io.Put_Line("Date : " & Jour.Release.Date);
Ada.Text_Io.Put_Line("License : " & Jour.Release.License);
Ada.Text_Io.Put_Line("Program : " & Jour.Release.Program);
Ada.Text_Io.New_Line;
end Afficher_Version;
Major : Major_Type := Alpha;
Minor : Minor_Type := Debug;
Revision : Revision_Type := Manual;
The_Matrix : Release_Type := (Author => "The matrix ",
Lang => "fr ",
Copyright => "Copyleft (L) Ada 2014 ",
Date => "jeudi 27 novembre 2014 ",
License => "Gnu General Public License ",
Program => "Chaos Ex Digit ");
Ce_Jour : Version_Type := Initial_Version;
begin
-- for I in 1..5 loop
Text_Io.New_Line;
Ada.Text_Io.Put_Line("Programme de mise au jour " & Ce_Jour.Release.Program);
Text_Io.New_Line;
Au_Jour(Ce_Jour);
Ada.Text_Io.Put_Line("Hier " & Ce_Jour.Release.date);
Text_Io.New_Line;
Afficher_Version( Jour => Ce_Jour);
if Revision_Type'Val(Boolean'Pos(not Boolean'Val(abs(Revision_type'Pos(Revision))))) /= Ce_Jour.revision then
Ada.Text_Io.Put_Line("Mise au jour...");
case Revision is
when Manual =>
Ada.Text_Io.Put_Line("Aujourd'hui " & Ce_Jour.Release.Date & " : mise au jour manuelle." );
Afficher_Version( Jour => Ce_Jour);
Text_Io.Put_Line ("Veuillez saisir les informations requises pour la mise au jour !");
Text_Io.New_Line;
Text_Io.Put_Line("Major val : ");
for Index in Major_Type'Range loop
Text_Io.Put_Line(Major_Type'Image(Index));
end loop;
loop
begin
Text_Io.Put_Line("Major : " & Major_Type'Image(Major));
Text_Io.Put("votre choix : ");
Major := Major_Type'Value(Text_Io.Get_Line);
exit;
exception
when Constraint_Error =>
Text_Io.New_Line;
end;
end loop;
Text_Io.Put(" ... Major : " & Major_Type'Image(Major));
Text_Io.New_Line;
Text_Io.Put_Line("Minor val : ");
for Index in Minor_Type'Range loop
Text_Io.Put_Line(Minor_Type'Image(Index));
end loop;
loop
begin
Text_Io.Put_Line("Minor : " & Minor_Type'Image(Minor));
Text_Io.Put("votre choix : ");
Minor := Minor_Type'Value(Text_Io.Get_Line);
exit;
exception
when Constraint_Error =>
Text_Io.New_Line;
end;
end loop;
Text_Io.Put(" ... Minor : " & Minor_Type'Image(Minor));
Text_Io.New_Line;
if Ce_Jour.Major = Alpha then
if Ce_Jour.Minor = Test then
Minor := Minor_Type'Val(Boolean'Pos(not Boolean'Val(abs(Minor_type'Pos(Ce_jour.Minor)-2)-1)));
Revision := Manual;
else
Minor := Minor_Type'Val(Boolean'Pos(not Boolean'Val(abs(Minor_type'Pos(Ce_jour.Minor)-2)-1)));
Revision := Machinal;
end if;
else
if Ce_Jour.Minor = Real then
Major := Major_Type'Val(Boolean'Pos(not Boolean'Val(abs(Major_type'Pos(Ce_jour.Major)-2)-1)));
Minor := Minor_Type'Succ(Ce_Jour.Minor);
Revision := Manual;
else
Minor := Minor_Type'Succ(Ce_Jour.Minor);
Revision := Machinal;
end if;
end if;
Chaos(Demain => Ce_Jour,
Major => Major,
Minor => Minor,
Revision => Revision,
Release => Ce_Jour.Release);
Text_Io.New_Line;
Afficher_Version( Jour => Ce_Jour);
when Machinal =>
Ada.Text_Io.Put_Line("Aujourd'hui " & Ce_Jour.Release.Date & " : mise au jour automatique." );
if Ce_Jour.Major = Alpha then
if Ce_Jour.Minor = Test then
Minor := Minor_Type'Val(Boolean'Pos(not Boolean'Val(abs(Minor_type'Pos(Ce_jour.Minor)-2)-1)));
Revision := Manual;
else
Minor := Minor_Type'Val(Boolean'Pos(not Boolean'Val(abs(Minor_type'Pos(Ce_jour.Minor)-2)-1)));
Revision := Machinal;
end if;
else
if Ce_Jour.Minor = Real then
Major := Major_Type'Val(Boolean'Pos(not Boolean'Val(abs(Major_type'Pos(Ce_jour.Major)-2)-1)));
Minor := Minor_Type'Succ(Ce_Jour.Minor);
Revision := Machinal;
else
Minor := Minor_Type'Succ(Ce_Jour.Minor);
Revision := Manual;
end if;
end if;
Chaos(Demain => Ce_Jour,
Major => Major,
Minor => Minor,
Revision => Revision,
Release => The_matrix);
Text_Io.New_Line;
Afficher_Version( Jour => Ce_Jour);
end case;
end if;
Au_Jour( Jour => Ce_Jour );
Ada.Text_Io.Put_Line("Demain n'est pas une date.");
Text_Io.New_Line;
Afficher_Version( Jour => Ce_Jour);
delay 1.0;
--end loop;
end Ex_Digit; |
Partager