divvy_up 0.1.1 → 0.1.2

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: 7428ae33e30e958f738f5af7e4ae41fdd667774c
4
- data.tar.gz: 7b499f0c387fc0f36dbc6b6119d0e7ec0f624986
3
+ metadata.gz: cb8031716a0ff8be7b2330f02f3729980a2f0611
4
+ data.tar.gz: f7e589444af474686c6ab06ca77d9dd01becdd69
5
5
  SHA512:
6
- metadata.gz: 5d6402894878432babb2ed1c555fd042b1aeed327a7c11b7f7cc4fd579e7daaa7b531cdd9ed30759c39e73f94c0fddf04fce8cbfe72d3f9f41d04e113dfecac8
7
- data.tar.gz: 31025cac7d76fbe7294fbb0fcb41f25b56d04fd33a274703e6e604977b84efecb9d84ecacea46ba445a534982a4d293ec041f9cf7c93214cde5b49394c81ed13
6
+ metadata.gz: eacc87d816ed1236597a458a0a2ef90578647bd6529ce88aeedbb91e92ba788ae8b10f6e6a6dab071eb497e4525cf6247f04bf502d99d5262e032f9c81bc6a67
7
+ data.tar.gz: ce779873f08a334cc3f9476c27c487e2e374d034160826115852fe96aba95703428e128b255c659f238d9985f5c8c799c09d5949de69bf1867f8e0bbabfb4bdf
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.1.2] - 2015-07-09
8
+ ### Fixed
9
+ - Resolve potential infinite loop in `#split` occurring when no valid solution is possible using "permute" technique
10
+
7
11
  ## [0.1.1] - 2015-07-05
8
12
  ### Fixed
9
13
  - Resolve error occurring in `#split` method for certain list and group number combinations
@@ -15,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
15
19
  ## 0.0.1 - 2015-03-09
16
20
  - Initial release
17
21
 
18
- [unreleased]: https://github.com/djpowers/divvy_up/compare/v0.1.1...HEAD
19
- [0.1.1]: https://github.com/djpowers/divvy_up/compare/v0.0.1...v0.1.1
22
+ [unreleased]: https://github.com/djpowers/divvy_up/compare/v0.1.2...HEAD
23
+ [0.1.2]: https://github.com/djpowers/divvy_up/compare/v0.1.1...v0.1.2
24
+ [0.1.1]: https://github.com/djpowers/divvy_up/compare/v0.1.0...v0.1.1
20
25
  [0.1.0]: https://github.com/djpowers/divvy_up/compare/v0.0.1...v0.1.0
data/lib/divvy_up/list.rb CHANGED
@@ -113,15 +113,14 @@ module DivvyUp
113
113
  def output_final_sublists(sublist_options_sorted)
114
114
  sublists = []
115
115
  accounted_items = []
116
- until sublists.size == @groups
117
- sublist_options_sorted.each do |list|
118
- if (accounted_items & list.keys).empty?
119
- sublists << [list, (list.values.reduce(:+)).round(2)]
120
- accounted_items << list.keys
121
- accounted_items.flatten!
122
- end
116
+ sublist_options_sorted.each do |list|
117
+ if (accounted_items & list.keys).empty?
118
+ sublists << [list, (list.values.reduce(:+)).round(2)]
119
+ accounted_items << list.keys
120
+ accounted_items.flatten!
123
121
  end
124
122
  end
123
+ sublists = nil if sublists.count > @groups
125
124
  sublists
126
125
  end
127
126
 
@@ -130,6 +129,7 @@ module DivvyUp
130
129
  snake_result = snake
131
130
  price_is_right_result = price_is_right
132
131
  results = [permute_result, snake_result, price_is_right_result]
132
+ results.delete(nil)
133
133
  result_differences = []
134
134
  results.each do |result|
135
135
  result_totals = []
@@ -1,3 +1,3 @@
1
1
  module DivvyUp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -87,5 +87,17 @@ module DivvyUp
87
87
  ]
88
88
  )
89
89
  end
90
+
91
+ it "splits a large list into three groups" do
92
+ shopping_list = { orange_juice_1: 3, orange_juice_2: 3, eggs_dozen: 2.99, spring_mix_16_oz: 6.99, bacon: 4.99, pasta_sauce: 2.50, blueberries: 3.99, frozen_strawberries: 2.99, olive_oil: 8.99, paper_towels: 1.59, toilet_paper: 1.99, aluminum_foil: 3 }
93
+ list = DivvyUp::List.new(shopping_list)
94
+ expect(list.split(3)).to eql(
95
+ [
96
+ [{olive_oil:8.99, orange_juice_1:3, orange_juice_2:3, paper_towels:1.59}, 16.58],
97
+ [{spring_mix_16_oz:6.99, aluminum_foil:3, frozen_strawberries:2.99, toilet_paper:1.99}, 14.97],
98
+ [{bacon:4.99, blueberries:3.99, eggs_dozen:2.99, pasta_sauce:2.5}, 14.47]
99
+ ]
100
+ )
101
+ end
90
102
  end
91
103
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: divvy_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Powers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler