rkoans 0.0.1 → 0.1.0

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.
Files changed (460) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/CURRICULUM.md +86 -0
  4. data/README.md +77 -0
  5. data/THIRD_PARTY_NOTICES.md +30 -0
  6. data/exercises/about-array-assignment/about_array_assignment.rb +45 -0
  7. data/exercises/about-array-assignment/brief.md +11 -0
  8. data/exercises/about-array-assignment/hint.md +11 -0
  9. data/exercises/about-arrays/about_arrays.rb +77 -0
  10. data/exercises/about-arrays/brief.md +16 -0
  11. data/exercises/about-arrays/hint.md +13 -0
  12. data/exercises/about-asserts/about_asserts.rb +22 -0
  13. data/exercises/about-asserts/brief.md +22 -0
  14. data/exercises/about-asserts/hint.md +10 -0
  15. data/exercises/about-blocks/about_blocks.rb +76 -0
  16. data/exercises/about-blocks/brief.md +44 -0
  17. data/exercises/about-blocks/hint.md +7 -0
  18. data/exercises/about-class-methods/about_class_methods.rb +105 -0
  19. data/exercises/about-class-methods/brief.md +73 -0
  20. data/exercises/about-class-methods/hint.md +8 -0
  21. data/exercises/about-classes/about_classes.rb +131 -0
  22. data/exercises/about-classes/brief.md +73 -0
  23. data/exercises/about-classes/hint.md +7 -0
  24. data/exercises/about-constants/about_constants.rb +49 -0
  25. data/exercises/about-constants/brief.md +51 -0
  26. data/exercises/about-constants/hint.md +7 -0
  27. data/exercises/about-control-statements/about_control_statements.rb +152 -0
  28. data/exercises/about-control-statements/brief.md +9 -0
  29. data/exercises/about-control-statements/hint.md +7 -0
  30. data/exercises/about-dice-project/about_dice_project.rb +27 -0
  31. data/exercises/about-dice-project/brief.md +12 -0
  32. data/exercises/about-dice-project/hint.md +5 -0
  33. data/exercises/about-exceptions/about_exceptions.rb +84 -0
  34. data/exercises/about-exceptions/brief.md +19 -0
  35. data/exercises/about-exceptions/hint.md +8 -0
  36. data/exercises/about-extra-credit/about_extra_credit.rb +117 -0
  37. data/exercises/about-extra-credit/brief.md +28 -0
  38. data/exercises/about-extra-credit/hint.md +5 -0
  39. data/exercises/about-hashes/about_hashes.rb +160 -0
  40. data/exercises/about-hashes/brief.md +9 -0
  41. data/exercises/about-hashes/hint.md +8 -0
  42. data/exercises/about-inheritance/about_inheritance.rb +63 -0
  43. data/exercises/about-inheritance/brief.md +50 -0
  44. data/exercises/about-inheritance/hint.md +8 -0
  45. data/exercises/about-iteration/about_iteration.rb +96 -0
  46. data/exercises/about-iteration/brief.md +26 -0
  47. data/exercises/about-iteration/hint.md +6 -0
  48. data/exercises/about-keyword-arguments/about_keyword_arguments.rb +56 -0
  49. data/exercises/about-keyword-arguments/brief.md +28 -0
  50. data/exercises/about-keyword-arguments/hint.md +7 -0
  51. data/exercises/about-message-passing/about_message_passing.rb +112 -0
  52. data/exercises/about-message-passing/brief.md +59 -0
  53. data/exercises/about-message-passing/hint.md +8 -0
  54. data/exercises/about-methods/about_methods.rb +104 -0
  55. data/exercises/about-methods/brief.md +55 -0
  56. data/exercises/about-methods/hint.md +8 -0
  57. data/exercises/about-modules/about_modules.rb +43 -0
  58. data/exercises/about-modules/brief.md +44 -0
  59. data/exercises/about-modules/hint.md +8 -0
  60. data/exercises/about-nil/about_nil.rb +29 -0
  61. data/exercises/about-nil/brief.md +12 -0
  62. data/exercises/about-nil/hint.md +11 -0
  63. data/exercises/about-objects/about_objects.rb +51 -0
  64. data/exercises/about-objects/brief.md +14 -0
  65. data/exercises/about-objects/hint.md +12 -0
  66. data/exercises/about-open-classes/about_open_classes.rb +38 -0
  67. data/exercises/about-open-classes/brief.md +34 -0
  68. data/exercises/about-open-classes/hint.md +7 -0
  69. data/exercises/about-pattern-matching/about_pattern_matching.rb +106 -0
  70. data/exercises/about-pattern-matching/brief.md +124 -0
  71. data/exercises/about-pattern-matching/hint.md +8 -0
  72. data/exercises/about-proxy-object-project/about_proxy_object_project.rb +43 -0
  73. data/exercises/about-proxy-object-project/brief.md +10 -0
  74. data/exercises/about-proxy-object-project/hint.md +5 -0
  75. data/exercises/about-regular-expressions/about_regular_expressions.rb +174 -0
  76. data/exercises/about-regular-expressions/brief.md +9 -0
  77. data/exercises/about-regular-expressions/hint.md +8 -0
  78. data/exercises/about-sandwich-code/about_sandwich_code.rb +58 -0
  79. data/exercises/about-sandwich-code/brief.md +14 -0
  80. data/exercises/about-sandwich-code/hint.md +5 -0
  81. data/exercises/about-scope/about_scope.rb +76 -0
  82. data/exercises/about-scope/brief.md +35 -0
  83. data/exercises/about-scope/hint.md +8 -0
  84. data/exercises/about-scoring-project/about_scoring_project.rb +16 -0
  85. data/exercises/about-scoring-project/brief.md +10 -0
  86. data/exercises/about-scoring-project/hint.md +5 -0
  87. data/exercises/about-strings/about_strings.rb +142 -0
  88. data/exercises/about-strings/brief.md +22 -0
  89. data/exercises/about-strings/hint.md +11 -0
  90. data/exercises/about-symbols/about_symbols.rb +53 -0
  91. data/exercises/about-symbols/brief.md +21 -0
  92. data/exercises/about-symbols/hint.md +12 -0
  93. data/exercises/about-to-str/about_to_str.rb +49 -0
  94. data/exercises/about-to-str/brief.md +37 -0
  95. data/exercises/about-to-str/hint.md +7 -0
  96. data/exercises/about-triangle-project/about_triangle_project.rb +15 -0
  97. data/exercises/about-triangle-project/brief.md +11 -0
  98. data/exercises/about-triangle-project/hint.md +5 -0
  99. data/exercises/about-triangle-project-two/about_triangle_project_two.rb +22 -0
  100. data/exercises/about-triangle-project-two/brief.md +10 -0
  101. data/exercises/about-triangle-project-two/hint.md +5 -0
  102. data/exercises/about-true-and-false/about_true_and_false.rb +26 -0
  103. data/exercises/about-true-and-false/brief.md +22 -0
  104. data/exercises/about-true-and-false/hint.md +7 -0
  105. data/exercises/blocks-and-methods/blocks_and_methods.rb +14 -0
  106. data/exercises/blocks-and-methods/brief.md +8 -0
  107. data/exercises/blocks-and-methods/hint.md +6 -0
  108. data/exercises/catalog.json +61 -0
  109. data/exercises/class-state/brief.md +8 -0
  110. data/exercises/class-state/class_state.rb +39 -0
  111. data/exercises/class-state/hint.md +5 -0
  112. data/exercises/closure-capture/brief.md +8 -0
  113. data/exercises/closure-capture/closure_capture.rb +21 -0
  114. data/exercises/closure-capture/hint.md +5 -0
  115. data/exercises/collection-basics/brief.md +8 -0
  116. data/exercises/collection-basics/collection_basics.rb +16 -0
  117. data/exercises/collection-basics/hint.md +6 -0
  118. data/exercises/constant-scope/brief.md +8 -0
  119. data/exercises/constant-scope/constant_scope.rb +18 -0
  120. data/exercises/constant-scope/hint.md +5 -0
  121. data/exercises/core-protocols/brief.md +8 -0
  122. data/exercises/core-protocols/core_protocols.rb +43 -0
  123. data/exercises/core-protocols/hint.md +5 -0
  124. data/exercises/delegation/brief.md +8 -0
  125. data/exercises/delegation/delegation.rb +20 -0
  126. data/exercises/delegation/hint.md +5 -0
  127. data/exercises/dynamic-methods/brief.md +8 -0
  128. data/exercises/dynamic-methods/dynamic_methods.rb +33 -0
  129. data/exercises/dynamic-methods/hint.md +5 -0
  130. data/exercises/exception-flow/brief.md +8 -0
  131. data/exercises/exception-flow/exception_flow.rb +27 -0
  132. data/exercises/exception-flow/hint.md +5 -0
  133. data/exercises/heredoc-layout/brief.md +14 -0
  134. data/exercises/heredoc-layout/heredoc_layout.rb +25 -0
  135. data/exercises/heredoc-layout/hint.md +9 -0
  136. data/exercises/keyword-forwarding/brief.md +8 -0
  137. data/exercises/keyword-forwarding/hint.md +5 -0
  138. data/exercises/keyword-forwarding/keyword_forwarding.rb +27 -0
  139. data/exercises/lazy-enumeration/brief.md +8 -0
  140. data/exercises/lazy-enumeration/hint.md +5 -0
  141. data/exercises/lazy-enumeration/lazy_enumeration.rb +16 -0
  142. data/exercises/literals-and-operators/brief.md +20 -0
  143. data/exercises/literals-and-operators/hint.md +5 -0
  144. data/exercises/literals-and-operators/literals_and_operators.rb +15 -0
  145. data/exercises/method-contracts/brief.md +8 -0
  146. data/exercises/method-contracts/hint.md +5 -0
  147. data/exercises/method-contracts/method_contracts.rb +22 -0
  148. data/exercises/method-lookup/brief.md +8 -0
  149. data/exercises/method-lookup/hint.md +5 -0
  150. data/exercises/method-lookup/method_lookup.rb +26 -0
  151. data/exercises/nonlocal-exit/brief.md +8 -0
  152. data/exercises/nonlocal-exit/hint.md +5 -0
  153. data/exercises/nonlocal-exit/nonlocal_exit.rb +29 -0
  154. data/exercises/numbered-parameters/brief.md +18 -0
  155. data/exercises/numbered-parameters/hint.md +5 -0
  156. data/exercises/numbered-parameters/numbered_parameters.rb +18 -0
  157. data/exercises/numeric-precision/brief.md +8 -0
  158. data/exercises/numeric-precision/hint.md +5 -0
  159. data/exercises/numeric-precision/numeric_precision.rb +17 -0
  160. data/exercises/pattern-matching/brief.md +8 -0
  161. data/exercises/pattern-matching/hint.md +5 -0
  162. data/exercises/pattern-matching/pattern_matching.rb +22 -0
  163. data/exercises/refinement-scope/brief.md +8 -0
  164. data/exercises/refinement-scope/hint.md +5 -0
  165. data/exercises/refinement-scope/refinement_scope.rb +33 -0
  166. data/exercises/regexp-captures/brief.md +8 -0
  167. data/exercises/regexp-captures/hint.md +5 -0
  168. data/exercises/regexp-captures/regexp_captures.rb +25 -0
  169. data/exercises/runtime-context/brief.md +20 -0
  170. data/exercises/runtime-context/hint.md +8 -0
  171. data/exercises/runtime-context/runtime_context.rb +11 -0
  172. data/exercises/shared-rows/brief.md +8 -0
  173. data/exercises/shared-rows/hint.md +7 -0
  174. data/exercises/shared-rows/shared_rows.rb +13 -0
  175. data/exercises/singleton-pattern/brief.md +8 -0
  176. data/exercises/singleton-pattern/hint.md +5 -0
  177. data/exercises/singleton-pattern/singleton_pattern.rb +20 -0
  178. data/exercises/time-and-date/brief.md +8 -0
  179. data/exercises/time-and-date/hint.md +5 -0
  180. data/exercises/time-and-date/time_and_date.rb +21 -0
  181. data/exercises/visibility/brief.md +8 -0
  182. data/exercises/visibility/hint.md +5 -0
  183. data/exercises/visibility/visibility.rb +32 -0
  184. data/lib/rkoans/catalog.rb +31 -0
  185. data/lib/rkoans/checker.rb +62 -0
  186. data/lib/rkoans/cli.rb +79 -0
  187. data/lib/rkoans/error.rb +6 -0
  188. data/lib/rkoans/exercise.rb +50 -0
  189. data/lib/rkoans/keyboard.rb +51 -0
  190. data/lib/rkoans/progress.rb +39 -0
  191. data/lib/rkoans/selection.rb +31 -0
  192. data/lib/rkoans/session.rb +127 -0
  193. data/lib/rkoans/terminal_view.rb +99 -0
  194. data/lib/rkoans/version.rb +1 -1
  195. data/lib/rkoans/watcher.rb +58 -0
  196. data/lib/rkoans.rb +13 -3
  197. data/sig/about_array_assignment_acceptance_test.rbs +3 -0
  198. data/sig/about_arrays_acceptance_test.rbs +3 -0
  199. data/sig/about_asserts_command_test.rbs +4 -0
  200. data/sig/about_blocks_acceptance_test.rbs +3 -0
  201. data/sig/about_class_methods_acceptance_test.rbs +3 -0
  202. data/sig/about_classes_acceptance_test.rbs +3 -0
  203. data/sig/about_constants_acceptance_test.rbs +3 -0
  204. data/sig/about_control_statements_acceptance_test.rbs +3 -0
  205. data/sig/about_dice_project_acceptance_test.rbs +3 -0
  206. data/sig/about_exceptions_acceptance_test.rbs +3 -0
  207. data/sig/about_extra_credit_acceptance_test.rbs +5 -0
  208. data/sig/about_hashes_acceptance_test.rbs +3 -0
  209. data/sig/about_inheritance_acceptance_test.rbs +3 -0
  210. data/sig/about_iteration_acceptance_test.rbs +3 -0
  211. data/sig/about_keyword_arguments_acceptance_test.rbs +3 -0
  212. data/sig/about_message_passing_acceptance_test.rbs +3 -0
  213. data/sig/about_methods_acceptance_test.rbs +3 -0
  214. data/sig/about_modules_acceptance_test.rbs +3 -0
  215. data/sig/about_nil_acceptance_test.rbs +3 -0
  216. data/sig/about_objects_acceptance_test.rbs +3 -0
  217. data/sig/about_open_classes_acceptance_test.rbs +3 -0
  218. data/sig/about_pattern_matching_acceptance_test.rbs +3 -0
  219. data/sig/about_proxy_object_project_acceptance_test.rbs +3 -0
  220. data/sig/about_regular_expressions_acceptance_test.rbs +3 -0
  221. data/sig/about_sandwich_code_acceptance_test.rbs +3 -0
  222. data/sig/about_scope_acceptance_test.rbs +3 -0
  223. data/sig/about_scoring_project_acceptance_test.rbs +3 -0
  224. data/sig/about_strings_acceptance_test.rbs +3 -0
  225. data/sig/about_symbols_acceptance_test.rbs +3 -0
  226. data/sig/about_to_str_acceptance_test.rbs +3 -0
  227. data/sig/about_triangle_project_acceptance_test.rbs +3 -0
  228. data/sig/about_triangle_project_two_acceptance_test.rbs +3 -0
  229. data/sig/about_true_and_false_command_test.rbs +4 -0
  230. data/sig/catalog_error_command_test.rbs +4 -0
  231. data/sig/checker_test.rbs +9 -0
  232. data/sig/class_state_acceptance_test.rbs +3 -0
  233. data/sig/closure_capture_acceptance_test.rbs +3 -0
  234. data/sig/command_support.rbs +18 -0
  235. data/sig/command_test.rbs +5 -0
  236. data/sig/constant_scope_acceptance_test.rbs +3 -0
  237. data/sig/core_protocols_acceptance_test.rbs +3 -0
  238. data/sig/curriculum_cop_test.rbs +9 -0
  239. data/sig/delegation_acceptance_test.rbs +3 -0
  240. data/sig/dynamic_methods_acceptance_test.rbs +3 -0
  241. data/sig/exception_flow_acceptance_test.rbs +3 -0
  242. data/sig/exercise_test.rbs +3 -0
  243. data/sig/exercises/about_array_assignment.rbs +36 -0
  244. data/sig/exercises/about_arrays.rbs +51 -0
  245. data/sig/exercises/about_asserts.rbs +23 -0
  246. data/sig/exercises/about_blocks.rbs +40 -0
  247. data/sig/exercises/about_class_methods.rbs +62 -0
  248. data/sig/exercises/about_classes.rbs +88 -0
  249. data/sig/exercises/about_constants.rbs +53 -0
  250. data/sig/exercises/about_control_statements.rbs +46 -0
  251. data/sig/exercises/about_dice_project.rbs +16 -0
  252. data/sig/exercises/about_exceptions.rbs +36 -0
  253. data/sig/exercises/about_extra_credit.rbs +36 -0
  254. data/sig/exercises/about_hashes.rbs +62 -0
  255. data/sig/exercises/about_inheritance.rbs +50 -0
  256. data/sig/exercises/about_iteration.rbs +37 -0
  257. data/sig/exercises/about_keyword_arguments.rbs +33 -0
  258. data/sig/exercises/about_message_passing.rbs +68 -0
  259. data/sig/exercises/about_methods.rbs +68 -0
  260. data/sig/exercises/about_modules.rbs +38 -0
  261. data/sig/exercises/about_nil.rbs +23 -0
  262. data/sig/exercises/about_objects.rbs +38 -0
  263. data/sig/exercises/about_open_classes.rbs +31 -0
  264. data/sig/exercises/about_pattern_matching.rbs +65 -0
  265. data/sig/exercises/about_proxy_object_project.rbs +31 -0
  266. data/sig/exercises/about_regular_expressions.rbs +83 -0
  267. data/sig/exercises/about_sandwich_code.rbs +17 -0
  268. data/sig/exercises/about_scope.rbs +59 -0
  269. data/sig/exercises/about_scoring_project.rbs +16 -0
  270. data/sig/exercises/about_strings.rbs +85 -0
  271. data/sig/exercises/about_symbols.rbs +46 -0
  272. data/sig/exercises/about_to_str.rbs +36 -0
  273. data/sig/exercises/about_triangle_project.rbs +11 -0
  274. data/sig/exercises/about_triangle_project_two.rbs +12 -0
  275. data/sig/exercises/about_true_and_false.rbs +27 -0
  276. data/sig/exercises/blocks_and_methods.rbs +11 -0
  277. data/sig/exercises/class_state.rbs +19 -0
  278. data/sig/exercises/closure_capture.rbs +10 -0
  279. data/sig/exercises/collection_basics.rbs +6 -0
  280. data/sig/exercises/collection_basics_test.rbs +4 -0
  281. data/sig/exercises/constant_scope.rbs +11 -0
  282. data/sig/exercises/core_protocols.rbs +20 -0
  283. data/sig/exercises/delegation.rbs +14 -0
  284. data/sig/exercises/dynamic_methods.rbs +13 -0
  285. data/sig/exercises/exception_flow.rbs +11 -0
  286. data/sig/exercises/heredoc_layout.rbs +11 -0
  287. data/sig/exercises/keyword_forwarding.rbs +12 -0
  288. data/sig/exercises/lazy_enumeration.rbs +10 -0
  289. data/sig/exercises/literals_and_operators.rbs +12 -0
  290. data/sig/exercises/method_contracts.rbs +11 -0
  291. data/sig/exercises/method_lookup.rbs +16 -0
  292. data/sig/exercises/nonlocal_exit.rbs +14 -0
  293. data/sig/exercises/numbered_parameters.rbs +11 -0
  294. data/sig/exercises/numeric_precision.rbs +11 -0
  295. data/sig/exercises/pattern_matching.rbs +10 -0
  296. data/sig/exercises/refinement_scope.rbs +18 -0
  297. data/sig/exercises/regexp_captures.rbs +11 -0
  298. data/sig/exercises/runtime_context.rbs +23 -0
  299. data/sig/exercises/shared_rows.rbs +11 -0
  300. data/sig/exercises/singleton_pattern.rbs +14 -0
  301. data/sig/exercises/time_and_date.rbs +11 -0
  302. data/sig/exercises/visibility.rbs +18 -0
  303. data/sig/fixture_support.rbs +11 -0
  304. data/sig/help_hint_command_test.rbs +8 -0
  305. data/sig/heredoc_layout_acceptance_test.rbs +3 -0
  306. data/sig/keyboard_session_test.rbs +9 -0
  307. data/sig/keyword_forwarding_acceptance_test.rbs +3 -0
  308. data/sig/lazy_enumeration_acceptance_test.rbs +3 -0
  309. data/sig/literals_and_operators_acceptance_test.rbs +3 -0
  310. data/sig/method_contracts_acceptance_test.rbs +3 -0
  311. data/sig/method_lookup_acceptance_test.rbs +3 -0
  312. data/sig/nonlocal_exit_acceptance_test.rbs +3 -0
  313. data/sig/numbered_parameters_acceptance_test.rbs +3 -0
  314. data/sig/numeric_precision_acceptance_test.rbs +4 -0
  315. data/sig/packaging_test.rbs +3 -0
  316. data/sig/pattern_matching_acceptance_test.rbs +3 -0
  317. data/sig/reference_solutions_test.rbs +3 -0
  318. data/sig/refinement_scope_acceptance_test.rbs +3 -0
  319. data/sig/regexp_captures_acceptance_test.rbs +4 -0
  320. data/sig/rkoans/catalog.rbs +11 -0
  321. data/sig/rkoans/checker.rbs +22 -0
  322. data/sig/rkoans/cli.rbs +21 -0
  323. data/sig/rkoans/exercise.rbs +18 -0
  324. data/sig/rkoans/keyboard.rbs +13 -0
  325. data/sig/rkoans/progress.rbs +9 -0
  326. data/sig/rkoans/selection.rbs +9 -0
  327. data/sig/rkoans/session.rbs +30 -0
  328. data/sig/rkoans/terminal_view.rbs +24 -0
  329. data/sig/rkoans/watcher.rbs +18 -0
  330. data/sig/rkoans.rbs +2 -0
  331. data/sig/runtime_context_command_test.rbs +4 -0
  332. data/sig/selection_command_test.rbs +5 -0
  333. data/sig/session_command_test.rbs +12 -0
  334. data/sig/session_edge_cases_test.rbs +4 -0
  335. data/sig/shared_rows_acceptance_test.rbs +3 -0
  336. data/sig/singleton_pattern_acceptance_test.rbs +3 -0
  337. data/sig/time_and_date_acceptance_test.rbs +4 -0
  338. data/sig/visibility_acceptance_test.rbs +4 -0
  339. data/sig/watcher_test.rbs +3 -0
  340. data/solutions/about-array-assignment/about_array_assignment.rb +36 -0
  341. data/solutions/about-arrays/about_arrays.rb +53 -0
  342. data/solutions/about-asserts/about_asserts.rb +22 -0
  343. data/solutions/about-blocks/about_blocks.rb +30 -0
  344. data/solutions/about-class-methods/about_class_methods.rb +36 -0
  345. data/solutions/about-classes/about_classes.rb +40 -0
  346. data/solutions/about-constants/about_constants.rb +26 -0
  347. data/solutions/about-control-statements/about_control_statements.rb +35 -0
  348. data/solutions/about-dice-project/about_dice_project.rb +27 -0
  349. data/solutions/about-exceptions/about_exceptions.rb +30 -0
  350. data/solutions/about-extra-credit/about_extra_credit.rb +114 -0
  351. data/solutions/about-hashes/about_hashes.rb +52 -0
  352. data/solutions/about-inheritance/about_inheritance.rb +27 -0
  353. data/solutions/about-iteration/about_iteration.rb +31 -0
  354. data/solutions/about-keyword-arguments/about_keyword_arguments.rb +28 -0
  355. data/solutions/about-message-passing/about_message_passing.rb +38 -0
  356. data/solutions/about-methods/about_methods.rb +39 -0
  357. data/solutions/about-modules/about_modules.rb +23 -0
  358. data/solutions/about-nil/about_nil.rb +23 -0
  359. data/solutions/about-objects/about_objects.rb +34 -0
  360. data/solutions/about-open-classes/about_open_classes.rb +23 -0
  361. data/solutions/about-pattern-matching/about_pattern_matching.rb +39 -0
  362. data/solutions/about-proxy-object-project/about_proxy_object_project.rb +44 -0
  363. data/solutions/about-regular-expressions/about_regular_expressions.rb +60 -0
  364. data/solutions/about-sandwich-code/about_sandwich_code.rb +60 -0
  365. data/solutions/about-scope/about_scope.rb +33 -0
  366. data/solutions/about-scoring-project/about_scoring_project.rb +19 -0
  367. data/solutions/about-strings/about_strings.rb +56 -0
  368. data/solutions/about-symbols/about_symbols.rb +35 -0
  369. data/solutions/about-to-str/about_to_str.rb +24 -0
  370. data/solutions/about-triangle-project/about_triangle_project.rb +19 -0
  371. data/solutions/about-triangle-project-two/about_triangle_project_two.rb +25 -0
  372. data/solutions/about-true-and-false/about_true_and_false.rb +25 -0
  373. data/solutions/blocks-and-methods/blocks_and_methods.rb +14 -0
  374. data/solutions/class-state/class_state.rb +33 -0
  375. data/solutions/closure-capture/closure_capture.rb +12 -0
  376. data/solutions/collection-basics/collection_basics.rb +14 -0
  377. data/solutions/constant-scope/constant_scope.rb +18 -0
  378. data/solutions/core-protocols/core_protocols.rb +44 -0
  379. data/solutions/delegation/delegation.rb +17 -0
  380. data/solutions/dynamic-methods/dynamic_methods.rb +32 -0
  381. data/solutions/exception-flow/exception_flow.rb +34 -0
  382. data/solutions/heredoc-layout/heredoc_layout.rb +24 -0
  383. data/solutions/keyword-forwarding/keyword_forwarding.rb +26 -0
  384. data/solutions/lazy-enumeration/lazy_enumeration.rb +11 -0
  385. data/solutions/literals-and-operators/literals_and_operators.rb +22 -0
  386. data/solutions/method-contracts/method_contracts.rb +18 -0
  387. data/solutions/method-lookup/method_lookup.rb +26 -0
  388. data/solutions/nonlocal-exit/nonlocal_exit.rb +46 -0
  389. data/solutions/numbered-parameters/numbered_parameters.rb +18 -0
  390. data/solutions/numeric-precision/numeric_precision.rb +17 -0
  391. data/solutions/pattern-matching/pattern_matching.rb +17 -0
  392. data/solutions/refinement-scope/refinement_scope.rb +34 -0
  393. data/solutions/regexp-captures/regexp_captures.rb +24 -0
  394. data/solutions/runtime-context/runtime_context.rb +19 -0
  395. data/solutions/shared-rows/shared_rows.rb +13 -0
  396. data/solutions/singleton-pattern/singleton_pattern.rb +19 -0
  397. data/solutions/time-and-date/time_and_date.rb +16 -0
  398. data/solutions/visibility/visibility.rb +34 -0
  399. data/test/exercises/about_array_assignment_test.rb +87 -0
  400. data/test/exercises/about_arrays_test.rb +119 -0
  401. data/test/exercises/about_asserts_test.rb +41 -0
  402. data/test/exercises/about_blocks_test.rb +140 -0
  403. data/test/exercises/about_class_methods_test.rb +232 -0
  404. data/test/exercises/about_classes_test.rb +261 -0
  405. data/test/exercises/about_constants_test.rb +111 -0
  406. data/test/exercises/about_control_statements_test.rb +188 -0
  407. data/test/exercises/about_dice_project_test.rb +40 -0
  408. data/test/exercises/about_exceptions_test.rb +98 -0
  409. data/test/exercises/about_extra_credit_test.rb +74 -0
  410. data/test/exercises/about_hashes_test.rb +163 -0
  411. data/test/exercises/about_inheritance_test.rb +121 -0
  412. data/test/exercises/about_iteration_test.rb +148 -0
  413. data/test/exercises/about_keyword_arguments_test.rb +80 -0
  414. data/test/exercises/about_message_passing_test.rb +230 -0
  415. data/test/exercises/about_methods_test.rb +208 -0
  416. data/test/exercises/about_modules_test.rb +98 -0
  417. data/test/exercises/about_nil_test.rb +35 -0
  418. data/test/exercises/about_objects_test.rb +74 -0
  419. data/test/exercises/about_open_classes_test.rb +60 -0
  420. data/test/exercises/about_pattern_matching_test.rb +257 -0
  421. data/test/exercises/about_proxy_object_project_test.rb +75 -0
  422. data/test/exercises/about_regular_expressions_test.rb +243 -0
  423. data/test/exercises/about_sandwich_code_test.rb +82 -0
  424. data/test/exercises/about_scope_test.rb +123 -0
  425. data/test/exercises/about_scoring_project_test.rb +62 -0
  426. data/test/exercises/about_strings_test.rb +255 -0
  427. data/test/exercises/about_symbols_test.rb +120 -0
  428. data/test/exercises/about_to_str_test.rb +89 -0
  429. data/test/exercises/about_triangle_project_test.rb +29 -0
  430. data/test/exercises/about_triangle_project_two_test.rb +28 -0
  431. data/test/exercises/about_true_and_false_test.rb +43 -0
  432. data/test/exercises/blocks_and_methods_test.rb +22 -0
  433. data/test/exercises/class_state_test.rb +29 -0
  434. data/test/exercises/closure_capture_test.rb +29 -0
  435. data/test/exercises/collection_basics_test.rb +18 -0
  436. data/test/exercises/constant_scope_test.rb +18 -0
  437. data/test/exercises/core_protocols_test.rb +28 -0
  438. data/test/exercises/delegation_test.rb +23 -0
  439. data/test/exercises/dynamic_methods_test.rb +28 -0
  440. data/test/exercises/exception_flow_test.rb +17 -0
  441. data/test/exercises/heredoc_layout_test.rb +18 -0
  442. data/test/exercises/keyword_forwarding_test.rb +22 -0
  443. data/test/exercises/lazy_enumeration_test.rb +15 -0
  444. data/test/exercises/literals_and_operators_test.rb +25 -0
  445. data/test/exercises/method_contracts_test.rb +28 -0
  446. data/test/exercises/method_lookup_test.rb +14 -0
  447. data/test/exercises/nonlocal_exit_test.rb +22 -0
  448. data/test/exercises/numbered_parameters_test.rb +15 -0
  449. data/test/exercises/numeric_precision_test.rb +24 -0
  450. data/test/exercises/pattern_matching_test.rb +18 -0
  451. data/test/exercises/refinement_scope_test.rb +14 -0
  452. data/test/exercises/regexp_captures_test.rb +20 -0
  453. data/test/exercises/runtime_context_test.rb +59 -0
  454. data/test/exercises/shared_rows_test.rb +34 -0
  455. data/test/exercises/singleton_pattern_test.rb +16 -0
  456. data/test/exercises/time_and_date_test.rb +22 -0
  457. data/test/exercises/visibility_test.rb +22 -0
  458. metadata +471 -4
  459. data/Rakefile +0 -12
  460. data/sig/test_rkoans.rbs +0 -3
