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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9da424188c5df8f91c61f90ea21e3322877af560c5c56e073267c863c43156a9
4
- data.tar.gz: 15fde98c5158a6b49c9f9bd3cc606556e43380695cf4045c27b5ecf3b8dfbe98
3
+ metadata.gz: 20e5b0bf25e0df8e45b6e657a17ea17d11261ea4898a8c3324a76c6140fdf7ff
4
+ data.tar.gz: e957886a95dcf25e1d2bb4d4baf16423f0c63b9bdee5f67ca066ac427f95ff6f
5
5
  SHA512:
6
- metadata.gz: c4a4d73b82063fcbd98cdafa982f19cb7787efc80f3f688f94068cfcf184c4b35341352a714ff159b012a04b533b20aa5240575c7fe62023421c06608c338664
7
- data.tar.gz: 9f8d4751b8525ec5fa38b8ecf8b4f51c7d4f80dd7d22557138428e0a013044d9273fa4ddf6e7a2755e873ac4077eb31d99e6cd508333071f54efde0ca75bde6d
6
+ metadata.gz: a909d17fea94d5acba405c4b720df92719cd4eb923247d0e0b35346df3b0f31261a7dcf3e207139670a2b36bea8b55f3916964ea56eac77691f6943329057305
7
+ data.tar.gz: ac1f4eb219698c0aca30530d49c7c5b500c00a7158f53d0fe2df892ecdbbc48bdb031bf2e843b8194c9acc6d7d4e5e678d49e3e21ee31b6b2ad3cc5a89308fc9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.0]
4
+
5
+ - Expand the Ruby track to 59 lessons, including the MRI-compatible Ruby Koans
6
+ sequence, triangle, scoring, dice and proxy projects, and a Greed game capstone.
7
+ - Document practice coverage for the published Ruby Gold version 3 topics and
8
+ the differences between the exam's Ruby 3.1 target and this gem's runtime.
9
+ - Add hints, reference solutions and RBS signatures for the exercises.
10
+ - Correct lesson commands and strengthen regexp ID type checks.
11
+
12
+ Existing selections, saved edits and completion history are preserved. Use
13
+ `rkoans list` and `rkoans start EXERCISE` to try lessons added earlier in the
14
+ sequence. See [the curriculum guide](CURRICULUM.md) for scope and exclusions.
15
+
3
16
  ## [0.0.1] - 2026-10-13
4
17
 
5
18
  - Initial release
