laser-cutter 2.0.1 → 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 (104) 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/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
  6. 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
  7. 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
  8. data/.plans/decisions.md +11 -0
  9. data/CHANGELOG.md +134 -0
  10. data/CLAUDE.md +18 -6
  11. data/Gemfile +2 -1
  12. data/README.md +223 -50
  13. data/Rakefile +11 -7
  14. data/docs/badges/coverage_badge.svg +2 -2
  15. data/docs/decisions/decisions-on-angled-box.md +93 -0
  16. data/docs/decisions/stack.md +6 -0
  17. data/docs/images/box-3d.avif +0 -0
  18. data/docs/images/box-sloped-3d.avif +0 -0
  19. data/docs/images/box-sloped.avif +0 -0
  20. data/justfile +24 -8
  21. data/laser-cutter.gemspec +1 -1
  22. data/lib/laser/cutter/aggregator.rb +28 -0
  23. data/lib/laser/cutter/box.rb +95 -5
  24. data/lib/laser/cutter/box_factory.rb +15 -0
  25. data/lib/laser/cutter/cli/command.rb +27 -1
  26. data/lib/laser/cutter/cli/config_file.rb +2 -0
  27. data/lib/laser/cutter/cli/examples.rb +3 -0
  28. data/lib/laser/cutter/cli/generate.rb +37 -6
  29. data/lib/laser/cutter/cli/help.rb +4 -0
  30. data/lib/laser/cutter/cli/page_sizes.rb +3 -0
  31. data/lib/laser/cutter/cli/version.rb +2 -0
  32. data/lib/laser/cutter/cli.rb +23 -4
  33. data/lib/laser/cutter/configuration.rb +38 -4
  34. data/lib/laser/cutter/geometry/dimensions.rb +7 -0
  35. data/lib/laser/cutter/geometry/line.rb +42 -0
  36. data/lib/laser/cutter/geometry/loop.rb +138 -0
  37. data/lib/laser/cutter/geometry/point.rb +3 -0
  38. data/lib/laser/cutter/geometry/rect.rb +25 -0
  39. data/lib/laser/cutter/geometry/shape.rb +19 -1
  40. data/lib/laser/cutter/geometry/transform.rb +50 -0
  41. data/lib/laser/cutter/geometry/tuple.rb +47 -11
  42. data/lib/laser/cutter/launcher.rb +14 -1
  43. data/lib/laser/cutter/missing_option.rb +2 -0
  44. data/lib/laser/cutter/notching/angled_edge.rb +67 -0
  45. data/lib/laser/cutter/notching/base.rb +8 -0
  46. data/lib/laser/cutter/notching/edge.rb +44 -4
  47. data/lib/laser/cutter/notching/infinite_iterator.rb +11 -1
  48. data/lib/laser/cutter/notching/path_generator.rb +40 -6
  49. data/lib/laser/cutter/notching/shift.rb +4 -0
  50. data/lib/laser/cutter/options.rb +25 -4
  51. data/lib/laser/cutter/page_manager.rb +12 -2
  52. data/lib/laser/cutter/renderer/base.rb +19 -3
  53. data/lib/laser/cutter/renderer/box_renderer.rb +14 -1
  54. data/lib/laser/cutter/renderer/layout_renderer.rb +10 -0
  55. data/lib/laser/cutter/renderer/line_renderer.rb +6 -0
  56. data/lib/laser/cutter/renderer/meta_renderer.rb +33 -9
  57. data/lib/laser/cutter/renderer/rect_renderer.rb +5 -0
  58. data/lib/laser/cutter/renderer/svg_renderer.rb +9 -1
  59. data/lib/laser/cutter/renderer.rb +2 -0
  60. data/lib/laser/cutter/sloped/box.rb +90 -0
  61. data/lib/laser/cutter/sloped/corners.rb +58 -0
  62. data/lib/laser/cutter/sloped/layout.rb +97 -0
  63. data/lib/laser/cutter/sloped/notcher.rb +53 -0
  64. data/lib/laser/cutter/sloped/panels.rb +121 -0
  65. data/lib/laser/cutter/sloped/placement.rb +36 -0
  66. data/lib/laser/cutter/sloped/profile.rb +176 -0
  67. data/lib/laser/cutter/sloped/request.rb +31 -0
  68. data/lib/laser/cutter/sloped/ring_panel.rb +120 -0
  69. data/lib/laser/cutter/sloped/side_panel.rb +89 -0
  70. data/lib/laser/cutter/types.rb +3 -0
  71. data/lib/laser/cutter/units_converter.rb +5 -0
  72. data/lib/laser/cutter/version.rb +2 -1
  73. data/lib/laser/cutter/zero_value_not_allowed.rb +2 -0
  74. data/lib/laser/cutter.rb +2 -0
  75. data/spec/laser/cutter/angled_edge_spec.rb +103 -0
  76. data/spec/laser/cutter/box_factory_spec.rb +19 -0
  77. data/spec/laser/cutter/cli_spec.rb +87 -7
  78. data/spec/laser/cutter/configuration_spec.rb +37 -0
  79. data/spec/laser/cutter/loop_spec.rb +107 -0
  80. data/spec/laser/cutter/options_spec.rb +51 -9
  81. data/spec/laser/cutter/renderer/layout_renderer_spec.rb +18 -0
  82. data/spec/laser/cutter/renderer/meta_renderer_spec.rb +82 -0
  83. data/spec/laser/cutter/renderer/svg_renderer_spec.rb +34 -0
  84. data/spec/laser/cutter/sloped/assembly_spec.rb +78 -0
  85. data/spec/laser/cutter/sloped/box_spec.rb +151 -0
  86. data/spec/laser/cutter/sloped/corners_spec.rb +45 -0
  87. data/spec/laser/cutter/sloped/layout_spec.rb +77 -0
  88. data/spec/laser/cutter/sloped/notcher_spec.rb +57 -0
  89. data/spec/laser/cutter/sloped/panels_spec.rb +175 -0
  90. data/spec/laser/cutter/sloped/placement_spec.rb +50 -0
  91. data/spec/laser/cutter/sloped/request_spec.rb +48 -0
  92. data/spec/laser/cutter/sloped/ring_panel_spec.rb +102 -0
  93. data/spec/laser/cutter/sloped/side_panel_spec.rb +98 -0
  94. data/spec/laser/cutter/sloped_profile_spec.rb +156 -0
  95. data/spec/laser/cutter/transform_spec.rb +53 -0
  96. data/spec/spec_helper.rb +4 -0
  97. data/spec/support/loops.rb +106 -0
  98. data/spec/support/sloped.rb +26 -0
  99. data/spec/support/solid.rb +95 -0
  100. data/spec/wishes/wish-tilted-box.png +0 -0
  101. metadata +55 -9
  102. /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
  103. /data/.plans/{002.00-lid-options/plan.md → 002.00/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257lid-options/plan.md"} +0 -0
  104. /data/.plans/{003.00-ruby-api/plan.md → 003.00/342/224/201/342/224/201/342/232/252/342/224/201/342/224/201/342/235/257ruby-api/plan.md"} +0 -0
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
@@ -34,6 +36,8 @@ Pipeline, from config to file:
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.
38
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.
39
43
  - `outlines` holds the merged lines of each face by name; `notches` is all of them, flattened.
@@ -41,12 +45,24 @@ Pipeline, from config to file:
41
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`.
42
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.
43
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
+
44
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.
45
61
 
46
62
  ### Ruby API
47
63
 
48
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.
49
- - `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 and `InvalidOption` for anything else, and turns into a `Configuration` with `to_configuration`. A new `generate` option needs an attribute here too.
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.
50
66
  - Renderers answer `document`, the String. `Renderer::Base#render` writes it to `config.file`.
51
67
 
52
68
  ### Command line
@@ -63,12 +79,8 @@ Geometry is unitless, in the config's units. Conversion to PDF points happens on
63
79
 
64
80
  - `just build` is an empty recipe, so `just publish` builds nothing. `rake build` is the real build.
65
81
 
66
- - The `Rakefile` YARD title is copied from another project, and it references a `CHANGELOG.md` that does not exist.
67
-
68
82
  - The gemspec lists `tty-*` and `pastel` directly, though only dry-cli-ui uses them.
69
83
 
70
- - `Box` still carries the comment "badly needs refactoring and tests".
71
-
72
84
  ## Conventions
73
85
 
74
86
  - `.rubocop.yml` inherits `.relaxed_rubocop.yml` and `.rubocop_todo.yml`, with a 120-column line limit and table-aligned hashes.
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'
data/README.md CHANGED
@@ -1,9 +1,13 @@
1
- [![Gem Version](https://badge.fury.io/rb/laser-cutter.svg)](http://badge.fury.io/rb/laser-cutter) ![coverage](docs/badges/coverage_badge.svg)
1
+ [![Gem Version](https://badge.fury.io/rb/laser-cutter.svg)](http://badge.fury.io/rb/laser-cutter) ![coverage](docs/badges/coverage_badge.svg) [![documentation](https://assets.readthedocs.org/static/projects/badges/passing-flat.svg)](https://kigster.github.io/laser-cutter/)
2
2
 
3
3
  ## LaserCutter and Make-A-Box.io
4
4
 
5
5
  `laser-cutter` is a ruby library for generating PDF designs for boxes of custom dimensions that suit your project, that can be cut from wood or acrylic using a laser-cutter. The sides of the box snap together using alternating notches, that are deliberately layed out in a symmetric form.
6
6
 
7
+ ![An assembled box, 5 in wide, 3 in deep and 4 in tall, its six panels joined by notches](docs/images/box-3d.avif)
8
+
9
+ A box 5 in wide, 3 in deep and 4 in tall, assembled from the six panels `laser-cutter` draws.
10
+
7
11
  To use `laser-cutter` you need to have a recent version of ruby interpreter, install it as a gem, and use command line to generate PDFs.
8
12
 
9
13
  [Make-A-Box](http://makeabox.io) is a online web application that uses `laser-cutter` library and provides a straight-forward user interface for generating PDF designs without the need to install the gem or use command line.
@@ -16,6 +20,8 @@ One of the design goals of this project is to provide a highly extensible platfo
16
20
 
17
21
  `laser-cutter` supports many flexible command line options that allow setting dimensions, stroke width, page size, layout, margins, padding (spacing between the boxes), and many more.
18
22
 
23
+ Version 3.0 adds a [sloped front](#a-sloped-front): a seven-panel enclosure whose front leans back, to hold a screen or a control panel.
24
+
19
25
  ## Dependencies
20
26
 
21
27
  The gem depends primarily on [Prawn](http://prawnpdf.org) – a fantastic PDF generation library. SVG output uses [Victor](https://github.com/DannyBen/victor), and the command line is built on [dry-cli](https://dry-cli.tools/). It needs Ruby 4.0 or newer.
@@ -42,8 +48,10 @@ $ gem install laser-cutter
42
48
 
43
49
  ## Usage
44
50
 
51
+ The gem installs two executables that run the same program: `laser-cutter`, and its shortcut `lc`. The examples below use `lc`.
52
+
45
53
  ```text
46
- laser-cutter COMMAND [OPTIONS]
54
+ lc COMMAND [OPTIONS]
47
55
 
48
56
  generate, g Draw the panels of a box into a PDF or an SVG file
49
57
  page-sizes List every page size, with its dimensions
@@ -53,20 +61,35 @@ laser-cutter COMMAND [OPTIONS]
53
61
  completion Print a bash or zsh completion script
54
62
  ```
55
63
 
56
- `laser-cutter help generate` lists every option. The common ones:
57
-
58
- | Option | Meaning |
59
- | :--------------------- | :------------------------------------------------------------- |
60
- | `-b`, `--box` | `WxHxD/T[/N]`: width, height, depth, thickness, optional notch |
61
- | `-w`, `-H`, `-d`, `-t` | Width, height, depth and thickness, one at a time |
62
- | `-n`, `--notch` | Notch length, a guide only |
63
- | `-k`, `--kerf` | Kerf, the width of the cut |
64
- | `-L`, `--lid` | `full` (default), `back` or `plain`, see below |
65
- | `-u`, `--units` | `in` (default) or `mm` |
66
- | `-o`, `--file` | File to write, required |
67
- | `-f`, `--format` | `pdf` (default) or `svg`, in either case |
68
- | `-B`, `--inside-box` | Also draw the box without kerf, in red |
69
- | `-W`, `-R` | Save the configuration to a file, or read it from one |
64
+ `lc help generate` lists every option:
65
+
66
+ | Option | Meaning | Default |
67
+ | :------------------------ | :---------------------------------------------------------------------------------------------------------------------- | :------------ |
68
+ | `-b`, `--box` | `WxHxD/T[/N]`: width, height, depth, thickness and optional notch, in one expression | |
69
+ | `-w`, `--width` | Internal width of the box | |
70
+ | `-H`, `--height` | Internal height of the box | |
71
+ | `-d`, `--depth` | Internal depth of the box | |
72
+ | `-t`, `--thickness` | Thickness of the material | |
73
+ | `-S`, `--slope` | Angle of a sloped panel above horizontal, in degrees, for mounting a screen. Requires `--front-height`, see below | |
74
+ | `-F`, `--front-height` | Internal height at the front of a sloped box, where the slope begins | |
75
+ | `-L`, `--lid` | `full` (notched on every side), `back` (into the back wall only, not with `--slope`) or `plain` (no notches), see below | `full` |
76
+ | `-n`, `--notch` | Notch length, a guide only | 3 × thickness |
77
+ | `-k`, `--kerf` | Kerf, the width of the cut | `0.0024in` |
78
+ | `-u`, `--units` | Units every dimension is in: `in` or `mm` | `in` |
79
+ | `-o`, `--file` | File to write | required |
80
+ | `-f`, `--format` | `pdf` or `svg`, in either case | `pdf` |
81
+ | `-m`, `--margin` | Margin from the edge of the page | |
82
+ | `-p`, `--padding` | Space between the panels | |
83
+ | `-s`, `--stroke` | Stroke width of the lines | |
84
+ | `-i`, `--page-size` | Page size, such as `LETTER` or `A3`; PDF only | fit the box |
85
+ | `-l`, `--page-layout` | `portrait` or `landscape`; PDF only | `portrait` |
86
+ | `-M`, `--[no-]metadata` | Print the settings of the box on the page | `true` |
87
+ | `-B`, `--[no-]inside-box` | Also draw the box without kerf, in red, to check the kerf | `false` |
88
+ | `-O`, `--[no-]open` | Open the file once it is written | `false` |
89
+ | `-W`, `--write` | Save the configuration to a file, or to STDOUT with `-` | |
90
+ | `-R`, `--read` | Read the configuration from a file, or from STDIN with `-` | |
91
+ | `-v`, `--[no-]verbose` | Print the configuration, and the full backtrace on failure | `false` |
92
+ | `-h`, `--help` | Show help | |
70
93
 
71
94
  Height is `-H`, because `-h` prints help.
72
95
 
@@ -75,13 +98,15 @@ Height is `-H`, because `-h` prints help.
75
98
  A box in inches, with the kerf set to 0.008", opened once it is written:
76
99
 
77
100
  ```bash
78
- laser-cutter generate -b 3x2x2/0.125 -k 0.008 -O -o box.pdf
101
+ lc generate -b 3x2x2/0.125 -k 0.008 -O -o box.pdf
79
102
  ```
80
103
 
104
+ `g` is short for `generate`, and the rest of the examples use it.
105
+
81
106
  A box with a lid that lifts off:
82
107
 
83
108
  ```bash
84
- laser-cutter generate -b 3x2x2/0.125 --lid plain -o box.pdf
109
+ lc g -b 3x2x2/0.125 --lid plain -o box.pdf
85
110
  ```
86
111
 
87
112
  ### The lid
@@ -98,34 +123,70 @@ The lid is the top panel. `--lid` sets how it joins the walls:
98
123
  | :------------------------------------------------------ | :--------------------------------------------------------------------- | :-------------------------------------------------------- |
99
124
  | ![A box with a full lid](docs/images/box-lid-full.avif) | ![A box with a lid notched at the back](docs/images/box-lid-back.avif) | ![A box with a plain lid](docs/images/box-lid-plain.avif) |
100
125
 
101
- Each is `laser-cutter generate -b 3x2x2/0.125 --lid …`. The lid is the panel at the bottom of the page, the back wall the one at the top.
126
+ Each is `lc g -b 3x2x2/0.125 --lid …`. The lid is the panel at the bottom of the page, the back wall the one at the top.
102
127
 
103
128
  A lid edge without notches reaches the outside of the wall under it, and that wall ends at the internal height. So a `plain` lid is `W + 2T` by `D + 2T` and lies on top of the box, and the space inside is still `W` by `H` by `D`.
104
129
 
130
+ ### A sloped front
131
+
132
+ `--slope` draws a console: a box whose front leans back, the kind that holds a display tilted towards the reader. `--front-height` is where the slope begins.
133
+
134
+ ![An assembled sloped box, 5 in wide, 3 in deep and 4 in tall, with a 2.1 in front and a 45 degree slope](docs/images/box-sloped-3d.avif)
135
+
136
+ Assembled: 5 in wide, 3 in deep, 4 in tall at the back, with a 2.1 in front and the tilted panel at 45°. Mount a display or a control panel on the tilted panel, and it faces the reader.
137
+
138
+ The panels to cut:
139
+
140
+ ```bash
141
+ lc g -b 4x3x5/0.125 --slope 45 --front-height 1 -o console.pdf
142
+ ```
143
+
144
+ ![A box whose front slopes back at 45 degrees](docs/images/box-sloped.avif)
145
+
146
+ Seen from the side, with `H` the height at the back and `D` the depth:
147
+
148
+ ```text
149
+ top strip
150
+ +-----------+
151
+ / |
152
+ / tilted | back, H
153
+ + |
154
+ | front |
155
+ +--------------+
156
+ bottom, D
157
+ ```
158
+
159
+ - Seven panels: two side walls, the bottom, the back, and the top strip, the tilted panel and the front strip, drawn in that order up the page from the back.
160
+ - `--slope` is the angle of the tilted panel above horizontal, above 0 and below 90. The top strip takes the depth the slope leaves: `D - (H - front height) / tan(slope)`.
161
+ - A strip of no size is dropped: `--front-height 0` starts the slope at the bottom, and a slope that reaches the back leaves no top strip.
162
+ - The tilted panel meets the strips in a plain butt joint, to be glued. Every other joint is notched.
163
+ - `--lid plain` makes the tilted panel a lid: a rectangle that lies on straight side walls and lifts off. `--lid back` does not apply.
164
+ - Numbers that do not make the shape are refused, with the reason: a slope too shallow for the depth, or strips that leave no room for a tilted panel.
165
+
105
166
  The same box as an SVG:
106
167
 
107
168
  ```bash
108
- laser-cutter generate -b 3x2x2/0.125 -f svg -o box.svg
169
+ lc g -b 3x2x2/0.125 -f svg -o box.svg
109
170
  ```
110
171
 
111
172
  A box in millimeters on a landscape A3 page, with a 0.5mm stroke:
112
173
 
113
174
  ```bash
114
- laser-cutter generate -u mm -w 70 -H 20 -d 50 -t 4.3 -n 5 -i A3 -l landscape -s 0.5 -o box.pdf
175
+ lc g -u mm -w 70 -H 20 -d 50 -t 4.3 -n 5 -i A3 -l landscape -s 0.5 -o box.pdf
115
176
  ```
116
177
 
117
178
  Every page size, in millimeters:
118
179
 
119
180
  ```bash
120
- laser-cutter page-sizes -u mm
181
+ lc page-sizes -u mm
121
182
  ```
122
183
 
123
184
  Save the settings of a box, and use them again:
124
185
 
125
186
  ```bash
126
- laser-cutter generate -b 1.1x2.5x1.5/0.125/0.125 -p 0.1 -o box.pdf -W box-settings.json
127
- laser-cutter generate -o box.pdf -R box-settings.json
128
- cat box-settings.json | laser-cutter generate -o box.pdf -R -
187
+ lc g -b 1.1x2.5x1.5/0.125/0.125 -p 0.1 -o box.pdf -W box-settings.json
188
+ lc g -o box.pdf -R box-settings.json
189
+ cat box-settings.json | lc g -o box.pdf -R -
129
190
  ```
130
191
 
131
192
  ### More boxes
@@ -133,7 +194,7 @@ cat box-settings.json | laser-cutter generate -o box.pdf -R -
133
194
  A shallow box in millimeters, glued shut:
134
195
 
135
196
  ```bash
136
- laser-cutter generate -u mm -w 70 -H 20 -d 50 -t 4.3 -n 5 -f svg -o box.svg
197
+ lc g -u mm -w 70 -H 20 -d 50 -t 4.3 -n 5 -f svg -o box.svg
137
198
  ```
138
199
 
139
200
  ![A 70 by 20 by 50 millimeter box](docs/images/box-metric.avif)
@@ -141,11 +202,24 @@ laser-cutter generate -u mm -w 70 -H 20 -d 50 -t 4.3 -n 5 -f svg -o box.svg
141
202
  A tray with a lid that lifts off, from 3mm material with wide notches:
142
203
 
143
204
  ```bash
144
- laser-cutter generate -u mm -w 120 -H 25 -d 80 -t 3 -n 12 --lid plain -f svg -o tray.svg
205
+ lc g -u mm -w 120 -H 25 -d 80 -t 3 -n 12 --lid plain -f svg -o tray.svg
145
206
  ```
146
207
 
147
208
  ![A 120 by 25 by 80 millimeter tray with a plain lid](docs/images/box-tray.avif)
148
209
 
210
+ ### Storage boxes
211
+
212
+ No special folding option is needed for notch-joined storage boxes: cut the separate panels and assemble them. These designs do not use hinges or fold flat as a single sheet. Use `--lid plain` for a removable lid, or leave that panel out when cutting to make an open tray.
213
+
214
+ For a 3" square footprint and 3" height, or a 9" square footprint and 4" height, using 1/8" material:
215
+
216
+ ```bash
217
+ lc g -u in -b 3x3x3/0.125 --lid plain -o storage-small.pdf
218
+ lc g -u in -b 9x4x9/0.125 --lid plain -o storage-large.pdf
219
+ ```
220
+
221
+ The shorthand is **width × height × depth**, and dimensions describe the inside space. To nest one assembled box inside another, allow clearance for the smaller box's outside dimensions, including the material thickness; sizes are not adjusted for nesting automatically.
222
+
149
223
  The pictures on this page are the SVG files themselves, drawn with a thicker stroke (`-s 0.5`) and converted:
150
224
 
151
225
  ```bash
@@ -154,6 +228,8 @@ magick -density 96 -background white box.svg -flatten box.avif
154
228
 
155
229
  ## Using it from Ruby
156
230
 
231
+ The API documentation is at [kigster.github.io/laser-cutter](https://kigster.github.io/laser-cutter/), built from the YARD comments with `rake doc`.
232
+
157
233
  A Ruby program draws a box in its own process; nothing runs the command line. It needs three things:
158
234
 
159
235
  | Call | What it does |
@@ -176,20 +252,22 @@ Laser::Cutter.write(options.new(file: "box.pdf", format: nil)) # the extension p
176
252
 
177
253
  `Options` has an attribute for each option of `generate`:
178
254
 
179
- | Attribute | Type | When left out |
180
- | :-------------------------------------- | :---------------------- | :----------------------------- |
181
- | `width`, `height`, `depth`, `thickness` | Float above zero | `MissingOption` is raised |
182
- | `notch` | Float above zero | Three times the thickness |
183
- | `kerf`, `margin`, `padding` | Float, zero or more | The default for the units |
184
- | `stroke` | Float above zero | The default for the units |
185
- | `units` | `in` or `mm` | `in` |
186
- | `lid` | `full`, `back`, `plain` | `full` |
187
- | `format` | `pdf` or `svg` | `pdf`, or the file's extension |
188
- | `file` | String | Only `write` needs it |
189
- | `page_size` | A name such as `A4` | The page fits the box |
190
- | `page_layout` | `portrait`, `landscape` | `portrait` |
191
- | `metadata` | Boolean | `true` |
192
- | `inside_box` | Boolean | `false` |
255
+ | Attribute | Type | When left out |
256
+ | :-------------------------------------- | :----------------------- | :----------------------------- |
257
+ | `width`, `height`, `depth`, `thickness` | Float above zero | `MissingOption` is raised |
258
+ | `notch` | Float above zero | Three times the thickness |
259
+ | `kerf`, `margin`, `padding` | Float, zero or more | The default for the units |
260
+ | `stroke` | Float above zero | The default for the units |
261
+ | `units` | `in` or `mm` | `in` |
262
+ | `lid` | `full`, `back`, `plain` | `full` |
263
+ | `slope` | Float, above 0, below 90 | The box has six panels |
264
+ | `front_height` | Float, zero or more | Required with `slope` |
265
+ | `format` | `pdf` or `svg` | `pdf`, or the file's extension |
266
+ | `file` | String | Only `write` needs it |
267
+ | `page_size` | A name such as `A4` | The page fits the box |
268
+ | `page_layout` | `portrait`, `landscape` | `portrait` |
269
+ | `metadata` | Boolean | `true` |
270
+ | `inside_box` | Boolean | `false` |
193
271
 
194
272
  - Values are coerced, so the Strings a web form sends will do, and a blank String counts as left out. Keys may be Strings or Symbols.
195
273
  - A value it cannot use, or a key that is not an option, raises `Laser::Cutter::InvalidOption` with a message such as `lid cannot be "sliding", but must be one of: full, back, plain.` Both errors descend from `Laser::Cutter::Error`.
@@ -206,7 +284,85 @@ rescue Laser::Cutter::Error => e
206
284
  end
207
285
  ```
208
286
 
209
- `Laser::Cutter::Box::LIDS` lists the lids, for a select. `Configuration`, `Renderer::LayoutRenderer#render` and `PageManager#page_size_values`, which MakeABox.io called in 1.0.3, still work.
287
+ `Laser::Cutter::Box::LIDS` lists the lids, for a select, and `Laser::Cutter::Sloped::Box::LIDS` those of a sloped box. `Configuration`, `Renderer::LayoutRenderer#render` and `PageManager#page_size_values`, which MakeABox.io called in 1.0.3, still work.
288
+
289
+ ### Drawing a PDF or an SVG
290
+
291
+ `render` and `write` share one path. A slope picks the box, and the format picks the renderer. `SlopedBox` in the diagram is `Sloped::Box`.
292
+
293
+ ```mermaid
294
+ ---
295
+ config:
296
+ layout: elk
297
+ look: neo
298
+ fontFamily: '''Open Sans Variable'', sans-serif'
299
+ theme: redux-color
300
+ htmlLabels: true
301
+ themeVariables:
302
+ fontFamily: '''Open Sans Variable'', sans-serif'
303
+ ---
304
+ classDiagram
305
+ direction TB
306
+ class Cutter {
307
+ +render(options) String
308
+ +write(options) String
309
+ }
310
+ class Options
311
+ class Configuration
312
+ class Renderer {
313
+ +for(format, config)
314
+ }
315
+ class LayoutRenderer
316
+ class SvgRenderer
317
+ class BoxFactory {
318
+ +for(config)
319
+ }
320
+ class Box
321
+ class SlopedBox
322
+
323
+ Cutter --> Options
324
+ Options --> Configuration
325
+ Cutter --> Renderer
326
+ Configuration --> Renderer
327
+ Renderer ..> LayoutRenderer : pdf
328
+ Renderer ..> SvgRenderer : svg
329
+ LayoutRenderer --> BoxFactory
330
+ SvgRenderer --> BoxFactory
331
+ BoxFactory --> Box : no slope
332
+ BoxFactory --> SlopedBox : slope
333
+ ```
334
+
335
+ ```mermaid
336
+ ---
337
+ config:
338
+ layout: elk
339
+ look: neo
340
+ fontFamily: '''Open Sans Variable'', sans-serif'
341
+ theme: redux-color
342
+ htmlLabels: true
343
+ themeVariables:
344
+ fontFamily: '''Open Sans Variable'', sans-serif'
345
+ ---
346
+ stateDiagram-v2
347
+ [*] --> Options
348
+ Options --> Checked : validate
349
+ Checked --> Configuration
350
+ Configuration --> BoxKind
351
+ state BoxKind <<choice>>
352
+ BoxKind --> Straight : no slope
353
+ BoxKind --> Sloped : slope
354
+ Straight --> Notched : generate notches
355
+ Sloped --> Notched : generate notches
356
+ Notched --> Format
357
+ state Format <<choice>>
358
+ Format --> PDF : pdf
359
+ Format --> SVG : svg
360
+ PDF --> Document
361
+ SVG --> Document
362
+ Document --> [*] : render
363
+ Document --> Written : write
364
+ Written --> [*]
365
+ ```
210
366
 
211
367
  ## Feature Wish List
212
368
 
@@ -246,18 +402,35 @@ And laser-cutter:
246
402
 
247
403
  ```bash
248
404
  gem install laser-cutter
249
- laser-cutter generate -b 1x1.5x2/0.125/0.125 -O -o box.pdf
405
+ lc g -b 1x1.5x2/0.125/0.125 -O -o box.pdf
250
406
  ```
251
407
 
252
408
  ![LaserCutter Comparison](docs/images/comparison.jpg).
253
409
 
254
- ## Contributing
255
-
256
- 1. Fork it ( https://github.com/[my-github-username]/laser-cutter/fork )
257
- 1. Create your feature branch (`git checkout -b my-new-feature`)
258
- 1. Commit your changes (`git commit -am 'Add some feature'`)
259
- 1. Create a new Pull Request
260
- 1. Push to the branch (`git push origin my-new-feature`)
410
+ ## Contributing to `laser-cutter`
411
+
412
+ The `justfile` runs the development commands. Ruby recipes load rbenv and then `bundle exec`, so they use the Ruby pinned in `.ruby-version`. `just` with no arguments opens a picker. `just --list` prints every recipe.
413
+
414
+ | Command | What it does |
415
+ | :--------------------- | :--------------------------------------------------------------------------------------------------------------- |
416
+ | `just lint` | Run RuboCop |
417
+ | `just format` | Autocorrect Ruby, then format every Markdown file. Extra arguments go to RuboCop. `-A` allows unsafe corrections |
418
+ | `just format-markdown` | Format every Markdown file |
419
+ | `just test` | Run RSpec. A path limits the run: `just test spec/laser/cutter/edge_spec.rb:42` |
420
+ | `just test-docs` | Run RSpec with the documentation formatter |
421
+ | `just test-coverage` | Run RSpec with coverage on, including a partial run |
422
+ | `just ci` | Lint, then run the coverage suite. `just check-all` is the same command |
423
+ | `just lefthook` | Run the pre-commit hooks against every file |
424
+ | `just clean` | Remove `.DS_Store` files, `tmp/`, and `coverage/` |
425
+ | `just clobber` | Remove generated files (`rake clobber`) |
426
+ | `just version` | Print the gem version |
427
+ | `just doc` | Build the YARD documentation into `doc/` |
428
+ | `just build` | Build the gem into `pkg/` |
429
+ | `just changelog` | Write `CHANGELOG.md` from the GitHub releases. Requires `CHANGELOG_GITHUB_TOKEN` |
430
+ | `just publish` | Build the gem and push it to RubyGems. `just publish 123456` passes that two-factor code |
431
+ | `just release` | Point the version tag at the current commit, force-push tags, and create the GitHub release |
432
+
433
+ The fork and pull request steps are in [CONTRIBUTING.md](CONTRIBUTING.md).
261
434
 
262
435
  ## License
263
436
 
data/Rakefile CHANGED
@@ -29,13 +29,17 @@ end
29
29
  task build: :permissions
30
30
 
31
31
  YARD::Rake::YardocTask.new(:doc) do |t|
32
- t.files = %w[lib/**/*.rb - README.md LICENSE.txt CHANGELOG.md]
33
- t.options.unshift("--title", '"dry-cli-ui: runtime terminal UI for dry-cli commands"')
34
- t.after = -> { exec("open doc/index.html") } if RUBY_PLATFORM =~ /darwin/
35
-
36
- require "fileutils"
37
- FileUtils.mkdir_p("doc/docs/badges")
38
- FileUtils.cp("docs/badges/coverage_badge.svg", "doc/docs/badges")
32
+ t.files = %w[lib/**/*.rb - README.md CHANGELOG.md CONTRIBUTING.md LICENSE.txt]
33
+ t.options = %w[--title laser-cutter --readme README.md --markup markdown --output-dir doc]
34
+ # The README shows the images and the coverage badge under docs/, so the
35
+ # site needs them at the same relative path.
36
+ t.after = lambda do
37
+ require "fileutils"
38
+ FileUtils.mkdir_p("doc/docs")
39
+ # Ensure images exist relative to the index.html
40
+ FileUtils.cp_r(%w[docs/images docs/badges], "doc/docs")
41
+ system("open", "doc/index.html") if RUBY_PLATFORM.include?("darwin") && !ENV["CI"]
42
+ end
39
43
  end
40
44
 
41
45
  RSpec::Core::RakeTask.new(:spec)