@@ -0,0 +1,62 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutClassMethods
7
+ type answers = {
8
+ objects_are_objects_one: (bool | :fill_me_in),
9
+ classes_are_classes_one: (bool | :fill_me_in),
10
+ classes_are_objects_too_one: (bool | :fill_me_in),
11
+ objects_have_methods_one: (bool | :fill_me_in),
12
+ classes_have_methods_one: (bool | :fill_me_in),
13
+ you_can_define_methods_on_individual_objects_one: (::Symbol | :fill_me_in),
14
+ other_objects_are_not_affected_by_these_singleton_methods_one: (singleton(::NoMethodError) | :fill_me_in),
15
+ since_classes_are_objects_you_can_define_singleton_methods_on_them_too_one: (::Symbol | :fill_me_in),
16
+ class_methods_are_independent_of_instance_methods_one: (::Symbol | :fill_me_in),
17
+ class_methods_are_independent_of_instance_methods_two: (::Symbol | :fill_me_in),
18
+ classes_and_instances_do_not_share_instance_variables_one: (::String | :fill_me_in),
19
+ classes_and_instances_do_not_share_instance_variables_two: (nil | :fill_me_in),
20
+ you_can_define_class_methods_inside_the_class_one: (::Symbol | :fill_me_in),
21
+ class_statements_return_the_value_of_their_last_expression_one: (::Integer | :fill_me_in),
22
+ self_while_inside_class_is_class_object_not_instance_one: (bool | :fill_me_in),
23
+ you_can_use_self_instead_of_an_explicit_reference_to_dog_one: (::Symbol | :fill_me_in),
24
+ heres_still_another_way_to_write_class_methods_one: (::Symbol | :fill_me_in),
25
+ heres_an_easy_way_to_call_class_methods_from_instance_methods_one: (::Symbol | :fill_me_in)
26
+ }
27
+ def self.koans: -> answers
28
+ end
29
+ end
30
+
31
+ class AboutClassMethodsTest
32
+ def test_objects_are_objects: -> void
33
+ def test_classes_are_classes: -> void
34
+ def test_classes_are_objects_too: -> void
35
+ def test_objects_have_methods: -> void
36
+ def test_classes_have_methods: -> void
37
+ def test_you_can_define_methods_on_individual_objects: -> void
38
+ def test_other_objects_are_not_affected_by_these_singleton_methods: -> void
39
+ def test_since_classes_are_objects_you_can_define_singleton_methods_on_them_too: -> void
40
+ def test_class_methods_are_independent_of_instance_methods: -> void
41
+ def test_classes_and_instances_do_not_share_instance_variables: -> void
42
+ def test_you_can_define_class_methods_inside_the_class: -> void
43
+ def test_class_statements_return_the_value_of_their_last_expression: -> void
44
+ def test_self_while_inside_class_is_class_object_not_instance: -> void
45
+ def test_you_can_use_self_instead_of_an_explicit_reference_to_dog: -> void
46
+ def test_heres_still_another_way_to_write_class_methods: -> void
47
+ def test_heres_an_easy_way_to_call_class_methods_from_instance_methods: -> void
48
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
49
+ end
50
+
51
+ class AboutClassMethodsTest::Dog
52
+ attr_accessor name: ::String?
53
+ def self.name: () -> ::String?
54
+ def self.a_class_method: () -> ::Symbol
55
+ def self.class_method2: () -> ::Symbol
56
+ def self.another_class_method: () -> ::Symbol
57
+ end
58
+
59
+ class AboutClassMethodsTest::Dog2
60
+ def wag: () -> ::Symbol
61
+ def self.wag: () -> ::Symbol
62
+ end
@@ -0,0 +1,88 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutClasses
7
+ type answers = {
8
+ instances_of_classes_can_be_created_with_new_one: (singleton(::AboutClassesTest::Dog) | :fill_me_in),
9
+ instance_variables_can_be_set_by_assigning_to_them_one: (::Array[untyped] | :fill_me_in),
10
+ instance_variables_can_be_set_by_assigning_to_them_two: (::Array[::Symbol] | :fill_me_in),
11
+ instance_variables_cannot_be_accessed_outside_the_class_one: (singleton(::NoMethodError) | :fill_me_in),
12
+ instance_variables_cannot_be_accessed_outside_the_class_two: (singleton(::SyntaxError) | :fill_me_in),
13
+ you_can_politely_ask_for_instance_variable_values_one: (::String | :fill_me_in),
14
+ you_can_rip_the_value_out_using_instance_eval_one: (::String | :fill_me_in),
15
+ you_can_rip_the_value_out_using_instance_eval_two: (::String | :fill_me_in),
16
+ you_can_create_accessor_methods_to_return_instance_variables_one: (::String | :fill_me_in),
17
+ attr_reader_will_automatically_define_an_accessor_one: (::String | :fill_me_in),
18
+ attr_accessor_will_automatically_define_both_read_and_write_accessors_one: (::String | :fill_me_in),
19
+ initialize_provides_initial_values_for_instance_variables_one: (::String | :fill_me_in),
20
+ args_to_new_must_match_initialize_one: (singleton(::ArgumentError) | :fill_me_in),
21
+ different_objects_have_different_instance_variables_one: (bool | :fill_me_in),
22
+ inside_a_method_self_refers_to_the_containing_object_one: (bool | :fill_me_in),
23
+ to_s_provides_a_string_version_of_the_object_one: (::String | :fill_me_in),
24
+ to_s_is_used_in_string_interpolation_one: (::String | :fill_me_in),
25
+ inspect_provides_a_more_complete_string_version_one: (::String | :fill_me_in),
26
+ all_objects_support_to_s_and_inspect_one: (::String | :fill_me_in),
27
+ all_objects_support_to_s_and_inspect_two: (::String | :fill_me_in),
28
+ all_objects_support_to_s_and_inspect_three: (::String | :fill_me_in),
29
+ all_objects_support_to_s_and_inspect_four: (::String | :fill_me_in)
30
+ }
31
+ def self.koans: -> answers
32
+ end
33
+ end
34
+
35
+ class AboutClassesTest
36
+ def test_instances_of_classes_can_be_created_with_new: -> void
37
+ def test_instance_variables_can_be_set_by_assigning_to_them: -> void
38
+ def test_instance_variables_cannot_be_accessed_outside_the_class: -> void
39
+ def test_you_can_politely_ask_for_instance_variable_values: -> void
40
+ def test_you_can_rip_the_value_out_using_instance_eval: -> void
41
+ def test_you_can_create_accessor_methods_to_return_instance_variables: -> void
42
+ def test_attr_reader_will_automatically_define_an_accessor: -> void
43
+ def test_attr_accessor_will_automatically_define_both_read_and_write_accessors: -> void
44
+ def test_initialize_provides_initial_values_for_instance_variables: -> void
45
+ def test_args_to_new_must_match_initialize: -> void
46
+ def test_different_objects_have_different_instance_variables: -> void
47
+ def test_inside_a_method_self_refers_to_the_containing_object: -> void
48
+ def test_to_s_provides_a_string_version_of_the_object: -> void
49
+ def test_to_s_is_used_in_string_interpolation: -> void
50
+ def test_inspect_provides_a_more_complete_string_version: -> void
51
+ def test_all_objects_support_to_s_and_inspect: -> void
52
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
53
+ end
54
+
55
+ class AboutClassesTest::Dog
56
+
57
+ end
58
+
59
+ class AboutClassesTest::Dog2
60
+ def set_name: (::String a_name) -> ::String
61
+ end
62
+
63
+ class AboutClassesTest::Dog3
64
+ def set_name: (::String a_name) -> ::String
65
+ def name: () -> ::String?
66
+ end
67
+
68
+ class AboutClassesTest::Dog4
69
+ attr_reader name: ::String?
70
+ def set_name: (::String a_name) -> ::String
71
+ end
72
+
73
+ class AboutClassesTest::Dog5
74
+ attr_accessor name: ::String?
75
+ end
76
+
77
+ class AboutClassesTest::Dog6
78
+ attr_reader name: ::String?
79
+ def initialize: (::String initial_name) -> void
80
+ end
81
+
82
+ class AboutClassesTest::Dog7
83
+ attr_reader name: ::String?
84
+ def initialize: (::String initial_name) -> void
85
+ def get_self: () -> self
86
+ def to_s: () -> ::String
87
+ def inspect: () -> ::String
88
+ end
@@ -0,0 +1,53 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutConstants
7
+ type answers = {
8
+ nested_constants_may_also_be_referenced_with_relative_paths_one: (::String | :fill_me_in),
9
+ top_level_constants_are_referenced_by_double_colons_one: (::String | :fill_me_in),
10
+ nested_constants_are_referenced_by_their_complete_path_one: (::String | :fill_me_in),
11
+ nested_constants_are_referenced_by_their_complete_path_two: (::String | :fill_me_in),
12
+ nested_classes_inherit_constants_from_enclosing_classes_one: (::Integer | :fill_me_in),
13
+ subclasses_inherit_constants_from_parent_classes_one: (::Integer | :fill_me_in),
14
+ who_wins_with_both_nested_and_inherited_constants_one: (::Integer | :fill_me_in),
15
+ who_wins_with_explicit_scoping_on_class_definition_one: (::Integer | :fill_me_in)
16
+ }
17
+ def self.koans: -> answers
18
+ end
19
+ end
20
+
21
+ class AboutConstantsTest
22
+ def test_nested_constants_may_also_be_referenced_with_relative_paths: -> void
23
+ def test_top_level_constants_are_referenced_by_double_colons: -> void
24
+ def test_nested_constants_are_referenced_by_their_complete_path: -> void
25
+ def test_nested_classes_inherit_constants_from_enclosing_classes: -> void
26
+ def test_subclasses_inherit_constants_from_parent_classes: -> void
27
+ def test_who_wins_with_both_nested_and_inherited_constants: -> void
28
+ def test_who_wins_with_explicit_scoping_on_class_definition: -> void
29
+ end
30
+
31
+ class AboutConstantsTest::Animal
32
+ def legs_in_animal: () -> ::Integer
33
+ end
34
+
35
+ class AboutConstantsTest::Animal::NestedAnimal
36
+ def legs_in_nested_animal: () -> ::Integer
37
+ end
38
+
39
+ class AboutConstantsTest::Reptile
40
+ def legs_in_reptile: () -> ::Integer
41
+ end
42
+
43
+ class AboutConstantsTest::MyAnimals
44
+
45
+ end
46
+
47
+ class AboutConstantsTest::MyAnimals::Bird
48
+ def legs_in_bird: () -> ::Integer
49
+ end
50
+
51
+ class AboutConstantsTest::MyAnimals::Oyster
52
+ def legs_in_oyster: () -> ::Integer
53
+ end
@@ -0,0 +1,46 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutControlStatements
7
+ type answers = {
8
+ if_then_else_statements_one: (::Symbol | :fill_me_in),
9
+ if_then_statements_one: (::Symbol | :fill_me_in),
10
+ if_statements_return_values_one: (::Symbol | :fill_me_in),
11
+ if_statements_return_values_two: (::Symbol | :fill_me_in),
12
+ if_statements_with_no_else_with_false_condition_return_value_one: (nil | :fill_me_in),
13
+ condition_operators_one: (::Symbol | :fill_me_in),
14
+ condition_operators_two: (::Symbol | :fill_me_in),
15
+ if_statement_modifiers_one: (::Symbol | :fill_me_in),
16
+ unless_statement_one: (::Symbol | :fill_me_in),
17
+ unless_statement_evaluate_true_one: (::Symbol | :fill_me_in),
18
+ unless_statement_modifier_one: (::Symbol | :fill_me_in),
19
+ while_statement_one: (::Integer | :fill_me_in),
20
+ break_statement_one: (::Integer | :fill_me_in),
21
+ break_statement_returns_values_one: (::Integer | :fill_me_in),
22
+ next_statement_one: (::Array[::Integer] | :fill_me_in),
23
+ for_statement_one: (::Array[::String] | :fill_me_in),
24
+ times_statement_one: (::Integer | :fill_me_in)
25
+ }
26
+ def self.koans: -> answers
27
+ end
28
+ end
29
+
30
+ class AboutControlStatementsTest
31
+ def test_if_then_else_statements: -> void
32
+ def test_if_then_statements: -> void
33
+ def test_if_statements_return_values: -> void
34
+ def test_if_statements_with_no_else_with_false_condition_return_value: -> void
35
+ def test_condition_operators: -> void
36
+ def test_if_statement_modifiers: -> void
37
+ def test_unless_statement: -> void
38
+ def test_unless_statement_evaluate_true: -> void
39
+ def test_unless_statement_modifier: -> void
40
+ def test_while_statement: -> void
41
+ def test_break_statement: -> void
42
+ def test_break_statement_returns_values: -> void
43
+ def test_next_statement: -> void
44
+ def test_for_statement: -> void
45
+ def test_times_statement: -> void
46
+ end
@@ -0,0 +1,16 @@
1
+ module Exercises
2
+ class AboutDiceProject
3
+ class DiceSet
4
+ @random: Random
5
+ @values: Array[Integer]
6
+ attr_reader values: Array[Integer]
7
+ def initialize: (?random: Random) -> void
8
+ def roll: (Integer count) -> Array[Integer]
9
+ end
10
+ end
11
+ end
12
+
13
+ class AboutDiceProjectTest
14
+ def test_can_create_and_resize_a_dice_set: -> void
15
+ def test_rolls_use_the_random_source_and_values_stay_stable: -> void
16
+ end
@@ -0,0 +1,36 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutExceptions
7
+ type answers = {
8
+ exceptions_inherit_from_Exception_one: (singleton(::RuntimeError) | :fill_me_in),
9
+ exceptions_inherit_from_Exception_two: (singleton(::StandardError) | :fill_me_in),
10
+ exceptions_inherit_from_Exception_three: (singleton(::Exception) | :fill_me_in),
11
+ exceptions_inherit_from_Exception_four: (singleton(::Object) | :fill_me_in),
12
+ rescue_clause_one: (::Symbol | :fill_me_in),
13
+ rescue_clause_two: (bool | :fill_me_in),
14
+ rescue_clause_three: (bool | :fill_me_in),
15
+ rescue_clause_four: (::String | :fill_me_in),
16
+ raising_a_particular_error_one: (::Symbol | :fill_me_in),
17
+ raising_a_particular_error_two: (::String | :fill_me_in),
18
+ ensure_clause_one: (::Symbol | :fill_me_in),
19
+ asserting_an_error_is_raised_one: (singleton(::AboutExceptionsTest::MySpecialError) | :fill_me_in)
20
+ }
21
+ def self.koans: -> answers
22
+ end
23
+ end
24
+
25
+ class AboutExceptionsTest
26
+ def test_exceptions_inherit_from_Exception: -> void
27
+ def test_rescue_clause: -> void
28
+ def test_raising_a_particular_error: -> void
29
+ def test_ensure_clause: -> void
30
+ def test_asserting_an_error_is_raised: -> void
31
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
32
+ end
33
+
34
+ class AboutExceptionsTest::MySpecialError < ::RuntimeError
35
+
36
+ end
@@ -0,0 +1,36 @@
1
+ module Exercises
2
+ class AboutExtraCredit
3
+ class Player
4
+ @name: String
5
+ @score: Integer
6
+ attr_reader name: String
7
+ attr_reader score: Integer
8
+ def initialize: (String name) -> void
9
+ def bank: (Integer points) -> Integer
10
+ end
11
+ class Game
12
+ @players: Array[Player]
13
+ @current: Integer
14
+ @remaining: Integer?
15
+ attr_reader players: Array[Player]
16
+ attr_reader current: Integer
17
+ def initialize: (Array[String] names) -> void
18
+ def play_turn: (Array[Array[Integer]] rolls) -> Integer
19
+ def finished?: -> bool
20
+ def winner: -> Player?
21
+ private
22
+ def turn_points: (Array[Array[Integer]] rolls) -> Integer
23
+ def validate_roll: (Array[Integer] roll, Integer count) -> void
24
+ def score_roll: (Array[Integer] roll) -> [Integer, Integer]
25
+ def advance: (Integer total) -> Integer
26
+ end
27
+ end
28
+ end
29
+
30
+ class AboutExtraCreditTest
31
+ def test_final_round_starts_at_3000_and_wraps_turn_order: -> void
32
+ def test_entry_threshold_and_later_banking: -> void
33
+ def test_bust_discards_the_entire_turn: -> void
34
+ def test_hot_dice_and_roll_validation: -> void
35
+ def test_every_other_player_gets_one_final_turn: -> void
36
+ end
@@ -0,0 +1,62 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutHashes
7
+ type answers = {
8
+ creating_hashes_one: (singleton(::Hash) | :fill_me_in),
9
+ creating_hashes_two: (::Hash[untyped, untyped] | :fill_me_in),
10
+ creating_hashes_three: (::Integer | :fill_me_in),
11
+ hash_literals_one: (::Integer | :fill_me_in),
12
+ accessing_hashes_one: (::String | :fill_me_in),
13
+ accessing_hashes_two: (::String | :fill_me_in),
14
+ accessing_hashes_three: (nil | :fill_me_in),
15
+ accessing_hashes_with_fetch_one: (::String | :fill_me_in),
16
+ accessing_hashes_with_fetch_two: (singleton(::KeyError) | :fill_me_in),
17
+ changing_hashes_one: (::Hash[::Symbol, ::String] | :fill_me_in),
18
+ hash_is_unordered_one: (bool | :fill_me_in),
19
+ hash_keys_one: (::Integer | :fill_me_in),
20
+ hash_keys_two: (bool | :fill_me_in),
21
+ hash_keys_three: (bool | :fill_me_in),
22
+ hash_keys_four: (singleton(::Array) | :fill_me_in),
23
+ hash_values_one: (::Integer | :fill_me_in),
24
+ hash_values_two: (bool | :fill_me_in),
25
+ hash_values_three: (bool | :fill_me_in),
26
+ hash_values_four: (singleton(::Array) | :fill_me_in),
27
+ combining_hashes_one: (bool | :fill_me_in),
28
+ combining_hashes_two: (bool | :fill_me_in),
29
+ default_value_one: (::Integer | :fill_me_in),
30
+ default_value_two: (nil | :fill_me_in),
31
+ default_value_three: (::Integer | :fill_me_in),
32
+ default_value_four: (::String | :fill_me_in),
33
+ default_value_is_the_same_object_one: (::Array[::String] | :fill_me_in),
34
+ default_value_is_the_same_object_two: (::Array[::String] | :fill_me_in),
35
+ default_value_is_the_same_object_three: (::Array[::String] | :fill_me_in),
36
+ default_value_is_the_same_object_four: (bool | :fill_me_in),
37
+ default_value_with_block_one: (::Array[::String] | :fill_me_in),
38
+ default_value_with_block_two: (::Array[::String] | :fill_me_in),
39
+ default_value_with_block_three: (::Array[untyped] | :fill_me_in),
40
+ default_value_attribute_one: (nil | :fill_me_in),
41
+ default_value_attribute_two: (::String | :fill_me_in)
42
+ }
43
+ def self.koans: -> answers
44
+ end
45
+ end
46
+
47
+ class AboutHashesTest
48
+ def test_creating_hashes: -> void
49
+ def test_hash_literals: -> void
50
+ def test_accessing_hashes: -> void
51
+ def test_accessing_hashes_with_fetch: -> void
52
+ def test_changing_hashes: -> void
53
+ def test_hash_is_unordered: -> void
54
+ def test_hash_keys: -> void
55
+ def test_hash_values: -> void
56
+ def test_combining_hashes: -> void
57
+ def test_default_value: -> void
58
+ def test_default_value_is_the_same_object: -> void
59
+ def test_default_value_with_block: -> void
60
+ def test_default_value_attribute: -> void
61
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
62
+ end
@@ -0,0 +1,50 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutInheritance
7
+ type answers = {
8
+ subclasses_have_the_parent_as_an_ancestor_one: (bool | :fill_me_in),
9
+ all_classes_ultimately_inherit_from_object_one: (bool | :fill_me_in),
10
+ subclasses_inherit_behavior_from_parent_class_one: (::String | :fill_me_in),
11
+ subclasses_add_new_behavior_one: (::Symbol | :fill_me_in),
12
+ subclasses_add_new_behavior_two: (singleton(::NoMethodError) | :fill_me_in),
13
+ subclasses_can_modify_existing_behavior_one: (::String | :fill_me_in),
14
+ subclasses_can_modify_existing_behavior_two: (::String | :fill_me_in),
15
+ subclasses_can_invoke_parent_behavior_via_super_one: (::String | :fill_me_in),
16
+ super_does_not_work_cross_method_one: (singleton(::NoMethodError) | :fill_me_in)
17
+ }
18
+ def self.koans: -> answers
19
+ end
20
+ end
21
+
22
+ class AboutInheritanceTest
23
+ def test_subclasses_have_the_parent_as_an_ancestor: -> void
24
+ def test_all_classes_ultimately_inherit_from_object: -> void
25
+ def test_subclasses_inherit_behavior_from_parent_class: -> void
26
+ def test_subclasses_add_new_behavior: -> void
27
+ def test_subclasses_can_modify_existing_behavior: -> void
28
+ def test_subclasses_can_invoke_parent_behavior_via_super: -> void
29
+ def test_super_does_not_work_cross_method: -> void
30
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
31
+ end
32
+
33
+ class AboutInheritanceTest::Dog
34
+ attr_reader name: ::String?
35
+ def initialize: (::String name) -> void
36
+ def bark: () -> ::String
37
+ end
38
+
39
+ class AboutInheritanceTest::Chihuahua < ::AboutInheritanceTest::Dog
40
+ def wag: () -> ::Symbol
41
+ def bark: () -> ::String
42
+ end
43
+
44
+ class AboutInheritanceTest::BullDog < ::AboutInheritanceTest::Dog
45
+ def bark: () -> ::String
46
+ end
47
+
48
+ class AboutInheritanceTest::GreatDane < ::AboutInheritanceTest::Dog
49
+ def growl: () -> untyped
50
+ end
@@ -0,0 +1,37 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutIteration
7
+ type answers = {
8
+ each_is_a_method_on_arrays_one: (bool | :fill_me_in),
9
+ iterating_with_each_one: (::Integer | :fill_me_in),
10
+ each_can_use_curly_brace_blocks_too_one: (::Integer | :fill_me_in),
11
+ break_works_with_each_style_iterations_one: (::Integer | :fill_me_in),
12
+ collect_transforms_elements_of_an_array_one: (::Array[::Integer] | :fill_me_in),
13
+ collect_transforms_elements_of_an_array_two: (::Array[::Integer] | :fill_me_in),
14
+ select_selects_certain_items_from_an_array_one: (::Array[::Integer] | :fill_me_in),
15
+ select_selects_certain_items_from_an_array_two: (::Array[::Integer] | :fill_me_in),
16
+ find_locates_the_first_element_matching_a_criteria_one: (::String | :fill_me_in),
17
+ inject_will_blow_your_mind_one: (::Integer | :fill_me_in),
18
+ inject_will_blow_your_mind_two: (::Integer | :fill_me_in),
19
+ all_iteration_methods_work_on_any_collection_not_just_arrays_one: (::Array[::Integer] | :fill_me_in),
20
+ all_iteration_methods_work_on_any_collection_not_just_arrays_two: (::Array[::String] | :fill_me_in)
21
+ }
22
+ def self.koans: -> answers
23
+ end
24
+ end
25
+
26
+ class AboutIterationTest
27
+ def test_each_is_a_method_on_arrays: -> void
28
+ def test_iterating_with_each: -> void
29
+ def test_each_can_use_curly_brace_blocks_too: -> void
30
+ def test_break_works_with_each_style_iterations: -> void
31
+ def test_collect_transforms_elements_of_an_array: -> void
32
+ def test_select_selects_certain_items_from_an_array: -> void
33
+ def test_find_locates_the_first_element_matching_a_criteria: -> void
34
+ def test_inject_will_blow_your_mind: -> void
35
+ def test_all_iteration_methods_work_on_any_collection_not_just_arrays: -> void
36
+ def with_example_file: [A] () { (File) -> A } -> A
37
+ end
@@ -0,0 +1,33 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutKeywordArguments
7
+ type answers = {
8
+ keyword_arguments_one: (singleton(::Array) | :fill_me_in),
9
+ keyword_arguments_two: (::Array[::Integer | ::String] | :fill_me_in),
10
+ keyword_arguments_three: (::Array[::String] | :fill_me_in),
11
+ keyword_arguments_four: (::Array[::Integer] | :fill_me_in),
12
+ keyword_arguments_with_wrong_number_of_arguments_one: (singleton(::ArgumentError) | :fill_me_in),
13
+ keyword_arguments_with_wrong_number_of_arguments_two: (::String | :fill_me_in),
14
+ mandatory_keyword_arguments_one: (::Array[::String] | :fill_me_in),
15
+ mandatory_keyword_arguments_two: (::Array[::Integer] | :fill_me_in),
16
+ mandatory_keyword_arguments_without_mandatory_argument_one: (singleton(::ArgumentError) | :fill_me_in),
17
+ mandatory_keyword_arguments_without_mandatory_argument_two: (::String | :fill_me_in)
18
+ }
19
+ def self.koans: -> answers
20
+ end
21
+ end
22
+
23
+ class AboutKeywordArgumentsTest
24
+ def method_with_keyword_arguments: (?one: Integer | String, ?two: Integer | String) -> [Integer | String, Integer | String]
25
+ def test_keyword_arguments: -> void
26
+ def method_with_keyword_arguments_with_mandatory_argument: (untyped one, ?two: Integer, ?three: Integer) -> [untyped, Integer, Integer]
27
+ def test_keyword_arguments_with_wrong_number_of_arguments: -> void
28
+ def method_with_mandatory_keyword_arguments: (one: Integer | String, ?two: Integer | String) -> [Integer | String, Integer | String]
29
+ def test_mandatory_keyword_arguments: -> void
30
+ def test_mandatory_keyword_arguments_without_mandatory_argument: -> void
31
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
32
+ def assert_predicted_message: (::Symbol key, ::String message) -> void
33
+ end
@@ -0,0 +1,68 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutMessagePassing
7
+ type answers = {
8
+ methods_can_be_invoked_more_dynamically_one: (bool | :fill_me_in),
9
+ methods_can_be_invoked_more_dynamically_two: (bool | :fill_me_in),
10
+ send_with_underscores_will_also_send_messages_one: (bool | :fill_me_in),
11
+ classes_can_be_asked_if_they_know_how_to_respond_one: (bool | :fill_me_in),
12
+ classes_can_be_asked_if_they_know_how_to_respond_two: (bool | :fill_me_in),
13
+ sending_a_message_with_arguments_one: (::Array[untyped] | :fill_me_in),
14
+ sending_a_message_with_arguments_two: (::Array[untyped] | :fill_me_in),
15
+ sending_a_message_with_arguments_three: (::Array[::Integer | nil] | :fill_me_in),
16
+ sending_a_message_with_arguments_four: (::Array[::Integer | nil] | :fill_me_in),
17
+ sending_undefined_messages_to_a_typical_object_results_in_errors_one: (singleton(::NoMethodError) | :fill_me_in),
18
+ calling_method_missing_causes_the_no_method_error_one: (singleton(::NoMethodError) | :fill_me_in),
19
+ all_messages_are_caught_one: (::String | :fill_me_in),
20
+ all_messages_are_caught_two: (::String | :fill_me_in),
21
+ all_messages_are_caught_three: (::String | :fill_me_in),
22
+ catching_messages_makes_respond_to_lie_one: (bool | :fill_me_in),
23
+ foo_method_are_caught_one: (::String | :fill_me_in),
24
+ foo_method_are_caught_two: (::String | :fill_me_in),
25
+ non_foo_messages_are_treated_normally_one: (singleton(::NoMethodError) | :fill_me_in),
26
+ explicitly_implementing_respond_to_lets_objects_tell_the_truth_one: (bool | :fill_me_in),
27
+ explicitly_implementing_respond_to_lets_objects_tell_the_truth_two: (bool | :fill_me_in)
28
+ }
29
+ def self.koans: -> answers
30
+ end
31
+ end
32
+
33
+ class AboutMessagePassingTest
34
+ def test_methods_can_be_called_directly: -> void
35
+ def test_methods_can_be_invoked_by_sending_the_message: -> void
36
+ def test_methods_can_be_invoked_more_dynamically: -> void
37
+ def test_send_with_underscores_will_also_send_messages: -> void
38
+ def test_classes_can_be_asked_if_they_know_how_to_respond: -> void
39
+ def test_sending_a_message_with_arguments: -> void
40
+ def test_sending_undefined_messages_to_a_typical_object_results_in_errors: -> void
41
+ def test_calling_method_missing_causes_the_no_method_error: -> void
42
+ def test_all_messages_are_caught: -> void
43
+ def test_catching_messages_makes_respond_to_lie: -> void
44
+ def test_foo_method_are_caught: -> void
45
+ def test_non_foo_messages_are_treated_normally: -> void
46
+ def test_explicitly_implementing_respond_to_lets_objects_tell_the_truth: -> void
47
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
48
+ end
49
+
50
+ class AboutMessagePassingTest::MessageCatcher
51
+ def caught?: () -> bool
52
+ def add_a_payload: [A] (*A args) -> Array[A]
53
+ end
54
+
55
+ class AboutMessagePassingTest::TypicalObject
56
+
57
+ end
58
+
59
+ class AboutMessagePassingTest::AllMessageCatcher
60
+ def method_missing: (Symbol method_name, *untyped args) ?{ (*untyped) -> untyped } -> String
61
+ end
62
+
63
+ class AboutMessagePassingTest::WellBehavedFooCatcher
64
+ def method_missing: (Symbol method_name, *untyped args) ?{ (*untyped) -> untyped } -> String
65
+ private
66
+ def respond_to_missing?: (Symbol | String method_name, ?bool include_private) -> bool
67
+ public
68
+ end
@@ -0,0 +1,68 @@
1
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
2
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
3
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
4
+
5
+ module Exercises
6
+ class AboutMethods
7
+ type answers = {
8
+ calling_global_methods_one: (::Integer | :fill_me_in),
9
+ calling_global_methods_without_parentheses_one: (::Integer | :fill_me_in),
10
+ sometimes_missing_parentheses_are_ambiguous_one: (::Integer | :fill_me_in),
11
+ calling_global_methods_with_wrong_number_of_arguments_one: (singleton(::ArgumentError) | :fill_me_in),
12
+ calling_global_methods_with_wrong_number_of_arguments_two: (::String | :fill_me_in),
13
+ calling_global_methods_with_wrong_number_of_arguments_three: (singleton(::ArgumentError) | :fill_me_in),
14
+ calling_global_methods_with_wrong_number_of_arguments_four: (::String | :fill_me_in),
15
+ calling_with_default_values_one: (::Array[::Integer | ::Symbol] | :fill_me_in),
16
+ calling_with_default_values_two: (::Array[::Integer] | :fill_me_in),
17
+ calling_with_variable_arguments_one: (singleton(::Array) | :fill_me_in),
18
+ calling_with_variable_arguments_two: (::Array[untyped] | :fill_me_in),
19
+ calling_with_variable_arguments_three: (::Array[::Symbol] | :fill_me_in),
20
+ calling_with_variable_arguments_four: (::Array[::Symbol] | :fill_me_in),
21
+ method_with_explicit_return_one: (::Symbol | :fill_me_in),
22
+ method_without_explicit_return_one: (::Symbol | :fill_me_in),
23
+ calling_methods_in_same_class_one: (::Integer | :fill_me_in),
24
+ calling_methods_in_same_class_with_explicit_receiver_one: (::Integer | :fill_me_in),
25
+ calling_private_methods_without_receiver_one: (::String | :fill_me_in),
26
+ calling_private_methods_with_an_explicit_receiver_one: (::String | :fill_me_in),
27
+ calling_methods_in_other_objects_require_explicit_receiver_one: (::String | :fill_me_in),
28
+ calling_private_methods_in_other_objects_one: (singleton(::NoMethodError) | :fill_me_in)
29
+ }
30
+ def self.koans: -> answers
31
+ end
32
+ end
33
+
34
+ class AboutMethodsTest
35
+ def test_calling_global_methods: -> void
36
+ def test_calling_global_methods_without_parentheses: -> void
37
+ def test_sometimes_missing_parentheses_are_ambiguous: -> void
38
+ def test_calling_global_methods_with_wrong_number_of_arguments: -> void
39
+ def method_with_defaults: [A, B] (A a, ?B b) -> [A, B | Symbol]
40
+ def test_calling_with_default_values: -> void
41
+ def method_with_var_args: [A] (*A args) -> Array[A]
42
+ def test_calling_with_variable_arguments: -> void
43
+ def method_with_explicit_return: -> Symbol
44
+ def test_method_with_explicit_return: -> void
45
+ def method_without_explicit_return: -> Symbol
46
+ def test_method_without_explicit_return: -> void
47
+ def my_method_in_the_same_class: (Integer a, Integer b) -> Integer
48
+ def test_calling_methods_in_same_class: -> void
49
+ def test_calling_methods_in_same_class_with_explicit_receiver: -> void
50
+ private
51
+ def my_private_method: -> String
52
+ public
53
+ def test_calling_private_methods_without_receiver: -> void
54
+ def test_calling_private_methods_with_an_explicit_receiver: -> void
55
+ def test_calling_methods_in_other_objects_require_explicit_receiver: -> void
56
+ def test_calling_private_methods_in_other_objects: -> void
57
+ def assert_predicted_error: (::Symbol key, singleton(::Exception) klass) { () -> untyped } -> ::Exception
58
+ def assert_predicted_message: (::Symbol key, ::String message) -> void
59
+ end
60
+
61
+ class AboutMethodsTest::Dog
62
+ def name: () -> ::String?
63
+ def tail: () -> ::String
64
+ end
65
+
66
+ class Object
67
+ def my_global_method: (Integer a, Integer b) -> Integer
68
+ end