data/CURRICULUM.md ADDED
@@ -0,0 +1,86 @@
1
+ # Ruby curriculum
2
+
3
+ The Ruby track combines the MRI-compatible Ruby Koans chapters with implementation
4
+ exercises covering the published Ruby Gold version 3 topic outline. Lessons build
5
+ from predictions about Ruby expressions to small programming projects.
6
+
7
+ ## Ruby Koans scope
8
+
9
+ The sequence includes all 33 MRI-compatible `about_*` chapters in the source
10
+ curriculum, including the optional extra-credit project. Another 26 exercises,
11
+ including the heredoc prediction lesson, bring the track to 59 lessons.
12
+ `about-pattern-matching` is included even though the source runner restricts it
13
+ to older runtime versions.
14
+
15
+ The JRuby-only `about_java_interop` chapter is excluded: this gem targets MRI Ruby
16
+ 4.0.7 and does not provide a Java runtime. Obsolete Ruby 1.8 behavior is explained
17
+ or replaced with current behavior, rather than presented as a current answer.
18
+ For example, indexing a string returns a string, and `self` can receive a private
19
+ method call in modern Ruby.
20
+
21
+ The triangle projects are independent learner files, so part two supplies a
22
+ classifier to extend. File examples use real temporary files rather than requiring
23
+ a file in the caller's working directory. Dice checks replay a seeded random
24
+ stream; they never assume that two random rolls must differ. The original
25
+ free-form extra credit is adapted as a deterministic Greed engine repair, with
26
+ an optional interface or automated player left for further practice.
27
+
28
+ See [third-party notices](THIRD_PARTY_NOTICES.md) for Koans attribution and terms.
29
+
30
+ ## Gold topics
31
+
32
+ Mapped against the Ruby Association's [official Gold version 3 outline](https://www.ruby.or.jp/en/certification/examination/)
33
+ on October 14, 2026. The exam targets **Ruby 3.1.x**; Rkoans runs on **Ruby 4.0.7 or
34
+ newer**. These are practice examples for every published topic category, not an
35
+ exhaustive model of the exam or a guarantee of exam readiness. Runtime-specific
36
+ behavior can differ, and the suite has not been validated on Ruby 3.1.
37
+
38
+ Each link points to an independent Minitest check; the named method identifies a
39
+ concrete behavior checked there. References are teaching examples, not the source
40
+ of expected values inside those checks. Checks establish observable behavior;
41
+ they do not require one particular implementation technique.
42
+
43
+ | Topic | Exercise check | Behavior exercised |
44
+ | --- | --- | --- |
45
+ | `environment.predefined` | [runtime-context: `test_runtime_globals`](test/exercises/runtime_context_test.rb) | ARGV and ENV; runtime constants and empty/missing input checks |
46
+ | `syntax.literals` | [literals-and-operators: `test_literals_and_precedence`](test/exercises/literals_and_operators_test.rb) | Literal values and numeric division |
47
+ | `syntax.variables_constants` | [constant-scope: `test_scope_predictions`](test/exercises/constant_scope_test.rb) | Lexical constants, shared class state and local scope |
48
+ | `syntax.operators` | [literals-and-operators: `test_short_circuit_default`](test/exercises/literals_and_operators_test.rb) | Precedence, truthiness and nil-only defaults |
49
+ | `syntax.blocks` | [blocks-and-methods: `test_apply_block`](test/exercises/blocks_and_methods_test.rb) | Yielded arguments, result and invocation count |
50
+ | `syntax.exceptions` | [exception-flow: `test_ensure_and_else`](test/exercises/exception_flow_test.rb) | Rescue, else, ensure and reraising |
51
+ | `syntax.nonlocal_exit` | [nonlocal-exit: `test_catch_throw_and_next`](test/exercises/nonlocal_exit_test.rb) | Catch/throw, next, and escaped proc return |
52
+ | `syntax.keywords` | [keyword-forwarding: `test_keyword_and_block`](test/exercises/keyword_forwarding_test.rb) | Keywords, defaults, positional hashes and blocks |
53
+ | `syntax.numbered_parameters` | [numbered-parameters: `test_numbered_pair_input`](test/exercises/numbered_parameters_test.rb) | Numbered block arguments and syntax predictions |
54
+ | `syntax.lambda` | [closure-capture: `test_lambda_contract`](test/exercises/closure_capture_test.rb) | Lambda identity, strict arity and independent captures |
55
+ | `syntax.pattern_matching` | [pattern-matching: `test_pinned_kind`](test/exercises/pattern_matching_test.rb) | Pinned values, type patterns and guards |
56
+ | `syntax.heredocs` | [heredoc-layout: `test_squiggly_indentation`](test/exercises/heredoc_layout_test.rb) | Indentation and interpolation |
57
+ | `oop.methods` | [method-contracts: `test_parameter_metadata`](test/exercises/method_contracts_test.rb) | Parameter kinds, required keywords, defaults and blocks |
58
+ | `oop.access` | [visibility: `test_protected_peer_calls`](test/exercises/visibility_test.rb) | Protected peer access and private normalization |
59
+ | `oop.classes` | [class-state: `test_independent_class_instance_state`](test/exercises/class_state_test.rb) | Independent class-object instance state |
60
+ | `oop.inheritance` | [class-state: `test_class_inheritance_and_singleton`](test/exercises/class_state_test.rb) | Superclass method calls and singleton ancestry |
61
+ | `oop.modules` | [method-lookup: `test_ancestor_order`](test/exercises/method_lookup_test.rb) | Module lookup order and wrapping |
62
+ | `oop.prepend` | [method-lookup: `test_prepend_wrapper`](test/exercises/method_lookup_test.rb) | Prepending a wrapper around the original method |
63
+ | `oop.refinements` | [refinement-scope: `test_lexical_refinement`](test/exercises/refinement_scope_test.rb) | Lexical activation and behavior outside the scope |
64
+ | `meta.eval` | [dynamic-methods: `test_eval_binding_and_reflection`](test/exercises/dynamic_methods_test.rb) | Evaluation with a captured local binding |
65
+ | `meta.define_method` | [dynamic-methods: `test_defined_reader_closures`](test/exercises/dynamic_methods_test.rb) | Dynamically defined readers with separate captured names |
66
+ | `meta.instance_variables` | [dynamic-methods: `test_eval_binding_and_reflection`](test/exercises/dynamic_methods_test.rb) | Reflective instance-variable access and class evaluation |
67
+ | `builtin.object` | [core-protocols: `test_enumerable_protocol`](test/exercises/core_protocols_test.rb) | Object membership and capability introspection |
68
+ | `builtin.module` | [method-lookup: `test_ancestor_order`](test/exercises/method_lookup_test.rb) | Module ancestry; dynamic methods also exercise Module APIs |
69
+ | `builtin.kernel` | [dynamic-methods: `test_eval_binding_and_reflection`](test/exercises/dynamic_methods_test.rb) | Kernel eval and binding; enum_for in core protocols |
70
+ | `builtin.enumerable` | [core-protocols: `test_enumerable_protocol`](test/exercises/core_protocols_test.rb) | Custom each powering map and enumeration |
71
+ | `builtin.comparable` | [core-protocols: `test_comparable_and_conversion`](test/exercises/core_protocols_test.rb) | Comparison protocol, ordering and printable conversion |
72
+ | `builtin.numeric` | [numeric-precision: `test_numeric_division`](test/exercises/numeric_precision_test.rb) | Integer, Float, Rational and Complex type/value contracts |
73
+ | `builtin.regexp` | [regexp-captures: `test_whole_string_and_captures`](test/exercises/regexp_captures_test.rb) | Whole-string anchors, named captures and Integer conversion |
74
+ | `builtin.proc` | [nonlocal-exit: `test_proc_nonlocal_return`](test/exercises/nonlocal_exit_test.rb) | Escaped proc return; closures and lambdas in closure-capture |
75
+ | `builtin.enumerator` | [lazy-enumeration: `test_lazy_limit`](test/exercises/lazy_enumeration_test.rb) | Finite demand from an unbounded lazy enumerator |
76
+ | `stdlib.time` | [time-and-date: `test_time_offset`](test/exercises/time_and_date_test.rb) | Parsing an explicit offset and converting to UTC |
77
+ | `stdlib.date` | [time-and-date: `test_calendar_days`](test/exercises/time_and_date_test.rb) | Signed calendar-day distances across leap day |
78
+ | `stdlib.singleton` | [singleton-pattern: `test_singleton_identity`](test/exercises/singleton_pattern_test.rb) | Stable identity and an inaccessible constructor |
79
+ | `stdlib.forwardable` | [delegation: `test_live_receiver`](test/exercises/delegation_test.rb) | Delegation to a live receiver and return-value preservation |
80
+
81
+ ## Returning learners
82
+
83
+ Your selected exercise, saved edits and completion history are preserved across
84
+ updates. Newly added lessons earlier in the sequence are not visited automatically.
85
+ Use `rkoans list` to find them and `rkoans start EXERCISE` to select one. Then use
86
+ `rkoans check` to check the selected exercise once, or save while watching.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Rkoans
2
+
3
+ Learn Ruby by editing code and watching Minitest checks respond to each save.
4
+
5
+ ## Get started
6
+
7
+ Rkoans requires Ruby 4.0.7 or newer. From a source checkout, run:
8
+
9
+ ```sh
10
+ bundle install
11
+ bundle exec rkoans
12
+ ```
13
+
14
+ Rkoans creates your study directory at `~/ruby-koans`, shows the exercise
15
+ instructions, and prints the file to edit. The starter intentionally fails.
16
+ Save your changes to rerun the checks automatically.
17
+
18
+ Running `rkoans` again resumes your selected exercise and preserves your edits.
19
+ Once the gem is installed, you can run it from any directory.
20
+ `rkoans start` has the same behavior as `rkoans`.
21
+
22
+ ## Curriculum
23
+
24
+ Practice Ruby through expression predictions and implementation projects, from
25
+ basic syntax to blocks, object protocols, metaprogramming and standard libraries.
26
+ See the [curriculum guide](CURRICULUM.md) for Ruby Koans scope, Gold topic coverage
27
+ and runtime differences.
28
+
29
+ Your current selection and saved work survive updates. To try a newly added
30
+ lesson, use `rkoans list` and `rkoans start EXERCISE`.
31
+
32
+ ## Commands
33
+
34
+ ```sh
35
+ rkoans list # List available exercises
36
+ rkoans start blocks-and-methods # Select an exercise
37
+ rkoans check # Check the selected exercise once
38
+ ```
39
+
40
+ Each exercise has a separate file in `~/ruby-koans/exercises`, such as
41
+ `collection-basics/collection_basics.rb`. Switching exercises preserves your work.
42
+
43
+ `rkoans check` exits with 0 for success, 1 for failed checks, or 2 for a setup or
44
+ command error. Checks that run longer than 30 seconds are stopped.
45
+
46
+ ## Interactive session
47
+
48
+ The terminal refreshes after each check. When an exercise passes, Rkoans shows
49
+ `Exercise done ✓`, your progress, and a reference solution you can compare with
50
+ your own code. The exercise stays open so you can experiment.
51
+
52
+ - `?` shows keyboard help.
53
+ - `h` shows a hint for the unfinished current exercise.
54
+ - `l` lists exercises; `s` returns to the current exercise.
55
+ - `n` followed by Enter advances to the next exercise.
56
+ - `q` followed by Enter quits. Ctrl-C also exits.
57
+
58
+ Help, hints, and view changes respond immediately. Available keys appear at the
59
+ bottom of each screen. Saving while viewing the list keeps the list open.
60
+
61
+ Rkoans remembers completed exercises, even if you later experiment with their
62
+ code. Advancing checks your current code again and requires it to pass.
63
+
64
+ ## Licenses
65
+
66
+ The CLI and original exercises use the MIT license. Adapted Ruby Koans lessons
67
+ use CC BY-NC-SA 3.0; see [third-party notices](THIRD_PARTY_NOTICES.md) for their
68
+ attribution, covered files, and license terms.
69
+
70
+ ## Development
71
+
72
+ From the gem directory:
73
+
74
+ ```sh
75
+ bundle exec rake
76
+ gem build rkoans.gemspec
77
+ ```
@@ -0,0 +1,30 @@
1
+ # Third-party exercise content
2
+
3
+ Rkoans' CLI and original exercises are covered by the MIT license in `LICENSE.txt`.
4
+ Lessons named `about-*` are adapted from **Ruby Koans**, authored by
5
+ Jim Weirich and Joe O'Brien. Their adapted content is distributed under
6
+ **Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
7
+ (CC BY-NC-SA 3.0)**.
8
+
9
+ This notice covers:
10
+
11
+ - `exercises/about-*/` — starters, briefs, and hints
12
+ - `test/exercises/about_*_test.rb` — exercise checks
13
+ - `solutions/about-*/` — reference solutions
14
+ - `sig/exercises/about_*.rbs` — signatures
15
+
16
+ The `about-*` lesson names are reserved for Ruby Koans adaptations.
17
+
18
+ Source: [Ruby Koans](https://github.com/edgecase/ruby_koans).
19
+ Project: [Ruby Koans](https://www.rubykoans.com/).
20
+ License: [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/).
21
+ Full terms: [legal code](https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode).
22
+
23
+ Adaptations replace the Neo runner with Minitest, use Rkoans' learner-answer
24
+ format, and add instructions, hints, references, and signatures.
25
+ Individual files retain attribution and license notices.
26
+ The original authors do not endorse these adaptations.
27
+
28
+ The license permits sharing and adaptation with attribution, for noncommercial
29
+ purposes, and requires adapted material to use the same license. The MIT license
30
+ does not replace these terms for the covered files.
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
4
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
5
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
6
+
7
+ module Exercises
8
+ # Predicts how array values are assigned to one or several variables.
9
+ class AboutArrayAssignment
10
+ # Replace each :fill_me_in with the assigned value shown in its example.
11
+ # @return [Hash<Symbol, String | Array<String> | nil>]
12
+ def self.koans
13
+ {
14
+ # names = ['John', 'Smith']; names
15
+ names: :fill_me_in,
16
+ # first_name, last_name = ['John', 'Smith']; first_name
17
+ first_name: :fill_me_in,
18
+ # first_name, last_name = ['John', 'Smith']; last_name
19
+ last_name: :fill_me_in,
20
+ # first_name, last_name = ['John', 'Smith', 'III']; first_name
21
+ extra_first: :fill_me_in,
22
+ # first_name, last_name = ['John', 'Smith', 'III']; last_name
23
+ extra_last: :fill_me_in,
24
+ # first_name, *last_name = ['John', 'Smith', 'III']; first_name
25
+ splat_first: :fill_me_in,
26
+ # first_name, *last_name = ['John', 'Smith', 'III']; last_name
27
+ splat_last: :fill_me_in,
28
+ # first_name, last_name = ['Cher']; first_name
29
+ short_first: :fill_me_in,
30
+ # first_name, last_name = ['Cher']; last_name
31
+ short_last: :fill_me_in,
32
+ # first_name, last_name = [['Willie', 'Rae'], 'Johnson']; first_name
33
+ nested_first: :fill_me_in,
34
+ # first_name, last_name = [['Willie', 'Rae'], 'Johnson']; last_name
35
+ nested_last: :fill_me_in,
36
+ # first_name, = ['John', 'Smith']; first_name
37
+ single_first: :fill_me_in,
38
+ # first_name = 'Roy'; last_name = 'Rob'; first_name, last_name = last_name, first_name; first_name
39
+ swapped_first: :fill_me_in,
40
+ # first_name = 'Roy'; last_name = 'Rob'; first_name, last_name = last_name, first_name; last_name
41
+ swapped_last: :fill_me_in
42
+ }
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,11 @@
1
+ # About Array Assignment
2
+
3
+ Predict the values assigned by each example in `about_array_assignment.rb`.
4
+ Replace each `:fill_me_in` with a string, array, or `nil` as appropriate.
5
+
6
+ Explore assignment to one variable, parallel assignment, extra and missing
7
+ values, splats, nested arrays, a trailing comma, and swapping two variables.
8
+ Compare each variable's value after assignment with the original array.
9
+
10
+ Adapted from Ruby Koans by Jim Weirich and Joe O'Brien, licensed under
11
+ CC BY-NC-SA 3.0. See `THIRD_PARTY_NOTICES.md` for attribution and license terms.
@@ -0,0 +1,11 @@
1
+ # Hint
2
+
3
+ One variable normally receives the whole array. Several variables receive its
4
+ values in order. A splat collects the remaining values in an array; without it,
5
+ extra values are discarded. Missing values become `nil`.
6
+
7
+ Compare `name = names` with `name, = names`. When swapping variables, Ruby
8
+ evaluates the right-hand values before updating either left-hand variable.
9
+
10
+ Adapted from Ruby Koans by Jim Weirich and Joe O'Brien, licensed under
11
+ CC BY-NC-SA 3.0. See `THIRD_PARTY_NOTICES.md` for attribution and license terms.
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
4
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
5
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
6
+
7
+ module Exercises
8
+ # Predicts array construction, indexing, slicing, ranges, and destructive operations.
9
+ class AboutArrays
10
+ # Replace each :fill_me_in with the result of its example.
11
+ # Index and slice examples use [:peanut, :butter, :and, :jelly].
12
+ # @return [Hash<Symbol, Class | Integer | Symbol | Array | nil>]
13
+ # The answer table is data, not a sequence of operations.
14
+ def self.koans # rubocop:disable Metrics/MethodLength
15
+ {
16
+ # Array.new.class
17
+ empty_type: :fill_me_in,
18
+ # Array.new.size
19
+ empty_size: :fill_me_in,
20
+ # array = [1]; array[1] = 2; array[1]
21
+ second_literal: :fill_me_in,
22
+ # array = [1, 2]; array << 333; array
23
+ after_append: :fill_me_in,
24
+ # array[0]
25
+ first_index: :fill_me_in,
26
+ # array.first
27
+ first_method: :fill_me_in,
28
+ # array[3]
29
+ last_index: :fill_me_in,
30
+ # array.last
31
+ last_method: :fill_me_in,
32
+ # array[-1]
33
+ negative_last: :fill_me_in,
34
+ # array[-3]
35
+ negative_third: :fill_me_in,
36
+ # array[0, 1]
37
+ slice_one: :fill_me_in,
38
+ # array[0, 2]
39
+ slice_two: :fill_me_in,
40
+ # array[2, 2]
41
+ slice_tail: :fill_me_in,
42
+ # array[2, 20]
43
+ slice_long_tail: :fill_me_in,
44
+ # array[4, 0]
45
+ slice_at_end_zero: :fill_me_in,
46
+ # array[4, 100]
47
+ slice_at_end_long: :fill_me_in,
48
+ # array[5, 0]
49
+ slice_beyond_end: :fill_me_in,
50
+ # (1..5).class
51
+ range_type: :fill_me_in,
52
+ # (1..5).to_a
53
+ inclusive_range: :fill_me_in,
54
+ # (1...5).to_a
55
+ exclusive_range: :fill_me_in,
56
+ # array[0..2]
57
+ inclusive_slice: :fill_me_in,
58
+ # array[0...2]
59
+ exclusive_slice: :fill_me_in,
60
+ # array[2..-1]
61
+ negative_range_slice: :fill_me_in,
62
+ # array = [1, 2]; array.push(:last); array
63
+ after_push: :fill_me_in,
64
+ # array = [1, 2, :last]; array.pop
65
+ popped_value: :fill_me_in,
66
+ # array = [1, 2, :last]; array.pop; array
67
+ after_pop: :fill_me_in,
68
+ # array = [1, 2]; array.unshift(:first); array
69
+ after_unshift: :fill_me_in,
70
+ # array = [:first, 1, 2]; array.shift
71
+ shifted_value: :fill_me_in,
72
+ # array = [:first, 1, 2]; array.shift; array
73
+ after_shift: :fill_me_in
74
+ }
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,16 @@
1
+ # About Arrays
2
+
3
+ Predict how Ruby arrays are constructed, indexed, sliced, and changed.
4
+
5
+ Open `about_arrays.rb` and replace each `:fill_me_in` with the value produced by
6
+ its example. For indexing and slicing, the examples use
7
+ `[:peanut, :butter, :and, :jelly]`. Answers can be classes, integers, symbols,
8
+ arrays, or `nil`.
9
+
10
+ Explore positive and negative indexes, start-and-length slices, inclusive and
11
+ exclusive ranges, and the difference between an operation's return value and
12
+ the array it changes. Run the checks after each edit to see the next prediction
13
+ to investigate.
14
+
15
+ Adapted from Ruby Koans by Jim Weirich and Joe O'Brien, licensed under
16
+ CC BY-NC-SA 3.0. See `THIRD_PARTY_NOTICES.md` for attribution and license terms.
@@ -0,0 +1,13 @@
1
+ # Hint
2
+
3
+ Array indexes start at zero. Negative indexes count backward from the end.
4
+
5
+ With `array[start, length]`, `length` is a count of elements. Compare a start at
6
+ `array.length` with a start beyond it: an empty array and `nil` are different.
7
+ For ranges, `..` includes the endpoint and `...` excludes it.
8
+
9
+ Try `push`, `pop`, `unshift`, and `shift` in IRB. Inspect the array after each
10
+ operation as well as the value returned by the operation.
11
+
12
+ Adapted from Ruby Koans by Jim Weirich and Joe O'Brien, licensed under
13
+ CC BY-NC-SA 3.0. See `THIRD_PARTY_NOTICES.md` for attribution and license terms.
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
4
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
5
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
6
+
7
+ module Exercises
8
+ # Supplies the expectations used by the five introductory assertion koans.
9
+ class AboutAsserts
10
+ # Replace the false and nil values with answers that make the checks pass.
11
+ # @return [Hash<Symbol, Boolean | Integer | nil>]
12
+ def self.koans
13
+ {
14
+ truth: false,
15
+ with_message: false,
16
+ expected_value: nil,
17
+ better_expected_value: nil,
18
+ filled_value: nil
19
+ }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # Start with assertions
2
+
3
+ An assertion checks whether something is true. A passing check stays quiet;
4
+ a failing check tells you what to investigate.
5
+
6
+ Open your `about_asserts.rb` file and replace the five answers in `koans`:
7
+
8
+ - `truth`: make `assert truth` pass.
9
+ - `with_message`: make `assert with_message, "This should be true -- Please fix this"` pass.
10
+ - `expected_value`: supply the expected result for `1 + 1`, checked with `assert expected_value == actual_value`.
11
+ - `better_expected_value`: supply that same result, checked with `assert_equal expected_value, actual_value`.
12
+ - `filled_value`: fill the expectation in `assert_equal filled_value, 1 + 1`.
13
+
14
+ Start with one answer and save. Compare the failures for `expected_value` and
15
+ `better_expected_value`: `assert_equal` reports the expected and actual values,
16
+ which makes the failure easier to understand.
17
+
18
+ You only need to change the answers inside the braces. The surrounding Ruby code
19
+ will become familiar in later exercises. Save to rerun the checks automatically.
20
+
21
+ Adapted from **Ruby Koans: About Asserts** by Jim Weirich and Joe O'Brien.
22
+ Licensed under [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/).
@@ -0,0 +1,10 @@
1
+ # Hint: expectations and reality
2
+
3
+ `assert` passes when its value is truthy. Try `true` for the first two answers.
4
+ For the remaining answers, evaluate `1 + 1` and supply that result.
5
+
6
+ `assert_equal expected, actual` compares both values and explains a mismatch.
7
+ A message on `assert` gives you a clue about what went wrong.
8
+
9
+ Adapted from **Ruby Koans: About Asserts** by Jim Weirich and Joe O'Brien.
10
+ Licensed under [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/).
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-License-Identifier: CC-BY-NC-SA-3.0
4
+ # Adapted from Ruby Koans by Jim Weirich and Joe O'Brien.
5
+ # See THIRD_PARTY_NOTICES.md for attribution and license terms.
6
+
7
+ module Exercises
8
+ # Predictions for blocks examples.
9
+ class AboutBlocks
10
+ # Replace each :fill_me_in with the result of the described expression.
11
+ # @return [Hash<Symbol, Object>]
12
+ # This method is an answer table, not a sequence of operations.
13
+ def self.koans
14
+ {
15
+ # Methods can take blocks.
16
+ # yielded_result = method_with_block { 1 + 2 }
17
+ # assert_equal __, yielded_result
18
+ # Predict: yielded_result
19
+ methods_can_take_blocks_one: :fill_me_in,
20
+ # Blocks can be defined with do end too.
21
+ # yielded_result = method_with_block do 1 + 2 end
22
+ # assert_equal __, yielded_result
23
+ # Predict: yielded_result
24
+ blocks_can_be_defined_with_do_end_too_one: :fill_me_in,
25
+ # Blocks can take arguments.
26
+ # method_with_block_arguments do |argument|
27
+ # assert_equal __, argument
28
+ # end
29
+ # Predict: argument
30
+ blocks_can_take_arguments_one: :fill_me_in,
31
+ # Methods can call yield many times.
32
+ # result = []
33
+ # many_yields { |item| result << item }
34
+ # assert_equal __, result
35
+ # Predict: result
36
+ methods_can_call_yield_many_times_one: :fill_me_in,
37
+ # Methods can see if they have been called with a block.
38
+ # assert_equal __, yield_tester { :with_block }
39
+ # assert_equal __, yield_tester
40
+ # Predict: yield_tester { :with_block }
41
+ methods_can_see_if_they_have_been_called_with_a_block_one: :fill_me_in,
42
+ # Predict: yield_tester
43
+ methods_can_see_if_they_have_been_called_with_a_block_two: :fill_me_in,
44
+ # Block can affect variables in the code where they are created.
45
+ # value = :initial_value
46
+ # method_with_block { value = :modified_in_a_block }
47
+ # assert_equal __, value
48
+ # Predict: value
49
+ block_can_affect_variables_in_the_code_where_they_are_created_one: :fill_me_in,
50
+ # Blocks can be assigned to variables and called explicitly.
51
+ # add_one = lambda { |n| n + 1 }
52
+ # assert_equal __, add_one.call(10)
53
+ # Alternative calling syntax
54
+ # assert_equal __, add_one[10]
55
+ # Predict: add_one.call(10)
56
+ blocks_can_be_assigned_to_variables_and_called_explicitly_one: :fill_me_in,
57
+ # Predict: add_one[10]
58
+ blocks_can_be_assigned_to_variables_and_called_explicitly_two: :fill_me_in,
59
+ # Stand alone blocks can be passed to methods expecting blocks.
60
+ # make_upper = lambda { |n| n.upcase }
61
+ # result = method_with_block_arguments(&make_upper)
62
+ # assert_equal __, result
63
+ # Predict: result
64
+ stand_alone_blocks_can_be_passed_to_methods_expecting_blocks_one: :fill_me_in,
65
+ # Methods can take an explicit block argument.
66
+ # assert_equal __, method_with_explicit_block { |n| n * 2 }
67
+ # add_one = lambda { |n| n + 1 }
68
+ # assert_equal __, method_with_explicit_block(&add_one)
69
+ # Predict: method_with_explicit_block { |n| n * 2 }
70
+ methods_can_take_an_explicit_block_argument_one: :fill_me_in,
71
+ # Predict: method_with_explicit_block(&add_one)
72
+ methods_can_take_an_explicit_block_argument_two: :fill_me_in
73
+ }
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,44 @@
1
+ # About Blocks
2
+
3
+ Replace each `:fill_me_in` in `about_blocks.rb` with the predicted result.
4
+ Each field identifies its example. Run the checks after edits to investigate the
5
+ next prediction. Answers include the Ruby values and exception classes shown by
6
+ the examples. Read the setup comments before evaluating an expression.
7
+
8
+ ## Example definitions
9
+
10
+ These definitions supply the objects and methods used by the prediction examples.
11
+ They run in the check class `AboutBlocksTest`.
12
+
13
+ ```ruby
14
+ def method_with_block
15
+ result = yield
16
+ result
17
+ end
18
+
19
+ def method_with_block_arguments
20
+ yield("Jim")
21
+ end
22
+
23
+ def many_yields
24
+ yield(:peanut)
25
+ yield(:butter)
26
+ yield(:and)
27
+ yield(:jelly)
28
+ end
29
+
30
+ def yield_tester
31
+ if block_given?
32
+ yield
33
+ else
34
+ :no_block
35
+ end
36
+ end
37
+
38
+ def method_with_explicit_block(&block)
39
+ block.call(10)
40
+ end
41
+ ```
42
+
43
+ Adapted from Ruby Koans by Jim Weirich and Joe O'Brien, licensed under
44
+ CC BY-NC-SA 3.0. See `THIRD_PARTY_NOTICES.md` for attribution and license terms.
@@ -0,0 +1,7 @@
1
+ # Hint
2
+
3
+ Follow each `yield`, including its arguments and return value. Blocks capture
4
+ variables from their surrounding scope. `&` passes a callable as a block.
5
+
6
+ Adapted from Ruby Koans by Jim Weirich and Joe O'Brien, licensed under
7
+ CC BY-NC-SA 3.0. See `THIRD_PARTY_NOTICES.md` for attribution and license terms.