box_packer 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +4 -2
- data/box_packer.gemspec +2 -2
- data/lib/box_packer/container.rb +15 -5
- data/lib/box_packer/packer.rb +1 -1
- data/lib/box_packer/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 959809e7eac3a76e95054ec7eccbc68e91ad1794
|
4
|
+
data.tar.gz: 898284b8f4dfee101bb8df784ed2f26787ef8aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 452b2949f4716224416ebcfe8ca91d56eeb1866086c9edaa638f901f2709ca0d1353f179471d5d462639325a77e52a6fa97fa5e0d6553bed29c8dd57ccea6ddc
|
7
|
+
data.tar.gz: d8c849a45ab956d649bea7e2d84db8ce81fba6baee0d196a17ebfe40ed1d9058376ae8955624108610ac372911a61afc65e0539fdb4478bd689afb11a0dca3bc
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -45,16 +45,18 @@ BoxPacker.container [3, 6, 7] do
|
|
45
45
|
end
|
46
46
|
```
|
47
47
|
|
48
|
-
With optional labels, weights and packings limit:
|
48
|
+
With optional labels, weights, quantity and packings limit:
|
49
49
|
|
50
50
|
``` ruby
|
51
51
|
BoxPacker.container [15, 20, 13], label: 'Parcel', weight_limit: 50, packings_limit: 3 do
|
52
|
-
add_item [2, 3, 5], label: 'Shoes', weight: 47
|
52
|
+
add_item [2, 3, 5], label: 'Shoes', weight: 47, quantity: 2
|
53
53
|
add_item [3, 3, 1], label: 'Watch', weight: 24
|
54
54
|
add_item [1, 1, 4], label: 'Bag', weight: 7
|
55
55
|
pack! # returns 2
|
56
56
|
|
57
57
|
puts self # |Container| Parcel 20x15x13 Weight Limit:50 Packings Limit:3
|
58
|
+
# | Packing| Remaining Volume:3870 Remaining Weight:3
|
59
|
+
# | Item| Shoes 5x3x2 (0,0,0) Volume:30 Weight:47
|
58
60
|
# | Packing| Remaining Volume:3870 Remaining Weight:3
|
59
61
|
# | Item| Shoes 5x3x2 (0,0,0) Volume:30 Weight:47
|
60
62
|
# | Packing| Remaining Volume:3887 Remaining Weight:19
|
data/box_packer.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'rake'
|
22
22
|
spec.add_development_dependency 'rspec'
|
23
23
|
|
24
|
-
spec.add_dependency 'attr_extras'
|
25
|
-
spec.add_dependency 'rasem'
|
24
|
+
spec.add_dependency 'attr_extras', '~> 3.1.0'
|
25
|
+
spec.add_dependency 'rasem', '~> 0.6.0'
|
26
26
|
|
27
27
|
end
|
data/lib/box_packer/container.rb
CHANGED
@@ -25,8 +25,11 @@ module BoxPacker
|
|
25
25
|
self.instance_exec(&b) if block_given?
|
26
26
|
end
|
27
27
|
|
28
|
-
def add_item(
|
29
|
-
|
28
|
+
def add_item(dimensions, opts={})
|
29
|
+
quantity = opts.delete(:quantity) || 1
|
30
|
+
quantity.times do
|
31
|
+
items << Item.new(dimensions, opts)
|
32
|
+
end
|
30
33
|
end
|
31
34
|
|
32
35
|
def <<(item)
|
@@ -40,8 +43,11 @@ module BoxPacker
|
|
40
43
|
def pack!
|
41
44
|
prepare_to_pack!
|
42
45
|
return unless packable?
|
43
|
-
@packed_successfully = Packer.pack(self)
|
44
|
-
|
46
|
+
if @packed_successfully = Packer.pack(self)
|
47
|
+
packings.count
|
48
|
+
else
|
49
|
+
@packings = []
|
50
|
+
end
|
45
51
|
end
|
46
52
|
|
47
53
|
def new_packing!
|
@@ -56,7 +62,11 @@ module BoxPacker
|
|
56
62
|
s << " Weight Limit:#{weight_limit}" if weight_limit
|
57
63
|
s << " Packings Limit:#{packings_limit}" if packings_limit
|
58
64
|
s << "\n"
|
59
|
-
|
65
|
+
if packed_successfully
|
66
|
+
s << packings.map(&:to_s).join
|
67
|
+
else
|
68
|
+
s << "| | Did Not Pack!"
|
69
|
+
end
|
60
70
|
end
|
61
71
|
|
62
72
|
def draw!(filename, opts={})
|
data/lib/box_packer/packer.rb
CHANGED
data/lib/box_packer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: box_packer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max White
|
@@ -56,30 +56,30 @@ dependencies:
|
|
56
56
|
name: attr_extras
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.1.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rasem
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.6.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.6.0
|
83
83
|
description: A Heuristic First-Fit 3D Bin Packing Algorithm with Weight Limit
|
84
84
|
email:
|
85
85
|
- mushishi78@gmail.com
|