timequiz 0.2.2 → 0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daea9447b170a102d8da289d83d0a3308e7978ffd6398f685b3ba38c1a9b8a3e
4
- data.tar.gz: 6d5c7ef90601c861f2c5af709cf6db654e76f7a21b6ef17c5e09889b9aa6e35c
3
+ metadata.gz: a7e38d8b9eb74d76bb8e87d548a7ac05427adfd515b34886d83c672dd2c9f8b0
4
+ data.tar.gz: e48d79a87c7bb51f4fac84b2a4a957e953657385fc9e91f9ec8102279f5b139f
5
5
  SHA512:
6
- metadata.gz: eb8af1641167be90a179d1a659172ec38ebbaeae264c0aa0b32eeb878c1330cab038e8ffcc900c343105297e8265bf28006b8aee7349400a45651bc54fd83824
7
- data.tar.gz: bfd0f786ec2df827c1ceb40968c13fe34c70ddab9c7fca3a1d5fb9fbc00ae3f95fba21ed441dd653ac93c7dda8e85592c3138f7611c3c1d00b4188338e92f618
6
+ metadata.gz: b9db06d19755fb81f085ad3f8d719fd75a4fd81fef834192df149c39bd11adc519211952a8938e64f999ac9e71f265830d64032681962a9f92eec442f9c68103
7
+ data.tar.gz: 31aea480b7b839796b7257f4b393dc1c90697f66ff544069a1d262a0b561f2cbb4aa75681eed7673f05d7c07efab363b6a7d68e9f5781ba43c0ae0b1136d46e8
@@ -1,200 +1,336 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
2
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
3
  <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- <meta name="generator" content="Docutils 0.21.2: https://docutils.sourceforge.io/" />
7
- <title>TIMEQUIZ</title>
8
- <style type="text/css">
4
+ <meta name="generator" content="vim - Vi Improved, a programmer's editor; HTML Tidy for Linux version 5.8.0
5
+ "/>
6
+ <meta charset="utf-8" />
7
+ <meta name="viewport" content=
8
+ "width=device-width, initial-scale=1" />
9
+ <title>Timequiz</title>
10
+ <style type="text/css">
11
+ /*<![CDATA[*/
9
12
 
10
- /*
11
- :Author: Michael Uplawski
12
- :Contact: michael.uplawski@uplawski.eu
13
- :License: WTFPL 2.0, see http://www.wtfpl.net/about/
13
+ /*
14
+ :Author: Michael Uplawski
15
+ :Contact: michael.uplawski@uplawski.eu
16
+ :License: WTFPL 2.0, see http://www.wtfpl.net/about/
14
17
 
15
- Stylesheet for use with Docutils.
16
- */
18
+ Stylesheet for use with Docutils.
19
+ */
17
20
 
