box_packer 2.0.2 → 2.0.3

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/box_packer.rb +6 -6
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 500717c2ecd384e045a1896b6a99eabc55765b29
4
- data.tar.gz: de40bda0f5fb060b5e50dee5e0038294877a44d9
3
+ metadata.gz: c2f6de250fb518dfccb889ba7096d310956fa985
4
+ data.tar.gz: 13fa697ca9eed3a1ce7ef6cf175ad14d84cc8dd1
5
5
  SHA512:
6
- metadata.gz: 153af3ccf8ada5e2d9732b5de8de1716228c14e41ffb0f538711d3277d42b3891048098eb25f866fb6f100fc909a1ae00891ae7cb351e29af779244a1f3f2b71
7
- data.tar.gz: 4afbe0d73c59d5458df1bc9adafe40cae06ed4c0d87524813fd304d597fd4076f98509923e8451282536385fb5398ab8d90f25a50ce506711280983bda415a3f
6
+ metadata.gz: 93640e9ec9867690dee6bae8914868ef6d78d8419d324cd7b219c9739235efcd8bbb2fe7c78e597e774ecc7662b9de26c05c386bc638020f2056d614b795c123
7
+ data.tar.gz: ca3dbe811840640065554c164dd827ab1f0639df6955ed5f7030407f0d5abbcfd1fb6cd97b308b88eb4551b6465f9fdc4675d040a2df452d7407e7674914c90d
data/box_packer.rb CHANGED
@@ -5,7 +5,7 @@ module BoxPacker
5
5
 
6
6
  items.each do |item|
7
7
  # If the item is just too big for the container lets give up on this
8
- raise 'Item is too heavy for container' if item[:weight] > container[:weight_limit]
8
+ raise 'Item is too heavy for container' if item[:weight].to_f > container[:weight_limit].to_f
9
9
 
10
10
  # Need a bool so we can break out nested loops once it's been packed
11
11
  item_has_been_packed = false
@@ -13,17 +13,17 @@ module BoxPacker
13
13
  packings.each do |packing|
14
14
  # If this packings going to be too big with this
15
15
  # item as well then skip on to the next packing
16
- next if packing[:weight] + item[:weight] > container[:weight_limit]
16
+ next if packing[:weight].to_f + item[:weight].to_f > container[:weight_limit].to_f
17
17
 
18
18
  packing[:spaces].each do |space|
19
19
  # Try placing the item in this space,
20
- # if it doesn't fit skip on the next space
20
+ # if it doesn't fit skip on the next space
21
21
  next unless placement = place(item, space)
22
22
 
23
23
  # Add the item to the packing and
24
24
  # break up the surrounding spaces
25
25
  packing[:placements] += [placement]
26
- packing[:weight] += item[:weight]
26
+ packing[:weight] += item[:weight].to_f
27
27
  packing[:spaces] -= [space]
28
28
  packing[:spaces] += break_up_space(space, placement)
29
29
  item_has_been_packed = true
@@ -49,7 +49,7 @@ module BoxPacker
49
49
  # and break up the remaing free space around it
50
50
  packings += [{
51
51
  placements: [placement],
52
- weight: item[:weight],
52
+ weight: item[:weight].to_f,
53
53
  spaces: break_up_space(space, placement)
54
54
  }]
55
55
  end
@@ -78,7 +78,7 @@ module BoxPacker
78
78
  return {
79
79
  dimensions: perm,
80
80
  position: space[:position],
81
- weight: item[:weight]
81
+ weight: item[:weight].to_f
82
82
  }
83
83
  end
84
84
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: box_packer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max White
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.1.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: pry
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  description:
34
48
  email: mushishi78@gmail.com
35
49
  executables: []