@k2works/claude-code-booster 4.11.0 → 4.12.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 (749) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +42 -42
  3. package/bin/claude-code-booster +90 -90
  4. package/lib/assets/.claude/README.md +281 -279
  5. package/lib/assets/.claude/agents/xp-architect.md +250 -250
  6. package/lib/assets/.claude/agents/xp-executive.md +207 -207
  7. package/lib/assets/.claude/agents/xp-interaction-designer.md +239 -239
  8. package/lib/assets/.claude/agents/xp-product-manager.md +245 -245
  9. package/lib/assets/.claude/agents/xp-programmer.md +268 -268
  10. package/lib/assets/.claude/agents/xp-project-manager.md +229 -229
  11. package/lib/assets/.claude/agents/xp-technical-writer.md +224 -224
  12. package/lib/assets/.claude/agents/xp-tester.md +265 -265
  13. package/lib/assets/.claude/agents/xp-user-representative.md +204 -204
  14. package/lib/assets/.claude/scripts/generate-inception-deck.mjs +911 -911
  15. package/lib/assets/.claude/settings.json +11 -11
  16. package/lib/assets/.claude/skills/ai-agent-guidelines/SKILL.md +111 -111
  17. package/lib/assets/.claude/skills/analyzing-architecture/SKILL.md +83 -83
  18. package/lib/assets/.claude/skills/analyzing-business-architecture/SKILL.md +122 -122
  19. package/lib/assets/.claude/skills/analyzing-business-case/SKILL.md +148 -148
  20. package/lib/assets/.claude/skills/analyzing-business-strategy/SKILL.md +277 -277
  21. package/lib/assets/.claude/skills/analyzing-data-model/SKILL.md +77 -77
  22. package/lib/assets/.claude/skills/analyzing-domain-model/SKILL.md +117 -117
  23. package/lib/assets/.claude/skills/analyzing-inception-deck/SKILL.md +84 -84
  24. package/lib/assets/.claude/skills/analyzing-non-functional/SKILL.md +95 -95
  25. package/lib/assets/.claude/skills/analyzing-operation/SKILL.md +95 -95
  26. package/lib/assets/.claude/skills/analyzing-requirements/SKILL.md +91 -91
  27. package/lib/assets/.claude/skills/analyzing-review/SKILL.md +174 -174
  28. package/lib/assets/.claude/skills/analyzing-tech-stack/SKILL.md +101 -101
  29. package/lib/assets/.claude/skills/analyzing-test-strategy/SKILL.md +89 -89
  30. package/lib/assets/.claude/skills/analyzing-ui-design/SKILL.md +80 -80
  31. package/lib/assets/.claude/skills/analyzing-usecases/SKILL.md +72 -72
  32. package/lib/assets/.claude/skills/closing-iteration/SKILL.md +129 -0
  33. package/lib/assets/.claude/skills/creating-adr/SKILL.md +113 -113
  34. package/lib/assets/.claude/skills/creating-development-strategy/SKILL.md +101 -101
  35. package/lib/assets/.claude/skills/creating-iteration-report/SKILL.md +210 -210
  36. package/lib/assets/.claude/skills/creating-journal/SKILL.md +129 -129
  37. package/lib/assets/.claude/skills/creating-release-report/SKILL.md +161 -161
  38. package/lib/assets/.claude/skills/creating-slides/SKILL.md +86 -86
  39. package/lib/assets/.claude/skills/creating-slides/agents/openai.yaml +4 -4
  40. package/lib/assets/.claude/skills/creating-slides/references/manga-css.md +45 -45
  41. package/lib/assets/.claude/skills/creating-slides/scripts/slide_tools.py +239 -239
  42. package/lib/assets/.claude/skills/developing-backend/SKILL.md +100 -100
  43. package/lib/assets/.claude/skills/developing-frontend/SKILL.md +93 -93
  44. package/lib/assets/.claude/skills/developing-release/SKILL.md +120 -120
  45. package/lib/assets/.claude/skills/developing-review/SKILL.md +175 -175
  46. package/lib/assets/.claude/skills/developing-uiux-review/SKILL.md +207 -207
  47. package/lib/assets/.claude/skills/generating-bmc/SKILL.md +123 -123
  48. package/lib/assets/.claude/skills/generating-slides/SKILL.md +94 -94
  49. package/lib/assets/.claude/skills/git-commit/SKILL.md +81 -81
  50. package/lib/assets/.claude/skills/killing-processes/SKILL.md +44 -44
  51. package/lib/assets/.claude/skills/opening-iteration/SKILL.md +105 -0
  52. package/lib/assets/.claude/skills/operating-backup/SKILL.md +59 -59
  53. package/lib/assets/.claude/skills/operating-cicd/SKILL.md +54 -54
  54. package/lib/assets/.claude/skills/operating-deploy/SKILL.md +67 -67
  55. package/lib/assets/.claude/skills/operating-docs/SKILL.md +219 -219
  56. package/lib/assets/.claude/skills/operating-provision/SKILL.md +77 -77
  57. package/lib/assets/.claude/skills/operating-qt/SKILL.md +147 -147
  58. package/lib/assets/.claude/skills/operating-review/SKILL.md +171 -171
  59. package/lib/assets/.claude/skills/operating-script/SKILL.md +145 -145
  60. package/lib/assets/.claude/skills/operating-setup/SKILL.md +63 -63
  61. package/lib/assets/.claude/skills/orchestrating-analysis/SKILL.md +104 -104
  62. package/lib/assets/.claude/skills/orchestrating-development/SKILL.md +168 -168
  63. package/lib/assets/.claude/skills/orchestrating-operation/SKILL.md +158 -158
  64. package/lib/assets/.claude/skills/orchestrating-project/SKILL.md +144 -144
  65. package/lib/assets/.claude/skills/planning-releases/SKILL.md +119 -119
  66. package/lib/assets/.claude/skills/practicing-getting-start-tdd/SKILL.md +266 -266
  67. package/lib/assets/.claude/skills/syncing-github-project/SKILL.md +151 -151
  68. package/lib/assets/.claude/skills/tracking-progress/SKILL.md +91 -91
  69. package/lib/assets/.claude/skills/validating-design/SKILL.md +130 -130
  70. package/lib/assets/.claude/skills/validating-iteration-plan/SKILL.md +238 -238
  71. package/lib/assets/.claude/skills/validating-operating-setup/SKILL.md +118 -118
  72. package/lib/assets/.devcontainer/devcontainer.json +37 -37
  73. package/lib/assets/.env.example +17 -17
  74. package/lib/assets/.gitattributes +4 -4
  75. package/lib/assets/.github/workflows/docker-publish.yml +77 -77
  76. package/lib/assets/.github/workflows/mkdocs.yml +39 -39
  77. package/lib/assets/AGENTS.md +94 -94
  78. package/lib/assets/CLAUDE.md +197 -195
  79. package/lib/assets/README.md +291 -291
  80. package/lib/assets/docker-compose.yml +33 -33
  81. package/lib/assets/docs/adr/index.md +10 -10
  82. package/lib/assets/docs/article/functional-desgin-ppp/all/01-immutability-and-data-transformation.md +475 -475
  83. package/lib/assets/docs/article/functional-desgin-ppp/all/02-function-composition.md +519 -519
  84. package/lib/assets/docs/article/functional-desgin-ppp/all/03-polymorphism.md +537 -537
  85. package/lib/assets/docs/article/functional-desgin-ppp/all/04-data-validation.md +300 -300
  86. package/lib/assets/docs/article/functional-desgin-ppp/all/05-property-based-testing.md +320 -320
  87. package/lib/assets/docs/article/functional-desgin-ppp/all/06-tdd-and-functional.md +498 -498
  88. package/lib/assets/docs/article/functional-desgin-ppp/all/07-composite-pattern.md +298 -298
  89. package/lib/assets/docs/article/functional-desgin-ppp/all/08-decorator-pattern.md +291 -291
  90. package/lib/assets/docs/article/functional-desgin-ppp/all/09-adapter-pattern.md +336 -336
  91. package/lib/assets/docs/article/functional-desgin-ppp/all/10-strategy-pattern.md +303 -303
  92. package/lib/assets/docs/article/functional-desgin-ppp/all/11-command-pattern.md +286 -286
  93. package/lib/assets/docs/article/functional-desgin-ppp/all/12-visitor-pattern.md +322 -322
  94. package/lib/assets/docs/article/functional-desgin-ppp/all/13-abstract-factory-pattern.md +319 -319
  95. package/lib/assets/docs/article/functional-desgin-ppp/all/14-abstract-server-pattern.md +365 -365
  96. package/lib/assets/docs/article/functional-desgin-ppp/all/15-gossiping-bus-drivers.md +156 -156
  97. package/lib/assets/docs/article/functional-desgin-ppp/all/16-payroll-system.md +178 -178
  98. package/lib/assets/docs/article/functional-desgin-ppp/all/17-video-rental-system.md +312 -312
  99. package/lib/assets/docs/article/functional-desgin-ppp/all/18-concurrency-system.md +287 -287
  100. package/lib/assets/docs/article/functional-desgin-ppp/all/19-wa-tor-simulation.md +286 -286
  101. package/lib/assets/docs/article/functional-desgin-ppp/all/20-pattern-interactions.md +274 -274
  102. package/lib/assets/docs/article/functional-desgin-ppp/all/21-best-practices.md +294 -294
  103. package/lib/assets/docs/article/functional-desgin-ppp/all/22-oo-to-fp-migration.md +337 -337
  104. package/lib/assets/docs/article/functional-desgin-ppp/all/index.md +388 -388
  105. package/lib/assets/docs/article/functional-desgin-ppp/clojure/01-immutability-and-data-transformation.md +273 -273
  106. package/lib/assets/docs/article/functional-desgin-ppp/clojure/02-function-composition.md +380 -380
  107. package/lib/assets/docs/article/functional-desgin-ppp/clojure/03-polymorphism.md +384 -384
  108. package/lib/assets/docs/article/functional-desgin-ppp/clojure/04-clojure-spec.md +350 -350
  109. package/lib/assets/docs/article/functional-desgin-ppp/clojure/05-property-based-testing.md +352 -352
  110. package/lib/assets/docs/article/functional-desgin-ppp/clojure/06-tdd-in-functional.md +383 -383
  111. package/lib/assets/docs/article/functional-desgin-ppp/clojure/07-composite-pattern.md +529 -529
  112. package/lib/assets/docs/article/functional-desgin-ppp/clojure/08-decorator-pattern.md +395 -395
  113. package/lib/assets/docs/article/functional-desgin-ppp/clojure/09-adapter-pattern.md +399 -399
  114. package/lib/assets/docs/article/functional-desgin-ppp/clojure/10-strategy-pattern.md +485 -485
  115. package/lib/assets/docs/article/functional-desgin-ppp/clojure/11-command-pattern.md +566 -566
  116. package/lib/assets/docs/article/functional-desgin-ppp/clojure/12-visitor-pattern.md +567 -567
  117. package/lib/assets/docs/article/functional-desgin-ppp/clojure/13-abstract-factory-pattern.md +475 -475
  118. package/lib/assets/docs/article/functional-desgin-ppp/clojure/14-abstract-server-pattern.md +462 -462
  119. package/lib/assets/docs/article/functional-desgin-ppp/clojure/15-gossiping-bus-drivers.md +325 -325
  120. package/lib/assets/docs/article/functional-desgin-ppp/clojure/16-payroll-system.md +401 -401
  121. package/lib/assets/docs/article/functional-desgin-ppp/clojure/17-video-rental-system.md +450 -450
  122. package/lib/assets/docs/article/functional-desgin-ppp/clojure/18-concurrency-system.md +475 -475
  123. package/lib/assets/docs/article/functional-desgin-ppp/clojure/19-wator-simulation.md +739 -739
  124. package/lib/assets/docs/article/functional-desgin-ppp/clojure/20-pattern-interactions.md +567 -567
  125. package/lib/assets/docs/article/functional-desgin-ppp/clojure/21-best-practices.md +518 -518
  126. package/lib/assets/docs/article/functional-desgin-ppp/clojure/22-oo-to-fp-migration.md +532 -532
  127. package/lib/assets/docs/article/functional-desgin-ppp/clojure/index.md +241 -241
  128. package/lib/assets/docs/article/functional-desgin-ppp/elixir/01-immutability-and-data-transformation.md +383 -383
  129. package/lib/assets/docs/article/functional-desgin-ppp/elixir/02-function-composition.md +374 -374
  130. package/lib/assets/docs/article/functional-desgin-ppp/elixir/03-polymorphism.md +375 -375
  131. package/lib/assets/docs/article/functional-desgin-ppp/elixir/04-data-validation.md +195 -195
  132. package/lib/assets/docs/article/functional-desgin-ppp/elixir/05-property-based-testing.md +268 -268
  133. package/lib/assets/docs/article/functional-desgin-ppp/elixir/06-tdd-and-fp.md +294 -294
  134. package/lib/assets/docs/article/functional-desgin-ppp/elixir/07-effects-and-pure-functions.md +164 -164
  135. package/lib/assets/docs/article/functional-desgin-ppp/elixir/08-error-handling-strategies.md +168 -168
  136. package/lib/assets/docs/article/functional-desgin-ppp/elixir/09-io-and-external-systems.md +254 -254
  137. package/lib/assets/docs/article/functional-desgin-ppp/elixir/10-concurrency-patterns.md +269 -269
  138. package/lib/assets/docs/article/functional-desgin-ppp/elixir/11-command-pattern.md +148 -148
  139. package/lib/assets/docs/article/functional-desgin-ppp/elixir/12-visitor-pattern.md +176 -176
  140. package/lib/assets/docs/article/functional-desgin-ppp/elixir/13-abstract-factory-pattern.md +604 -604
  141. package/lib/assets/docs/article/functional-desgin-ppp/elixir/14-abstract-server-pattern.md +729 -729
  142. package/lib/assets/docs/article/functional-desgin-ppp/elixir/15-gossiping-bus-drivers.md +291 -291
  143. package/lib/assets/docs/article/functional-desgin-ppp/elixir/16-payroll-system.md +420 -420
  144. package/lib/assets/docs/article/functional-desgin-ppp/elixir/17-video-rental-system.md +319 -319
  145. package/lib/assets/docs/article/functional-desgin-ppp/elixir/18-concurrency-system.md +466 -466
  146. package/lib/assets/docs/article/functional-desgin-ppp/elixir/19-wator-simulation.md +523 -523
  147. package/lib/assets/docs/article/functional-desgin-ppp/elixir/20-pattern-interactions.md +287 -287
  148. package/lib/assets/docs/article/functional-desgin-ppp/elixir/21-best-practices.md +340 -340
  149. package/lib/assets/docs/article/functional-desgin-ppp/elixir/22-oo-to-fp-migration.md +395 -395
  150. package/lib/assets/docs/article/functional-desgin-ppp/elixir/index.md +248 -248
  151. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/01-immutability-and-data-transformation.md +384 -384
  152. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/02-function-composition.md +452 -452
  153. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/03-polymorphism.md +495 -495
  154. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/04-data-validation.md +416 -416
  155. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/05-property-based-testing.md +382 -382
  156. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/06-tdd-functional.md +687 -687
  157. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/07-composite-pattern.md +442 -442
  158. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/08-decorator-pattern.md +479 -479
  159. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/09-adapter-pattern.md +479 -479
  160. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/10-strategy-pattern.md +427 -427
  161. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/11-command-pattern.md +428 -428
  162. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/12-visitor-pattern.md +339 -339
  163. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/13-abstract-factory-pattern.md +309 -309
  164. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/14-abstract-server-pattern.md +596 -596
  165. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/15-gossiping-bus-drivers.md +355 -355
  166. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/16-payroll-system.md +350 -350
  167. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/17-video-rental-system.md +414 -414
  168. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/18-concurrency-system.md +367 -367
  169. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/19-wator-simulation.md +403 -403
  170. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/20-pattern-interactions.md +291 -291
  171. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/21-best-practices.md +324 -324
  172. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/22-oo-to-fp-migration.md +332 -332
  173. package/lib/assets/docs/article/functional-desgin-ppp/fsharp/index.md +274 -274
  174. package/lib/assets/docs/article/functional-desgin-ppp/haskell/01-immutability-and-data-transformation.md +298 -298
  175. package/lib/assets/docs/article/functional-desgin-ppp/haskell/02-function-composition.md +304 -304
  176. package/lib/assets/docs/article/functional-desgin-ppp/haskell/03-polymorphism.md +362 -362
  177. package/lib/assets/docs/article/functional-desgin-ppp/haskell/04-data-validation.md +257 -257
  178. package/lib/assets/docs/article/functional-desgin-ppp/haskell/05-property-based-testing.md +254 -254
  179. package/lib/assets/docs/article/functional-desgin-ppp/haskell/06-tdd-functional.md +283 -283
  180. package/lib/assets/docs/article/functional-desgin-ppp/haskell/07-composite-pattern.md +395 -395
  181. package/lib/assets/docs/article/functional-desgin-ppp/haskell/08-decorator-pattern.md +319 -319
  182. package/lib/assets/docs/article/functional-desgin-ppp/haskell/09-adapter-pattern.md +382 -382
  183. package/lib/assets/docs/article/functional-desgin-ppp/haskell/10-strategy-pattern.md +287 -287
  184. package/lib/assets/docs/article/functional-desgin-ppp/haskell/11-command-pattern.md +303 -303
  185. package/lib/assets/docs/article/functional-desgin-ppp/haskell/12-visitor-pattern.md +326 -326
  186. package/lib/assets/docs/article/functional-desgin-ppp/haskell/13-abstract-factory-pattern.md +332 -332
  187. package/lib/assets/docs/article/functional-desgin-ppp/haskell/14-abstract-server-pattern.md +379 -379
  188. package/lib/assets/docs/article/functional-desgin-ppp/haskell/15-gossiping-bus-drivers.md +177 -177
  189. package/lib/assets/docs/article/functional-desgin-ppp/haskell/16-payroll-system.md +219 -219
  190. package/lib/assets/docs/article/functional-desgin-ppp/haskell/17-video-rental-system.md +244 -244
  191. package/lib/assets/docs/article/functional-desgin-ppp/haskell/18-concurrency-system.md +363 -363
  192. package/lib/assets/docs/article/functional-desgin-ppp/haskell/19-wator-simulation.md +438 -438
  193. package/lib/assets/docs/article/functional-desgin-ppp/haskell/20-pattern-interactions.md +325 -325
  194. package/lib/assets/docs/article/functional-desgin-ppp/haskell/21-best-practices.md +403 -403
  195. package/lib/assets/docs/article/functional-desgin-ppp/haskell/22-oo-to-fp-migration.md +469 -469
  196. package/lib/assets/docs/article/functional-desgin-ppp/haskell/index.md +174 -174
  197. package/lib/assets/docs/article/functional-desgin-ppp/index.md +90 -90
  198. package/lib/assets/docs/article/functional-desgin-ppp/rust/01-immutability-and-data-transformation.md +450 -450
  199. package/lib/assets/docs/article/functional-desgin-ppp/rust/02-function-composition.md +463 -463
  200. package/lib/assets/docs/article/functional-desgin-ppp/rust/03-polymorphism.md +425 -425
  201. package/lib/assets/docs/article/functional-desgin-ppp/rust/04-data-validation.md +273 -273
  202. package/lib/assets/docs/article/functional-desgin-ppp/rust/05-property-based-testing.md +247 -247
  203. package/lib/assets/docs/article/functional-desgin-ppp/rust/06-tdd-and-functional.md +841 -841
  204. package/lib/assets/docs/article/functional-desgin-ppp/rust/07-composite-pattern.md +384 -384
  205. package/lib/assets/docs/article/functional-desgin-ppp/rust/08-decorator-pattern.md +383 -383
  206. package/lib/assets/docs/article/functional-desgin-ppp/rust/09-adapter-pattern.md +339 -339
  207. package/lib/assets/docs/article/functional-desgin-ppp/rust/10-strategy-pattern.md +331 -331
  208. package/lib/assets/docs/article/functional-desgin-ppp/rust/11-command-pattern.md +356 -356
  209. package/lib/assets/docs/article/functional-desgin-ppp/rust/12-visitor-pattern.md +379 -379
  210. package/lib/assets/docs/article/functional-desgin-ppp/rust/13-abstract-factory-pattern.md +361 -361
  211. package/lib/assets/docs/article/functional-desgin-ppp/rust/14-abstract-server-pattern.md +392 -392
  212. package/lib/assets/docs/article/functional-desgin-ppp/rust/15-gossiping-bus-drivers.md +300 -300
  213. package/lib/assets/docs/article/functional-desgin-ppp/rust/16-payroll-system.md +297 -297
  214. package/lib/assets/docs/article/functional-desgin-ppp/rust/17-video-rental-system.md +304 -304
  215. package/lib/assets/docs/article/functional-desgin-ppp/rust/18-concurrency-system.md +315 -315
  216. package/lib/assets/docs/article/functional-desgin-ppp/rust/19-wator-simulation.md +311 -311
  217. package/lib/assets/docs/article/functional-desgin-ppp/rust/20-pattern-interactions.md +304 -304
  218. package/lib/assets/docs/article/functional-desgin-ppp/rust/21-best-practices.md +336 -336
  219. package/lib/assets/docs/article/functional-desgin-ppp/rust/22-oo-to-fp-migration.md +349 -349
  220. package/lib/assets/docs/article/functional-desgin-ppp/rust/index.md +243 -243
  221. package/lib/assets/docs/article/functional-desgin-ppp/scala/01-immutability-and-data-transformation.md +328 -328
  222. package/lib/assets/docs/article/functional-desgin-ppp/scala/02-function-composition.md +348 -348
  223. package/lib/assets/docs/article/functional-desgin-ppp/scala/03-polymorphism.md +357 -357
  224. package/lib/assets/docs/article/functional-desgin-ppp/scala/04-data-validation.md +364 -364
  225. package/lib/assets/docs/article/functional-desgin-ppp/scala/05-property-based-testing.md +515 -515
  226. package/lib/assets/docs/article/functional-desgin-ppp/scala/06-tdd-functional.md +557 -557
  227. package/lib/assets/docs/article/functional-desgin-ppp/scala/07-composite-pattern.md +363 -363
  228. package/lib/assets/docs/article/functional-desgin-ppp/scala/08-decorator-pattern.md +327 -327
  229. package/lib/assets/docs/article/functional-desgin-ppp/scala/09-adapter-pattern.md +517 -517
  230. package/lib/assets/docs/article/functional-desgin-ppp/scala/10-strategy-pattern.md +441 -441
  231. package/lib/assets/docs/article/functional-desgin-ppp/scala/11-command-pattern.md +407 -407
  232. package/lib/assets/docs/article/functional-desgin-ppp/scala/12-visitor-pattern.md +379 -379
  233. package/lib/assets/docs/article/functional-desgin-ppp/scala/13-abstract-factory-pattern.md +398 -398
  234. package/lib/assets/docs/article/functional-desgin-ppp/scala/14-abstract-server-pattern.md +476 -476
  235. package/lib/assets/docs/article/functional-desgin-ppp/scala/15-gossiping-bus-drivers.md +391 -391
  236. package/lib/assets/docs/article/functional-desgin-ppp/scala/16-payroll-system.md +342 -342
  237. package/lib/assets/docs/article/functional-desgin-ppp/scala/17-video-rental-system.md +324 -324
  238. package/lib/assets/docs/article/functional-desgin-ppp/scala/18-concurrency-system.md +730 -730
  239. package/lib/assets/docs/article/functional-desgin-ppp/scala/19-wator-simulation.md +624 -624
  240. package/lib/assets/docs/article/functional-desgin-ppp/scala/20-pattern-interactions.md +512 -512
  241. package/lib/assets/docs/article/functional-desgin-ppp/scala/21-best-practices.md +433 -433
  242. package/lib/assets/docs/article/functional-desgin-ppp/scala/22-oo-to-fp-migration.md +688 -688
  243. package/lib/assets/docs/article/functional-desgin-ppp/scala/index.md +243 -243
  244. package/lib/assets/docs/article/getting-start-tdd/clojure/01-todo-list-and-first-test.md +166 -166
  245. package/lib/assets/docs/article/getting-start-tdd/clojure/02-fake-it-and-triangulation.md +162 -162
  246. package/lib/assets/docs/article/getting-start-tdd/clojure/03-obvious-implementation-and-refactoring.md +135 -135
  247. package/lib/assets/docs/article/getting-start-tdd/clojure/04-version-control-and-conventional-commits.md +88 -88
  248. package/lib/assets/docs/article/getting-start-tdd/clojure/05-package-management-and-static-analysis.md +299 -299
  249. package/lib/assets/docs/article/getting-start-tdd/clojure/06-task-runner-and-ci-cd.md +241 -241
  250. package/lib/assets/docs/article/getting-start-tdd/clojure/07-protocols-and-records.md +131 -131
  251. package/lib/assets/docs/article/getting-start-tdd/clojure/08-multimethods-and-design-patterns.md +130 -130
  252. package/lib/assets/docs/article/getting-start-tdd/clojure/09-namespaces-and-module-design.md +127 -127
  253. package/lib/assets/docs/article/getting-start-tdd/clojure/10-higher-order-functions-and-composition.md +114 -114
  254. package/lib/assets/docs/article/getting-start-tdd/clojure/11-persistent-data-and-pipeline.md +138 -138
  255. package/lib/assets/docs/article/getting-start-tdd/clojure/12-error-handling-and-spec.md +161 -161
  256. package/lib/assets/docs/article/getting-start-tdd/clojure/index.md +65 -65
  257. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter01.md +232 -232
  258. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter02.md +244 -244
  259. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter03.md +202 -202
  260. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter04.md +92 -92
  261. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter05.md +256 -256
  262. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter06.md +195 -195
  263. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter07.md +214 -214
  264. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter08.md +249 -249
  265. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter09.md +174 -174
  266. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter10.md +166 -166
  267. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter11.md +192 -192
  268. package/lib/assets/docs/article/getting-start-tdd/csharp/chapter12.md +211 -211
  269. package/lib/assets/docs/article/getting-start-tdd/csharp/index.md +83 -83
  270. package/lib/assets/docs/article/getting-start-tdd/elixir/01-todo-list-and-first-test.md +87 -87
  271. package/lib/assets/docs/article/getting-start-tdd/elixir/02-fake-it-and-triangulation.md +95 -95
  272. package/lib/assets/docs/article/getting-start-tdd/elixir/03-obvious-implementation-and-refactoring.md +109 -109
  273. package/lib/assets/docs/article/getting-start-tdd/elixir/04-version-control-and-conventional-commits.md +96 -96
  274. package/lib/assets/docs/article/getting-start-tdd/elixir/05-package-management-and-static-analysis.md +88 -88
  275. package/lib/assets/docs/article/getting-start-tdd/elixir/06-task-runner-and-ci-cd.md +71 -71
  276. package/lib/assets/docs/article/getting-start-tdd/elixir/07-structs-and-protocols.md +110 -110
  277. package/lib/assets/docs/article/getting-start-tdd/elixir/08-pattern-matching-and-guards.md +108 -108
  278. package/lib/assets/docs/article/getting-start-tdd/elixir/09-module-design-and-behaviours.md +104 -104
  279. package/lib/assets/docs/article/getting-start-tdd/elixir/10-higher-order-functions-and-pipeline.md +178 -178
  280. package/lib/assets/docs/article/getting-start-tdd/elixir/11-stream-and-lazy-evaluation.md +142 -142
  281. package/lib/assets/docs/article/getting-start-tdd/elixir/12-error-handling-and-with.md +145 -145
  282. package/lib/assets/docs/article/getting-start-tdd/elixir/index.md +35 -35
  283. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter01.md +202 -202
  284. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter02.md +246 -246
  285. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter03.md +218 -218
  286. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter04.md +179 -179
  287. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter05.md +267 -267
  288. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter06.md +190 -190
  289. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter07.md +161 -161
  290. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter08.md +175 -175
  291. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter09.md +222 -222
  292. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter10.md +189 -189
  293. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter11.md +212 -212
  294. package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter12.md +215 -215
  295. package/lib/assets/docs/article/getting-start-tdd/fsharp/index.md +71 -71
  296. package/lib/assets/docs/article/getting-start-tdd/go/01-todo-list-and-first-test.md +213 -213
  297. package/lib/assets/docs/article/getting-start-tdd/go/02-fake-it-and-triangulation.md +302 -302
  298. package/lib/assets/docs/article/getting-start-tdd/go/03-obvious-implementation-and-refactoring.md +339 -339
  299. package/lib/assets/docs/article/getting-start-tdd/go/04-version-control-and-conventional-commits.md +112 -112
  300. package/lib/assets/docs/article/getting-start-tdd/go/05-package-management-and-static-analysis.md +272 -272
  301. package/lib/assets/docs/article/getting-start-tdd/go/06-task-runner-and-ci-cd.md +233 -233
  302. package/lib/assets/docs/article/getting-start-tdd/go/07-encapsulation-and-polymorphism.md +394 -394
  303. package/lib/assets/docs/article/getting-start-tdd/go/08-design-patterns.md +422 -422
  304. package/lib/assets/docs/article/getting-start-tdd/go/09-solid-principles-and-module-design.md +400 -400
  305. package/lib/assets/docs/article/getting-start-tdd/go/10-higher-order-functions-and-composition.md +226 -226
  306. package/lib/assets/docs/article/getting-start-tdd/go/11-immutable-data-and-pipeline.md +296 -296
  307. package/lib/assets/docs/article/getting-start-tdd/go/12-error-handling-and-type-safety.md +411 -411
  308. package/lib/assets/docs/article/getting-start-tdd/go/index.md +83 -83
  309. package/lib/assets/docs/article/getting-start-tdd/haskell/01-todo-list-and-first-test.md +279 -279
  310. package/lib/assets/docs/article/getting-start-tdd/haskell/02-fake-it-and-triangulation.md +337 -337
  311. package/lib/assets/docs/article/getting-start-tdd/haskell/03-obvious-implementation-and-refactoring.md +257 -257
  312. package/lib/assets/docs/article/getting-start-tdd/haskell/04-version-control-and-conventional-commits.md +182 -182
  313. package/lib/assets/docs/article/getting-start-tdd/haskell/05-package-management-and-static-analysis.md +313 -313
  314. package/lib/assets/docs/article/getting-start-tdd/haskell/06-task-runner-and-ci-cd.md +309 -309
  315. package/lib/assets/docs/article/getting-start-tdd/haskell/07-algebraic-data-types-and-type-classes.md +412 -412
  316. package/lib/assets/docs/article/getting-start-tdd/haskell/08-pattern-matching-and-guards.md +390 -390
  317. package/lib/assets/docs/article/getting-start-tdd/haskell/09-module-design-and-smart-constructors.md +461 -461
  318. package/lib/assets/docs/article/getting-start-tdd/haskell/10-higher-order-functions-and-currying.md +434 -434
  319. package/lib/assets/docs/article/getting-start-tdd/haskell/11-function-composition-and-point-free.md +392 -392
  320. package/lib/assets/docs/article/getting-start-tdd/haskell/12-monad-and-error-handling.md +631 -631
  321. package/lib/assets/docs/article/getting-start-tdd/haskell/index.md +49 -49
  322. package/lib/assets/docs/article/getting-start-tdd/index.md +93 -93
  323. package/lib/assets/docs/article/getting-start-tdd/integration/01-language-overview.md +375 -375
  324. package/lib/assets/docs/article/getting-start-tdd/integration/02-test-framework-comparison.md +349 -349
  325. package/lib/assets/docs/article/getting-start-tdd/integration/03-tdd-pattern-comparison.md +445 -445
  326. package/lib/assets/docs/article/getting-start-tdd/integration/04-type-system-comparison.md +409 -409
  327. package/lib/assets/docs/article/getting-start-tdd/integration/05-dev-environment-comparison.md +330 -330
  328. package/lib/assets/docs/article/getting-start-tdd/integration/06-learning-roadmap.md +290 -290
  329. package/lib/assets/docs/article/getting-start-tdd/integration/index.md +69 -69
  330. package/lib/assets/docs/article/getting-start-tdd/java/01-todo-list-and-first-test.md +234 -234
  331. package/lib/assets/docs/article/getting-start-tdd/java/02-fake-it-and-triangulation.md +261 -261
  332. package/lib/assets/docs/article/getting-start-tdd/java/03-obvious-implementation-and-refactoring.md +185 -185
  333. package/lib/assets/docs/article/getting-start-tdd/java/04-version-control-and-conventional-commits.md +115 -115
  334. package/lib/assets/docs/article/getting-start-tdd/java/05-package-management-and-static-analysis.md +382 -382
  335. package/lib/assets/docs/article/getting-start-tdd/java/06-task-runner-and-ci-cd.md +272 -272
  336. package/lib/assets/docs/article/getting-start-tdd/java/07-encapsulation-and-polymorphism.md +626 -626
  337. package/lib/assets/docs/article/getting-start-tdd/java/08-design-patterns.md +393 -393
  338. package/lib/assets/docs/article/getting-start-tdd/java/09-solid-principles-and-module-design.md +310 -310
  339. package/lib/assets/docs/article/getting-start-tdd/java/10-higher-order-functions-and-composition.md +188 -188
  340. package/lib/assets/docs/article/getting-start-tdd/java/11-immutable-data-and-pipeline.md +167 -167
  341. package/lib/assets/docs/article/getting-start-tdd/java/12-error-handling-and-type-safety.md +205 -205
  342. package/lib/assets/docs/article/getting-start-tdd/java/index.md +61 -61
  343. package/lib/assets/docs/article/getting-start-tdd/node/01-todo-list-and-first-test.md +244 -244
  344. package/lib/assets/docs/article/getting-start-tdd/node/02-fake-it-and-triangulation.md +262 -262
  345. package/lib/assets/docs/article/getting-start-tdd/node/03-obvious-implementation-and-refactoring.md +169 -169
  346. package/lib/assets/docs/article/getting-start-tdd/node/04-version-control-and-conventional-commits.md +112 -112
  347. package/lib/assets/docs/article/getting-start-tdd/node/05-package-management-and-static-analysis.md +314 -314
  348. package/lib/assets/docs/article/getting-start-tdd/node/06-task-runner-and-ci-cd.md +235 -235
  349. package/lib/assets/docs/article/getting-start-tdd/node/07-encapsulation-and-polymorphism.md +327 -327
  350. package/lib/assets/docs/article/getting-start-tdd/node/08-design-patterns.md +322 -322
  351. package/lib/assets/docs/article/getting-start-tdd/node/09-solid-principles-and-module-design.md +285 -285
  352. package/lib/assets/docs/article/getting-start-tdd/node/10-higher-order-functions-and-composition.md +199 -199
  353. package/lib/assets/docs/article/getting-start-tdd/node/11-immutable-data-and-pipeline.md +207 -207
  354. package/lib/assets/docs/article/getting-start-tdd/node/12-error-handling-and-type-safety.md +295 -295
  355. package/lib/assets/docs/article/getting-start-tdd/node/index.md +56 -56
  356. package/lib/assets/docs/article/getting-start-tdd/php/01-todo-list-and-first-test.md +259 -259
  357. package/lib/assets/docs/article/getting-start-tdd/php/02-fake-it-and-triangulation.md +200 -200
  358. package/lib/assets/docs/article/getting-start-tdd/php/03-obvious-implementation-and-refactoring.md +248 -248
  359. package/lib/assets/docs/article/getting-start-tdd/php/04-version-control-and-conventional-commits.md +141 -141
  360. package/lib/assets/docs/article/getting-start-tdd/php/05-package-management-and-static-analysis.md +410 -410
  361. package/lib/assets/docs/article/getting-start-tdd/php/06-task-runner-and-ci-cd.md +321 -321
  362. package/lib/assets/docs/article/getting-start-tdd/php/07-encapsulation-and-polymorphism.md +372 -372
  363. package/lib/assets/docs/article/getting-start-tdd/php/08-design-patterns.md +453 -453
  364. package/lib/assets/docs/article/getting-start-tdd/php/09-solid-principles-and-module-design.md +460 -460
  365. package/lib/assets/docs/article/getting-start-tdd/php/10-higher-order-functions-and-composition.md +182 -182
  366. package/lib/assets/docs/article/getting-start-tdd/php/11-immutable-data-and-pipeline.md +266 -266
  367. package/lib/assets/docs/article/getting-start-tdd/php/12-error-handling-and-type-safety.md +308 -308
  368. package/lib/assets/docs/article/getting-start-tdd/php/index.md +84 -84
  369. package/lib/assets/docs/article/getting-start-tdd/python/01-todo-list-and-first-test.md +201 -201
  370. package/lib/assets/docs/article/getting-start-tdd/python/02-fake-it-and-triangulation.md +247 -247
  371. package/lib/assets/docs/article/getting-start-tdd/python/03-obvious-implementation-and-refactoring.md +199 -199
  372. package/lib/assets/docs/article/getting-start-tdd/python/04-version-control-and-conventional-commits.md +87 -87
  373. package/lib/assets/docs/article/getting-start-tdd/python/05-package-management-and-static-analysis.md +274 -274
  374. package/lib/assets/docs/article/getting-start-tdd/python/06-task-runner-and-ci-cd.md +190 -190
  375. package/lib/assets/docs/article/getting-start-tdd/python/07-encapsulation-and-polymorphism.md +208 -208
  376. package/lib/assets/docs/article/getting-start-tdd/python/08-design-patterns.md +172 -172
  377. package/lib/assets/docs/article/getting-start-tdd/python/09-solid-principles-and-module-design.md +130 -130
  378. package/lib/assets/docs/article/getting-start-tdd/python/10-higher-order-functions-and-composition.md +122 -122
  379. package/lib/assets/docs/article/getting-start-tdd/python/11-immutable-data-and-pipeline.md +116 -116
  380. package/lib/assets/docs/article/getting-start-tdd/python/12-error-handling-and-type-safety.md +126 -126
  381. package/lib/assets/docs/article/getting-start-tdd/python/index.md +55 -55
  382. package/lib/assets/docs/article/getting-start-tdd/ruby/01-todo-list-and-first-test.md +231 -231
  383. package/lib/assets/docs/article/getting-start-tdd/ruby/02-fake-it-and-triangulation.md +238 -238
  384. package/lib/assets/docs/article/getting-start-tdd/ruby/03-obvious-implementation-and-refactoring.md +228 -228
  385. package/lib/assets/docs/article/getting-start-tdd/ruby/04-version-control-and-conventional-commits.md +112 -112
  386. package/lib/assets/docs/article/getting-start-tdd/ruby/05-package-management-and-static-analysis.md +287 -287
  387. package/lib/assets/docs/article/getting-start-tdd/ruby/06-task-runner-and-ci-cd.md +248 -248
  388. package/lib/assets/docs/article/getting-start-tdd/ruby/07-encapsulation-and-polymorphism.md +279 -279
  389. package/lib/assets/docs/article/getting-start-tdd/ruby/08-design-patterns.md +329 -329
  390. package/lib/assets/docs/article/getting-start-tdd/ruby/09-solid-principles-and-module-design.md +196 -196
  391. package/lib/assets/docs/article/getting-start-tdd/ruby/10-higher-order-functions-and-composition.md +175 -175
  392. package/lib/assets/docs/article/getting-start-tdd/ruby/11-immutable-data-and-pipeline.md +237 -237
  393. package/lib/assets/docs/article/getting-start-tdd/ruby/12-error-handling-and-type-safety.md +398 -398
  394. package/lib/assets/docs/article/getting-start-tdd/ruby/index.md +83 -83
  395. package/lib/assets/docs/article/getting-start-tdd/rust/01-todo-list-and-first-test.md +211 -211
  396. package/lib/assets/docs/article/getting-start-tdd/rust/02-fake-it-and-triangulation.md +264 -264
  397. package/lib/assets/docs/article/getting-start-tdd/rust/03-obvious-implementation-and-refactoring.md +233 -233
  398. package/lib/assets/docs/article/getting-start-tdd/rust/04-version-control-and-conventional-commits.md +92 -92
  399. package/lib/assets/docs/article/getting-start-tdd/rust/05-package-management-and-static-analysis.md +212 -212
  400. package/lib/assets/docs/article/getting-start-tdd/rust/06-task-runner-and-ci-cd.md +164 -164
  401. package/lib/assets/docs/article/getting-start-tdd/rust/07-encapsulation-and-polymorphism.md +142 -142
  402. package/lib/assets/docs/article/getting-start-tdd/rust/08-design-patterns.md +145 -145
  403. package/lib/assets/docs/article/getting-start-tdd/rust/09-solid-principles-and-module-design.md +110 -110
  404. package/lib/assets/docs/article/getting-start-tdd/rust/10-higher-order-functions-and-composition.md +94 -94
  405. package/lib/assets/docs/article/getting-start-tdd/rust/11-immutable-data-and-pipeline.md +105 -105
  406. package/lib/assets/docs/article/getting-start-tdd/rust/12-error-handling-and-type-safety.md +112 -112
  407. package/lib/assets/docs/article/getting-start-tdd/rust/index.md +83 -83
  408. package/lib/assets/docs/article/getting-start-tdd/scala/01-todo-list-and-first-test.md +111 -111
  409. package/lib/assets/docs/article/getting-start-tdd/scala/02-fake-it-and-triangulation.md +107 -107
  410. package/lib/assets/docs/article/getting-start-tdd/scala/03-obvious-implementation-and-refactoring.md +99 -99
  411. package/lib/assets/docs/article/getting-start-tdd/scala/04-version-control-and-conventional-commits.md +123 -123
  412. package/lib/assets/docs/article/getting-start-tdd/scala/05-package-management-and-static-analysis.md +196 -196
  413. package/lib/assets/docs/article/getting-start-tdd/scala/06-task-runner-and-ci-cd.md +186 -186
  414. package/lib/assets/docs/article/getting-start-tdd/scala/07-case-classes-and-traits.md +139 -139
  415. package/lib/assets/docs/article/getting-start-tdd/scala/08-pattern-matching-and-sealed-traits.md +106 -106
  416. package/lib/assets/docs/article/getting-start-tdd/scala/09-packages-and-module-design.md +75 -75
  417. package/lib/assets/docs/article/getting-start-tdd/scala/10-higher-order-functions-and-composition.md +104 -104
  418. package/lib/assets/docs/article/getting-start-tdd/scala/11-collections-and-lazy-evaluation.md +94 -94
  419. package/lib/assets/docs/article/getting-start-tdd/scala/12-error-handling-and-type-safety.md +92 -92
  420. package/lib/assets/docs/article/getting-start-tdd/scala/index.md +65 -65
  421. package/lib/assets/docs/article/grokking-concurrency/all/index.md +404 -404
  422. package/lib/assets/docs/article/grokking-concurrency/all/part-1-ch02-sequential.md +554 -554
  423. package/lib/assets/docs/article/grokking-concurrency/all/part-2-ch04-05-threads.md +469 -469
  424. package/lib/assets/docs/article/grokking-concurrency/all/part-3-ch06-multitasking.md +520 -520
  425. package/lib/assets/docs/article/grokking-concurrency/all/part-4-ch07-parallel-patterns.md +420 -420
  426. package/lib/assets/docs/article/grokking-concurrency/all/part-5-ch08-09-synchronization.md +510 -510
  427. package/lib/assets/docs/article/grokking-concurrency/all/part-6-ch10-11-nonblocking-io.md +435 -435
  428. package/lib/assets/docs/article/grokking-concurrency/all/part-7-ch12-async.md +465 -465
  429. package/lib/assets/docs/article/grokking-concurrency/all/part-8-ch13-mapreduce.md +377 -377
  430. package/lib/assets/docs/article/grokking-concurrency/clojure/index.md +116 -116
  431. package/lib/assets/docs/article/grokking-concurrency/clojure/part-1.md +108 -108
  432. package/lib/assets/docs/article/grokking-concurrency/clojure/part-2.md +101 -101
  433. package/lib/assets/docs/article/grokking-concurrency/clojure/part-3.md +122 -122
  434. package/lib/assets/docs/article/grokking-concurrency/clojure/part-4.md +123 -123
  435. package/lib/assets/docs/article/grokking-concurrency/clojure/part-5.md +118 -118
  436. package/lib/assets/docs/article/grokking-concurrency/clojure/part-6.md +89 -89
  437. package/lib/assets/docs/article/grokking-concurrency/clojure/part-7.md +100 -100
  438. package/lib/assets/docs/article/grokking-concurrency/clojure/part-8.md +120 -120
  439. package/lib/assets/docs/article/grokking-concurrency/csharp/index.md +101 -101
  440. package/lib/assets/docs/article/grokking-concurrency/csharp/part-1.md +97 -97
  441. package/lib/assets/docs/article/grokking-concurrency/csharp/part-2.md +123 -123
  442. package/lib/assets/docs/article/grokking-concurrency/csharp/part-3.md +101 -101
  443. package/lib/assets/docs/article/grokking-concurrency/csharp/part-4.md +112 -112
  444. package/lib/assets/docs/article/grokking-concurrency/csharp/part-5.md +99 -99
  445. package/lib/assets/docs/article/grokking-concurrency/csharp/part-6.md +61 -61
  446. package/lib/assets/docs/article/grokking-concurrency/csharp/part-7.md +84 -84
  447. package/lib/assets/docs/article/grokking-concurrency/csharp/part-8.md +92 -92
  448. package/lib/assets/docs/article/grokking-concurrency/fsharp/index.md +65 -65
  449. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-1.md +80 -80
  450. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-2.md +103 -103
  451. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-3.md +94 -94
  452. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-4.md +110 -110
  453. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-5.md +104 -104
  454. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-6.md +93 -93
  455. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-7.md +121 -121
  456. package/lib/assets/docs/article/grokking-concurrency/fsharp/part-8.md +107 -107
  457. package/lib/assets/docs/article/grokking-concurrency/haskell/index.md +248 -248
  458. package/lib/assets/docs/article/grokking-concurrency/haskell/part-1.md +96 -96
  459. package/lib/assets/docs/article/grokking-concurrency/haskell/part-2.md +96 -96
  460. package/lib/assets/docs/article/grokking-concurrency/haskell/part-3.md +91 -91
  461. package/lib/assets/docs/article/grokking-concurrency/haskell/part-4.md +106 -106
  462. package/lib/assets/docs/article/grokking-concurrency/haskell/part-5.md +99 -99
  463. package/lib/assets/docs/article/grokking-concurrency/haskell/part-6.md +95 -95
  464. package/lib/assets/docs/article/grokking-concurrency/haskell/part-7.md +111 -111
  465. package/lib/assets/docs/article/grokking-concurrency/haskell/part-8.md +118 -118
  466. package/lib/assets/docs/article/grokking-concurrency/index.md +66 -66
  467. package/lib/assets/docs/article/grokking-concurrency/java/index.md +102 -102
  468. package/lib/assets/docs/article/grokking-concurrency/java/part-1.md +308 -308
  469. package/lib/assets/docs/article/grokking-concurrency/java/part-2.md +334 -334
  470. package/lib/assets/docs/article/grokking-concurrency/java/part-3.md +221 -221
  471. package/lib/assets/docs/article/grokking-concurrency/java/part-4.md +213 -213
  472. package/lib/assets/docs/article/grokking-concurrency/java/part-5.md +112 -112
  473. package/lib/assets/docs/article/grokking-concurrency/java/part-6.md +69 -69
  474. package/lib/assets/docs/article/grokking-concurrency/java/part-7.md +101 -101
  475. package/lib/assets/docs/article/grokking-concurrency/java/part-8.md +101 -101
  476. package/lib/assets/docs/article/grokking-concurrency/python/index.md +313 -313
  477. package/lib/assets/docs/article/grokking-concurrency/python/part-1.md +239 -239
  478. package/lib/assets/docs/article/grokking-concurrency/python/part-2.md +418 -418
  479. package/lib/assets/docs/article/grokking-concurrency/python/part-3.md +227 -227
  480. package/lib/assets/docs/article/grokking-concurrency/python/part-4.md +299 -299
  481. package/lib/assets/docs/article/grokking-concurrency/python/part-5.md +315 -315
  482. package/lib/assets/docs/article/grokking-concurrency/python/part-6.md +297 -297
  483. package/lib/assets/docs/article/grokking-concurrency/python/part-7.md +314 -314
  484. package/lib/assets/docs/article/grokking-concurrency/python/part-8.md +360 -360
  485. package/lib/assets/docs/article/grokking-concurrency/rust/index.md +270 -270
  486. package/lib/assets/docs/article/grokking-concurrency/rust/part-1.md +108 -108
  487. package/lib/assets/docs/article/grokking-concurrency/rust/part-2.md +120 -120
  488. package/lib/assets/docs/article/grokking-concurrency/rust/part-3.md +126 -126
  489. package/lib/assets/docs/article/grokking-concurrency/rust/part-4.md +175 -175
  490. package/lib/assets/docs/article/grokking-concurrency/rust/part-5.md +158 -158
  491. package/lib/assets/docs/article/grokking-concurrency/rust/part-6.md +94 -94
  492. package/lib/assets/docs/article/grokking-concurrency/rust/part-7.md +133 -133
  493. package/lib/assets/docs/article/grokking-concurrency/rust/part-8.md +155 -155
  494. package/lib/assets/docs/article/grokking-concurrency/scala/index.md +69 -69
  495. package/lib/assets/docs/article/grokking-concurrency/scala/part-1.md +78 -78
  496. package/lib/assets/docs/article/grokking-concurrency/scala/part-2.md +112 -112
  497. package/lib/assets/docs/article/grokking-concurrency/scala/part-3.md +93 -93
  498. package/lib/assets/docs/article/grokking-concurrency/scala/part-4.md +110 -110
  499. package/lib/assets/docs/article/grokking-concurrency/scala/part-5.md +119 -119
  500. package/lib/assets/docs/article/grokking-concurrency/scala/part-6.md +83 -83
  501. package/lib/assets/docs/article/grokking-concurrency/scala/part-7.md +131 -131
  502. package/lib/assets/docs/article/grokking-concurrency/scala/part-8.md +129 -129
  503. package/lib/assets/docs/article/grokkingfp/all/index.md +368 -368
  504. package/lib/assets/docs/article/grokkingfp/all/part-1-ch01-fp-introduction.md +530 -530
  505. package/lib/assets/docs/article/grokkingfp/all/part-1-ch02-pure-functions.md +923 -923
  506. package/lib/assets/docs/article/grokkingfp/all/part-2-ch03-immutable-data.md +1128 -1128
  507. package/lib/assets/docs/article/grokkingfp/all/part-2-ch04-higher-order-functions.md +1104 -1104
  508. package/lib/assets/docs/article/grokkingfp/all/part-2-ch05-flatmap.md +1026 -1026
  509. package/lib/assets/docs/article/grokkingfp/all/part-3-ch06-option.md +785 -785
  510. package/lib/assets/docs/article/grokkingfp/all/part-3-ch07-either-adt.md +871 -871
  511. package/lib/assets/docs/article/grokkingfp/all/part-4-ch08-io-monad.md +972 -972
  512. package/lib/assets/docs/article/grokkingfp/all/part-4-ch09-streams.md +926 -926
  513. package/lib/assets/docs/article/grokkingfp/all/part-5-ch10-concurrency.md +870 -870
  514. package/lib/assets/docs/article/grokkingfp/all/part-6-ch11-application.md +715 -715
  515. package/lib/assets/docs/article/grokkingfp/all/part-6-ch12-testing.md +626 -626
  516. package/lib/assets/docs/article/grokkingfp/all/writing-plan.md +712 -712
  517. package/lib/assets/docs/article/grokkingfp/clojure/index.md +276 -276
  518. package/lib/assets/docs/article/grokkingfp/clojure/part-1.md +667 -667
  519. package/lib/assets/docs/article/grokkingfp/clojure/part-2.md +643 -643
  520. package/lib/assets/docs/article/grokkingfp/clojure/part-3.md +620 -620
  521. package/lib/assets/docs/article/grokkingfp/clojure/part-4.md +697 -697
  522. package/lib/assets/docs/article/grokkingfp/clojure/part-5.md +751 -751
  523. package/lib/assets/docs/article/grokkingfp/clojure/part-6.md +721 -721
  524. package/lib/assets/docs/article/grokkingfp/csharp/index.md +246 -246
  525. package/lib/assets/docs/article/grokkingfp/csharp/part-1.md +811 -811
  526. package/lib/assets/docs/article/grokkingfp/csharp/part-2.md +971 -971
  527. package/lib/assets/docs/article/grokkingfp/csharp/part-3.md +981 -981
  528. package/lib/assets/docs/article/grokkingfp/csharp/part-4.md +949 -949
  529. package/lib/assets/docs/article/grokkingfp/csharp/part-5.md +947 -947
  530. package/lib/assets/docs/article/grokkingfp/csharp/part-6.md +739 -739
  531. package/lib/assets/docs/article/grokkingfp/elixir/index.md +203 -203
  532. package/lib/assets/docs/article/grokkingfp/elixir/part-1.md +712 -712
  533. package/lib/assets/docs/article/grokkingfp/elixir/part-2.md +838 -838
  534. package/lib/assets/docs/article/grokkingfp/elixir/part-3.md +985 -985
  535. package/lib/assets/docs/article/grokkingfp/elixir/part-4.md +974 -974
  536. package/lib/assets/docs/article/grokkingfp/elixir/part-5.md +1286 -1286
  537. package/lib/assets/docs/article/grokkingfp/elixir/part-6.md +1049 -1049
  538. package/lib/assets/docs/article/grokkingfp/fsharp/index.md +210 -210
  539. package/lib/assets/docs/article/grokkingfp/fsharp/part-1.md +714 -714
  540. package/lib/assets/docs/article/grokkingfp/fsharp/part-2.md +961 -961
  541. package/lib/assets/docs/article/grokkingfp/fsharp/part-3.md +972 -972
  542. package/lib/assets/docs/article/grokkingfp/fsharp/part-4.md +832 -832
  543. package/lib/assets/docs/article/grokkingfp/fsharp/part-5.md +911 -911
  544. package/lib/assets/docs/article/grokkingfp/fsharp/part-6.md +922 -922
  545. package/lib/assets/docs/article/grokkingfp/haskell/index.md +234 -234
  546. package/lib/assets/docs/article/grokkingfp/haskell/part-1.md +591 -591
  547. package/lib/assets/docs/article/grokkingfp/haskell/part-2.md +866 -866
  548. package/lib/assets/docs/article/grokkingfp/haskell/part-3.md +915 -915
  549. package/lib/assets/docs/article/grokkingfp/haskell/part-4.md +878 -878
  550. package/lib/assets/docs/article/grokkingfp/haskell/part-5.md +845 -845
  551. package/lib/assets/docs/article/grokkingfp/haskell/part-6.md +844 -844
  552. package/lib/assets/docs/article/grokkingfp/index.md +143 -143
  553. package/lib/assets/docs/article/grokkingfp/java/index.md +211 -211
  554. package/lib/assets/docs/article/grokkingfp/java/part-1.md +648 -648
  555. package/lib/assets/docs/article/grokkingfp/java/part-2.md +675 -675
  556. package/lib/assets/docs/article/grokkingfp/java/part-3.md +672 -672
  557. package/lib/assets/docs/article/grokkingfp/java/part-4.md +771 -771
  558. package/lib/assets/docs/article/grokkingfp/java/part-5.md +959 -959
  559. package/lib/assets/docs/article/grokkingfp/java/part-6.md +1328 -1328
  560. package/lib/assets/docs/article/grokkingfp/python/index.md +258 -258
  561. package/lib/assets/docs/article/grokkingfp/python/part-1.md +443 -443
  562. package/lib/assets/docs/article/grokkingfp/python/part-2.md +958 -958
  563. package/lib/assets/docs/article/grokkingfp/python/part-3.md +1004 -1004
  564. package/lib/assets/docs/article/grokkingfp/python/part-4.md +765 -765
  565. package/lib/assets/docs/article/grokkingfp/python/part-5.md +747 -747
  566. package/lib/assets/docs/article/grokkingfp/python/part-6.md +861 -861
  567. package/lib/assets/docs/article/grokkingfp/ruby/index.md +330 -330
  568. package/lib/assets/docs/article/grokkingfp/ruby/part-1.md +755 -755
  569. package/lib/assets/docs/article/grokkingfp/ruby/part-2.md +938 -938
  570. package/lib/assets/docs/article/grokkingfp/ruby/part-3.md +946 -946
  571. package/lib/assets/docs/article/grokkingfp/ruby/part-4.md +921 -921
  572. package/lib/assets/docs/article/grokkingfp/ruby/part-5.md +908 -908
  573. package/lib/assets/docs/article/grokkingfp/ruby/part-6.md +1412 -1412
  574. package/lib/assets/docs/article/grokkingfp/rust/index.md +242 -242
  575. package/lib/assets/docs/article/grokkingfp/rust/part-1.md +634 -634
  576. package/lib/assets/docs/article/grokkingfp/rust/part-2.md +1060 -1060
  577. package/lib/assets/docs/article/grokkingfp/rust/part-3.md +994 -994
  578. package/lib/assets/docs/article/grokkingfp/rust/part-4.md +573 -573
  579. package/lib/assets/docs/article/grokkingfp/rust/part-5.md +705 -705
  580. package/lib/assets/docs/article/grokkingfp/rust/part-6.md +508 -508
  581. package/lib/assets/docs/article/grokkingfp/scala/index.md +171 -171
  582. package/lib/assets/docs/article/grokkingfp/scala/part-1.md +543 -543
  583. package/lib/assets/docs/article/grokkingfp/scala/part-2.md +946 -946
  584. package/lib/assets/docs/article/grokkingfp/scala/part-3.md +919 -919
  585. package/lib/assets/docs/article/grokkingfp/scala/part-4.md +742 -742
  586. package/lib/assets/docs/article/grokkingfp/scala/part-5.md +722 -722
  587. package/lib/assets/docs/article/grokkingfp/scala/part-6.md +867 -867
  588. package/lib/assets/docs/article/grokkingfp/typescript/index.md +273 -273
  589. package/lib/assets/docs/article/grokkingfp/typescript/part-1.md +561 -561
  590. package/lib/assets/docs/article/grokkingfp/typescript/part-2.md +1129 -1129
  591. package/lib/assets/docs/article/grokkingfp/typescript/part-3.md +842 -842
  592. package/lib/assets/docs/article/grokkingfp/typescript/part-4.md +1087 -1087
  593. package/lib/assets/docs/article/grokkingfp/typescript/part-5.md +717 -717
  594. package/lib/assets/docs/article/grokkingfp/typescript/part-6.md +982 -982
  595. package/lib/assets/docs/article/index.md +41 -41
  596. package/lib/assets/docs/article/practical-database-design/index.md +121 -121
  597. package/lib/assets/docs/article/practical-database-design/part1/chapter01.md +288 -288
  598. package/lib/assets/docs/article/practical-database-design/part1/chapter02.md +518 -518
  599. package/lib/assets/docs/article/practical-database-design/part1/chapter03.md +557 -557
  600. package/lib/assets/docs/article/practical-database-design/part2/chapter04.md +924 -924
  601. package/lib/assets/docs/article/practical-database-design/part2/chapter05.md +1627 -1627
  602. package/lib/assets/docs/article/practical-database-design/part2/chapter06.md +2716 -2716
  603. package/lib/assets/docs/article/practical-database-design/part2/chapter07.md +2082 -2082
  604. package/lib/assets/docs/article/practical-database-design/part2/chapter08.md +2105 -2105
  605. package/lib/assets/docs/article/practical-database-design/part2/chapter09.md +2031 -2031
  606. package/lib/assets/docs/article/practical-database-design/part2/chapter10.md +1387 -1387
  607. package/lib/assets/docs/article/practical-database-design/part2/chapter11.md +1677 -1677
  608. package/lib/assets/docs/article/practical-database-design/part2/chapter12.md +1417 -1417
  609. package/lib/assets/docs/article/practical-database-design/part2/chapter13.md +1434 -1434
  610. package/lib/assets/docs/article/practical-database-design/part3/chapter14.md +667 -667
  611. package/lib/assets/docs/article/practical-database-design/part3/chapter15.md +1625 -1625
  612. package/lib/assets/docs/article/practical-database-design/part3/chapter16.md +1915 -1915
  613. package/lib/assets/docs/article/practical-database-design/part3/chapter17.md +1708 -1708
  614. package/lib/assets/docs/article/practical-database-design/part3/chapter18.md +2095 -2095
  615. package/lib/assets/docs/article/practical-database-design/part3/chapter19.md +1123 -1123
  616. package/lib/assets/docs/article/practical-database-design/part3/chapter20.md +1031 -1031
  617. package/lib/assets/docs/article/practical-database-design/part3/chapter21.md +1382 -1382
  618. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter14-orm.md +991 -991
  619. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter15-orm.md +1300 -1300
  620. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter16-orm.md +1166 -1166
  621. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter17-orm.md +1584 -1584
  622. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter18-orm.md +1183 -1183
  623. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter19-orm.md +1016 -1016
  624. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter20-orm.md +1753 -1753
  625. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter21-orm.md +1447 -1447
  626. package/lib/assets/docs/article/practical-database-design/part3-orm/chapter22-orm.md +1878 -1878
  627. package/lib/assets/docs/article/practical-database-design/part4/chapter22.md +965 -965
  628. package/lib/assets/docs/article/practical-database-design/part4/chapter23.md +2069 -2069
  629. package/lib/assets/docs/article/practical-database-design/part4/chapter24.md +2439 -2439
  630. package/lib/assets/docs/article/practical-database-design/part4/chapter25.md +3661 -3661
  631. package/lib/assets/docs/article/practical-database-design/part4/chapter26.md +2916 -2916
  632. package/lib/assets/docs/article/practical-database-design/part4/chapter27.md +3105 -3105
  633. package/lib/assets/docs/article/practical-database-design/part4/chapter28.md +2697 -2697
  634. package/lib/assets/docs/article/practical-database-design/part4/chapter29.md +2544 -2544
  635. package/lib/assets/docs/article/practical-database-design/part4/chapter30.md +2180 -2180
  636. package/lib/assets/docs/article/practical-database-design/part4/chapter31.md +1192 -1192
  637. package/lib/assets/docs/article/practical-database-design/part4/chapter32.md +2101 -2101
  638. package/lib/assets/docs/article/practical-database-design/part5/chapter33.md +1032 -1032
  639. package/lib/assets/docs/article/practical-database-design/part5/chapter34.md +1609 -1609
  640. package/lib/assets/docs/article/practical-database-design/part5/chapter35.md +1453 -1453
  641. package/lib/assets/docs/article/practical-database-design/part5/chapter36.md +1292 -1292
  642. package/lib/assets/docs/article/practical-database-design/part5/chapter37.md +1470 -1470
  643. package/lib/assets/docs/article/practical-database-design/part5/chapter38.md +1698 -1698
  644. package/lib/assets/docs/article/practical-database-design/part5/chapter39.md +2334 -2334
  645. package/lib/assets/docs/article/practical-database-design/study/study2-1.md +1693 -1693
  646. package/lib/assets/docs/article/practical-database-design/study/study2-2.md +1347 -1347
  647. package/lib/assets/docs/article/practical-database-design/study/study2-3.md +2044 -2044
  648. package/lib/assets/docs/article/practical-database-design/study/study2-4.md +2229 -2229
  649. package/lib/assets/docs/article/practical-database-design/study/study2-5.md +2418 -2418
  650. package/lib/assets/docs/article/practical-database-design/study/study3-1.md +2205 -2205
  651. package/lib/assets/docs/article/practical-database-design/study/study3-2.md +2221 -2221
  652. package/lib/assets/docs/article/practical-database-design/study/study3-3.md +2253 -2253
  653. package/lib/assets/docs/article/practical-database-design/study/study3-4.md +2106 -2106
  654. package/lib/assets/docs/article/practical-database-design/study/study3-5.md +2507 -2507
  655. package/lib/assets/docs/article/practical-database-design/study/study4-1.md +2587 -2587
  656. package/lib/assets/docs/article/practical-database-design/study/study4-2.md +2075 -2075
  657. package/lib/assets/docs/article/practical-database-design/study/study4-3.md +1805 -1805
  658. package/lib/assets/docs/article/practical-database-design/study/study4-4.md +1895 -1895
  659. package/lib/assets/docs/article/practical-database-design/study/study4-5.md +2878 -2878
  660. package/lib/assets/docs/assets/css/extra.css +29 -29
  661. package/lib/assets/docs/assets/js/extra.js +44 -44
  662. package/lib/assets/docs/design/index.md +44 -44
  663. package/lib/assets/docs/development/index.md +39 -39
  664. package/lib/assets/docs/index.md +33 -33
  665. package/lib/assets/docs/operation/index.md +27 -27
  666. package/lib/assets/docs/reference/CodexCLIMCP/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/343/203/225/343/203/255/343/203/274.md +546 -546
  667. package/lib/assets/docs/reference/CodexCLIMCP/343/202/265/343/203/274/343/203/220/343/203/274/350/250/255/345/256/232/346/211/213/351/240/206.md +341 -341
  668. package/lib/assets/docs/reference/Java/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +581 -581
  669. package/lib/assets/docs/reference/SonarQube/343/203/255/343/203/274/343/202/253/343/203/253/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +642 -642
  670. package/lib/assets/docs/reference/TypeScript/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +465 -465
  671. package/lib/assets/docs/reference/UI/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +450 -450
  672. package/lib/assets/docs/reference/images/Ansoff.drawio.svg +3 -3
  673. package/lib/assets/docs/reference/images/BMC.drawio.svg +3 -3
  674. package/lib/assets/docs/reference/images/BrandBasicStrategy.drawio.svg +3 -3
  675. package/lib/assets/docs/reference/images/BrandCategorization.drawio.svg +3 -3
  676. package/lib/assets/docs/reference/images/BrandRecurutementStrategy.drawio.svg +3 -3
  677. package/lib/assets/docs/reference/images/BrandValue.drawio.svg +3 -3
  678. package/lib/assets/docs/reference/images/BusinessActivitiy.svg +3 -3
  679. package/lib/assets/docs/reference/images/HRM.drawio.svg +3 -3
  680. package/lib/assets/docs/reference/images/MarketingStructure.drawio.svg +3 -3
  681. package/lib/assets/docs/reference/images/OrganizationElemnts.svg +3 -3
  682. package/lib/assets/docs/reference/images/PPM.drawio.svg +3 -3
  683. package/lib/assets/docs/reference/images/PositioningMap.drawio.svg +3 -3
  684. package/lib/assets/docs/reference/images/ProductLayer.drawio.svg +3 -3
  685. package/lib/assets/docs/reference/images/ProductMix.drawio.svg +3 -3
  686. package/lib/assets/docs/reference/images/SWOT.drawio.svg +3 -3
  687. package/lib/assets/docs/reference/images/TargetMarket.drawio.svg +3 -3
  688. package/lib/assets/docs/reference/images/ThreeGenericStrategies.drawio.svg +3 -3
  689. package/lib/assets/docs/reference/images/VRIO.drawio.svg +3 -3
  690. package/lib/assets/docs/reference/images/ValueChain.drawio.svg +3 -3
  691. package/lib/assets/docs/reference/index.md +53 -53
  692. package/lib/assets/docs/reference//343/202/210/343/201/204/343/202/275/343/203/225/343/203/210/343/202/246/343/202/247/343/202/242/343/201/250/343/201/257.md +250 -250
  693. package/lib/assets/docs/reference//343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +2216 -2216
  694. package/lib/assets/docs/reference//343/202/244/343/203/263/343/203/225/343/203/251/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +1878 -1878
  695. package/lib/assets/docs/reference//343/202/250/343/202/257/343/202/271/343/203/210/343/203/252/343/203/274/343/203/240/343/203/227/343/203/255/343/202/260/343/203/251/343/203/237/343/203/263/343/202/260.md +550 -550
  696. package/lib/assets/docs/reference//343/202/263/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/343/201/250/343/203/206/343/202/271/343/203/210/343/202/254/343/202/244/343/203/211.md +705 -705
  697. package/lib/assets/docs/reference//343/203/206/343/202/271/343/203/210/346/210/246/347/225/245/343/202/254/343/202/244/343/203/211.md +1313 -1313
  698. package/lib/assets/docs/reference//343/203/207/343/203/274/343/202/277/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +311 -311
  699. package/lib/assets/docs/reference//343/203/211/343/203/241/343/202/244/343/203/263/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +599 -599
  700. package/lib/assets/docs/reference//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/345/210/206/346/236/220/343/202/254/343/202/244/343/203/211.md +528 -528
  701. package/lib/assets/docs/reference//343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +689 -689
  702. package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/202/254/343/202/244/343/203/211.md +461 -461
  703. package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/203/273/343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/350/250/210/347/224/273/343/202/254/343/202/244/343/203/211.md +580 -580
  704. package/lib/assets/docs/reference//343/203/255/343/202/270/343/202/253/343/203/253/343/202/267/343/203/263/343/202/255/343/203/263/343/202/260.md +1367 -1367
  705. package/lib/assets/docs/reference//344/274/201/346/245/255/347/265/214/345/226/266/350/253/226.md +2637 -2637
  706. package/lib/assets/docs/reference//347/222/260/345/242/203/345/244/211/346/225/260/347/256/241/347/220/206/343/202/254/343/202/244/343/203/211.md +665 -665
  707. package/lib/assets/docs/reference//347/265/214/345/226/266/346/210/246/347/225/245/345/210/206/346/236/220/343/202/254/343/202/244/343/203/211.md +566 -566
  708. package/lib/assets/docs/reference//350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1248 -1248
  709. package/lib/assets/docs/reference//350/250/200/350/252/236/345/210/245/351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +518 -518
  710. package/lib/assets/docs/reference//351/201/213/345/226/266/347/256/241/347/220/206.md +1482 -1482
  711. package/lib/assets/docs/reference//351/201/213/347/224/250/343/202/271/343/202/257/343/203/252/343/203/227/343/203/210/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +421 -421
  712. package/lib/assets/docs/reference//351/201/213/347/224/250/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +392 -392
  713. package/lib/assets/docs/reference//351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +305 -305
  714. package/lib/assets/docs/reference//351/235/236/346/251/237/350/203/275/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1236 -1236
  715. package/lib/assets/docs/requirements/index.md +17 -17
  716. package/lib/assets/docs/review/index.md +5 -5
  717. package/lib/assets/docs/strategy/index.md +17 -17
  718. package/lib/assets/docs/template/ADR.md +30 -30
  719. package/lib/assets/docs/template/AWS/343/202/271/343/203/206/343/203/274/343/202/270/343/203/263/343/202/260/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +1366 -1366
  720. package/lib/assets/docs/template/AWS/343/203/227/343/203/255/343/203/200/343/202/257/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +634 -634
  721. package/lib/assets/docs/template/README.md +50 -50
  722. package/lib/assets/docs/template/index.md +24 -24
  723. package/lib/assets/docs/template//343/201/276/343/201/232/343/201/223/343/202/214/343/202/222/350/252/255/343/202/202/343/201/206/343/203/252/343/202/271/343/203/210.md +12 -12
  724. package/lib/assets/docs/template//343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +547 -547
  725. package/lib/assets/docs/template//343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/345/256/214/344/272/206/345/240/261/345/221/212/346/233/270.md +58 -58
  726. package/lib/assets/docs/template//343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/350/250/210/347/224/273.md +327 -327
  727. package/lib/assets/docs/template//343/202/244/343/203/263/343/202/273/343/203/227/343/202/267/343/203/247/343/203/263/343/203/207/343/203/203/343/202/255.md +13 -13
  728. package/lib/assets/docs/template//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243.md +379 -379
  729. package/lib/assets/docs/template//343/203/252/343/203/252/343/203/274/343/202/271/345/256/214/344/272/206/345/240/261/345/221/212/346/233/270.md +275 -275
  730. package/lib/assets/docs/template//344/272/213/344/276/213/345/210/206/346/236/220.md +513 -513
  731. package/lib/assets/docs/template//344/274/201/346/245/255/345/210/206/346/236/220.md +573 -573
  732. package/lib/assets/docs/template//345/256/214/345/205/250/345/275/242/345/274/217/343/201/256/343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271.md +69 -69
  733. package/lib/assets/docs/template//350/246/201/344/273/266/345/256/232/347/276/251.md +669 -669
  734. package/lib/assets/docs/template//350/250/255/350/250/210.md +173 -173
  735. package/lib/assets/docs/template//351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +688 -688
  736. package/lib/assets/gulpfile.js +25 -25
  737. package/lib/assets/mkdocs.yml +139 -139
  738. package/lib/assets/ops/docker/mkdoc/Dockerfile +19 -19
  739. package/lib/assets/ops/docker/sonarqube-local/docker-compose.yml +57 -57
  740. package/lib/assets/ops/scripts/journal.js +180 -180
  741. package/lib/assets/ops/scripts/mkdocs.js +82 -82
  742. package/lib/assets/ops/scripts/release.js +431 -431
  743. package/lib/assets/ops/scripts/sonar_local.js +726 -726
  744. package/lib/assets/ops/scripts/ssh.js +190 -190
  745. package/lib/assets/ops/scripts/vault.js +299 -299
  746. package/lib/assets/package-lock.json +1653 -1653
  747. package/lib/assets/package.json +40 -40
  748. package/lib/gulpfile.js +37 -37
  749. package/package.json +41 -41