18
- /* The defaults for docutils */
19
- @import url(html4css1.css);
20
-
21
- body {
21
+ body {
22
22
  background-color:#200030;
23
23
  font-family: Verdana,Helvetica,Univers;
24
24
  color:#f0f0f0;
25
25
  color:#f0f0f0;
26
- }
27
-
28
- h1 {color:cyan;font-size:1.5em;}
29
- h1.title {color:#a0a0f0;font-size:2em;}
30
- h2 {color:#ffffa0;}
31
-
32
- p, ul.simple, ol.simple, dt {margin-left:2em;}
33
- p.first {font-weight:bold;}
34
- dd {margin-left:4em;}
35
- td {color:#f0f080;}
36
-
37
- /* correct left margin of nested block tags*/
38
- dd p, li p {margin-left:0;}
39
- dd * ul {margin-left:0 ! important; }
40
- dd ul {margin-left:0 ! important; }
41
- dd dl dt, dd dl dd {margin-left:0 ! important;}
42
- dt {font-weight:bold;}
43
- dt, dd {color:#f0f0f0}
44
-
45
- tt.docutils {color:#000080;
26
+ }
27
+
28
+ h1 {color:cyan;font-size:1.5em;}
29
+ h1.title {color:#a0a0f0;font-size:2em;}
30
+ h2 {color:#ffffa0;}
31
+
32
+ p, ul.simple, ol.simple, dt {margin-left:2em;}
33
+ p.first {font-weight:bold;}
34
+ dd {margin-left:4em;}
35
+ table {
36
+ border: 0.5pt dotted #ffa050;
37
+ margin-left:2em;
38
+ border-radius:1em;
39
+ }
40
+ td {color:#f0f080;}
41
+
42
+ /* correct left margin of nested block tags*/
43
+ dd p, li p {margin-left:0;}
44
+ dd * ul {margin-left:0 ! important; }
45
+ dd ul {margin-left:0 ! important; }
46
+ dd dl dt, dd dl dd {margin-left:0 ! important;}
47
+ dt {font-weight:bold;}
48
+ dt, dd {color:#f0f0f0}
49
+
50
+ tt.docutils {color:#000080;
46
51
  background-color:#a080a0;
47
52
  padding-left:3px;
48
53
  padding-right:3px;
49
54
  white-space:nowrap;
50
- }
55
+ }
51
56
 
52
- a.external {color:#ff90ff;}
57
+ a.external {color:#ff90ff;}
53
58
 
54
- blockquote {background-color:#ffc090;
59
+ blockquote {background-color:#ffc090;
55
60
  padding:0.5em;
56
61
  border-radius:0.5em;
57
- }
62
+ }
58
63
 
59
64
 
60
- </style>
65
+ /*]]>*/
66
+ </style>
61
67
  </head>
62
68
  <body>
63
- <div class="document" id="timequiz">
64
- <h1 class="title">TIMEQUIZ</h1>
65
- <h2 class="subtitle" id="play-a-history-quiz-game">Play a history-quiz game</h2>
66
-
67
- <div class="section" id="synopsis">
68
- <h1>SYNOPSIS</h1>
69
- <p>timequiz [options]</p>
70
- <p>Run timequiz without any options to begin a quiz using the default set of
71
- historical events—the provided collection is modest in size.</p>
72
- </div>
73
- <div class="section" id="description">
74
- <h1>DESCRIPTION</h1>
75
- <p>The game presents a limited number of historical events (currently three) in
76
- random order. Your task is to correctly arrange them chronologically. In each
77
- subsequent round, a single new event appears—you must place it in the correct
78
- position relative to the previously ordered events (either before one of the
79
- listed events or later).</p>
80
- <p>After every round—including the first—your performance is assessed. You may
81
- then choose to proceed with another event or review the brief description of
82
- any event already in the sequence.</p>
83
- <p>The game continues until you press q to quit or until the maximum of 15 events
84
- have been played.</p>
85
- <div class="section" id="you-dont-need-to-know-every-date">
86
- <h2>YOU DON’T NEED TO KNOW EVERY DATE</h2>
87
- <p>Winning often does not require exact historical knowledge. Instead, logical
88
- reasoning or educated guesses—eliminating events that are clearly too early or
89
- too lateusually suffices. Reading the event descriptions may also help you
90
- situate other events in historical context later on.</p>
91
- </div>
92
- </div>
93
- <div class="section" id="options-not-needed-to-play">
94
- <h1>OPTIONS (not needed to play)</h1>
95
- <p><strong>-a, --add</strong> Add a new event to the game</p>
96
- <p><strong>-e, --event</strong> [EVENT] Provide a name of the new event</p>
97
- <p><strong>-y, --year</strong> [YEAR] Specify the year of the new event</p>
98
- <p><strong>-b, --background</strong> [INFO] Supply background information for the new event</p>
99
- <p><strong>-f, --file</strong> [FILE] Specify the file for reading/writing events</p>
100
- <p><strong>-d, --debug</strong> Enable verbose debug output</p>
101
- <p><strong>-v, --version</strong> Display program version</p>
102
- <p><strong>-h, --help</strong> Show help message</p>
103
- <div class="section" id="the-options-in-detail">
104
- <h2>The Options in detail:</h2>
105
- <dl class="docutils">
106
- <dt>-a --add</dt>
107
- <dd>Requires -e, -y, and -f. This redundancy may be removed in future versions.</dd>
108
- <dt>-e --event [EVENT]</dt>
109
- <dd>The name of the event to add. Requires --add, --year, and --file. Use quotes
110
- for multi-word events, e.g., --event &quot;Some Guy Was Born and Something Broke&quot;.</dd>
111
- <dt>-y --year [YEAR]</dt>
112
- <dd>The year of the event, e.g., -y 1244.</dd>
113
- <dt>-b --background [INFO]</dt>
114
- <dd>Optional context to help with the quiz—use sparingly. For example: -b &quot;The
115
- phenomenon was of no significance whatsoever&quot;.</dd>
116
- <dt>-f --file [FILE]</dt>
117
- <dd>Path to the events file used for quizzes or for adding new events. If the file
118
- does not exist, it is created with some sample events. It must be readable for
119
- quizzes and writable for additions.</dd>
120
- <dt>-d --debug</dt>
121
- <dd>Enables verbose debugging output. Mainly useful for developers.</dd>
122
- <dt>-v --version</dt>
123
- <dd>Display the current version of the program.</dd>
124
- <dt>-h --help</dt>
125
- <dd>Show this list of options and usage instructions.</dd>
126
- </dl>
127
- </div>
128
- </div>
129
- <div class="section" id="game-example">
130
- <h1>GAME EXAMPLE</h1>
131
- <p>Launching timequiz with no options displays three random historical events,
132
- prompting:</p>
133
- <table border="1" class="docutils">
134
- <colgroup>
135
- <col width="100%" />
136
- </colgroup>
137
- <tbody valign="top">
138
- <tr><td><p class="first">Put the following events into the right chronological order (e.g.: 2 3 1).</p>
139
- <ol class="arabic simple">
140
- <li>The Roman emperor Diocletian devides the empire in two</li>
141
- <li>End of the &quot;War of the mercenaries&quot;</li>
142
- <li>Destruction of Nimrod and Ninive by the Medians and Neo-Babylonians</li>
143
- </ol>
144
- <p class="last">Available: 1, 2, 3)</p>
145
- </td>
146
- </tr>
147
- </tbody>
148
- </table>
149
- <p>Enter your sequence (e.g., 321) without needing to press Enter after each
150
- number. The game then shows the correct order with years and evaluates your
151
- input. You’ll be asked if you wish to continue with a new event or view more
152
- info on the listed events.</p>
153
- <table border="1" class="docutils">
154
- <colgroup>
155
- <col width="100%" />
156
- </colgroup>
157
- <tbody valign="top">
158
- <tr><td>Enter number for more information about an event, 'a' to play with one new, random event, 'q' to quit.</td>
159
- </tr>
160
- </tbody>
161
- </table>
162
- <p>To continue:</p>
163
- <p>Press a number to view an event’s details,</p>
164
- <p>a to add a new random event, or</p>
165
- <p>q to quit.</p>
166
- <p>If you choose a, here’s how the next prompt may appear:</p>
167
- <table border="1" class="docutils">
168
- <colgroup>
169
- <col width="100%" />
170
- </colgroup>
171
- <tbody valign="top">
172
- <tr><td><p class="first">Indicate the event from the previous list, which precedes the following, or '0' (zero) to put it in front:</p>
173
- <p class="last">The Italian painter Lorenzo Lotto dies.</p>
174
- </td>
175
- </tr>
176
- </tbody>
177
- </table>
178
- <p>You must then enter the corresponding number or 0 if you believe that the event
179
- occurred before all listed events (which, in this case, would be historically
180
- inaccurate). Press Enter to submit your answer.</p>
181
- </div>
182
- <div class="section" id="additional-information">
183
- <h1>ADDITIONAL INFORMATION</h1>
184
- <dl class="docutils">
185
- <dt>Development &amp; Source Code</dt>
186
- <dd>timequiz is written in Ruby. As it's interpreted, the executable is
187
- essentially the source code—you can open it in any text editor. If installed
188
- from a Ruby gem, you can extract it using <tt class="docutils literal">tar <span class="pre">-x</span></tt>, then <tt class="docutils literal">tar <span class="pre">-xzf</span></tt>.</dd>
189
- <dt>Known Bug</dt>
190
- <dd>At times, the list of events may wrap incorrectly in the display.</dd>
191
- <dt>License</dt>
192
- <dd>Distributed under the GNU General Public License (GPL) version 3.</dd>
193
- <dt>Author</dt>
194
- <dd>Developed by Michael Uplawski &lt;<a class="reference external" href="mailto:michael.uplawski&#64;uplawski.eu">michael.uplawski&#64;uplawski.eu</a>&gt;</dd>
195
- </dl>
196
- <p>Ω</p>
197
- </div>
198
- </div>
69
+ <main id="timequiz">
70
+ <h1 class="title">TIMEQUIZ</h1>
71
+
72
+ <p class="subtitle" id="play-a-history-quiz-game">Play a
73
+ history-quiz game</p>
74
+
75
+ <section id="synopsis">
76
+ <h2>SYNOPSIS</h2>
77
+
78
+ <p>timequiz [options]</p>
79
+
80
+ <p>Run timequiz without any options to begin a quiz using the
81
+ default set of historical events—the provided collection is
82
+ modest in size.</p>
83
+ </section>
84
+
85
+ <section id="description">
86
+ <h2>DESCRIPTION</h2>
87
+
88
+ <p>The game presents a limited number of historical events
89
+ (currently three) in random order. Your task is to correctly
90
+ arrange them chronologically. In each subsequent round, a
91
+ single new event appears—you must place it in the correct
92
+ position relative to the previously ordered events (either
93
+ before one of the listed events or later).</p>
94
+
95
+ <p>After every roundincluding the first—your performance is
96
+ assessed. You may then choose to proceed with another event
97
+ or review the brief description of any event already in the
98
+ sequence.</p>
99
+
100
+ <p>The game continues until you press q to quit or until the
101
+ maximum of 15 events have been played.</p>
102
+
103
+ <section id="you-dont-need-to-know-every-date">
104
+ <h3>YOU DON’T NEED TO KNOW EVERY DATE</h3>
105
+
106
+ <p>Winning often does not require exact historical
107
+ knowledge. Instead, logical reasoning or educated
108
+ guesses—eliminating events that are clearly too early or
109
+ too late—usually suffices. Reading the event descriptions
110
+ may also help you situate other events in historical
111
+ context later on.</p>
112
+ </section>
113
+ </section>
114
+
115
+ <section id="options-not-needed-to-play">
116
+ <h2>OPTIONS (not needed to play)</h2>
117
+
118
+ <p><strong>-a, --add</strong> Add a new event to the game</p>
119
+
120
+ <p><strong>-e, --event</strong> [EVENT] Provide a name of the
121
+ new event</p>
122
+
123
+ <p><strong>-y, --year</strong> [YEAR] Specify the year of the
124
+ new event</p>
125
+
126
+ <p><strong>-b, --background</strong> [INFO] Supply background
127
+ information for the new event</p>
128
+
129
+ <p><strong>-f, --file</strong> [FILE] Specify the file for
130
+ reading/writing events</p>
131
+
132
+ <p><strong>-d, --debug</strong> Enable verbose debug
133
+ output</p>
134
+
135
+ <p><strong>-v, --version</strong> Display program version</p>
136
+
137
+ <p><strong>-h, --help</strong> Show help message</p>
138
+
139
+ <section id="the-options-in-detail">
140
+ <h3>The Options in detail:</h3>
141
+
142
+ <dl class="simple">
143
+ <dt>-a --add</dt>
144
+
145
+ <dd>
146
+ <p>Requires -e, -y, and -f. This redundancy may be
147
+ removed in future versions.</p>
148
+ </dd>
149
+
150
+ <dt>-e --event [EVENT]</dt>
151
+
152
+ <dd>
153
+ <p>The name of the event to add. Requires --add,
154
+ --year, and --file. Use quotes for multi-word events,
155
+ e.g., --event "Some Guy Was Born and Something
156
+ Broke".</p>
157
+ </dd>
158
+
159
+ <dt>-y --year [YEAR]</dt>
160
+
161
+ <dd>
162
+ <p>The year of the event, e.g., -y 1244.</p>
163
+ </dd>
164
+
165
+ <dt>-b --background [INFO]</dt>
166
+
167
+ <dd>
168
+ <p>Optional context to help with the quiz—use
169
+ sparingly. For example: -b "The phenomenon was of no
170
+ significance whatsoever".</p>
171
+ </dd>
172
+
173
+ <dt>-f --file [FILE]</dt>
174
+
175
+ <dd>
176
+ <p>Path to the events file used for quizzes or for
177
+ adding new events. If the file does not exist, it is
178
+ created with some sample events. It must be readable
179
+ for quizzes and writable for additions.</p>
180
+ </dd>
181
+
182
+ <dt>-d --debug</dt>
183
+
184
+ <dd>
185
+ <p>Enables verbose debugging output. Mainly useful for
186
+ developers.</p>
187
+ </dd>
188
+
189
+ <dt>-v --version</dt>
190
+
191
+ <dd>
192
+ <p>Display the current version of the program.</p>
193
+ </dd>
194
+
195
+ <dt>-h --help</dt>
196
+
197
+ <dd>
198
+ <p>Show this list of options and usage
199
+ instructions.</p>
200
+ </dd>
201
+ </dl>
202
+ </section>
203
+ </section>
204
+
205
+ <section id="game-example">
206
+ <h2>GAME EXAMPLE</h2>
207
+
208
+ <p>Launching timequiz with no options displays three random
209
+ historical events, prompting:</p>
210
+
211
+ <table>
212
+ <tbody>
213
+ <tr>
214
+ <td>
215
+ <p>Put the following events into the right
216
+ chronological order (e.g.: 2 3 1).</p>
217
+
218
+ <ol class="arabic simple">
219
+ <li>
220
+ <p>The Roman emperor Diocletian devides the
221
+ empire in two</p>
222
+ </li>
223
+
224
+ <li>
225
+ <p>End of the "War of the mercenaries"</p>
226
+ </li>
227
+
228
+ <li>
229
+ <p>Destruction of Nimrod and Ninive by the
230
+ Medians and Neo-Babylonians</p>
231
+ </li>
232
+ </ol>
233
+
234
+ <p>Available: 1, 2, 3)</p>
235
+ </td>
236
+ </tr>
237
+ </tbody>
238
+ </table>
239
+
240
+ <p>Enter your sequence (e.g., 321) without needing to press
241
+ Enter after each number. The game then shows the correct
242
+ order with years and evaluates your input. You’ll be asked if
243
+ you wish to continue with a new event or view more info on
244
+ the listed events.</p>
245
+
246
+ <table>
247
+ <tbody>
248
+ <tr>
249
+ <td>
250
+ <p>Enter number for more information about an event,
251
+ 'a' to play with one new, random event, 'q' to
252
+ quit.</p>
253
+ </td>
254
+ </tr>
255
+ </tbody>
256
+ </table>
257
+
258
+ <p>To continue:</p>
259
+
260
+ <p>Press a number to view an event’s details,</p>
261
+
262
+ <p>a to add a new random event, or</p>
263
+
264
+ <p>q to quit.</p>
265
+
266
+ <p>If you choose a, here’s how the next prompt may
267
+ appear:</p>
268
+
269
+ <table>
270
+ <tbody>
271
+ <tr>
272
+ <td>
273
+ <p>Indicate the event from the previous list, which
274
+ precedes the following, or '0' (zero) to put it in
275
+ front:</p>
276
+
277
+ <p>The Italian painter Lorenzo Lotto dies.</p>
278
+ </td>
279
+ </tr>
280
+ </tbody>
281
+ </table>
282
+
283
+ <p>You must then enter the corresponding number or 0 if you
284
+ believe that the event occurred before all listed events
285
+ (which, in this case, would be historically inaccurate).
286
+ Press Enter to submit your answer.</p>
287
+ </section>
288
+
289
+ <section id="additional-information">
290
+ <h2>ADDITIONAL INFORMATION</h2>
291
+
292
+ <dl class="simple">
293
+ <dt>Development &amp; Source Code</dt>
294
+
295
+ <dd>
296
+ <p>timequiz is written in Ruby. As it's interpreted, the
297
+ executable is essentially the source code—you can open it
298
+ in any text editor. If installed from a Ruby gem, you can
299
+ extract it using <span class="docutils literal">tar
300
+ <span class="pre">-x</span></span>, then <span class=
301
+ "docutils literal">tar <span class=
302
+ "pre">-xzf</span></span>.</p>
303
+ </dd>
304
+
305
+ <dt>Known Bug</dt>
306
+
307
+ <dd>
308
+ <p>At times, the list of events may wrap incorrectly in
309
+ the display.</p>
310
+ </dd>
311
+
312
+ <dt>License</dt>
313
+
314
+ <dd>
315
+ <p>Timequiz is distributed under the WTFPL-2.0 or later
316
+ License. For more details, visit <a class=
317
+ "reference external" href=
318
+ "http://www.wtfpl.net/txt/copying/">http://www.wtfpl.net/txt/copying/</a></p>
319
+ </dd>
320
+
321
+ <dt>Author</dt>
322
+
323
+ <dd>
324
+ <p>Developed by Michael Uplawski &lt;<a class=
325
+ "reference external" href=
326
+ "mailto:michael.uplawski@uplawski.eu">michael.uplawski@uplawski.eu</a>&gt;</p>
327
+ </dd>
328
+ </dl>
329
+ </section>
330
+
331
+ <section id="section-1">
332
+ <h2>Ω</h2>
333
+ </section>
334
+ </main>
199
335
  </body>
200
336
  </html>
Binary file
data/doc/pdf/timequiz.pdf CHANGED
Binary file
data/doc/rst/timequiz.rst CHANGED
@@ -141,9 +141,11 @@ Known Bug
141
141
  At times, the list of events may wrap incorrectly in the display.
142
142
 
143
143
  License
144
- Distributed under the GNU General Public License (GPL) version 3.
144
+ Timequiz is distributed under the WTFPL-2.0 or later License.
145
+ For more details, visit http://www.wtfpl.net/txt/copying/
145
146
 
146
147
  Author
147
148
  Developed by Michael Uplawski <michael.uplawski@uplawski.eu>
148
149
 
149
150
  Ω
151
+ ============
data/lib/adder.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #encoding: UTF-8
3
3
  =begin
4
4
  /***************************************************************************
5
- * ©2017-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * ©2017-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
6
  * *
7
7
  * This program is free software; you can redistribute it and/or modify *
8
8
  * it under the terms of the WTFPL 2.0 or later, see *
@@ -22,13 +22,16 @@ require_relative 'basic_logging'
22
22
  class Adder
23
23
  #@@events_file = File.dirname(__FILE__) << File::Separator << 'events.rb'
24
24
  #@@events_backup = File.dirname(__FILE__) << File::Separator << 'bak_events.rb'
25
- include BasicLogging
26
25
 
26
+ self::extend BasicLogging
27
+
27
28
  def self::add(options)
28
29
  debug('options are ' << options.to_s)
29
30
  if options.file
30
31
  @@events_file = options.file
31
- @@events_backup = File.dirname(@@events_file) << File::Separator << 'bak_' << File.basename(@@events_file)
32
+ if(File::exist?(@@events_file) )
33
+ @@events_backup = File.dirname(@@events_file) << File::Separator << 'bak_' << File.basename(@@events_file)
34
+ end
32
35
  else
33
36
  error('To add events, you must name a file on the command-line. Aborting')
34
37
  exit false
data/lib/argparser.rb CHANGED
@@ -17,6 +17,7 @@
17
17
  require 'optparse'
18
18
  require 'optparse/time'
19
19
  require 'ostruct'
20
+ require_relative 'version'
20
21
  require_relative 'basic_logging'
21
22
  require_relative 'constants'
22
23
 
@@ -55,7 +56,7 @@ class ArgParser
55
56
  options.debug = 'debug'
56
57
  end
57
58
  opts.on("-v", "--version", 'Show program version') do
58
- puts $APPNAME.dup << ", version " << $VERSION
59
+ puts APPNAME.dup << ", version " << VERSION
59
60
  exit true
60
61
  end
61
62
  end
data/lib/console.rb CHANGED
@@ -16,12 +16,14 @@
16
16
  require_relative 'extstring'
17
17
  require_relative 'user_input'
18
18
  require_relative 'constants'
19
+ require_relative 'basic_logging'
19
20
 
20
21
  # Functions which create a user-interface in the terminal
21
22
  module Console
23
+ include BasicLogging
24
+
22
25
  # Some definitions which may change one day, become configurable one day,
23
26
  # need to be accessed (one day) from somewhere else or not.
24
-
25
27
  @@won_text = %q"__ __ _ __ __
26
28
  \ \/ /___ __ __ | | / /___ ____ / /
27
29
  \ / __ \/ / / / | | /| / / __ \/ __ \ / /
@@ -41,7 +43,7 @@ module Console
41
43
  def start_game
42
44
  available = $events
43
45
  clear
44
- puts bold("\nPut the following events into the right chronological order (e.g.: 2 3 1).")
46
+ puts bold("\nPut the following events into the correct chronological order (e.g.: 2 3 1).")
45
47
  @m_events = Array.new
46
48
  out = ''
47
49
  $num_events.times do |i|
@@ -80,6 +82,7 @@ module Console
80
82
  end
81
83
  if('a' == ui)
82
84
  ev = new_event
85
+ # all known events have been handled.
83
86
  if ev == :all_events_done
84
87
  score(@@points, true)
85
88
  exit true
@@ -112,7 +115,7 @@ module Console
112
115
  else
113
116
  lose
114
117
  end
115
- score(@@points)
118
+ score(@@points, @m_events.length == $MAX_NUM_EVENTS)
116
119
  else
117
120
  detail( a2i(ui) )
118
121
  end
@@ -166,6 +169,7 @@ module Console
166
169
 
167
170
  def score(pts, all_done = false)
168
171
  intro = (all_done ? 'Final score' : 'Current score')
172
+ debug('all_done? ' << all_done.to_s)
169
173
  puts ' (' << intro << ': %i %s)' %[pts, (pts == 1 ? 'point' : 'points')]
170
174
  end
171
175
 
@@ -178,7 +182,7 @@ module Console
178
182
  end
179
183
 
180
184
  def show_correct_order
181
- cmt = "\tThe right order is:\n" << @m_events.collect {|ev| (@m_events.index(ev) + 1).to_s << ') ' << ev.title << ' (' << ev.year.to_s << ')'}.join("\n").box()
185
+ cmt = "\tThe correct order is:\n" << @m_events.collect {|ev| (@m_events.index(ev) + 1).to_s << ') ' << ev.title << ' (' << ev.year.to_s << ')'}.join("\n").box()
182
186
  wait(@@wait_sequence, 1, cmt)
183
187
  end
184
188
 
@@ -205,7 +209,7 @@ module Console
205
209
  def compare_order(response)
206
210
  puts "\n... You say: " << bold(response.join(', '))
207
211
  devents = @m_events.dup.sort {|f, s| f.year <=> s.year }
208
- cmt = "\tThe right order is:\n" << devents.collect {|ev| ev.disp_index.to_s << ') ' << ev.year.to_s }.join("\n").box()
212
+ cmt = "\tThe correct order is:\n" << devents.collect {|ev| ev.disp_index.to_s << ') ' << ev.year.to_s }.join("\n").box()
209
213
  wait(@@wait_sequence, 1, cmt)
210
214
  end
211
215
 
data/lib/events.rb CHANGED
@@ -15,6 +15,11 @@
15
15
  =end
16
16
 
17
17
  # All events known.
18
+ $events << ['Howard Hughes founds his own aircraft company', 1932,'Hughes was an American manufacturer, aviator, and motion-picture producer and director who acquired enormous wealth and celebrity from his various ventures but was perhaps better known for his eccentricities, especially his reclusiveness (britannica.com).' ]
19
+ $events << ['Destruction of the German town Dresden', 1945,'The bombing on February 1945 caused a firestorm which left the town ablaze for weeks and killed about 35000 people although the precise number will probably never be established.' ]
20
+ $events << ['The aviator Charles Lindbergh dies', 1974,'Charles Lindbergh was the first aviator to complete a solo transatlantic flight in May 1927.' ]
21
+ $events << ['The antropologist Claude Lévi-Strauss is born', 1908,'Lévi-Strauss argued that the "savage" mind had the same structures as the "civilized" mind and that human characteristics are the same everywhere. He received numerous honors from universities and institutions throughout the world.' ]
22
+ $events << ['Napoleon Bonaparte dies', 1821,'Napoleon Bonaparte died at 5.49pm on 5 May 1821, at Longwood on the island of Saint Helena. An autopsy was carried out on 6 May; a preliminary cast for a death mask was taken on 7 May; and on 9 May the Emperor was buried, in the presence of French and English witnesses. Yet since the nineteenth century, mystery and myths have shrouded Napoleon’s death, and the events and people that surrounded it (napoleon.org).' ]
18
23
  $events << ['First hydrogen bomb', 1952,'The first test bomb was called the Ivy Mike device. It was not a deliverable bomb- it weighed 82 tons and used an Atomic bomb to trigger the hydrogen explosion. The bomb was set off on Eniwetok atoll on November 1st. The weapon was 10.4 megatons- 1,000 times stronger than the bomb that destroyed Hiroshima. It was twice the power of all the bombs dropped during World War II.' ]
19
24
  $events << ['Publication of the theory of Special Relativity by Albert Einstein', 1905, "Einstein postulated in his study that the speed of light is immutable, constant, and independent of the observer's motion. Therefore, except the constant speed of light, everything is relative, including time, distance, and mass."]
20
25
  $events << ['The mass of the Earth is estimated for the first time.', 1775, 'Nevil Maskelyne’s experiment on the Scottish mountain Schiehallion set out to derive the mean density of the Earth, from astronomical observations of the deflection of the vertical and calculation of the mountain’s relative gravitational attraction. His results were later amended by the works of Charles Hutton.']
data/lib/user_input.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  =begin
4
4
  /***************************************************************************
5
- * ©2017-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * ©2017-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
6
  * *
7
7
  * This program is free software; you can redistribute it and/or modify *
8
8
  * it under the terms of the WTFPL 2.0 or later, see *
@@ -15,7 +15,8 @@
15
15
  ***************************************************************************/
16
16
  =end
17
17
 
18
- require 'io/wait'
18
+ # Modified for ruby 4.x
19
+ # require 'io/wait'
19
20
  require 'io/console'
20
21
  require_relative 'color_output'
21
22
 
@@ -220,7 +221,10 @@ class UserInput
220
221
 
221
222
  STDIN.raw do
222
223
  STDIN.noecho do
223
- until (STDIN.ready?)
224
+ # STDIN.ready?
225
+ # Modification for ruby 4.0.1 compatibility. Unclear what the
226
+ # requirements are. This works.
227
+ until IO.select([STDIN], nil, nil, 0)
224
228
  sleep(0.1)
225
229
  end
226
230
  char = (STDIN.read_nonblock(1).ord rescue nil)
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  =begin
4
4
  /***************************************************************************
5
- * ©2017-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * ©2017-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
6
  * *
7
7
  * This program is free software; you can redistribute it and/or modify *
8
8
  * it under the terms of the WTFPL 2.0 or later, see *
@@ -15,8 +15,9 @@
15
15
  ***************************************************************************/
16
16
  =end
17
17
 
18
- VERSION = '0.2.2'
19
- SUMMARY = 'New documentation- and homepage URIs.'
18
+ APPNAME = 'Timequiz'
19
+ VERSION = '0.32'
20
+ SUMMARY = 'Bugfix (--version) && Ruby 4.x compatibility (STDIN.ready?) '
20
21
  AUTHOR = 'Michael Uplawski'
21
22
  AUTHOR_MAIL = '<michael.uplawski@uplawski.eu>'
22
- YEARS = 2017 - 2025
23
+ YEARS = 2017 - 2026
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timequiz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: '0.32'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Uplawski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-08-27 00:00:00.000000000 Z
10
+ date: 2026-04-10 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Play a history game
13
13
  email: michael.uplawski@uplawski.eu
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.6.7
60
+ rubygems_version: 4.0.10
61
61
  specification_version: 4
62
- summary: New documentation- and homepage URIs.
62
+ summary: Bugfix (--version) && Ruby 4.x compatibility (STDIN.ready?)
63
63
  test_files: []