laser-cutter 2.0.0 → 3.0.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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/pages.yml +44 -0
  3. data/.gitignore +2 -0
  4. data/.openlanes/config.yml +106 -0
  5. data/.plans/002.00/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257lid-options/plan.md +45 -0
  6. data/.plans/003.00/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257ruby-api/plan.md +37 -0
  7. data/.plans/004.00/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257can-we-create-an-angled-box-where-angle-is-configurable-like-in-spec-wishes-image-shows/spec.md +40 -0
  8. data/.plans/004.00/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257can-we-create-an-angled-box-where-angle-is-configurable-like-in-spec-wishes-image-shows/state.json +337 -0
  9. data/.plans/004.01/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257sloped-box-panels/plan.md +91 -0
  10. data/.plans/decisions.md +11 -0
  11. data/CHANGELOG.md +134 -0
  12. data/CLAUDE.md +30 -5
  13. data/Gemfile +2 -1
  14. data/README.md +309 -31
  15. data/Rakefile +11 -7
  16. data/docs/badges/coverage_badge.svg +2 -2
  17. data/docs/decisions/decisions-on-angled-box.md +93 -0
  18. data/docs/decisions/stack.md +6 -0
  19. data/docs/images/box-3d.avif +0 -0
  20. data/docs/images/box-lid-back.avif +0 -0
  21. data/docs/images/box-lid-full.avif +0 -0
  22. data/docs/images/box-lid-plain.avif +0 -0
  23. data/docs/images/box-metric.avif +0 -0
  24. data/docs/images/box-sloped-3d.avif +0 -0
  25. data/docs/images/box-sloped.avif +0 -0
  26. data/docs/images/box-tray.avif +0 -0
  27. data/justfile +24 -8
  28. data/laser-cutter.gemspec +2 -1
  29. data/lib/laser/cutter/aggregator.rb +28 -0
  30. data/lib/laser/cutter/box.rb +192 -24
  31. data/lib/laser/cutter/box_factory.rb +15 -0
  32. data/lib/laser/cutter/cli/command.rb +27 -1
  33. data/lib/laser/cutter/cli/config_file.rb +2 -0
  34. data/lib/laser/cutter/cli/examples.rb +8 -0
  35. data/lib/laser/cutter/cli/generate.rb +41 -5
  36. data/lib/laser/cutter/cli/help.rb +4 -0
  37. data/lib/laser/cutter/cli/page_sizes.rb +3 -0
  38. data/lib/laser/cutter/cli/version.rb +2 -0
  39. data/lib/laser/cutter/cli.rb +23 -4
  40. data/lib/laser/cutter/configuration.rb +42 -2
  41. data/lib/laser/cutter/geometry/dimensions.rb +7 -0
  42. data/lib/laser/cutter/geometry/line.rb +42 -0
  43. data/lib/laser/cutter/geometry/loop.rb +138 -0
  44. data/lib/laser/cutter/geometry/point.rb +3 -0
  45. data/lib/laser/cutter/geometry/rect.rb +25 -0
  46. data/lib/laser/cutter/geometry/shape.rb +19 -1
  47. data/lib/laser/cutter/geometry/transform.rb +50 -0
  48. data/lib/laser/cutter/geometry/tuple.rb +47 -11
  49. data/lib/laser/cutter/invalid_option.rb +8 -0
  50. data/lib/laser/cutter/launcher.rb +14 -1
  51. data/lib/laser/cutter/missing_option.rb +2 -0
  52. data/lib/laser/cutter/notching/angled_edge.rb +67 -0
  53. data/lib/laser/cutter/notching/base.rb +8 -0
  54. data/lib/laser/cutter/notching/edge.rb +59 -4
  55. data/lib/laser/cutter/notching/infinite_iterator.rb +11 -1
  56. data/lib/laser/cutter/notching/path_generator.rb +86 -81
  57. data/lib/laser/cutter/notching/shift.rb +4 -0
  58. data/lib/laser/cutter/options.rb +175 -0
  59. data/lib/laser/cutter/page_manager.rb +12 -2
  60. data/lib/laser/cutter/renderer/base.rb +26 -4
  61. data/lib/laser/cutter/renderer/box_renderer.rb +14 -1
  62. data/lib/laser/cutter/renderer/layout_renderer.rb +13 -3
  63. data/lib/laser/cutter/renderer/line_renderer.rb +6 -0
  64. data/lib/laser/cutter/renderer/meta_renderer.rb +33 -9
  65. data/lib/laser/cutter/renderer/rect_renderer.rb +5 -0
  66. data/lib/laser/cutter/renderer/svg_renderer.rb +12 -4
  67. data/lib/laser/cutter/renderer.rb +2 -0
  68. data/lib/laser/cutter/sloped/box.rb +90 -0
  69. data/lib/laser/cutter/sloped/corners.rb +58 -0
  70. data/lib/laser/cutter/sloped/layout.rb +97 -0
  71. data/lib/laser/cutter/sloped/notcher.rb +53 -0
  72. data/lib/laser/cutter/sloped/panels.rb +121 -0
  73. data/lib/laser/cutter/sloped/placement.rb +36 -0
  74. data/lib/laser/cutter/sloped/profile.rb +176 -0
  75. data/lib/laser/cutter/sloped/request.rb +31 -0
  76. data/lib/laser/cutter/sloped/ring_panel.rb +120 -0
  77. data/lib/laser/cutter/sloped/side_panel.rb +89 -0
  78. data/lib/laser/cutter/types.rb +60 -0
  79. data/lib/laser/cutter/units_converter.rb +5 -0
  80. data/lib/laser/cutter/version.rb +2 -1
  81. data/lib/laser/cutter/zero_value_not_allowed.rb +2 -0
  82. data/lib/laser/cutter.rb +40 -0
  83. data/spec/laser/cutter/angled_edge_spec.rb +103 -0
  84. data/spec/laser/cutter/box_factory_spec.rb +19 -0
  85. data/spec/laser/cutter/box_lid_spec.rb +142 -0
  86. data/spec/laser/cutter/cli_spec.rb +114 -7
  87. data/spec/laser/cutter/configuration_spec.rb +54 -0
  88. data/spec/laser/cutter/loop_spec.rb +107 -0
  89. data/spec/laser/cutter/options_spec.rb +162 -0
  90. data/spec/laser/cutter/renderer/layout_renderer_spec.rb +21 -20
  91. data/spec/laser/cutter/renderer/meta_renderer_spec.rb +82 -0
  92. data/spec/laser/cutter/renderer/svg_renderer_spec.rb +34 -0
  93. data/spec/laser/cutter/sloped/assembly_spec.rb +78 -0
  94. data/spec/laser/cutter/sloped/box_spec.rb +151 -0
  95. data/spec/laser/cutter/sloped/corners_spec.rb +45 -0
  96. data/spec/laser/cutter/sloped/layout_spec.rb +77 -0
  97. data/spec/laser/cutter/sloped/notcher_spec.rb +57 -0
  98. data/spec/laser/cutter/sloped/panels_spec.rb +175 -0
  99. data/spec/laser/cutter/sloped/placement_spec.rb +50 -0
  100. data/spec/laser/cutter/sloped/request_spec.rb +48 -0
  101. data/spec/laser/cutter/sloped/ring_panel_spec.rb +102 -0
  102. data/spec/laser/cutter/sloped/side_panel_spec.rb +98 -0
  103. data/spec/laser/cutter/sloped_profile_spec.rb +156 -0
  104. data/spec/laser/cutter/transform_spec.rb +53 -0
  105. data/spec/laser/cutter_spec.rb +114 -0
  106. data/spec/spec_helper.rb +4 -0
  107. data/spec/support/loops.rb +106 -0
  108. data/spec/support/outline.rb +53 -0
  109. data/spec/support/sloped.rb +26 -0
  110. data/spec/support/solid.rb +95 -0
  111. data/spec/wishes/wish-tilted-box.png +0 -0
  112. metadata +81 -7
  113. /data/.plans/{001.00-dry-cli-migration/plan.md → 001.00/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257dry-cli-migration/plan.md"} +0 -0
@@ -0,0 +1,91 @@
1
+ # Plan 004.01: draw the sloped box
2
+
3
+ Follows `docs/decisions/decisions-on-angled-box.md`. PR #25 built `Geometry::Transform`, `Notching::AngledEdge` and `Sloped::Profile`. This plan draws the box.
4
+
5
+ ## Outcome
6
+
7
+ `laser-cutter generate -b 4x3x5/0.125 --slope 45 --front-height 1 -o box.pdf` writes seven panels: two sides, bottom, back, top strip, tilted panel, front strip. Without `--slope` nothing changes.
8
+
9
+ ## Design
10
+
11
+ ```mermaid
12
+ flowchart TD
13
+ Config --> BoxFactory
14
+ BoxFactory -->|no slope| Box
15
+ BoxFactory -->|slope| SB[Sloped::Box]
16
+ SB --> Profile
17
+ SB --> Panels
18
+ Panels --> SidePanel
19
+ Panels --> RingPanel
20
+ Panels --> Corners
21
+ SidePanel --> Notcher
22
+ RingPanel --> Notcher
23
+ Notcher --> AngledEdge
24
+ SB --> Layout --> Placement
25
+ SB --> Loop[Geometry::Loop]
26
+ ```
27
+
28
+ - **`Geometry::Loop`**: a closed outline as ordered points. It drops repeated points, spikes and collinear points, grows by a distance (the kerf), and turns into lines.
29
+ - **`Sloped::Notcher`**: the notched path from one point to another, through `AngledEdge` without kerf.
30
+ - **`Sloped::RingPanel`**: a rectangular panel. Each long edge is notched or plain; each end is notched for a stretch and covers the side wall for the rest; each corner square is its own or not.
31
+ - **`Sloped::SidePanel`**: the five-sided wall, with the two triangles that close the wedges under the strips.
32
+ - **`Sloped::Corners`**: which panel owns the corner cube at each square corner of the side.
33
+ - **`Sloped::Panels`**: the seven panels, each in its own frame.
34
+ - **`Sloped::Layout`** and **`Sloped::Placement`**: where each panel goes on the sheet.
35
+ - **`Sloped::Box`**: the facade the renderers use, with the interface of `Box`: `generate_notches`, `outlines`, `notches`, `enclosure`, `metadata=`.
36
+ - **`BoxFactory`**: picks `Box` or `Sloped::Box`. The two renderers ask it instead of naming `Box`.
37
+
38
+ ### Joints
39
+
40
+ | Joint | Kind |
41
+ | -------------------------------------------------------- | --------------------------------------------------------------------------------- |
42
+ | side to bottom, back, top strip, front strip | notched, side centre in |
43
+ | side to tilted panel | notched with `--lid full`; plain with `--lid plain`, the panel lying on the sides |
44
+ | bottom to back, bottom to front strip, back to top strip | notched; back and front strip centre out |
45
+ | tilted panel to a strip | plain butt joint, the strip covering the end of the side |
46
+ | tilted panel to back or bottom, a strip dropped | plain, both ending at the corner |
47
+
48
+ A corner cube goes to the back or the front strip, unless both of its notches at that corner are holes; then the bottom or the top strip takes it.
49
+
50
+ ### Kerf
51
+
52
+ Every panel is built without kerf and its loop is then grown by half the kerf. That is exact at the corners that are not square.
53
+
54
+ ### Sheet
55
+
56
+ ```text
57
+ +-------+
58
+ | front |
59
+ +-------+
60
+ | tilted|
61
+ +-------+
62
+ | top |
63
+ +------++-------++------+
64
+ | side || back || side |
65
+ +------++-------++------+
66
+ | bottom|
67
+ +-------+
68
+ ```
69
+
70
+ The metadata block keeps its place at the bottom left.
71
+
72
+ ### Options
73
+
74
+ - `--slope DEGREES`, above 0 and below 90. `--front-height HF`, zero or more.
75
+ - `--slope` needs `--front-height`, and `--front-height` needs `--slope`.
76
+ - `--lid back` with `--slope` raises `InvalidOption`.
77
+ - Both are `Options` attributes, and are printed in the metadata.
78
+
79
+ ## Steps
80
+
81
+ 1. `Geometry::Loop`, with specs.
82
+ 1. `Notcher`, `RingPanel`, `SidePanel`, `Corners`, `Panels`, with specs that every joint interlocks.
83
+ 1. `Placement`, `Layout`, `Sloped::Box`, `BoxFactory`; renderers through the factory.
84
+ 1. `Configuration`, `Types`, `Options`, `generate`, metadata.
85
+ 1. README, `CLAUDE.md`, decisions.
86
+
87
+ ## Done when
88
+
89
+ - `just lint` and `just test` are green, coverage above 95%.
90
+ - A PDF and an SVG of a sloped box render, with and without each strip, for both lids.
91
+ - The six-panel box draws exactly what it drew before.
@@ -0,0 +1,11 @@
1
+ # Decisions
2
+
3
+ ## desired_codebase_quality: high
4
+
5
+ Please indicate the desired quality of the codebase. Decided by openlanes init on 2026-11-25, written to `.openlanes/config.yml`.
6
+
7
+ a) high: the highest quality software design, modularity, low inter-module coupling, high intra-module cohesion, design patterns, events, immutability and functional programming, at the cost of slower delivery, more rounds per plan and high standards for accepting the review. SOLID classes and maximum reuse in OO code; the most sophisticated UI. A "review-passed" PR returns to developers. **(chosen)**
8
+
9
+ b) standard: a reasonable middle ground. Similar modularity and full test coverage, but less strict on SOLID, immutability and functional programming; likely fewer rounds and faster delivery. A "review-passed" PR returns to developers.
10
+
11
+ c) mvp: the fastest and least designed codebase, for MVPs and prototypes, not for software with paying customers. Cheapest in AI tokens, most likely to have bugs, and a less sophisticated UI. A "review-passed" PR is accepted, as it has no blocking issues.
data/CHANGELOG.md ADDED
@@ -0,0 +1,134 @@
1
+ # Changelog
2
+
3
+ ## [v3.0.0](https://github.com/kigster/laser-cutter/tree/v3.0.0) (2026-12-02)
4
+
5
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v2.0.1...v3.0.0)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Changing tab size lead to minor error - a 'finger' thats not needed. [\#16](https://github.com/kigster/laser-cutter/issues/16)
10
+ - setting Notch value can result in one side with incorrect tab width [\#6](https://github.com/kigster/laser-cutter/issues/6)
11
+
12
+ **Closed issues:**
13
+
14
+ - Nesting Storage boxes [\#3](https://github.com/kigster/laser-cutter/issues/3)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - Document the gem with YARD and publish it to Pages [\#29](https://github.com/kigster/laser-cutter/pull/29) ([kigster](https://github.com/kigster))
19
+ - Show the assembled sloped box in the README [\#28](https://github.com/kigster/laser-cutter/pull/28) ([kigster](https://github.com/kigster))
20
+ - Add notching along edges at any angle [\#25](https://github.com/kigster/laser-cutter/pull/25) ([kigster](https://github.com/kigster))
21
+ - Pin the terminal width for the CLI specs [\#24](https://github.com/kigster/laser-cutter/pull/24) ([kigster](https://github.com/kigster))
22
+ - Document storage-box assembly and requested sizes [\#23](https://github.com/kigster/laser-cutter/pull/23) ([Copilot](https://github.com/apps/copilot-swe-agent))
23
+
24
+ ## [v2.0.1](https://github.com/kigster/laser-cutter/tree/v2.0.1) (2026-09-30)
25
+
26
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v2.0.0...v2.0.1)
27
+
28
+ **Merged pull requests:**
29
+
30
+ - Add a typed Ruby API: Options, render and write [\#22](https://github.com/kigster/laser-cutter/pull/22) ([kigster](https://github.com/kigster))
31
+ - Add lids that lift off: --lid back and plain [\#21](https://github.com/kigster/laser-cutter/pull/21) ([kigster](https://github.com/kigster))
32
+
33
+ ## [v2.0.0](https://github.com/kigster/laser-cutter/tree/v2.0.0) (2026-09-30)
34
+
35
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v1.0.5...v2.0.0)
36
+
37
+ **Merged pull requests:**
38
+
39
+ - Sweep collinear lines instead of comparing every pair [\#20](https://github.com/kigster/laser-cutter/pull/20) ([kigster](https://github.com/kigster))
40
+ - Fixing rake doc and removing unused files [\#19](https://github.com/kigster/laser-cutter/pull/19) ([kigster](https://github.com/kigster))
41
+ - Migrate the CLI to dry-cli, load with Zeitwerk [\#18](https://github.com/kigster/laser-cutter/pull/18) ([kigster](https://github.com/kigster))
42
+ - Version 2.0.0-alpha [\#17](https://github.com/kigster/laser-cutter/pull/17) ([kigster](https://github.com/kigster))
43
+ - Adding matrix gem dependency [\#15](https://github.com/kigster/laser-cutter/pull/15) ([kigster](https://github.com/kigster))
44
+ - Working branch of 1.0.3 [\#13](https://github.com/kigster/laser-cutter/pull/13) ([kigster](https://github.com/kigster))
45
+
46
+ ## [v1.0.5](https://github.com/kigster/laser-cutter/tree/v1.0.5) (2018-01-01)
47
+
48
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v1.0.3...v1.0.5)
49
+
50
+ **Fixed bugs:**
51
+
52
+ - Stuart - download of PDF [\#11](https://github.com/kigster/laser-cutter/issues/11)
53
+ - Issue with generating PDF file when using millimeters unit via the website \(makebox.io\) [\#10](https://github.com/kigster/laser-cutter/issues/10)
54
+ - "Include dimensions?"-checkbox doesn't seem to be working [\#5](https://github.com/kigster/laser-cutter/issues/5)
55
+
56
+ **Merged pull requests:**
57
+
58
+ - Add a Gitter chat badge to README.md [\#8](https://github.com/kigster/laser-cutter/pull/8) ([gitter-badger](https://github.com/gitter-badger))
59
+
60
+ ## [v1.0.3](https://github.com/kigster/laser-cutter/tree/v1.0.3) (2014-11-01)
61
+
62
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v1.0.2...v1.0.3)
63
+
64
+ ## [v1.0.2](https://github.com/kigster/laser-cutter/tree/v1.0.2) (2014-10-30)
65
+
66
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v1.0.1...v1.0.2)
67
+
68
+ ## [v1.0.1](https://github.com/kigster/laser-cutter/tree/v1.0.1) (2014-10-30)
69
+
70
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v1.0.0...v1.0.1)
71
+
72
+ ## [v1.0.0](https://github.com/kigster/laser-cutter/tree/v1.0.0) (2014-10-30)
73
+
74
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.5.3...v1.0.0)
75
+
76
+ **Merged pull requests:**
77
+
78
+ - Adding Kerf implementation – it's a bit ugly, but it goddamn works :\) [\#2](https://github.com/kigster/laser-cutter/pull/2) ([kigster](https://github.com/kigster))
79
+
80
+ ## [v0.5.3](https://github.com/kigster/laser-cutter/tree/v0.5.3) (2014-10-05)
81
+
82
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.5.1...v0.5.3)
83
+
84
+ ## [v0.5.1](https://github.com/kigster/laser-cutter/tree/v0.5.1) (2014-09-30)
85
+
86
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.5.0...v0.5.1)
87
+
88
+ ## [v0.5.0](https://github.com/kigster/laser-cutter/tree/v0.5.0) (2014-09-29)
89
+
90
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.4.3...v0.5.0)
91
+
92
+ ## [v0.4.3](https://github.com/kigster/laser-cutter/tree/v0.4.3) (2014-09-28)
93
+
94
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.4.1...v0.4.3)
95
+
96
+ ## [v0.4.1](https://github.com/kigster/laser-cutter/tree/v0.4.1) (2014-09-27)
97
+
98
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.4.0...v0.4.1)
99
+
100
+ ## [v0.4.0](https://github.com/kigster/laser-cutter/tree/v0.4.0) (2014-09-23)
101
+
102
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.3.2...v0.4.0)
103
+
104
+ **Fixed bugs:**
105
+
106
+ - Sometimes depending on the size of the side, corners may be cut out [\#1](https://github.com/kigster/laser-cutter/issues/1)
107
+
108
+ ## [v0.3.2](https://github.com/kigster/laser-cutter/tree/v0.3.2) (2014-09-22)
109
+
110
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.3.1...v0.3.2)
111
+
112
+ ## [v0.3.1](https://github.com/kigster/laser-cutter/tree/v0.3.1) (2014-09-22)
113
+
114
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.3.0...v0.3.1)
115
+
116
+ ## [v0.3.0](https://github.com/kigster/laser-cutter/tree/v0.3.0) (2014-09-22)
117
+
118
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.2.2...v0.3.0)
119
+
120
+ ## [v0.2.2](https://github.com/kigster/laser-cutter/tree/v0.2.2) (2014-09-22)
121
+
122
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.2.1...v0.2.2)
123
+
124
+ ## [v0.2.1](https://github.com/kigster/laser-cutter/tree/v0.2.1) (2014-09-22)
125
+
126
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/v0.2.0...v0.2.1)
127
+
128
+ ## [v0.2.0](https://github.com/kigster/laser-cutter/tree/v0.2.0) (2014-09-22)
129
+
130
+ [Full Changelog](https://github.com/kigster/laser-cutter/compare/580f3922bfb1c00847dc7e44f72b6a234179cecb...v0.2.0)
131
+
132
+
133
+
134
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/CLAUDE.md CHANGED
@@ -17,11 +17,13 @@ just test # rspec (progress format, random order)
17
17
  just test spec/laser/cutter/edge_spec.rb:42 # one file or example
18
18
  just test-docs # rspec --format documentation
19
19
  just ci # lint + test-coverage
20
- just doc # YARD docs
20
+ just doc # YARD docs into doc/ (rake doc)
21
21
  ```
22
22
 
23
23
  - `bundle exec rspec`, `bundle exec rubocop` and `bundle exec rake` (default task `spec`) also work.
24
24
  - Every rspec run rewrites `docs/badges/coverage_badge.svg` through the SimpleCov `at_exit` hook in `spec/spec_helper.rb`. That file shows up in `git status` after any test run.
25
+ - `rake doc` builds the YARD site into `doc/` and copies `docs/images` and `docs/badges` beside it, so the README's images resolve. `.github/workflows/pages.yml` runs it on every push to master and deploys `doc/` to GitHub Pages.
26
+ - Every class, module, constant and method carries YARD docs, private ones included, with `@param` and `@return` tags: `bundle exec yard stats --list-undoc --private --protected` reports 100%. Keep it there.
25
27
  - `spec_helper.rb` fails the run under 95% line coverage. The Aruba suite in `spec/laser/cutter/cli_spec.rb` counts towards it.
26
28
 
27
29
  ## Architecture
@@ -30,17 +32,39 @@ Everything lives under `Laser::Cutter`, in `lib/laser/cutter/`. `lib/laser/cutte
30
32
 
31
33
  Pipeline, from config to file:
32
34
 
33
- 1. **`Configuration`** is a `Hashie::Mash` with symbolized keys. It parses the `--box WxHxD/T[/N]` shorthand, casts numeric strings to floats, and merges per-unit defaults for kerf, margin, padding and stroke. Notch defaults to `3 × thickness`. `validate!` raises `MissingOption` / `ZeroValueNotAllowed`. `units` defaults to the Symbol `:in`, and arrives as a String from the command line, so compare it with `to_s` or `to_sym`.
35
+ 1. **`Configuration`** is a `Hashie::Mash` with symbolized keys. It parses the `--box WxHxD/T[/N]` shorthand, casts numeric strings to floats, and merges per-unit defaults for kerf, margin, padding and stroke. Notch defaults to `3 × thickness`. `validate!` raises `MissingOption` / `ZeroValueNotAllowed`, and `InvalidOption` for a lid it does not know. `units` defaults to the Symbol `:in`, and arrives as a String from the command line, so compare it with `to_s` or `to_sym`.
34
36
  1. **`Renderer.for(format, config)`** picks `LayoutRenderer` (PDF, Prawn) or `SvgRenderer` (SVG, Victor). Both answer `total` (lines to draw) and `render { |line| }`, which yields after each line. That block drives the progress bar.
35
37
  - `LayoutRenderer` draws a `BoxRenderer`, a `MetaRenderer` when `config.metadata` is set, and a second red `BoxRenderer` without kerf when `config.debug` is set. It sizes the page from the box enclosure unless `page_size` is given.
36
38
  - `SvgRenderer` fits the page to the box, flips y (SVG counts down from the top), and writes the metadata as a `<desc>`.
39
+ - Both get their box from `BoxFactory.for(config)`: `Sloped::Box` when the config has a `slope`, `Box` otherwise. A box answers `generate_notches`, `notches`, `outlines`, `enclosure` and `metadata=`.
40
+ - `MetaRenderer` is as tall as the settings it prints (`fields`). A fixed height once pushed the last line onto a second page.
37
41
  1. **`Box`** models the six faces as `Geometry::Rect`s. `position_faces!` lays them out in a cross (see the ASCII diagram in that method). `generate_notches` pairs each side of a face with the matching side of its outer bounding rect (face grown by `thickness`) as a **`Notching::Edge`**. The `conf` table sets per-face alignment: `valign`/`halign` decide whether a side's center notch points `:out` or `:in`. `corners` plus `pick_corners_face` decide which face fills the corner squares.
42
+ - `lid` (`full`, `back`, `plain`) sets how the `top` panel joins the walls. A plain lid edge is the edge's **outside** line, and the wall side under it (`LID_SIDES`) is the edge's **inside** line, so the lid lies on walls that end at the inner height. The lid then owns the corners above the walls: `corner_ends` strips the corner box from the wall sides that touch it.
43
+ - `outlines` holds the merged lines of each face by name; `notches` is all of them, flattened.
38
44
  1. **`Notching::Edge`** holds the inside and outside lines of one side, both shifted by `kerf / 2`. `calculate_notch_width!` forces an **odd** notch count of at least 3 and recomputes the real notch width, so the requested notch is only a guide. It rounds `length / notch` to `RATIO_DIGITS` before `ceil`: two panels meeting at a joint must get the same count, and float noise used to split them when the notch divided the side exactly.
39
- 1. **`Notching::PathGenerator`** turns an `Edge` into `Geometry::Line`s. It zigzags between the inside and outside lines using `Shift` deltas from two alternating `InfiniteIterator`s. It widens or narrows notches by `kerf` and adds the corner boxes.
45
+ 1. **`Notching::PathGenerator`** turns an `Edge` into `Geometry::Line`s. It zigzags between the inside and outside lines using `Shift` deltas from two alternating `InfiniteIterator`s. It widens or narrows notches by `kerf` and adds the corner boxes, at the ends the edge names in `corner_ends`. Kerf grows every outline by half the kerf on every side; `spec/laser/cutter/box_lid_spec.rb` checks exactly that, point by point, through `spec/support/outline.rb`.
40
46
  1. **`Aggregator`** merges the lines of a face into the outline to cut. Neighbouring edges draw shared stretches twice, and a shared stretch runs through the material, so each collinear group is combined as a symmetric difference: a point is cut when an odd number of lines cover it. It groups lines by axis and offset and sweeps each group once, so a face takes n log n; the old pairwise version made a 100×80×60 box take 55 seconds.
41
47
 
48
+ ### The sloped box
49
+
50
+ `--slope` and `--front-height` draw seven panels instead of six. Everything is in `lib/laser/cutter/sloped/`, behind `Sloped::Box`; `docs/decisions/decisions-on-angled-box.md` has the geometry.
51
+
52
+ - **`Sloped::Profile`** is the side view: the inside outline of a side wall, and the lengths of the top strip, the tilted panel and the front strip. It refuses numbers that do not make the shape.
53
+ - **`Sloped::Request.validate!`** checks settings before anything is drawn. `Configuration#validate!` and `Options.new` both call it: a slope needs a front height, a front height needs a slope, and the lid is `full` or `plain`.
54
+ - **`Sloped::Panels`** builds each panel in its own frame as a **`Geometry::Loop`**, one walk of points, counter-clockwise. `SidePanel` is the five-sided wall; `RingPanel` is every rectangle (bottom, back, strips, tilted panel); `Corners` picks the panel that carries each corner cube.
55
+ - **`Sloped::Notcher`** notches a run between two points through `Notching::AngledEdge`, without kerf and to the right of the walk, which is outwards.
56
+ - **`Aggregator` is not used.** A `Loop` drops what a walk leaves behind (a point given twice, a spike, a point mid-run), so no line is drawn twice. Kerf is `loop.grow(kerf / 2)`: every side moves out and the corners stay sharp, which is exact where a corner is not square. `loop_spec.rb` checks that this equals what `Box` draws with the same kerf.
57
+ - **`Sloped::Layout`** places the panels as an unfolded strip around the back; a **`Placement`** moves a panel there, mirrored for the right wall and turned for the front strip.
58
+ - `spec/support/loops.rb` reads outlines without the code that drew them: `Loops.tabs` finds the tabs along a joint, and `Loops.interlock?` checks that two panels fill it between them. `panels_spec.rb` runs that over every joint of every variant. `spec/support/solid.rb` stands the panels up in space the way they are glued, and `assembly_spec.rb` checks that no two of them claim the same material, which is what covers the corners where three panels meet.
59
+
42
60
  Geometry is unitless, in the config's units. Conversion to PDF points happens only at render time (`value.send(:in)` / `.send(:mm)`). `PageManager#value_from_units` converts PDF points back.
43
61
 
62
+ ### Ruby API
63
+
64
+ - `Laser::Cutter.render(options)` returns the document as a String, and `Laser::Cutter.write(options)` writes it to `options.file`. Both live in `lib/laser/cutter.rb`, take an `Options` or a Hash, and pass a block through as the per-line callback. MakeABox.io calls these; keep them working without a file, a terminal or the CLI classes.
65
+ - `Options` (`options.rb`) is a strict `Dry::Struct`, one attribute per `generate` option, with its types in `Types` (`types.rb`). It raises `MissingOption` for a missing dimension, or a slope without a front height, and `InvalidOption` for anything else, and turns into a `Configuration` with `to_configuration`. A new `generate` option needs an attribute here too.
66
+ - Renderers answer `document`, the String. `Renderer::Base#render` writes it to `config.file`.
67
+
44
68
  ### Command line
45
69
 
46
70
  - `exe/laser-cutter` (and `exe/lc`) call `Laser::Cutter::Launcher.new(ARGV).execute!`. The Launcher takes argv, the three streams and `kernel`, and exits only through `kernel.exit`. Aruba runs it in-process (`spec/support/aruba.rb`), so commands must write to `out` and `err`, never to `$stdout`.
@@ -51,10 +75,11 @@ Geometry is unitless, in the config's units. Conversion to PDF points happens on
51
75
 
52
76
  ## Known gaps
53
77
 
78
+ - `generate` declares defaults for `--units` and `--page-layout`, and they override what `-R` reads from a saved configuration. `--lid` has no dry-cli default for that reason.
79
+
54
80
  - `just build` is an empty recipe, so `just publish` builds nothing. `rake build` is the real build.
55
- - The `Rakefile` YARD title is copied from another project, and it references a `CHANGELOG.md` that does not exist.
81
+
56
82
  - The gemspec lists `tty-*` and `pastel` directly, though only dry-cli-ui uses them.
57
- - `Box` still carries the comment "badly needs refactoring and tests".
58
83
 
59
84
  ## Conventions
60
85
 
data/Gemfile CHANGED
@@ -6,8 +6,9 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  group 'development', 'test' do
9
- gem 'aruba'
9
+ gem 'aruba', '>= 3.0'
10
10
  gem 'coverage-badge'
11
+ gem 'irb' # yard's legacy parser loads irb/notifier, no longer a default gem
11
12
  gem 'rake'
12
13
  gem 'rspec'
13
14
  gem 'rspec-its'