hotel_beds 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hotel_beds.gemspec +1 -0
- data/lib/hotel_beds/model.rb +3 -3
- data/lib/hotel_beds/model/available_room.rb +2 -3
- data/lib/hotel_beds/parser.rb +2 -2
- data/lib/hotel_beds/parser/room_grouper.rb +7 -11
- data/lib/hotel_beds/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ab8d652ac737f488dfb4dbd72cb12c26f10047
|
4
|
+
data.tar.gz: b889af49744f86368e8dc594d28aa30e4778ef7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0a25ec9e60cda2906296bd454a234f2db94654ccac0bfd6f351aa8d78851f1cf61a6b136f138f5f8fa8546a78964f664ffff2253bb22bbb016be6e3e666b4d3
|
7
|
+
data.tar.gz: d4d393e6d5d66cbb8bb324c3af0df244724fd84cb5ca4232320f1e5240020f4f737be34e968e806605c4c4030e35676d017f73369b00391fc0e91091f2a137d0
|
data/hotel_beds.gemspec
CHANGED
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "guard-rspec", "~> 4.2.10"
|
29
29
|
spec.add_development_dependency "dotenv", "~> 0.11.1"
|
30
30
|
spec.add_development_dependency "codeclimate-test-reporter"
|
31
|
+
spec.add_development_dependency "ox", "~> 2.1.3"
|
31
32
|
end
|
data/lib/hotel_beds/model.rb
CHANGED
@@ -11,11 +11,11 @@ module HotelBeds
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def deep_attributes
|
14
|
-
attributes.
|
14
|
+
attributes.each_with_object(Hash.new) do |(key, value), result|
|
15
15
|
if value.respond_to?(:deep_attributes)
|
16
|
-
result
|
16
|
+
result[key] = value.deep_attributes
|
17
17
|
else
|
18
|
-
result
|
18
|
+
result[key] = value
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -27,11 +27,10 @@ module HotelBeds
|
|
27
27
|
prices = values.map do |attrs|
|
28
28
|
HotelBeds::Model::Price.new(attrs)
|
29
29
|
end
|
30
|
-
hash = prices.
|
30
|
+
hash = prices.each_with_object(Hash.new) do |price, result|
|
31
31
|
price.dates.each do |date|
|
32
|
-
result
|
32
|
+
result[date] = price.amount
|
33
33
|
end
|
34
|
-
result
|
35
34
|
end
|
36
35
|
super(hash)
|
37
36
|
else
|
data/lib/hotel_beds/parser.rb
CHANGED
@@ -88,8 +88,8 @@ module HotelBeds
|
|
88
88
|
|
89
89
|
# parses the document into a hash of attributes
|
90
90
|
def to_h
|
91
|
-
self.class.attributes.
|
92
|
-
result
|
91
|
+
self.class.attributes.each_with_object(Hash.new) do |attribute, result|
|
92
|
+
result[attribute.name] = attribute.retrieve(doc)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -23,7 +23,7 @@ module HotelBeds
|
|
23
23
|
|
24
24
|
def expand_combinations(combinations)
|
25
25
|
combinations.map do |rooms|
|
26
|
-
rooms.
|
26
|
+
rooms.each_with_object(Array.new) do |room, result|
|
27
27
|
# get an array of all the child ages
|
28
28
|
child_ages = requested_rooms_child_ages_by_occupants.fetch(occupant_key(room))
|
29
29
|
1.upto(room.room_count) do |i|
|
@@ -32,7 +32,6 @@ module HotelBeds
|
|
32
32
|
r.child_ages = child_ages.pop
|
33
33
|
end
|
34
34
|
end
|
35
|
-
result
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
@@ -46,7 +45,7 @@ module HotelBeds
|
|
46
45
|
# returns a array of arrays, each contains available rooms for a given
|
47
46
|
# room occupancy
|
48
47
|
def room_options_grouped_by_occupants
|
49
|
-
requested_room_count_by_occupants.
|
48
|
+
requested_room_count_by_occupants.each_with_object(Array.new) do |(key, count), result|
|
50
49
|
result << response_rooms_by_occupants.fetch(key).select do |room|
|
51
50
|
room.room_count == count
|
52
51
|
end
|
@@ -57,38 +56,35 @@ module HotelBeds
|
|
57
56
|
|
58
57
|
# returns a hash of OK => [Integer]
|
59
58
|
def requested_rooms_child_ages_by_occupants
|
60
|
-
requested_rooms.
|
59
|
+
requested_rooms.each_with_object(Hash.new) do |room, result|
|
61
60
|
key = occupant_key(room)
|
62
61
|
result[key] ||= Array.new
|
63
62
|
result[key] += room.child_ages
|
64
|
-
result
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
68
66
|
# returns a hash of OK => [RR]
|
69
67
|
def requested_rooms_by_occupants
|
70
|
-
requested_rooms.
|
68
|
+
requested_rooms.each_with_object(Hash.new) do |room, result|
|
71
69
|
key = occupant_key(room)
|
72
70
|
result[key] ||= Array.new
|
73
71
|
result[key] << room
|
74
|
-
result
|
75
72
|
end
|
76
73
|
end
|
77
74
|
|
78
75
|
# returns a hash of OK => 1 (count)
|
79
76
|
def requested_room_count_by_occupants
|
80
|
-
requested_rooms_by_occupants.
|
81
|
-
result
|
77
|
+
requested_rooms_by_occupants.each_with_object(Hash.new) do |(key, rooms), result|
|
78
|
+
result[key] = rooms.size
|
82
79
|
end
|
83
80
|
end
|
84
81
|
|
85
82
|
# returns a hash of OK => [AvailableRoom, AvailableRoom, AvailableRoom]
|
86
83
|
def response_rooms_by_occupants
|
87
|
-
response_rooms.
|
84
|
+
response_rooms.each_with_object(Hash.new) do |room, result|
|
88
85
|
key = occupant_key(room)
|
89
86
|
result[key] ||= Array.new
|
90
87
|
result[key].push(room)
|
91
|
-
result
|
92
88
|
end
|
93
89
|
end
|
94
90
|
|
data/lib/hotel_beds/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotel_beds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Townsend
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ox
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.1.3
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.1.3
|
153
167
|
description:
|
154
168
|
email:
|
155
169
|
- ryan@ryantownsend.co.uk
|