@@ -1,1412 +1,1412 @@
1
- # Part VI: 実践的なアプリケーション構築とテスト
2
-
3
- 本章では、これまで学んだ関数型プログラミングの概念を統合し、実践的なアプリケーションを構築します。また、関数型プログラミングにおけるテスト戦略についても学びます。
4
-
5
- ---
6
-
7
- ## 第11章: 実践的なアプリケーション構築
8
-
9
- ### 11.1 TravelGuide アプリケーション
10
-
11
- 旅行ガイドアプリケーションを例に、実践的な FP アプリケーションの構築方法を学びます。
12
-
13
- ```plantuml
14
- @startuml
15
- !theme plain
16
-
17
- package "TravelGuide Application" {
18
- rectangle "Model" {
19
- class Location {
20
- id: LocationId
21
- name: String
22
- population: Integer
23
- }
24
-
25
- class Attraction {
26
- name: String
27
- description: String
28
- location: Location
29
- }
30
-
31
- class TravelGuide {
32
- attraction: Attraction
33
- subjects: Array[String]
34
- }
35
- }
36
-
37
- rectangle "Data Access" {
38
- interface DataAccess {
39
- +find_attractions(): IO[Array[Attraction]]
40
- +find_artists_from_location(): IO[Hash]
41
- +find_movies_about_location(): IO[Hash]
42
- }
43
-
44
- class InMemoryDataAccess
45
- class CachedDataAccess
46
- }
47
-
48
- DataAccess <|.. InMemoryDataAccess
49
- DataAccess <|.. CachedDataAccess
50
- }
51
-
52
- @enduml
53
- ```
54
-
55
- ### 11.2 ドメインモデルの定義
56
-
57
- **ソースファイル**: `app/ruby/src/ch11_application.rb`
58
-
59
- ```ruby
60
- # 位置情報を表す値オブジェクト
61
- class LocationId
62
- attr_reader :value
63
-
64
- def initialize(value)
65
- @value = value
66
- end
67
-
68
- def ==(other)
69
- other.is_a?(LocationId) && @value == other.value
70
- end
71
- alias eql? ==
72
-
73
- def hash
74
- @value.hash
75
- end
76
- end
77
-
78
- # ロケーション
79
- Location = Struct.new(:id, :name, :population, keyword_init: true)
80
-
81
- # アトラクション(観光地)
82
- Attraction = Struct.new(:name, :description, :location, keyword_init: true)
83
-
84
- # 旅行ガイド
85
- TravelGuide = Struct.new(:attraction, :subjects, :search_report, keyword_init: true)
86
- ```
87
-
88
- ### 11.3 データアクセス層の抽象化
89
-
90
- 外部データソースへのアクセスをモジュールで抽象化します。
91
-
92
- ```ruby
93
- module DataAccess
94
- def find_attractions(name, ordering, limit)
95
- raise NotImplementedError
96
- end
97
-
98
- def find_artists_from_location(location_id, limit)
99
- raise NotImplementedError
100
- end
101
-
102
- def find_movies_about_location(location_id, limit)
103
- raise NotImplementedError
104
- end
105
-
106
- def find_hotels_near_location(location_id, limit)
107
- raise NotImplementedError
108
- end
109
- end
110
- ```
111
-
112
- ```plantuml
113
- @startuml
114
- !theme plain
115
-
116
- interface DataAccess {
117
- +find_attractions(): IO[Array[Attraction]]
118
- +find_artists_from_location(): IO[Hash]
119
- +find_movies_about_location(): IO[Hash]
120
- +find_hotels_near_location(): IO[Hash]
121
- }
122
-
123
- note right of DataAccess
124
- 純粋な関数型インターフェース
125
- すべての操作は IO でラップ
126
- end note
127
-
128
- class InMemoryDataAccess {
129
- -attractions: Array
130
- -artists: Hash
131
- -movies: Hash
132
- +find_attractions(): IO[Array[Attraction]]
133
- +find_artists_from_location(): IO[Hash]
134
- +find_movies_about_location(): IO[Hash]
135
- }
136
-
137
- class CachedDataAccess {
138
- -base_access: DataAccess
139
- -cache: Ref[Hash]
140
- +find_attractions(): IO[Array[Attraction]]
141
- +cache_stats(): Hash
142
- }
143
-
144
- DataAccess <|.. InMemoryDataAccess
145
- DataAccess <|.. CachedDataAccess
146
-
147
- @enduml
148
- ```
149
-
150
- ### 11.4 InMemoryDataAccess の実装
151
-
152
- テストや開発用のインメモリ実装:
153
-
154
- ```ruby
155
- class InMemoryDataAccess
156
- include DataAccess
157
-
158
- def initialize(attractions: [], artists: {}, movies: {}, hotels: {})
159
- @attractions = attractions
160
- @artists = artists
161
- @movies = movies
162
- @hotels = hotels
163
- end
164
-
165
- def find_attractions(name, ordering, limit)
166
- Ch08IO::IO.delay do
167
- filtered = @attractions.select do |a|
168
- a.name.downcase.include?(name.downcase)
169
- end
170
-
171
- sorted = case ordering
172
- when AttractionOrdering::BY_NAME
173
- filtered.sort_by(&:name)
174
- when AttractionOrdering::BY_LOCATION_POPULATION
175
- filtered.sort_by { |a| -a.location.population }
176
- else
177
- filtered
178
- end
179
-
180
- sorted.take(limit)
181
- end
182
- end
183
-
184
- def find_artists_from_location(location_id, limit)
185
- Ch08IO::IO.delay do
186
- artists = @artists[location_id] || []
187
- { success: true, value: artists.take(limit) }
188
- end
189
- end
190
-
191
- # 他のメソッドも同様に実装...
192
- end
193
- ```
194
-
195
- ### 11.5 Resource によるリソース管理
196
-
197
- 安全なリソース管理を実現する `Resource` パターンの実装:
198
-
199
- **ソースファイル**: `app/ruby/src/ch11_application.rb`
200
-
201
- ```ruby
202
- class Resource
203
- def initialize(acquire, &release)
204
- @acquire = acquire
205
- @release = release
206
- end
207
-
208
- def self.make(acquire_io, &release)
209
- new(acquire_io, &release)
210
- end
211
-
212
- def use(&fn)
213
- Ch08IO::IO.delay do
214
- resource = @acquire.run!
215
- begin
216
- fn.call(resource)
217
- ensure
218
- @release&.call(resource)
219
- end
220
- end
221
- end
222
-
223
- def fmap(&fn)
224
- Resource.new(
225
- @acquire.fmap(&fn),
226
- &@release
227
- )
228
- end
229
- end
230
- ```
231
-
232
- ```plantuml
233
- @startuml
234
- !theme plain
235
-
236
- participant "Application" as app
237
- participant "Resource" as res
238
- participant "リソース" as resource
239
-
240
- app -> res: Resource.make(acquire) { release }
241
- res -> resource: acquire (IO を実行)
242
- resource --> res: リソースを取得
243
-
244
- app -> res: use { |r| ... }
245
- res -> resource: 処理を実行
246
- resource --> res: 結果
247
-
248
- app -> res: release (自動)
249
- res -> resource: クリーンアップ
250
-
251
- note over res
252
- Resource は例外が発生しても
253
- 必ず release を実行する
254
- (ensure ブロック)
255
- end note
256
-
257
- @enduml
258
- ```
259
-
260
- #### Resource の使用例
261
-
262
- ```ruby
263
- # ファイルリソースの例
264
- file_resource = Resource.make(
265
- Ch08IO::IO.delay { File.open('data.txt', 'r') }
266
- ) { |file| file.close }
267
-
268
- # 使用
269
- content = file_resource.use { |file| file.read }.run!
270
-
271
- # データベース接続の例
272
- db_resource = Resource.make(
273
- Ch08IO::IO.delay { Database.connect }
274
- ) { |conn| conn.disconnect }
275
-
276
- result = db_resource.use { |conn| conn.query('SELECT * FROM users') }.run!
277
- ```
278
-
279
- ### 11.6 キャッシュの実装
280
-
281
- `Ref` を使用したスレッドセーフなキャッシュの実装:
282
-
283
- ```ruby
284
- class CachedDataAccess
285
- include DataAccess
286
-
287
- def initialize(base_access)
288
- @base_access = base_access
289
- @attractions_cache = Ch10Concurrency::Ref.new({})
290
- @artists_cache = Ch10Concurrency::Ref.new({})
291
- @movies_cache = Ch10Concurrency::Ref.new({})
292
- @hotels_cache = Ch10Concurrency::Ref.new({})
293
- end
294
-
295
- def find_attractions(name, ordering, limit)
296
- Ch08IO::IO.delay do
297
- key = "#{name}-#{ordering}-#{limit}"
298
- cached = @attractions_cache.get.run!
299
-
300
- if cached.key?(key)
301
- cached[key]
302
- else
303
- result = @base_access.find_attractions(name, ordering, limit).run!
304
- @attractions_cache.update { |c| c.merge(key => result) }.run!
305
- result
306
- end
307
- end
308
- end
309
-
310
- def cache_stats
311
- {
312
- attractions: @attractions_cache.get.run!.size,
313
- artists: @artists_cache.get.run!.size,
314
- movies: @movies_cache.get.run!.size,
315
- hotels: @hotels_cache.get.run!.size
316
- }
317
- end
318
-
319
- # 他のメソッドも同様にキャッシュを実装...
320
- end
321
- ```
322
-
323
- ```plantuml
324
- @startuml
325
- !theme plain
326
- skinparam activity {
327
- BackgroundColor White
328
- BorderColor Black
329
- }
330
-
331
- start
332
-
333
- :キャッシュキー生成;
334
-
335
- :cache.get でキャッシュ確認;
336
-
337
- if (キャッシュにデータあり?) then (yes)
338
- :キャッシュからデータ返却;
339
- else (no)
340
- :base_access を呼び出し;
341
- :結果をキャッシュに保存;
342
- :結果を返却;
343
- endif
344
-
345
- stop
346
-
347
- note right
348
- Ref を使用した
349
- スレッドセーフなキャッシュ
350
- end note
351
-
352
- @enduml
353
- ```
354
-
355
- ### 11.7 FailingDataAccess - テスト用エラー注入
356
-
357
- テスト用にエラーを注入できる DataAccess の実装:
358
-
359
- ```ruby
360
- class FailingDataAccess
361
- include DataAccess
362
-
363
- def initialize(base_access, failing_methods: [])
364
- @base_access = base_access
365
- @failing_methods = failing_methods
366
- end
367
-
368
- def find_artists_from_location(location_id, limit)
369
- if @failing_methods.include?(:find_artists_from_location)
370
- Ch08IO::IO.pure({ success: false, error: 'Network error: artists service unavailable' })
371
- else
372
- @base_access.find_artists_from_location(location_id, limit)
373
- end
374
- end
375
-
376
- # 他のメソッドも同様...
377
- end
378
- ```
379
-
380
- ### 11.8 アプリケーションの組み立て
381
-
382
- すべてのコンポーネントを組み合わせてアプリケーションを構築します。
383
-
384
- ```ruby
385
- def self.travel_guide(data_access, attraction_name)
386
- Ch08IO::IO.delay do
387
- attractions = data_access.find_attractions(
388
- attraction_name,
389
- AttractionOrdering::BY_LOCATION_POPULATION,
390
- 1
391
- ).run!
392
-
393
- if attractions.empty?
394
- nil
395
- else
396
- attraction = attractions.first
397
- location_id = attraction.location.id
398
-
399
- # 複数のデータソースから情報を取得
400
- artists_result = data_access.find_artists_from_location(location_id, 2).run!
401
- movies_result = data_access.find_movies_about_location(location_id, 2).run!
402
-
403
- # エラーを収集
404
- errors = []
405
- errors << artists_result[:error] unless artists_result[:success]
406
- errors << movies_result[:error] unless movies_result[:success]
407
-
408
- # 成功した結果を抽出
409
- artists = artists_result[:success] ? artists_result[:value] : []
410
- movies = movies_result[:success] ? movies_result[:value] : []
411
-
412
- subjects = artists.map(&:name) + movies.map(&:name)
413
-
414
- TravelGuide.new(
415
- attraction: attraction,
416
- subjects: subjects,
417
- search_report: SearchReport.new(
418
- attractions_searched: attractions.size,
419
- errors: errors
420
- )
421
- )
422
- end
423
- end
424
- end
425
- ```
426
-
427
- ```plantuml
428
- @startuml
429
- !theme plain
430
-
431
- rectangle "travel_guide 関数" {
432
- card "1. アトラクション検索" as step1
433
- card "2. アーティスト検索" as step2
434
- card "3. 映画検索" as step3
435
- card "4. TravelGuide 組み立て" as step4
436
-
437
- step1 --> step2 : attraction
438
- step1 --> step3 : location.id
439
- step2 --> step4 : artists
440
- step3 --> step4 : movies
441
- }
442
-
443
- note bottom
444
- IO.delay 内で
445
- 複数の IO を順次実行
446
- end note
447
-
448
- @enduml
449
- ```
450
-
451
- ### 11.9 ExtendedTravelGuide
452
-
453
- ホテル情報も含む拡張版:
454
-
455
- ```ruby
456
- ExtendedTravelGuide = Struct.new(
457
- :attraction, :artists, :movies, :hotels, :search_report,
458
- keyword_init: true
459
- )
460
-
461
- def self.extended_travel_guide(data_access, attraction_name)
462
- Ch08IO::IO.delay do
463
- attractions = data_access.find_attractions(
464
- attraction_name,
465
- AttractionOrdering::BY_LOCATION_POPULATION,
466
- 1
467
- ).run!
468
-
469
- if attractions.empty?
470
- nil
471
- else
472
- attraction = attractions.first
473
- location_id = attraction.location.id
474
-
475
- # 並列で取得することも可能
476
- artists_result = data_access.find_artists_from_location(location_id, 5).run!
477
- movies_result = data_access.find_movies_about_location(location_id, 5).run!
478
- hotels_result = data_access.find_hotels_near_location(location_id, 5).run!
479
-
480
- errors = []
481
- errors << artists_result[:error] unless artists_result[:success]
482
- errors << movies_result[:error] unless movies_result[:success]
483
- errors << hotels_result[:error] unless hotels_result[:success]
484
-
485
- ExtendedTravelGuide.new(
486
- attraction: attraction,
487
- artists: artists_result[:success] ? artists_result[:value] : [],
488
- movies: movies_result[:success] ? movies_result[:value] : [],
489
- hotels: hotels_result[:success] ? hotels_result[:value] : [],
490
- search_report: SearchReport.new(
491
- attractions_searched: attractions.size,
492
- errors: errors
493
- )
494
- )
495
- end
496
- end
497
- end
498
- ```
499
-
500
- ---
501
-
502
- ## 第12章: テスト戦略
503
-
504
- ### 12.1 関数型プログラミングのテスト
505
-
506
- 関数型プログラミングでは、純粋関数のおかげでテストが非常に簡単になります。
507
-
508
- ```plantuml
509
- @startuml
510
- !theme plain
511
-
512
- rectangle "テストの種類" {
513
- rectangle "単体テスト" as unit {
514
- card "純粋関数のテスト"
515
- card "高速・独立"
516
- }
517
-
518
- rectangle "プロパティベーステスト" as property {
519
- card "ランダム入力"
520
- card "不変条件の検証"
521
- }
522
-
523
- rectangle "統合テスト" as integration {
524
- card "コンポーネント連携"
525
- card "スタブ/モック使用"
526
- }
527
- }
528
-
529
- unit --> property : 補完
530
- property --> integration : 補完
531
-
532
- @enduml
533
- ```
534
-
535
- ### 12.2 SearchReport の導入
536
-
537
- **ソースファイル**: `app/ruby/src/ch11_application.rb`
538
-
539
- テスト可能性を高めるため、`SearchReport` を導入します。
540
-
541
- ```ruby
542
- class SearchReport
543
- attr_reader :attractions_searched, :errors
544
-
545
- def initialize(attractions_searched:, errors:)
546
- @attractions_searched = attractions_searched
547
- @errors = errors.freeze
548
- end
549
-
550
- def self.empty
551
- new(attractions_searched: 0, errors: [])
552
- end
553
-
554
- def add_error(error)
555
- SearchReport.new(
556
- attractions_searched: @attractions_searched,
557
- errors: @errors + [error]
558
- )
559
- end
560
-
561
- def with_attractions_count(count)
562
- SearchReport.new(
563
- attractions_searched: count,
564
- errors: @errors
565
- )
566
- end
567
- end
568
- ```
569
-
570
- ```plantuml
571
- @startuml
572
- !theme plain
573
-
574
- class TravelGuide {
575
- attraction: Attraction
576
- subjects: Array[String]
577
- search_report: SearchReport
578
- }
579
-
580
- class SearchReport {
581
- attractions_searched: Integer
582
- errors: Array[String]
583
- +empty(): SearchReport
584
- +add_error(error): SearchReport
585
- }
586
-
587
- TravelGuide --> SearchReport
588
-
589
- note right of SearchReport
590
- 検索の統計情報と
591
- エラー情報を保持
592
- イミュータブルに更新
593
- end note
594
-
595
- @enduml
596
- ```
597
-
598
- ### 12.3 テストスタブの実装
599
-
600
- **ソースファイル**: `app/ruby/src/ch12_testing.rb`
601
-
602
- ```ruby
603
- class TestDataAccess
604
- include Ch11Application::DataAccess
605
-
606
- def initialize(
607
- attractions: [],
608
- artists_by_location: {},
609
- movies_by_location: {},
610
- hotels_by_location: {},
611
- artist_errors: {},
612
- movie_errors: {},
613
- hotel_errors: {}
614
- )
615
- @attractions = attractions
616
- @artists_by_location = artists_by_location
617
- @movies_by_location = movies_by_location
618
- @hotels_by_location = hotels_by_location
619
- @artist_errors = artist_errors
620
- @movie_errors = movie_errors
621
- @hotel_errors = hotel_errors
622
- end
623
-
624
- def find_attractions(name, ordering, limit)
625
- Ch08IO::IO.delay do
626
- filtered = @attractions.select { |a| a.name.downcase.include?(name.downcase) }
627
- sorted = case ordering
628
- when Ch11Application::AttractionOrdering::BY_NAME
629
- filtered.sort_by(&:name)
630
- when Ch11Application::AttractionOrdering::BY_LOCATION_POPULATION
631
- filtered.sort_by { |a| -a.location.population }
632
- else
633
- filtered
634
- end
635
- sorted.take(limit)
636
- end
637
- end
638
-
639
- def find_artists_from_location(location_id, limit)
640
- Ch08IO::IO.delay do
641
- if @artist_errors[location_id]
642
- { success: false, error: @artist_errors[location_id] }
643
- else
644
- artists = @artists_by_location[location_id] || []
645
- { success: true, value: artists.take(limit) }
646
- end
647
- end
648
- end
649
-
650
- # 他のメソッドも同様...
651
- end
652
- ```
653
-
654
- ```plantuml
655
- @startuml
656
- !theme plain
657
-
658
- rectangle "テスト構成" {
659
- rectangle "本番" as prod {
660
- interface "DataAccess" as da1
661
- class "WikidataDataAccess" as wda
662
- da1 <|.. wda
663
- }
664
-
665
- rectangle "テスト" as test {
666
- interface "DataAccess" as da2
667
- class "TestDataAccess" as tda
668
- da2 <|.. tda
669
- }
670
- }
671
-
672
- note bottom of prod
673
- 実際の API に接続
674
- end note
675
-
676
- note bottom of test
677
- テストデータを返す
678
- IO.pure/delay で即座に結果
679
- end note
680
-
681
- @enduml
682
- ```
683
-
684
- ### 12.4 テストデータビルダー
685
-
686
- テストデータを簡単に構築するためのビルダーパターン:
687
-
688
- ```ruby
689
- class LocationBuilder
690
- def initialize
691
- @id = Ch11Application::LocationId.new("Q#{rand(1000)}")
692
- @name = 'Test City'
693
- @population = 100_000
694
- end
695
-
696
- def with_id(id)
697
- @id = id.is_a?(Ch11Application::LocationId) ? id : Ch11Application::LocationId.new(id)
698
- self
699
- end
700
-
701
- def with_name(name)
702
- @name = name
703
- self
704
- end
705
-
706
- def with_population(population)
707
- @population = population
708
- self
709
- end
710
-
711
- def build
712
- Ch11Application::Location.new(id: @id, name: @name, population: @population)
713
- end
714
- end
715
-
716
- class AttractionBuilder
717
- def initialize
718
- @name = 'Test Attraction'
719
- @description = 'A test attraction'
720
- @location = LocationBuilder.new.build
721
- end
722
-
723
- def with_name(name)
724
- @name = name
725
- self
726
- end
727
-
728
- def with_location(location)
729
- @location = location
730
- self
731
- end
732
-
733
- def build
734
- Ch11Application::Attraction.new(
735
- name: @name,
736
- description: @description,
737
- location: @location
738
- )
739
- end
740
- end
741
- ```
742
-
743
- #### 使用例
744
-
745
- ```ruby
746
- # シンプルなロケーション
747
- location = LocationBuilder.new.build
748
-
749
- # カスタマイズしたロケーション
750
- sydney = LocationBuilder.new
751
- .with_name('Sydney')
752
- .with_population(5_000_000)
753
- .build
754
-
755
- # アトラクション with カスタムロケーション
756
- attraction = AttractionBuilder.new
757
- .with_name('Opera House')
758
- .with_location(sydney)
759
- .build
760
- ```
761
-
762
- ### 12.5 プロパティベーステスト
763
-
764
- ランダムな入力でプロパティ(不変条件)を検証するテスト手法:
765
-
766
- ```ruby
767
- module Gen
768
- def self.string(length = 10)
769
- chars = ('a'..'z').to_a + ('A'..'Z').to_a
770
- Array.new(length) { chars.sample }.join
771
- end
772
-
773
- def self.int(min = 0, max = 100)
774
- rand(min..max)
775
- end
776
-
777
- def self.positive_int(max = 1_000_000)
778
- rand(1..max)
779
- end
780
-
781
- def self.boolean
782
- [true, false].sample
783
- end
784
-
785
- def self.one_of(*options)
786
- options.sample
787
- end
788
-
789
- def self.list_of(size = 5, &generator)
790
- Array.new(size) { generator.call }
791
- end
792
-
793
- def self.location
794
- Ch11Application::Location.new(
795
- id: location_id,
796
- name: string(8),
797
- population: positive_int(50_000_000)
798
- )
799
- end
800
-
801
- def self.attraction
802
- Ch11Application::Attraction.new(
803
- name: string(15),
804
- description: option { string(50) },
805
- location: location
806
- )
807
- end
808
- end
809
- ```
810
-
811
- ```plantuml
812
- @startuml
813
- !theme plain
814
-
815
- rectangle "プロパティベーステスト" {
816
- card "Gen[A]" as gen
817
- card "ランダムデータ生成" as random
818
- card "プロパティ検証" as verify
819
- card "100回以上テスト" as repeat
820
-
821
- gen --> random
822
- random --> verify
823
- verify --> repeat
824
- repeat --> random : 繰り返し
825
- }
826
-
827
- note bottom
828
- ランダムな入力で
829
- 不変条件を検証
830
- end note
831
-
832
- @enduml
833
- ```
834
-
835
- ### 12.6 PropertyTest フレームワーク
836
-
837
- ```ruby
838
- class PropertyTest
839
- attr_reader :name, :failures
840
-
841
- def initialize(name, iterations: 100)
842
- @name = name
843
- @iterations = iterations
844
- @failures = []
845
- end
846
-
847
- def for_all(*generators, &property)
848
- @iterations.times do |i|
849
- inputs = generators.map(&:call)
850
- begin
851
- result = property.call(*inputs)
852
- unless result
853
- @failures << { iteration: i, inputs: inputs, error: 'Property returned false' }
854
- end
855
- rescue StandardError => e
856
- @failures << { iteration: i, inputs: inputs, error: e.message }
857
- end
858
- end
859
- self
860
- end
861
-
862
- def passed?
863
- @failures.empty?
864
- end
865
-
866
- def summary
867
- if passed?
868
- "#{@name}: PASSED (#{@iterations} iterations)"
869
- else
870
- "#{@name}: FAILED (#{@failures.size}/#{@iterations} failures)"
871
- end
872
- end
873
- end
874
- ```
875
-
876
- #### 使用例
877
-
878
- ```ruby
879
- # プロパティ: フィルタ結果は入力以下
880
- test = PropertyTest.new('filter returns subset', iterations: 100)
881
- test.for_all(
882
- -> { Gen.list_of(10) { Gen.location } },
883
- -> { Gen.positive_int(10_000_000) }
884
- ) do |locations, min_pop|
885
- result = filter_popular_locations(locations, min_pop)
886
- result.size <= locations.size
887
- end
888
-
889
- puts test.summary
890
- # => "filter returns subset: PASSED (100 iterations)"
891
- ```
892
-
893
- ### 12.7 共通プロパティの定義
894
-
895
- 再利用可能なプロパティを定義:
896
-
897
- ```ruby
898
- module Properties
899
- # フィルタ結果は入力以下
900
- def self.filter_bounded?(input, result)
901
- result.size <= input.size
902
- end
903
-
904
- # すべての結果が述語を満たす
905
- def self.filter_satisfies?(result, &predicate)
906
- result.all?(&predicate)
907
- end
908
-
909
- # 制限が守られている
910
- def self.limit_respected?(result, limit)
911
- result.size <= limit
912
- end
913
-
914
- # 順序が保持されている
915
- def self.ordering_preserved?(result, &compare)
916
- result.each_cons(2).all? { |a, b| compare.call(a, b) }
917
- end
918
-
919
- # エラー数が制限内
920
- def self.errors_bounded?(search_report, max_errors)
921
- search_report.errors.size <= max_errors
922
- end
923
- end
924
- ```
925
-
926
- ### 12.8 純粋関数のテスト
927
-
928
- 純粋関数は入力と出力の関係のみをテストすれば良いため、テストが簡単です。
929
-
930
- ```ruby
931
- # テスト対象の純粋関数
932
- def filter_popular_locations(locations, min_population)
933
- locations.select { |loc| loc.population >= min_population }
934
- end
935
-
936
- def sort_attractions_by_name(attractions)
937
- attractions.sort_by(&:name)
938
- end
939
-
940
- def average_rating(hotels)
941
- return nil if hotels.empty?
942
- hotels.sum(&:rating) / hotels.size.to_f
943
- end
944
- ```
945
-
946
- #### RSpec でのテスト
947
-
948
- ```ruby
949
- RSpec.describe '.filter_popular_locations' do
950
- it 'filters locations by population' do
951
- loc1 = LocationBuilder.new.with_population(100_000).build
952
- loc2 = LocationBuilder.new.with_population(500_000).build
953
- loc3 = LocationBuilder.new.with_population(200_000).build
954
-
955
- result = Ch12Testing.filter_popular_locations([loc1, loc2, loc3], 150_000)
956
-
957
- expect(result.size).to eq(2)
958
- expect(result.map(&:population)).to all(be >= 150_000)
959
- end
960
-
961
- # プロパティベーステスト
962
- it 'always returns subset of input' do
963
- test = PropertyTest.new('filter returns subset', iterations: 50)
964
- test.for_all(
965
- -> { Gen.list_of(10) { Gen.location } },
966
- -> { Gen.positive_int(10_000_000) }
967
- ) do |locations, min_pop|
968
- result = Ch12Testing.filter_popular_locations(locations, min_pop)
969
- Properties.filter_bounded?(locations, result)
970
- end
971
-
972
- expect(test.passed?).to be true
973
- end
974
- end
975
- ```
976
-
977
- ### 12.9 統合テスト
978
-
979
- コンポーネントを組み合わせた統合テスト:
980
-
981
- ```ruby
982
- RSpec.describe 'TravelGuide integration tests' do
983
- it 'works with TestDataAccess' do
984
- location = Fixtures.sydney
985
- attraction = Fixtures.sydney_opera_house
986
-
987
- data_access = TestDataAccess.new(
988
- attractions: [attraction],
989
- artists_by_location: { location.id => Fixtures.sydney_artists },
990
- movies_by_location: { location.id => Fixtures.sydney_movies },
991
- hotels_by_location: { location.id => Fixtures.sydney_hotels }
992
- )
993
-
994
- guide = Ch11Application.travel_guide(data_access, 'Sydney').run!
995
-
996
- Assertions.assert_travel_guide_valid(guide)
997
- Assertions.assert_no_errors(guide)
998
- Assertions.assert_subjects_present(guide)
999
- end
1000
-
1001
- it 'handles errors gracefully' do
1002
- location = Fixtures.sydney
1003
- attraction = Fixtures.sydney_opera_house
1004
-
1005
- data_access = TestDataAccess.new(
1006
- attractions: [attraction],
1007
- artist_errors: { location.id => 'Network error' },
1008
- movie_errors: { location.id => 'Timeout' }
1009
- )
1010
-
1011
- guide = Ch11Application.travel_guide(data_access, 'Sydney').run!
1012
-
1013
- Assertions.assert_travel_guide_valid(guide)
1014
- Assertions.assert_has_errors(guide, count: 2)
1015
- end
1016
- end
1017
- ```
1018
-
1019
- ### 12.10 テストフィクスチャ
1020
-
1021
- 事前に構築された再利用可能なテストデータ:
1022
-
1023
- ```ruby
1024
- module Fixtures
1025
- def self.sydney
1026
- @sydney ||= begin
1027
- id = Ch11Application::LocationId.new('Q60')
1028
- Ch11Application::Location.new(id: id, name: 'Sydney', population: 5_312_000)
1029
- end
1030
- end
1031
-
1032
- def self.sydney_opera_house
1033
- @sydney_opera_house ||= Ch11Application::Attraction.new(
1034
- name: 'Sydney Opera House',
1035
- description: 'Iconic performing arts venue',
1036
- location: sydney
1037
- )
1038
- end
1039
-
1040
- def self.sydney_artists
1041
- @sydney_artists ||= [
1042
- Ch11Application::MusicArtist.new(name: 'AC/DC', genre: 'Rock'),
1043
- Ch11Application::MusicArtist.new(name: 'Sia', genre: 'Pop')
1044
- ]
1045
- end
1046
-
1047
- def self.complete_data_access
1048
- @complete_data_access ||= TestDataAccess.new(
1049
- attractions: [sydney_opera_house],
1050
- artists_by_location: { sydney.id => sydney_artists },
1051
- movies_by_location: { sydney.id => sydney_movies },
1052
- hotels_by_location: { sydney.id => sydney_hotels }
1053
- )
1054
- end
1055
- end
1056
- ```
1057
-
1058
- ### 12.11 アサーションヘルパー
1059
-
1060
- テストアサーションを簡潔に書くためのヘルパー:
1061
-
1062
- ```ruby
1063
- module Assertions
1064
- def self.assert_travel_guide_valid(guide)
1065
- raise 'Guide is nil' if guide.nil?
1066
- raise 'Attraction is nil' if guide.attraction.nil?
1067
- raise 'Search report is nil' if guide.search_report.nil?
1068
- true
1069
- end
1070
-
1071
- def self.assert_no_errors(guide)
1072
- errors = guide.search_report.errors
1073
- raise "Expected no errors but got: #{errors}" unless errors.empty?
1074
- true
1075
- end
1076
-
1077
- def self.assert_has_errors(guide, count: nil)
1078
- errors = guide.search_report.errors
1079
- raise 'Expected errors but got none' if errors.empty?
1080
- raise "Expected #{count} errors but got #{errors.size}" if count && errors.size != count
1081
- true
1082
- end
1083
- end
1084
- ```
1085
-
1086
- ### 12.12 テストピラミッド
1087
-
1088
- ```plantuml
1089
- @startuml
1090
- !theme plain
1091
-
1092
- rectangle "テストピラミッド" {
1093
- rectangle "E2E テスト\n(少数)" as e2e
1094
- rectangle "統合テスト\n(中程度)" as integration
1095
- rectangle "単体テスト + プロパティテスト\n(多数)" as unit
1096
- }
1097
-
1098
- e2e -[hidden]down- integration
1099
- integration -[hidden]down- unit
1100
-
1101
- note right of unit
1102
- FP では純粋関数が多いため
1103
- 単体テストが非常に効果的
1104
- end note
1105
-
1106
- @enduml
1107
- ```
1108
-
1109
- ---
1110
-
1111
- ## まとめ
1112
-
1113
- ### Part VI で学んだこと
1114
-
1115
- ```plantuml
1116
- @startuml
1117
- !theme plain
1118
-
1119
- rectangle "Part VI: 実践的なアプリケーション" {
1120
- rectangle "第11章" as ch11 {
1121
- card "ドメインモデル設計"
1122
- card "DataAccess 抽象化"
1123
- card "Resource 管理"
1124
- card "キャッシュ実装"
1125
- }
1126
-
1127
- rectangle "第12章" as ch12 {
1128
- card "SearchReport"
1129
- card "スタブ/テストダブル"
1130
- card "プロパティベーステスト"
1131
- card "ビルダーパターン"
1132
- }
1133
- }
1134
-
1135
- ch11 --> ch12
1136
-
1137
- @enduml
1138
- ```
1139
-
1140
- ### 主要コンポーネント
1141
-
1142
- | コンポーネント | 用途 |
1143
- |----------------|------|
1144
- | `DataAccess` | 外部データソースへのアクセス抽象化 |
1145
- | `InMemoryDataAccess` | テスト・開発用のインメモリ実装 |
1146
- | `CachedDataAccess` | Ref を使ったキャッシュ層 |
1147
- | `FailingDataAccess` | エラー注入用のラッパー |
1148
- | `Resource` | 安全なリソース管理 |
1149
- | `SearchReport` | 検索統計とエラー追跡 |
1150
- | `TestDataAccess` | テスト用スタブ実装 |
1151
- | `LocationBuilder` | テストデータビルダー |
1152
- | `PropertyTest` | プロパティベーステスト |
1153
-
1154
- ### Ruby と Scala の対応
1155
-
1156
- | Scala | Ruby |
1157
- |-------|------|
1158
- | `trait DataAccess` | `module DataAccess` |
1159
- | `case class` | `Struct` |
1160
- | `opaque type LocationId` | `LocationId` クラス |
1161
- | `Resource[IO, A]` | `Resource` クラス |
1162
- | `Either[String, A]` | `{ success: bool, value/error: ... }` |
1163
- | `ScalaCheck Gen` | `Gen` モジュール |
1164
- | `property` | `PropertyTest` |
1165
-
1166
- ### キーポイント
1167
-
1168
- 1. **抽象化の重要性**: DataAccess モジュールで外部依存を抽象化
1169
- 2. **Resource でリソース管理**: ensure ブロックで安全なリソースの取得と解放
1170
- 3. **Ref でキャッシュ**: スレッドセーフな状態管理
1171
- 4. **Hash でエラー処理**: `{ success:, value/error: }` で明示的なエラーハンドリング
1172
- 5. **SearchReport**: テスト可能性と可観測性の向上
1173
- 6. **スタブ**: 外部依存を差し替えてテスト
1174
- 7. **プロパティベーステスト**: ランダム入力で不変条件を検証
1175
- 8. **ビルダーパターン**: テストデータの柔軟な構築
1176
-
1177
- ### 学習の総括
1178
-
1179
- ```plantuml
1180
- @startuml
1181
- !theme plain
1182
- left to right direction
1183
-
1184
- rectangle "FP の学習パス" {
1185
- card "Part I\n基礎" as p1
1186
- card "Part II\nイミュータブル操作" as p2
1187
- card "Part III\n型による安全性" as p3
1188
- card "Part IV\nIO/Stream" as p4
1189
- card "Part V\n並行処理" as p5
1190
- card "Part VI\n実践" as p6
1191
- }
1192
-
1193
- p1 --> p2
1194
- p2 --> p3
1195
- p3 --> p4
1196
- p4 --> p5
1197
- p5 --> p6
1198
-
1199
- @enduml
1200
- ```
1201
-
1202
- ---
1203
-
1204
- ## 演習問題
1205
-
1206
- ### 問題 1: DataAccess の拡張
1207
-
1208
- 以下の要件で `DataAccess` を拡張してください:
1209
-
1210
-
1211
- - 新しいメソッド `find_restaurants_near_location` を追加
1212
- - 戻り値は `IO[{ success: Boolean, value/error: ... }]`
1213
-
1214
- <details>
1215
- <summary>解答</summary>
1216
-
1217
- ```ruby
1218
- Restaurant = Struct.new(:name, :cuisine, :rating, :location, keyword_init: true)
1219
-
1220
- module DataAccess
1221
- # 既存のメソッド...
1222
-
1223
- def find_restaurants_near_location(location_id, limit)
1224
- raise NotImplementedError
1225
- end
1226
- end
1227
-
1228
- class InMemoryDataAccess
1229
- def initialize(attractions: [], artists: {}, movies: {}, hotels: {}, restaurants: {})
1230
- # ...
1231
- @restaurants = restaurants
1232
- end
1233
-
1234
- def find_restaurants_near_location(location_id, limit)
1235
- Ch08IO::IO.delay do
1236
- restaurants = @restaurants[location_id] || []
1237
- { success: true, value: restaurants.take(limit) }
1238
- end
1239
- end
1240
- end
1241
-
1242
- # テスト用スタブ
1243
- class TestDataAccess
1244
- def initialize(restaurants_by_location: {}, restaurant_errors: {}, **options)
1245
- # ...
1246
- @restaurants_by_location = restaurants_by_location
1247
- @restaurant_errors = restaurant_errors
1248
- end
1249
-
1250
- def find_restaurants_near_location(location_id, limit)
1251
- Ch08IO::IO.delay do
1252
- if @restaurant_errors[location_id]
1253
- { success: false, error: @restaurant_errors[location_id] }
1254
- else
1255
- restaurants = @restaurants_by_location[location_id] || []
1256
- { success: true, value: restaurants.take(limit) }
1257
- end
1258
- end
1259
- end
1260
- end
1261
- ```
1262
-
1263
- </details>
1264
-
1265
- ### 問題 2: プロパティベーステスト
1266
-
1267
- 以下の関数に対するプロパティベーステストを書いてください:
1268
-
1269
- ```ruby
1270
- def filter_popular_locations(locations, min_population)
1271
- locations.select { |loc| loc.population >= min_population }
1272
- end
1273
- ```
1274
-
1275
- <details>
1276
- <summary>解答</summary>
1277
-
1278
- ```ruby
1279
- # プロパティ1: 結果は入力以下の要素数
1280
- test1 = PropertyTest.new('result size <= input size', iterations: 100)
1281
- test1.for_all(
1282
- -> { Gen.list_of(10) { Gen.location } },
1283
- -> { Gen.positive_int(10_000_000) }
1284
- ) do |locations, min_pop|
1285
- result = filter_popular_locations(locations, min_pop)
1286
- result.size <= locations.size
1287
- end
1288
-
1289
- # プロパティ2: 結果のすべての要素は条件を満たす
1290
- test2 = PropertyTest.new('all results meet minimum', iterations: 100)
1291
- test2.for_all(
1292
- -> { Gen.list_of(10) { Gen.location } },
1293
- -> { Gen.positive_int(10_000_000) }
1294
- ) do |locations, min_pop|
1295
- result = filter_popular_locations(locations, min_pop)
1296
- result.all? { |loc| loc.population >= min_pop }
1297
- end
1298
-
1299
- # プロパティ3: 条件を満たす要素はすべて結果に含まれる
1300
- test3 = PropertyTest.new('all qualifying in result', iterations: 100)
1301
- test3.for_all(
1302
- -> { Gen.list_of(10) { Gen.location } },
1303
- -> { Gen.positive_int(10_000_000) }
1304
- ) do |locations, min_pop|
1305
- result = filter_popular_locations(locations, min_pop)
1306
- qualifying = locations.select { |loc| loc.population >= min_pop }
1307
- qualifying.all? { |loc| result.include?(loc) }
1308
- end
1309
- ```
1310
-
1311
- </details>
1312
-
1313
- ### 問題 3: Resource の実装
1314
-
1315
- ファイルを安全に読み取る `Resource` を実装してください。
1316
-
1317
- <details>
1318
- <summary>解答</summary>
1319
-
1320
- ```ruby
1321
- def file_resource(path)
1322
- Resource.make(
1323
- Ch08IO::IO.delay { File.open(path, 'r') }
1324
- ) { |file| file.close }
1325
- end
1326
-
1327
- def read_lines(path)
1328
- file_resource(path).use do |file|
1329
- file.readlines.map(&:chomp)
1330
- end
1331
- end
1332
-
1333
- # 使用例
1334
- lines = read_lines('data.txt').run!
1335
- puts "Read #{lines.size} lines"
1336
- ```
1337
-
1338
- </details>
1339
-
1340
- ### 問題 4: テストシナリオの作成
1341
-
1342
- `create_test_scenario` と `create_failing_scenario` を使って、以下のテストを実装してください:
1343
-
1344
- 1. 正常系: すべてのデータが取得できるケース
1345
- 2. 部分失敗: アーティスト取得のみ失敗するケース
1346
-
1347
- <details>
1348
- <summary>解答</summary>
1349
-
1350
- ```ruby
1351
- RSpec.describe 'TravelGuide scenarios' do
1352
- it 'handles complete success' do
1353
- data_access = Ch12Testing.create_test_scenario
1354
- guide = Ch11Application.travel_guide(data_access, 'Test').run!
1355
-
1356
- expect(guide).not_to be_nil
1357
- expect(guide.search_report.errors).to be_empty
1358
- expect(guide.subjects).not_to be_empty
1359
- end
1360
-
1361
- it 'handles partial failure' do
1362
- location = Ch12Testing::LocationBuilder.new.build
1363
- attraction = Ch12Testing::AttractionBuilder.new.with_location(location).build
1364
-
1365
- data_access = Ch12Testing.create_failing_scenario(
1366
- location: location,
1367
- attraction: attraction,
1368
- artist_error: 'Service unavailable'
1369
- )
1370
-
1371
- guide = Ch11Application.travel_guide(data_access, 'Test').run!
1372
-
1373
- expect(guide).not_to be_nil
1374
- expect(guide.search_report.errors.size).to eq(1)
1375
- expect(guide.search_report.errors.first).to include('Service unavailable')
1376
- end
1377
- end
1378
- ```
1379
-
1380
- </details>
1381
-
1382
- ---
1383
-
1384
- ## シリーズ全体の総括
1385
-
1386
- 本シリーズでは、「Grokking Functional Programming」の内容に沿って、関数型プログラミングの基礎から実践的なアプリケーション構築までを Ruby で学びました。
1387
-
1388
- ### 学んだ主な概念
1389
-
1390
- | Part | 章 | 主な概念 |
1391
- |------|-----|----------|
1392
- | I | 1-2 | 純粋関数、参照透過性 |
1393
- | II | 3-5 | イミュータブルデータ、高階関数、flatMap |
1394
- | III | 6-7 | Option (nil 安全)、Either (結果型)、ADT |
1395
- | IV | 8-9 | IO モナド、Stream |
1396
- | V | 10 | 並行処理、Ref、FiberHandle |
1397
- | VI | 11-12 | 実践アプリケーション、テスト |
1398
-
1399
- ### 関数型プログラミングの利点
1400
-
1401
- 1. **予測可能性**: 純粋関数は同じ入力に対して常に同じ出力
1402
- 2. **テスト容易性**: 副作用がないためテストが簡単
1403
- 3. **合成可能性**: 小さな関数を組み合わせて複雑な処理を構築
1404
- 4. **並行安全性**: イミュータブルデータは競合状態を防ぐ
1405
- 5. **型安全性**: Option、Either でエラーを明示的に表現
1406
-
1407
- ### 次のステップ
1408
-
1409
- - dry-rb ライブラリのより高度な機能を学ぶ
1410
- - dry-monads の実践的な使用方法を深める
1411
- - 実際のプロジェクトで FP パターンを適用する
1412
- - 他の FP 言語 (Haskell, Scala) との比較で理解を深める
1
+ # Part VI: 実践的なアプリケーション構築とテスト
2
+
3
+ 本章では、これまで学んだ関数型プログラミングの概念を統合し、実践的なアプリケーションを構築します。また、関数型プログラミングにおけるテスト戦略についても学びます。
4
+
5
+ ---
6
+
7
+ ## 第11章: 実践的なアプリケーション構築
8
+
9
+ ### 11.1 TravelGuide アプリケーション
10
+
11
+ 旅行ガイドアプリケーションを例に、実践的な FP アプリケーションの構築方法を学びます。
12
+
13
+ ```plantuml
14
+ @startuml
15
+ !theme plain
16
+
17
+ package "TravelGuide Application" {
18
+ rectangle "Model" {
19
+ class Location {
20
+ id: LocationId
21
+ name: String
22
+ population: Integer
23
+ }
24
+
25
+ class Attraction {
26
+ name: String
27
+ description: String
28
+ location: Location
29
+ }
30
+
31
+ class TravelGuide {
32
+ attraction: Attraction
33
+ subjects: Array[String]
34
+ }
35
+ }
36
+
37
+ rectangle "Data Access" {
38
+ interface DataAccess {
39
+ +find_attractions(): IO[Array[Attraction]]
40
+ +find_artists_from_location(): IO[Hash]
41
+ +find_movies_about_location(): IO[Hash]
42
+ }
43
+
44
+ class InMemoryDataAccess
45
+ class CachedDataAccess
46
+ }
47
+
48
+ DataAccess <|.. InMemoryDataAccess
49
+ DataAccess <|.. CachedDataAccess
50
+ }
51
+
52
+ @enduml
53
+ ```
54
+
55
+ ### 11.2 ドメインモデルの定義
56
+
57
+ **ソースファイル**: `app/ruby/src/ch11_application.rb`
58
+
59
+ ```ruby
60
+ # 位置情報を表す値オブジェクト
61
+ class LocationId
62
+ attr_reader :value
63
+
64
+ def initialize(value)
65
+ @value = value
66
+ end
67
+
68
+ def ==(other)
69
+ other.is_a?(LocationId) && @value == other.value
70
+ end
71
+ alias eql? ==
72
+
73
+ def hash
74
+ @value.hash
75
+ end
76
+ end
77
+
78
+ # ロケーション
79
+ Location = Struct.new(:id, :name, :population, keyword_init: true)
80
+
81
+ # アトラクション(観光地)
82
+ Attraction = Struct.new(:name, :description, :location, keyword_init: true)
83
+
84
+ # 旅行ガイド
85
+ TravelGuide = Struct.new(:attraction, :subjects, :search_report, keyword_init: true)
86
+ ```
87
+
88
+ ### 11.3 データアクセス層の抽象化
89
+
90
+ 外部データソースへのアクセスをモジュールで抽象化します。
91
+
92
+ ```ruby
93
+ module DataAccess
94
+ def find_attractions(name, ordering, limit)
95
+ raise NotImplementedError
96
+ end
97
+
98
+ def find_artists_from_location(location_id, limit)
99
+ raise NotImplementedError
100
+ end
101
+
102
+ def find_movies_about_location(location_id, limit)
103
+ raise NotImplementedError
104
+ end
105
+
106
+ def find_hotels_near_location(location_id, limit)
107
+ raise NotImplementedError
108
+ end
109
+ end
110
+ ```
111
+
112
+ ```plantuml
113
+ @startuml
114
+ !theme plain
115
+
116
+ interface DataAccess {
117
+ +find_attractions(): IO[Array[Attraction]]
118
+ +find_artists_from_location(): IO[Hash]
119
+ +find_movies_about_location(): IO[Hash]
120
+ +find_hotels_near_location(): IO[Hash]
121
+ }
122
+
123
+ note right of DataAccess
124
+ 純粋な関数型インターフェース
125
+ すべての操作は IO でラップ
126
+ end note
127
+
128
+ class InMemoryDataAccess {
129
+ -attractions: Array
130
+ -artists: Hash
131
+ -movies: Hash
132
+ +find_attractions(): IO[Array[Attraction]]
133
+ +find_artists_from_location(): IO[Hash]
134
+ +find_movies_about_location(): IO[Hash]
135
+ }
136
+
137
+ class CachedDataAccess {
138
+ -base_access: DataAccess
139
+ -cache: Ref[Hash]
140
+ +find_attractions(): IO[Array[Attraction]]
141
+ +cache_stats(): Hash
142
+ }
143
+
144
+ DataAccess <|.. InMemoryDataAccess
145
+ DataAccess <|.. CachedDataAccess
146
+
147
+ @enduml
148
+ ```
149
+
150
+ ### 11.4 InMemoryDataAccess の実装
151
+
152
+ テストや開発用のインメモリ実装:
153
+
154
+ ```ruby
155
+ class InMemoryDataAccess
156
+ include DataAccess
157
+
158
+ def initialize(attractions: [], artists: {}, movies: {}, hotels: {})
159
+ @attractions = attractions
160
+ @artists = artists
161
+ @movies = movies
162
+ @hotels = hotels
163
+ end
164
+
165
+ def find_attractions(name, ordering, limit)
166
+ Ch08IO::IO.delay do
167
+ filtered = @attractions.select do |a|
168
+ a.name.downcase.include?(name.downcase)
169
+ end
170
+
171
+ sorted = case ordering
172
+ when AttractionOrdering::BY_NAME
173
+ filtered.sort_by(&:name)
174
+ when AttractionOrdering::BY_LOCATION_POPULATION
175
+ filtered.sort_by { |a| -a.location.population }
176
+ else
177
+ filtered
178
+ end
179
+
180
+ sorted.take(limit)
181
+ end
182
+ end
183
+
184
+ def find_artists_from_location(location_id, limit)
185
+ Ch08IO::IO.delay do
186
+ artists = @artists[location_id] || []
187
+ { success: true, value: artists.take(limit) }
188
+ end
189
+ end
190
+
191
+ # 他のメソッドも同様に実装...
192
+ end
193
+ ```
194
+
195
+ ### 11.5 Resource によるリソース管理
196
+
197
+ 安全なリソース管理を実現する `Resource` パターンの実装:
198
+
199
+ **ソースファイル**: `app/ruby/src/ch11_application.rb`
200
+
201
+ ```ruby
202
+ class Resource
203
+ def initialize(acquire, &release)
204
+ @acquire = acquire
205
+ @release = release
206
+ end
207
+
208
+ def self.make(acquire_io, &release)
209
+ new(acquire_io, &release)
210
+ end
211
+
212
+ def use(&fn)
213
+ Ch08IO::IO.delay do
214
+ resource = @acquire.run!
215
+ begin
216
+ fn.call(resource)
217
+ ensure
218
+ @release&.call(resource)
219
+ end
220
+ end
221
+ end
222
+
223
+ def fmap(&fn)
224
+ Resource.new(
225
+ @acquire.fmap(&fn),
226
+ &@release
227
+ )
228
+ end
229
+ end
230
+ ```
231
+
232
+ ```plantuml
233
+ @startuml
234
+ !theme plain
235
+
236
+ participant "Application" as app
237
+ participant "Resource" as res
238
+ participant "リソース" as resource
239
+
240
+ app -> res: Resource.make(acquire) { release }
241
+ res -> resource: acquire (IO を実行)
242
+ resource --> res: リソースを取得
243
+
244
+ app -> res: use { |r| ... }
245
+ res -> resource: 処理を実行
246
+ resource --> res: 結果
247
+
248
+ app -> res: release (自動)
249
+ res -> resource: クリーンアップ
250
+
251
+ note over res
252
+ Resource は例外が発生しても
253
+ 必ず release を実行する
254
+ (ensure ブロック)
255
+ end note
256
+
257
+ @enduml
258
+ ```
259
+
260
+ #### Resource の使用例
261
+
262
+ ```ruby
263
+ # ファイルリソースの例
264
+ file_resource = Resource.make(
265
+ Ch08IO::IO.delay { File.open('data.txt', 'r') }
266
+ ) { |file| file.close }
267
+
268
+ # 使用
269
+ content = file_resource.use { |file| file.read }.run!
270
+
271
+ # データベース接続の例
272
+ db_resource = Resource.make(
273
+ Ch08IO::IO.delay { Database.connect }
274
+ ) { |conn| conn.disconnect }
275
+
276
+ result = db_resource.use { |conn| conn.query('SELECT * FROM users') }.run!
277
+ ```
278
+
279
+ ### 11.6 キャッシュの実装
280
+
281
+ `Ref` を使用したスレッドセーフなキャッシュの実装:
282
+
283
+ ```ruby
284
+ class CachedDataAccess
285
+ include DataAccess
286
+
287
+ def initialize(base_access)
288
+ @base_access = base_access
289
+ @attractions_cache = Ch10Concurrency::Ref.new({})
290
+ @artists_cache = Ch10Concurrency::Ref.new({})
291
+ @movies_cache = Ch10Concurrency::Ref.new({})
292
+ @hotels_cache = Ch10Concurrency::Ref.new({})
293
+ end
294
+
295
+ def find_attractions(name, ordering, limit)
296
+ Ch08IO::IO.delay do
297
+ key = "#{name}-#{ordering}-#{limit}"
298
+ cached = @attractions_cache.get.run!
299
+
300
+ if cached.key?(key)
301
+ cached[key]
302
+ else
303
+ result = @base_access.find_attractions(name, ordering, limit).run!
304
+ @attractions_cache.update { |c| c.merge(key => result) }.run!
305
+ result
306
+ end
307
+ end
308
+ end
309
+
310
+ def cache_stats
311
+ {
312
+ attractions: @attractions_cache.get.run!.size,
313
+ artists: @artists_cache.get.run!.size,
314
+ movies: @movies_cache.get.run!.size,
315
+ hotels: @hotels_cache.get.run!.size
316
+ }
317
+ end
318
+
319
+ # 他のメソッドも同様にキャッシュを実装...
320
+ end
321
+ ```
322
+
323
+ ```plantuml
324
+ @startuml
325
+ !theme plain
326
+ skinparam activity {
327
+ BackgroundColor White
328
+ BorderColor Black
329
+ }
330
+
331
+ start
332
+
333
+ :キャッシュキー生成;
334
+
335
+ :cache.get でキャッシュ確認;
336
+
337
+ if (キャッシュにデータあり?) then (yes)
338
+ :キャッシュからデータ返却;
339
+ else (no)
340
+ :base_access を呼び出し;
341
+ :結果をキャッシュに保存;
342
+ :結果を返却;
343
+ endif
344
+
345
+ stop
346
+
347
+ note right
348
+ Ref を使用した
349
+ スレッドセーフなキャッシュ
350
+ end note
351
+
352
+ @enduml
353
+ ```
354
+
355
+ ### 11.7 FailingDataAccess - テスト用エラー注入
356
+
357
+ テスト用にエラーを注入できる DataAccess の実装:
358
+
359
+ ```ruby
360
+ class FailingDataAccess
361
+ include DataAccess
362
+
363
+ def initialize(base_access, failing_methods: [])
364
+ @base_access = base_access
365
+ @failing_methods = failing_methods
366
+ end
367
+
368
+ def find_artists_from_location(location_id, limit)
369
+ if @failing_methods.include?(:find_artists_from_location)
370
+ Ch08IO::IO.pure({ success: false, error: 'Network error: artists service unavailable' })
371
+ else
372
+ @base_access.find_artists_from_location(location_id, limit)
373
+ end
374
+ end
375
+
376
+ # 他のメソッドも同様...
377
+ end
378
+ ```
379
+
380
+ ### 11.8 アプリケーションの組み立て
381
+
382
+ すべてのコンポーネントを組み合わせてアプリケーションを構築します。
383
+
384
+ ```ruby
385
+ def self.travel_guide(data_access, attraction_name)
386
+ Ch08IO::IO.delay do
387
+ attractions = data_access.find_attractions(
388
+ attraction_name,
389
+ AttractionOrdering::BY_LOCATION_POPULATION,
390
+ 1
391
+ ).run!
392
+
393
+ if attractions.empty?
394
+ nil
395
+ else
396
+ attraction = attractions.first
397
+ location_id = attraction.location.id
398
+
399
+ # 複数のデータソースから情報を取得
400
+ artists_result = data_access.find_artists_from_location(location_id, 2).run!
401
+ movies_result = data_access.find_movies_about_location(location_id, 2).run!
402
+
403
+ # エラーを収集
404
+ errors = []
405
+ errors << artists_result[:error] unless artists_result[:success]
406
+ errors << movies_result[:error] unless movies_result[:success]
407
+
408
+ # 成功した結果を抽出
409
+ artists = artists_result[:success] ? artists_result[:value] : []
410
+ movies = movies_result[:success] ? movies_result[:value] : []
411
+
412
+ subjects = artists.map(&:name) + movies.map(&:name)
413
+
414
+ TravelGuide.new(
415
+ attraction: attraction,
416
+ subjects: subjects,
417
+ search_report: SearchReport.new(
418
+ attractions_searched: attractions.size,
419
+ errors: errors
420
+ )
421
+ )
422
+ end
423
+ end
424
+ end
425
+ ```
426
+
427
+ ```plantuml
428
+ @startuml
429
+ !theme plain
430
+
431
+ rectangle "travel_guide 関数" {
432
+ card "1. アトラクション検索" as step1
433
+ card "2. アーティスト検索" as step2
434
+ card "3. 映画検索" as step3
435
+ card "4. TravelGuide 組み立て" as step4
436
+
437
+ step1 --> step2 : attraction
438
+ step1 --> step3 : location.id
439
+ step2 --> step4 : artists
440
+ step3 --> step4 : movies
441
+ }
442
+
443
+ note bottom
444
+ IO.delay 内で
445
+ 複数の IO を順次実行
446
+ end note
447
+
448
+ @enduml
449
+ ```
450
+
451
+ ### 11.9 ExtendedTravelGuide
452
+
453
+ ホテル情報も含む拡張版:
454
+
455
+ ```ruby
456
+ ExtendedTravelGuide = Struct.new(
457
+ :attraction, :artists, :movies, :hotels, :search_report,
458
+ keyword_init: true
459
+ )
460
+
461
+ def self.extended_travel_guide(data_access, attraction_name)
462
+ Ch08IO::IO.delay do
463
+ attractions = data_access.find_attractions(
464
+ attraction_name,
465
+ AttractionOrdering::BY_LOCATION_POPULATION,
466
+ 1
467
+ ).run!
468
+
469
+ if attractions.empty?
470
+ nil
471
+ else
472
+ attraction = attractions.first
473
+ location_id = attraction.location.id
474
+
475
+ # 並列で取得することも可能
476
+ artists_result = data_access.find_artists_from_location(location_id, 5).run!
477
+ movies_result = data_access.find_movies_about_location(location_id, 5).run!
478
+ hotels_result = data_access.find_hotels_near_location(location_id, 5).run!
479
+
480
+ errors = []
481
+ errors << artists_result[:error] unless artists_result[:success]
482
+ errors << movies_result[:error] unless movies_result[:success]
483
+ errors << hotels_result[:error] unless hotels_result[:success]
484
+
485
+ ExtendedTravelGuide.new(
486
+ attraction: attraction,
487
+ artists: artists_result[:success] ? artists_result[:value] : [],
488
+ movies: movies_result[:success] ? movies_result[:value] : [],
489
+ hotels: hotels_result[:success] ? hotels_result[:value] : [],
490
+ search_report: SearchReport.new(
491
+ attractions_searched: attractions.size,
492
+ errors: errors
493
+ )
494
+ )
495
+ end
496
+ end
497
+ end
498
+ ```
499
+
500
+ ---
501
+
502
+ ## 第12章: テスト戦略
503
+
504
+ ### 12.1 関数型プログラミングのテスト
505
+
506
+ 関数型プログラミングでは、純粋関数のおかげでテストが非常に簡単になります。
507
+
508
+ ```plantuml
509
+ @startuml
510
+ !theme plain
511
+
512
+ rectangle "テストの種類" {
513
+ rectangle "単体テスト" as unit {
514
+ card "純粋関数のテスト"
515
+ card "高速・独立"
516
+ }
517
+
518
+ rectangle "プロパティベーステスト" as property {
519
+ card "ランダム入力"
520
+ card "不変条件の検証"
521
+ }
522
+
523
+ rectangle "統合テスト" as integration {
524
+ card "コンポーネント連携"
525
+ card "スタブ/モック使用"
526
+ }
527
+ }
528
+
529
+ unit --> property : 補完
530
+ property --> integration : 補完
531
+
532
+ @enduml
533
+ ```
534
+
535
+ ### 12.2 SearchReport の導入
536
+
537
+ **ソースファイル**: `app/ruby/src/ch11_application.rb`
538
+
539
+ テスト可能性を高めるため、`SearchReport` を導入します。
540
+
541
+ ```ruby
542
+ class SearchReport
543
+ attr_reader :attractions_searched, :errors
544
+
545
+ def initialize(attractions_searched:, errors:)
546
+ @attractions_searched = attractions_searched
547
+ @errors = errors.freeze
548
+ end
549
+
550
+ def self.empty
551
+ new(attractions_searched: 0, errors: [])
552
+ end
553
+
554
+ def add_error(error)
555
+ SearchReport.new(
556
+ attractions_searched: @attractions_searched,
557
+ errors: @errors + [error]
558
+ )
559
+ end
560
+
561
+ def with_attractions_count(count)
562
+ SearchReport.new(
563
+ attractions_searched: count,
564
+ errors: @errors
565
+ )
566
+ end
567
+ end
568
+ ```
569
+
570
+ ```plantuml
571
+ @startuml
572
+ !theme plain
573
+
574
+ class TravelGuide {
575
+ attraction: Attraction
576
+ subjects: Array[String]
577
+ search_report: SearchReport
578
+ }
579
+
580
+ class SearchReport {
581
+ attractions_searched: Integer
582
+ errors: Array[String]
583
+ +empty(): SearchReport
584
+ +add_error(error): SearchReport
585
+ }
586
+
587
+ TravelGuide --> SearchReport
588
+
589
+ note right of SearchReport
590
+ 検索の統計情報と
591
+ エラー情報を保持
592
+ イミュータブルに更新
593
+ end note
594
+
595
+ @enduml
596
+ ```
597
+
598
+ ### 12.3 テストスタブの実装
599
+
600
+ **ソースファイル**: `app/ruby/src/ch12_testing.rb`
601
+
602
+ ```ruby
603
+ class TestDataAccess
604
+ include Ch11Application::DataAccess
605
+
606
+ def initialize(
607
+ attractions: [],
608
+ artists_by_location: {},
609
+ movies_by_location: {},
610
+ hotels_by_location: {},
611
+ artist_errors: {},
612
+ movie_errors: {},
613
+ hotel_errors: {}
614
+ )
615
+ @attractions = attractions
616
+ @artists_by_location = artists_by_location
617
+ @movies_by_location = movies_by_location
618
+ @hotels_by_location = hotels_by_location
619
+ @artist_errors = artist_errors
620
+ @movie_errors = movie_errors
621
+ @hotel_errors = hotel_errors
622
+ end
623
+
624
+ def find_attractions(name, ordering, limit)
625
+ Ch08IO::IO.delay do
626
+ filtered = @attractions.select { |a| a.name.downcase.include?(name.downcase) }
627
+ sorted = case ordering
628
+ when Ch11Application::AttractionOrdering::BY_NAME
629
+ filtered.sort_by(&:name)
630
+ when Ch11Application::AttractionOrdering::BY_LOCATION_POPULATION
631
+ filtered.sort_by { |a| -a.location.population }
632
+ else
633
+ filtered
634
+ end
635
+ sorted.take(limit)
636
+ end
637
+ end
638
+
639
+ def find_artists_from_location(location_id, limit)
640
+ Ch08IO::IO.delay do
641
+ if @artist_errors[location_id]
642
+ { success: false, error: @artist_errors[location_id] }
643
+ else
644
+ artists = @artists_by_location[location_id] || []
645
+ { success: true, value: artists.take(limit) }
646
+ end
647
+ end
648
+ end
649
+
650
+ # 他のメソッドも同様...
651
+ end
652
+ ```
653
+
654
+ ```plantuml
655
+ @startuml
656
+ !theme plain
657
+
658
+ rectangle "テスト構成" {
659
+ rectangle "本番" as prod {
660
+ interface "DataAccess" as da1
661
+ class "WikidataDataAccess" as wda
662
+ da1 <|.. wda
663
+ }
664
+
665
+ rectangle "テスト" as test {
666
+ interface "DataAccess" as da2
667
+ class "TestDataAccess" as tda
668
+ da2 <|.. tda
669
+ }
670
+ }
671
+
672
+ note bottom of prod
673
+ 実際の API に接続
674
+ end note
675
+
676
+ note bottom of test
677
+ テストデータを返す
678
+ IO.pure/delay で即座に結果
679
+ end note
680
+
681
+ @enduml
682
+ ```
683
+
684
+ ### 12.4 テストデータビルダー
685
+
686
+ テストデータを簡単に構築するためのビルダーパターン:
687
+
688
+ ```ruby
689
+ class LocationBuilder
690
+ def initialize
691
+ @id = Ch11Application::LocationId.new("Q#{rand(1000)}")
692
+ @name = 'Test City'
693
+ @population = 100_000
694
+ end
695
+
696
+ def with_id(id)
697
+ @id = id.is_a?(Ch11Application::LocationId) ? id : Ch11Application::LocationId.new(id)
698
+ self
699
+ end
700
+
701
+ def with_name(name)
702
+ @name = name
703
+ self
704
+ end
705
+
706
+ def with_population(population)
707
+ @population = population
708
+ self
709
+ end
710
+
711
+ def build
712
+ Ch11Application::Location.new(id: @id, name: @name, population: @population)
713
+ end
714
+ end
715
+
716
+ class AttractionBuilder
717
+ def initialize
718
+ @name = 'Test Attraction'
719
+ @description = 'A test attraction'
720
+ @location = LocationBuilder.new.build
721
+ end
722
+
723
+ def with_name(name)
724
+ @name = name
725
+ self
726
+ end
727
+
728
+ def with_location(location)
729
+ @location = location
730
+ self
731
+ end
732
+
733
+ def build
734
+ Ch11Application::Attraction.new(
735
+ name: @name,
736
+ description: @description,
737
+ location: @location
738
+ )
739
+ end
740
+ end
741
+ ```
742
+
743
+ #### 使用例
744
+
745
+ ```ruby
746
+ # シンプルなロケーション
747
+ location = LocationBuilder.new.build
748
+
749
+ # カスタマイズしたロケーション
750
+ sydney = LocationBuilder.new
751
+ .with_name('Sydney')
752
+ .with_population(5_000_000)
753
+ .build
754
+
755
+ # アトラクション with カスタムロケーション
756
+ attraction = AttractionBuilder.new
757
+ .with_name('Opera House')
758
+ .with_location(sydney)
759
+ .build
760
+ ```
761
+
762
+ ### 12.5 プロパティベーステスト
763
+
764
+ ランダムな入力でプロパティ(不変条件)を検証するテスト手法:
765
+
766
+ ```ruby
767
+ module Gen
768
+ def self.string(length = 10)
769
+ chars = ('a'..'z').to_a + ('A'..'Z').to_a
770
+ Array.new(length) { chars.sample }.join
771
+ end
772
+
773
+ def self.int(min = 0, max = 100)
774
+ rand(min..max)
775
+ end
776
+
777
+ def self.positive_int(max = 1_000_000)
778
+ rand(1..max)
779
+ end
780
+
781
+ def self.boolean
782
+ [true, false].sample
783
+ end
784
+
785
+ def self.one_of(*options)
786
+ options.sample
787
+ end
788
+
789
+ def self.list_of(size = 5, &generator)
790
+ Array.new(size) { generator.call }
791
+ end
792
+
793
+ def self.location
794
+ Ch11Application::Location.new(
795
+ id: location_id,
796
+ name: string(8),
797
+ population: positive_int(50_000_000)
798
+ )
799
+ end
800
+
801
+ def self.attraction
802
+ Ch11Application::Attraction.new(
803
+ name: string(15),
804
+ description: option { string(50) },
805
+ location: location
806
+ )
807
+ end
808
+ end
809
+ ```
810
+
811
+ ```plantuml
812
+ @startuml
813
+ !theme plain
814
+
815
+ rectangle "プロパティベーステスト" {
816
+ card "Gen[A]" as gen
817
+ card "ランダムデータ生成" as random
818
+ card "プロパティ検証" as verify
819
+ card "100回以上テスト" as repeat
820
+
821
+ gen --> random
822
+ random --> verify
823
+ verify --> repeat
824
+ repeat --> random : 繰り返し
825
+ }
826
+
827
+ note bottom
828
+ ランダムな入力で
829
+ 不変条件を検証
830
+ end note
831
+
832
+ @enduml
833
+ ```
834
+
835
+ ### 12.6 PropertyTest フレームワーク
836
+
837
+ ```ruby
838
+ class PropertyTest
839
+ attr_reader :name, :failures
840
+
841
+ def initialize(name, iterations: 100)
842
+ @name = name
843
+ @iterations = iterations
844
+ @failures = []
845
+ end
846
+
847
+ def for_all(*generators, &property)
848
+ @iterations.times do |i|
849
+ inputs = generators.map(&:call)
850
+ begin
851
+ result = property.call(*inputs)
852
+ unless result
853
+ @failures << { iteration: i, inputs: inputs, error: 'Property returned false' }
854
+ end
855
+ rescue StandardError => e
856
+ @failures << { iteration: i, inputs: inputs, error: e.message }
857
+ end
858
+ end
859
+ self
860
+ end
861
+
862
+ def passed?
863
+ @failures.empty?
864
+ end
865
+
866
+ def summary
867
+ if passed?
868
+ "#{@name}: PASSED (#{@iterations} iterations)"
869
+ else
870
+ "#{@name}: FAILED (#{@failures.size}/#{@iterations} failures)"
871
+ end
872
+ end
873
+ end
874
+ ```
875
+
876
+ #### 使用例
877
+
878
+ ```ruby
879
+ # プロパティ: フィルタ結果は入力以下
880
+ test = PropertyTest.new('filter returns subset', iterations: 100)
881
+ test.for_all(
882
+ -> { Gen.list_of(10) { Gen.location } },
883
+ -> { Gen.positive_int(10_000_000) }
884
+ ) do |locations, min_pop|
885
+ result = filter_popular_locations(locations, min_pop)
886
+ result.size <= locations.size
887
+ end
888
+
889
+ puts test.summary
890
+ # => "filter returns subset: PASSED (100 iterations)"
891
+ ```
892
+
893
+ ### 12.7 共通プロパティの定義
894
+
895
+ 再利用可能なプロパティを定義:
896
+
897
+ ```ruby
898
+ module Properties
899
+ # フィルタ結果は入力以下
900
+ def self.filter_bounded?(input, result)
901
+ result.size <= input.size
902
+ end
903
+
904
+ # すべての結果が述語を満たす
905
+ def self.filter_satisfies?(result, &predicate)
906
+ result.all?(&predicate)
907
+ end
908
+
909
+ # 制限が守られている
910
+ def self.limit_respected?(result, limit)
911
+ result.size <= limit
912
+ end
913
+
914
+ # 順序が保持されている
915
+ def self.ordering_preserved?(result, &compare)
916
+ result.each_cons(2).all? { |a, b| compare.call(a, b) }
917
+ end
918
+
919
+ # エラー数が制限内
920
+ def self.errors_bounded?(search_report, max_errors)
921
+ search_report.errors.size <= max_errors
922
+ end
923
+ end
924
+ ```
925
+
926
+ ### 12.8 純粋関数のテスト
927
+
928
+ 純粋関数は入力と出力の関係のみをテストすれば良いため、テストが簡単です。
929
+
930
+ ```ruby
931
+ # テスト対象の純粋関数
932
+ def filter_popular_locations(locations, min_population)
933
+ locations.select { |loc| loc.population >= min_population }
934
+ end
935
+
936
+ def sort_attractions_by_name(attractions)
937
+ attractions.sort_by(&:name)
938
+ end
939
+
940
+ def average_rating(hotels)
941
+ return nil if hotels.empty?
942
+ hotels.sum(&:rating) / hotels.size.to_f
943
+ end
944
+ ```
945
+
946
+ #### RSpec でのテスト
947
+
948
+ ```ruby
949
+ RSpec.describe '.filter_popular_locations' do
950
+ it 'filters locations by population' do
951
+ loc1 = LocationBuilder.new.with_population(100_000).build
952
+ loc2 = LocationBuilder.new.with_population(500_000).build
953
+ loc3 = LocationBuilder.new.with_population(200_000).build
954
+
955
+ result = Ch12Testing.filter_popular_locations([loc1, loc2, loc3], 150_000)
956
+
957
+ expect(result.size).to eq(2)
958
+ expect(result.map(&:population)).to all(be >= 150_000)
959
+ end
960
+
961
+ # プロパティベーステスト
962
+ it 'always returns subset of input' do
963
+ test = PropertyTest.new('filter returns subset', iterations: 50)
964
+ test.for_all(
965
+ -> { Gen.list_of(10) { Gen.location } },
966
+ -> { Gen.positive_int(10_000_000) }
967
+ ) do |locations, min_pop|
968
+ result = Ch12Testing.filter_popular_locations(locations, min_pop)
969
+ Properties.filter_bounded?(locations, result)
970
+ end
971
+
972
+ expect(test.passed?).to be true
973
+ end
974
+ end
975
+ ```
976
+
977
+ ### 12.9 統合テスト
978
+
979
+ コンポーネントを組み合わせた統合テスト:
980
+
981
+ ```ruby
982
+ RSpec.describe 'TravelGuide integration tests' do
983
+ it 'works with TestDataAccess' do
984
+ location = Fixtures.sydney
985
+ attraction = Fixtures.sydney_opera_house
986
+
987
+ data_access = TestDataAccess.new(
988
+ attractions: [attraction],
989
+ artists_by_location: { location.id => Fixtures.sydney_artists },
990
+ movies_by_location: { location.id => Fixtures.sydney_movies },
991
+ hotels_by_location: { location.id => Fixtures.sydney_hotels }
992
+ )
993
+
994
+ guide = Ch11Application.travel_guide(data_access, 'Sydney').run!
995
+
996
+ Assertions.assert_travel_guide_valid(guide)
997
+ Assertions.assert_no_errors(guide)
998
+ Assertions.assert_subjects_present(guide)
999
+ end
1000
+
1001
+ it 'handles errors gracefully' do
1002
+ location = Fixtures.sydney
1003
+ attraction = Fixtures.sydney_opera_house
1004
+
1005
+ data_access = TestDataAccess.new(
1006
+ attractions: [attraction],
1007
+ artist_errors: { location.id => 'Network error' },
1008
+ movie_errors: { location.id => 'Timeout' }
1009
+ )
1010
+
1011
+ guide = Ch11Application.travel_guide(data_access, 'Sydney').run!
1012
+
1013
+ Assertions.assert_travel_guide_valid(guide)
1014
+ Assertions.assert_has_errors(guide, count: 2)
1015
+ end
1016
+ end
1017
+ ```
1018
+
1019
+ ### 12.10 テストフィクスチャ
1020
+
1021
+ 事前に構築された再利用可能なテストデータ:
1022
+
1023
+ ```ruby
1024
+ module Fixtures
1025
+ def self.sydney
1026
+ @sydney ||= begin
1027
+ id = Ch11Application::LocationId.new('Q60')
1028
+ Ch11Application::Location.new(id: id, name: 'Sydney', population: 5_312_000)
1029
+ end
1030
+ end
1031
+
1032
+ def self.sydney_opera_house
1033
+ @sydney_opera_house ||= Ch11Application::Attraction.new(
1034
+ name: 'Sydney Opera House',
1035
+ description: 'Iconic performing arts venue',
1036
+ location: sydney
1037
+ )
1038
+ end
1039
+
1040
+ def self.sydney_artists
1041
+ @sydney_artists ||= [
1042
+ Ch11Application::MusicArtist.new(name: 'AC/DC', genre: 'Rock'),
1043
+ Ch11Application::MusicArtist.new(name: 'Sia', genre: 'Pop')
1044
+ ]
1045
+ end
1046
+
1047
+ def self.complete_data_access
1048
+ @complete_data_access ||= TestDataAccess.new(
1049
+ attractions: [sydney_opera_house],
1050
+ artists_by_location: { sydney.id => sydney_artists },
1051
+ movies_by_location: { sydney.id => sydney_movies },
1052
+ hotels_by_location: { sydney.id => sydney_hotels }
1053
+ )
1054
+ end
1055
+ end
1056
+ ```
1057
+
1058
+ ### 12.11 アサーションヘルパー
1059
+
1060
+ テストアサーションを簡潔に書くためのヘルパー:
1061
+
1062
+ ```ruby
1063
+ module Assertions
1064
+ def self.assert_travel_guide_valid(guide)
1065
+ raise 'Guide is nil' if guide.nil?
1066
+ raise 'Attraction is nil' if guide.attraction.nil?
1067
+ raise 'Search report is nil' if guide.search_report.nil?
1068
+ true
1069
+ end
1070
+
1071
+ def self.assert_no_errors(guide)
1072
+ errors = guide.search_report.errors
1073
+ raise "Expected no errors but got: #{errors}" unless errors.empty?
1074
+ true
1075
+ end
1076
+
1077
+ def self.assert_has_errors(guide, count: nil)
1078
+ errors = guide.search_report.errors
1079
+ raise 'Expected errors but got none' if errors.empty?
1080
+ raise "Expected #{count} errors but got #{errors.size}" if count && errors.size != count
1081
+ true
1082
+ end
1083
+ end
1084
+ ```
1085
+
1086
+ ### 12.12 テストピラミッド
1087
+
1088
+ ```plantuml
1089
+ @startuml
1090
+ !theme plain
1091
+
1092
+ rectangle "テストピラミッド" {
1093
+ rectangle "E2E テスト\n(少数)" as e2e
1094
+ rectangle "統合テスト\n(中程度)" as integration
1095
+ rectangle "単体テスト + プロパティテスト\n(多数)" as unit
1096
+ }
1097
+
1098
+ e2e -[hidden]down- integration
1099
+ integration -[hidden]down- unit
1100
+
1101
+ note right of unit
1102
+ FP では純粋関数が多いため
1103
+ 単体テストが非常に効果的
1104
+ end note
1105
+
1106
+ @enduml
1107
+ ```
1108
+
1109
+ ---
1110
+
1111
+ ## まとめ
1112
+
1113
+ ### Part VI で学んだこと
1114
+
1115
+ ```plantuml
1116
+ @startuml
1117
+ !theme plain
1118
+
1119
+ rectangle "Part VI: 実践的なアプリケーション" {
1120
+ rectangle "第11章" as ch11 {
1121
+ card "ドメインモデル設計"
1122
+ card "DataAccess 抽象化"
1123
+ card "Resource 管理"
1124
+ card "キャッシュ実装"
1125
+ }
1126
+
1127
+ rectangle "第12章" as ch12 {
1128
+ card "SearchReport"
1129
+ card "スタブ/テストダブル"
1130
+ card "プロパティベーステスト"
1131
+ card "ビルダーパターン"
1132
+ }
1133
+ }
1134
+
1135
+ ch11 --> ch12
1136
+
1137
+ @enduml
1138
+ ```
1139
+
1140
+ ### 主要コンポーネント
1141
+
1142
+ | コンポーネント | 用途 |
1143
+ |----------------|------|
1144
+ | `DataAccess` | 外部データソースへのアクセス抽象化 |
1145
+ | `InMemoryDataAccess` | テスト・開発用のインメモリ実装 |
1146
+ | `CachedDataAccess` | Ref を使ったキャッシュ層 |
1147
+ | `FailingDataAccess` | エラー注入用のラッパー |
1148
+ | `Resource` | 安全なリソース管理 |
1149
+ | `SearchReport` | 検索統計とエラー追跡 |
1150
+ | `TestDataAccess` | テスト用スタブ実装 |
1151
+ | `LocationBuilder` | テストデータビルダー |
1152
+ | `PropertyTest` | プロパティベーステスト |
1153
+
1154
+ ### Ruby と Scala の対応
1155
+
1156
+ | Scala | Ruby |
1157
+ |-------|------|
1158
+ | `trait DataAccess` | `module DataAccess` |
1159
+ | `case class` | `Struct` |
1160
+ | `opaque type LocationId` | `LocationId` クラス |
1161
+ | `Resource[IO, A]` | `Resource` クラス |
1162
+ | `Either[String, A]` | `{ success: bool, value/error: ... }` |
1163
+ | `ScalaCheck Gen` | `Gen` モジュール |
1164
+ | `property` | `PropertyTest` |
1165
+
1166
+ ### キーポイント
1167
+
1168
+ 1. **抽象化の重要性**: DataAccess モジュールで外部依存を抽象化
1169
+ 2. **Resource でリソース管理**: ensure ブロックで安全なリソースの取得と解放
1170
+ 3. **Ref でキャッシュ**: スレッドセーフな状態管理
1171
+ 4. **Hash でエラー処理**: `{ success:, value/error: }` で明示的なエラーハンドリング
1172
+ 5. **SearchReport**: テスト可能性と可観測性の向上
1173
+ 6. **スタブ**: 外部依存を差し替えてテスト
1174
+ 7. **プロパティベーステスト**: ランダム入力で不変条件を検証
1175
+ 8. **ビルダーパターン**: テストデータの柔軟な構築
1176
+
1177
+ ### 学習の総括
1178
+
1179
+ ```plantuml
1180
+ @startuml
1181
+ !theme plain
1182
+ left to right direction
1183
+
1184
+ rectangle "FP の学習パス" {
1185
+ card "Part I\n基礎" as p1
1186
+ card "Part II\nイミュータブル操作" as p2
1187
+ card "Part III\n型による安全性" as p3
1188
+ card "Part IV\nIO/Stream" as p4
1189
+ card "Part V\n並行処理" as p5
1190
+ card "Part VI\n実践" as p6
1191
+ }
1192
+
1193
+ p1 --> p2
1194
+ p2 --> p3
1195
+ p3 --> p4
1196
+ p4 --> p5
1197
+ p5 --> p6
1198
+
1199
+ @enduml
1200
+ ```
1201
+
1202
+ ---
1203
+
1204
+ ## 演習問題
1205
+
1206
+ ### 問題 1: DataAccess の拡張
1207
+
1208
+ 以下の要件で `DataAccess` を拡張してください:
1209
+
1210
+
1211
+ - 新しいメソッド `find_restaurants_near_location` を追加
1212
+ - 戻り値は `IO[{ success: Boolean, value/error: ... }]`
1213
+
1214
+ <details>
1215
+ <summary>解答</summary>
1216
+
1217
+ ```ruby
1218
+ Restaurant = Struct.new(:name, :cuisine, :rating, :location, keyword_init: true)
1219
+
1220
+ module DataAccess
1221
+ # 既存のメソッド...
1222
+
1223
+ def find_restaurants_near_location(location_id, limit)
1224
+ raise NotImplementedError
1225
+ end
1226
+ end
1227
+
1228
+ class InMemoryDataAccess
1229
+ def initialize(attractions: [], artists: {}, movies: {}, hotels: {}, restaurants: {})
1230
+ # ...
1231
+ @restaurants = restaurants
1232
+ end
1233
+
1234
+ def find_restaurants_near_location(location_id, limit)
1235
+ Ch08IO::IO.delay do
1236
+ restaurants = @restaurants[location_id] || []
1237
+ { success: true, value: restaurants.take(limit) }
1238
+ end
1239
+ end
1240
+ end
1241
+
1242
+ # テスト用スタブ
1243
+ class TestDataAccess
1244
+ def initialize(restaurants_by_location: {}, restaurant_errors: {}, **options)
1245
+ # ...
1246
+ @restaurants_by_location = restaurants_by_location
1247
+ @restaurant_errors = restaurant_errors
1248
+ end
1249
+
1250
+ def find_restaurants_near_location(location_id, limit)
1251
+ Ch08IO::IO.delay do
1252
+ if @restaurant_errors[location_id]
1253
+ { success: false, error: @restaurant_errors[location_id] }
1254
+ else
1255
+ restaurants = @restaurants_by_location[location_id] || []
1256
+ { success: true, value: restaurants.take(limit) }
1257
+ end
1258
+ end
1259
+ end
1260
+ end
1261
+ ```
1262
+
1263
+ </details>
1264
+
1265
+ ### 問題 2: プロパティベーステスト
1266
+
1267
+ 以下の関数に対するプロパティベーステストを書いてください:
1268
+
1269
+ ```ruby
1270
+ def filter_popular_locations(locations, min_population)
1271
+ locations.select { |loc| loc.population >= min_population }
1272
+ end
1273
+ ```
1274
+
1275
+ <details>
1276
+ <summary>解答</summary>
1277
+
1278
+ ```ruby
1279
+ # プロパティ1: 結果は入力以下の要素数
1280
+ test1 = PropertyTest.new('result size <= input size', iterations: 100)
1281
+ test1.for_all(
1282
+ -> { Gen.list_of(10) { Gen.location } },
1283
+ -> { Gen.positive_int(10_000_000) }
1284
+ ) do |locations, min_pop|
1285
+ result = filter_popular_locations(locations, min_pop)
1286
+ result.size <= locations.size
1287
+ end
1288
+
1289
+ # プロパティ2: 結果のすべての要素は条件を満たす
1290
+ test2 = PropertyTest.new('all results meet minimum', iterations: 100)
1291
+ test2.for_all(
1292
+ -> { Gen.list_of(10) { Gen.location } },
1293
+ -> { Gen.positive_int(10_000_000) }
1294
+ ) do |locations, min_pop|
1295
+ result = filter_popular_locations(locations, min_pop)
1296
+ result.all? { |loc| loc.population >= min_pop }
1297
+ end
1298
+
1299
+ # プロパティ3: 条件を満たす要素はすべて結果に含まれる
1300
+ test3 = PropertyTest.new('all qualifying in result', iterations: 100)
1301
+ test3.for_all(
1302
+ -> { Gen.list_of(10) { Gen.location } },
1303
+ -> { Gen.positive_int(10_000_000) }
1304
+ ) do |locations, min_pop|
1305
+ result = filter_popular_locations(locations, min_pop)
1306
+ qualifying = locations.select { |loc| loc.population >= min_pop }
1307
+ qualifying.all? { |loc| result.include?(loc) }
1308
+ end
1309
+ ```
1310
+
1311
+ </details>
1312
+
1313
+ ### 問題 3: Resource の実装
1314
+
1315
+ ファイルを安全に読み取る `Resource` を実装してください。
1316
+
1317
+ <details>
1318
+ <summary>解答</summary>
1319
+
1320
+ ```ruby
1321
+ def file_resource(path)
1322
+ Resource.make(
1323
+ Ch08IO::IO.delay { File.open(path, 'r') }
1324
+ ) { |file| file.close }
1325
+ end
1326
+
1327
+ def read_lines(path)
1328
+ file_resource(path).use do |file|
1329
+ file.readlines.map(&:chomp)
1330
+ end
1331
+ end
1332
+
1333
+ # 使用例
1334
+ lines = read_lines('data.txt').run!
1335
+ puts "Read #{lines.size} lines"
1336
+ ```
1337
+
1338
+ </details>
1339
+
1340
+ ### 問題 4: テストシナリオの作成
1341
+
1342
+ `create_test_scenario` と `create_failing_scenario` を使って、以下のテストを実装してください:
1343
+
1344
+ 1. 正常系: すべてのデータが取得できるケース
1345
+ 2. 部分失敗: アーティスト取得のみ失敗するケース
1346
+
1347
+ <details>
1348
+ <summary>解答</summary>
1349
+
1350
+ ```ruby
1351
+ RSpec.describe 'TravelGuide scenarios' do
1352
+ it 'handles complete success' do
1353
+ data_access = Ch12Testing.create_test_scenario
1354
+ guide = Ch11Application.travel_guide(data_access, 'Test').run!
1355
+
1356
+ expect(guide).not_to be_nil
1357
+ expect(guide.search_report.errors).to be_empty
1358
+ expect(guide.subjects).not_to be_empty
1359
+ end
1360
+
1361
+ it 'handles partial failure' do
1362
+ location = Ch12Testing::LocationBuilder.new.build
1363
+ attraction = Ch12Testing::AttractionBuilder.new.with_location(location).build
1364
+
1365
+ data_access = Ch12Testing.create_failing_scenario(
1366
+ location: location,
1367
+ attraction: attraction,
1368
+ artist_error: 'Service unavailable'
1369
+ )
1370
+
1371
+ guide = Ch11Application.travel_guide(data_access, 'Test').run!
1372
+
1373
+ expect(guide).not_to be_nil
1374
+ expect(guide.search_report.errors.size).to eq(1)
1375
+ expect(guide.search_report.errors.first).to include('Service unavailable')
1376
+ end
1377
+ end
1378
+ ```
1379
+
1380
+ </details>
1381
+
1382
+ ---
1383
+
1384
+ ## シリーズ全体の総括
1385
+
1386
+ 本シリーズでは、「Grokking Functional Programming」の内容に沿って、関数型プログラミングの基礎から実践的なアプリケーション構築までを Ruby で学びました。
1387
+
1388
+ ### 学んだ主な概念
1389
+
1390
+ | Part | 章 | 主な概念 |
1391
+ |------|-----|----------|
1392
+ | I | 1-2 | 純粋関数、参照透過性 |
1393
+ | II | 3-5 | イミュータブルデータ、高階関数、flatMap |
1394
+ | III | 6-7 | Option (nil 安全)、Either (結果型)、ADT |
1395
+ | IV | 8-9 | IO モナド、Stream |
1396
+ | V | 10 | 並行処理、Ref、FiberHandle |
1397
+ | VI | 11-12 | 実践アプリケーション、テスト |
1398
+
1399
+ ### 関数型プログラミングの利点
1400
+
1401
+ 1. **予測可能性**: 純粋関数は同じ入力に対して常に同じ出力
1402
+ 2. **テスト容易性**: 副作用がないためテストが簡単
1403
+ 3. **合成可能性**: 小さな関数を組み合わせて複雑な処理を構築
1404
+ 4. **並行安全性**: イミュータブルデータは競合状態を防ぐ
1405
+ 5. **型安全性**: Option、Either でエラーを明示的に表現
1406
+
1407
+ ### 次のステップ
1408
+
1409
+ - dry-rb ライブラリのより高度な機能を学ぶ
1410
+ - dry-monads の実践的な使用方法を深める
1411
+ - 実際のプロジェクトで FP パターンを適用する
1412
+ - 他の FP 言語 (Haskell, Scala) との比較で理解を深める