laser-cutter 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5deb406767dbe7132db874d700abb81d6c962c1
4
- data.tar.gz: 7703c53e8cef81e4dd8bade1084fe48ab9025e79
3
+ metadata.gz: b027c579de8cded3aba462a120045ed6ec685930
4
+ data.tar.gz: 76e13dddecbae505385b1064cb29198c7a0a5d41
5
5
  SHA512:
6
- metadata.gz: 7ef97b5e5ed0c0655cd45c1e1c101368cbb6887352ab81fbe1c57f2996bc1f8c1ad461925071acec8f0faae3d863547307991b366c574ddb0d4a6f7268f23766
7
- data.tar.gz: 677f12f8586448827cf4cce7d1895eb21ce6ae1eadb6182a7b511e6c2a888c7b5bd2290685af0695d76247c7444ee3482f1de41b1850b36c5899527cf9a7705d
6
+ metadata.gz: 843bd8781e86f9da4d6bee52529f625d7b04f177c1a3bf50847b33a51bcb938ce6310faf10b1f0bee57de4d21ee36427515ddfc1529e0c933f21ca268e842091
7
+ data.tar.gz: 337ae8d3ebe98ce3dc4380ef65a81c9172eb75ae7f799f60db35f228b2bd6713b525c6898c67dbff00da8de8ecd8adac8cff0d14e9d2d22c23e0598744f40294
@@ -61,7 +61,7 @@ Examples:
61
61
  opts.on("-d", "--depth DEPTH", "Internal depth of the box") { |value| options.depth= value }
62
62
  opts.on("-t", "--thickness THICKNESS", "Thickness of the box material") { |value| options.thickness = value }
63
63
  opts.on("-n", "--notch NOTCH", "Optional notch length (aka \"tab width\"), guide only") { |value| options.notch = value }
64
- opts.on("-k", "--kerf KERF", "Kerf - cut width (default is 0.007in)") { |value| options.kerf = value }
64
+ opts.on("-k", "--kerf KERF", "Kerf - cut width (default is #{Laser::Cutter::Configuration::UNIT_SPECIFIC_DEFAULTS['in'][:kerf]}in)") { |value| options.kerf = value }
65
65
  opts.separator ""
66
66
  opts.on("-m", "--margin MARGIN", "Margins from the edge of the document") { |value| options.margin = value }
67
67
  opts.on("-p", "--padding PADDING", "Space between the boxes on the page") { |value| options.padding = value }
@@ -4,10 +4,18 @@ require 'pdf/core/page_geometry'
4
4
 
5
5
  module Laser
6
6
  module Cutter
7
- class MissingOption < RuntimeError
8
- end
9
- class ZeroValueNotAllowed < MissingOption
7
+ class MissingOption < RuntimeError; end
8
+ class ZeroValueNotAllowed < MissingOption; end
9
+
10
+ class UnitsConverter
11
+ def self.mm2in value
12
+ 0.039370079 * value
13
+ end
14
+ def self.in2mm value
15
+ 25.4 * value
16
+ end
10
17
  end
18
+
11
19
  class Configuration < Hashie::Mash
12
20
  DEFAULTS = {
13
21
  units: 'in',
@@ -16,23 +24,19 @@ module Laser
16
24
  }
17
25
 
18
26
  UNIT_SPECIFIC_DEFAULTS = {
19
- 'mm' => {
20
- margin: 3,
21
- padding: 2,
22
- stroke: 0.0254,
23
- kerf: 0.1778
24
- },
25
27
  'in' => {
26
- kerf: 0.007, # smallest kerf for thin material, usually it's more than that.
28
+ kerf: 0.0024, # smallest kerf for thin material, usually it's more than that.
27
29
  margin: 0.125,
28
30
  padding: 0.1,
29
31
  stroke: 0.001,
30
32
  }
31
33
  }
32
34
 
35
+ UNIT_SPECIFIC_DEFAULTS['mm'] = UNIT_SPECIFIC_DEFAULTS['in'].map{|k, v| [k, UnitsConverter.in2mm(v)] }.to_h
36
+
33
37
  SIZE_REGEXP = /[\d\.]+x[\d\.]+x[\d\.]+\/[\d\.]+(\/[\d\.]+)?/
34
38
 
35
- FLOATS = %w(width height depth thickness notch margin padding stroke kerf)
39
+ FLOATS = %w(width height depth thickness notch margin padding stroke kerf)
36
40
  NON_ZERO = %w(width height depth thickness stroke)
37
41
  REQUIRED = %w(width height depth thickness notch file)
38
42
 
@@ -67,7 +71,7 @@ module Laser
67
71
 
68
72
  def change_units(new_units)
69
73
  return if (self.units.eql?(new_units) || !UNIT_SPECIFIC_DEFAULTS.keys.include?(new_units))
70
- k = (self.units == 'in') ? 25.4 : 0.039370079
74
+ k = (self.units == 'in') ? UnitsConverter.in2mm(1.0) : UnitsConverter.mm2in(1.0)
71
75
  FLOATS.each do |field|
72
76
  next if self.send(field.to_sym).nil?
73
77
  self.send("#{field}=".to_sym, (self.send(field.to_sym) * k).round(5))
@@ -38,23 +38,18 @@ module Laser
38
38
 
39
39
  def adjust_for_kerf!
40
40
  if kerf?
41
- k = kerf / 2.0
42
- p1 = inside.p1.plus(v1 * k)
43
- p2 = inside.p2.plus(v2 * k)
44
- self.inside = Geometry::Line.new(p1, p2)
45
-
46
- p1 = outside.p1.plus(v1 * k)
47
- p2 = outside.p2.plus(v2 * k)
48
- self.outside = Geometry::Line.new(p1, p2)
49
-
50
- inside.relocate!
51
- outside.relocate!
52
- # note – we have not increased the length of the sides to compensate
53
- # for kerf – we simply shifted both lines. We'll compenensate for this
54
- # in notch width calculations later, and also corner box inclusion.
41
+ self.inside = move_line_for_kerf(inside)
42
+ self.outside = move_line_for_kerf(outside)
55
43
  end
56
44
  end
57
45
 
46
+ def move_line_for_kerf line
47
+ k = kerf / 2.0
48
+ p1 = line.p1.plus(v1 * k)
49
+ p2 = line.p2.plus(v2 * k)
50
+ Geometry::Line.new(p1, p2).relocate!
51
+ end
52
+
58
53
  def kerf?
59
54
  self.kerf > 0.0
60
55
  end
@@ -1,5 +1,5 @@
1
1
  module Laser
2
2
  module Cutter
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laser-cutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2014-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn