Chrononaut-hostconnect 0.1.1 → 0.1.2
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.
- data/CHANGELOG +1 -0
- data/hostconnect.gemspec +6 -3
- data/lib/hostconnect/builders/room_config_builder.rb +1 -1
- data/lib/hostconnect/coercion.rb +13 -19
- data/lib/hostconnect/responses/get_booking.rb +3 -1
- data/lib/hostconnect/translation.rb +21 -0
- data/lib/hostconnect.rb +2 -2
- data/spec/builders/room_config_builder_spec.rb +2 -2
- data/spec/coercion_spec.rb +0 -9
- data/spec/translation_spec.rb +18 -0
- metadata +6 -3
data/CHANGELOG
CHANGED
data/hostconnect.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hostconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Bj\xC3\xB8rn Arild M\xC3\xA6land"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
|
11
|
-
date: 2008-08-
|
11
|
+
date: 2008-08-28 00:00:00 +02:00
|
12
12
|
default_executable:
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
@@ -88,6 +88,7 @@ extra_rdoc_files:
|
|
88
88
|
- lib/hostconnect/coercion.rb
|
89
89
|
- lib/hostconnect/core_extensions/string.rb
|
90
90
|
- lib/hostconnect/core_extensions/symbol.rb
|
91
|
+
- lib/hostconnect/translation.rb
|
91
92
|
- lib/hostconnect/responses/agent_info.rb
|
92
93
|
- lib/hostconnect/responses/get_services.rb
|
93
94
|
- lib/hostconnect/responses/list_bookings.rb
|
@@ -106,6 +107,7 @@ files:
|
|
106
107
|
- Rakefile
|
107
108
|
- README.markdown
|
108
109
|
- CHANGELOG
|
110
|
+
- hostconnect.gemspec
|
109
111
|
- lib/hostconnect.rb
|
110
112
|
- lib/hostconnect/builders/agent_info_builder.rb
|
111
113
|
- lib/hostconnect/builders/pax_details_builder.rb
|
@@ -124,6 +126,7 @@ files:
|
|
124
126
|
- lib/hostconnect/coercion.rb
|
125
127
|
- lib/hostconnect/core_extensions/string.rb
|
126
128
|
- lib/hostconnect/core_extensions/symbol.rb
|
129
|
+
- lib/hostconnect/translation.rb
|
127
130
|
- lib/hostconnect/responses/agent_info.rb
|
128
131
|
- lib/hostconnect/responses/get_services.rb
|
129
132
|
- lib/hostconnect/responses/list_bookings.rb
|
@@ -176,9 +179,9 @@ files:
|
|
176
179
|
- spec/responses/add_service_spec.rb
|
177
180
|
- spec/responses/ping_spec.rb
|
178
181
|
- spec/responses/get_locations_spec.rb
|
182
|
+
- spec/translation_spec.rb
|
179
183
|
- spec/coercion_spec.rb
|
180
184
|
- Manifest
|
181
|
-
- hostconnect.gemspec
|
182
185
|
has_rdoc: true
|
183
186
|
homepage: http://www.github.com/Chrononaut/hostconnect/
|
184
187
|
post_install_message:
|
@@ -10,7 +10,7 @@ module HostConnect
|
|
10
10
|
x = Builder::XmlMarkup.new(:indent => 2, :margin => 3)
|
11
11
|
x.RoomConfig {
|
12
12
|
x.Adults @adults if @adults
|
13
|
-
x.RoomType
|
13
|
+
x.RoomType @room_type if @room_type
|
14
14
|
|
15
15
|
if @pax_list
|
16
16
|
# Stack the PaxDetails builder objects onto the request
|
data/lib/hostconnect/coercion.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
module HostConnect
|
2
|
+
# Coercion
|
3
|
+
#
|
4
|
+
# Possible Types:
|
5
|
+
# * String
|
6
|
+
# * Strings with multiple lines (don't know yet if these must be handled specifically)
|
7
|
+
# * Boolean (Y/N)
|
8
|
+
# * Date (yyyy-mm-dd)
|
9
|
+
# * Time (hhmm)
|
10
|
+
# * Integer
|
11
|
+
# * Integer list (In an integer list, a single space is used to separate integer values.)
|
12
|
+
# * Price (Prices returned are Tourplan prices multiplied by 100, + currency stuff..)
|
13
|
+
#
|
14
|
+
# It must be possible to convert this data from/to native Ruby objects
|
2
15
|
class Coercion
|
3
|
-
# Coercion
|
4
|
-
#
|
5
|
-
# Possible Types:
|
6
|
-
# * String
|
7
|
-
# * Strings with multiple lines (don't know yet if these must be handled specifically)
|
8
|
-
# * Boolean (Y/N)
|
9
|
-
# * Date (yyyy-mm-dd)
|
10
|
-
# * Time (hhmm)
|
11
|
-
# * Integer
|
12
|
-
# * Integer list (In an integer list, a single space is used to separate integer values.)
|
13
|
-
# * Price (Prices returned are Tourplan prices multiplied by 100, + currency stuff..)
|
14
|
-
#
|
15
|
-
# It must be possible to convert this data from/to native Ruby objects
|
16
|
-
|
17
16
|
# Convert HostConnect formatted data to Ruby objects
|
18
17
|
def self.from_hc(data)
|
19
18
|
case data
|
@@ -35,11 +34,6 @@ module HostConnect
|
|
35
34
|
when nil then ""
|
36
35
|
when true then "Y"
|
37
36
|
when false then "N"
|
38
|
-
when "Single" then "SG"
|
39
|
-
when "Twin" then "TW"
|
40
|
-
when "Double" then "DB"
|
41
|
-
when "Triple" then "TR"
|
42
|
-
when "Quad" then "QD"
|
43
37
|
else data.strip
|
44
38
|
end
|
45
39
|
end
|
@@ -6,10 +6,12 @@ module HostConnect
|
|
6
6
|
|
7
7
|
@services = []
|
8
8
|
@data.search("/Reply/GetBookingReply/Services/Service").each do |service|
|
9
|
-
s = Struct.new(:service_line_id, :service_line_update_count, :opt
|
9
|
+
s = Struct.new(:service_line_id, :service_line_update_count, :opt,
|
10
|
+
:status).new
|
10
11
|
s.service_line_id = (service/"ServiceLineId").innerHTML.to_i
|
11
12
|
s.service_line_update_count = (service/"ServiceLineUpdateCount").innerHTML.to_i
|
12
13
|
s.opt = (service/"Opt").innerHTML
|
14
|
+
s.status = (service/"Status").innerHTML
|
13
15
|
|
14
16
|
@services << s
|
15
17
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HostConnect
|
2
|
+
# Translate to/from HostConnect codes
|
3
|
+
class Translation
|
4
|
+
GRAMMAR = {
|
5
|
+
"SG" => "Single",
|
6
|
+
"TW" => "Twin",
|
7
|
+
"DB" => "Double",
|
8
|
+
"TR" => "Triple",
|
9
|
+
"QD" => "Quad",
|
10
|
+
"CF" => "Confirmed",
|
11
|
+
"CX" => "Cancelled",
|
12
|
+
"FQ" => "FIT Quote",
|
13
|
+
"IN" => "Internet Booking",
|
14
|
+
"RQ" => "Request"
|
15
|
+
}
|
16
|
+
|
17
|
+
def self.translate(string)
|
18
|
+
(string =~ /^[A-Z]{2}$/) ? GRAMMAR[string] : GRAMMAR.invert[string]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/hostconnect.rb
CHANGED
@@ -10,7 +10,7 @@ $LOAD_PATH.unshift(pwd)
|
|
10
10
|
active_support yaml logger].each { |lib| require lib }
|
11
11
|
|
12
12
|
# Require HostConnect files
|
13
|
-
%w[client response builder rtf_document
|
13
|
+
%w[client response builder rtf_document translation
|
14
14
|
coercion].each { |lib| require "#{pwd}/hostconnect/#{lib}" }
|
15
15
|
|
16
16
|
Dir.glob("#{pwd}/hostconnect/builders/*.rb").each { |file| require file }
|
@@ -23,7 +23,7 @@ module HostConnect
|
|
23
23
|
module Version
|
24
24
|
MAJOR = '0'
|
25
25
|
MINOR = '1'
|
26
|
-
REVISION = '
|
26
|
+
REVISION = '2'
|
27
27
|
def self.combined
|
28
28
|
[MAJOR, MINOR, REVISION].join('.')
|
29
29
|
end
|
@@ -46,10 +46,10 @@ END
|
|
46
46
|
pax2 = PaxDetailsBuilder.new(:title => "Mrs", :forename => "Sally", :surname => "Jardim",
|
47
47
|
:pax_type => "A", :date_of_birth => "1980-12-24")
|
48
48
|
|
49
|
-
room = RoomConfigBuilder.new(:adults => 1, :room_type => "
|
49
|
+
room = RoomConfigBuilder.new(:adults => 1, :room_type => "TW", :pax_list => [ pax1 ])
|
50
50
|
room.to_s.should == @room_xml_1
|
51
51
|
|
52
|
-
room = RoomConfigBuilder.new(:adults => 2, :room_type => "
|
52
|
+
room = RoomConfigBuilder.new(:adults => 2, :room_type => "TW", :pax_list => [ pax1, pax2 ])
|
53
53
|
room.to_s.should == @room_xml_2
|
54
54
|
end
|
55
55
|
|
data/spec/coercion_spec.rb
CHANGED
@@ -81,14 +81,5 @@ describe HostConnect::Coercion do
|
|
81
81
|
Coercion.to_hc(nil).should == ""
|
82
82
|
Coercion.to_hc(" ").should == ""
|
83
83
|
end
|
84
|
-
|
85
|
-
it "should know about room types" do
|
86
|
-
Coercion.to_hc("Single").should == "SG"
|
87
|
-
Coercion.to_hc("Twin").should == "TW"
|
88
|
-
Coercion.to_hc("Double").should == "DB"
|
89
|
-
Coercion.to_hc("Triple").should == "TR"
|
90
|
-
Coercion.to_hc("Quad").should == "QD"
|
91
|
-
Coercion.to_hc("Twinn").should == "Twinn"
|
92
|
-
end
|
93
84
|
end
|
94
85
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
|
3
|
+
describe HostConnect::Translation do
|
4
|
+
it "should know about room types" do
|
5
|
+
Translation.translate("Single").should == "SG"
|
6
|
+
Translation.translate("Twin").should == "TW"
|
7
|
+
Translation.translate("Double").should == "DB"
|
8
|
+
Translation.translate("Triple").should == "TR"
|
9
|
+
Translation.translate("Quad").should == "QD"
|
10
|
+
Translation.translate("Twinn").should == nil
|
11
|
+
|
12
|
+
Translation.translate("SG").should == "Single"
|
13
|
+
Translation.translate("TW").should == "Twin"
|
14
|
+
Translation.translate("DB").should == "Double"
|
15
|
+
Translation.translate("TR").should == "Triple"
|
16
|
+
Translation.translate("QD").should == "Quad"
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Chrononaut-hostconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Bj\xC3\xB8rn Arild M\xC3\xA6land"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
|
-
date: 2008-08-
|
11
|
+
date: 2008-08-27 15:00:00 -07:00
|
12
12
|
default_executable:
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
@@ -88,6 +88,7 @@ extra_rdoc_files:
|
|
88
88
|
- lib/hostconnect/coercion.rb
|
89
89
|
- lib/hostconnect/core_extensions/string.rb
|
90
90
|
- lib/hostconnect/core_extensions/symbol.rb
|
91
|
+
- lib/hostconnect/translation.rb
|
91
92
|
- lib/hostconnect/responses/agent_info.rb
|
92
93
|
- lib/hostconnect/responses/get_services.rb
|
93
94
|
- lib/hostconnect/responses/list_bookings.rb
|
@@ -106,6 +107,7 @@ files:
|
|
106
107
|
- Rakefile
|
107
108
|
- README.markdown
|
108
109
|
- CHANGELOG
|
110
|
+
- hostconnect.gemspec
|
109
111
|
- lib/hostconnect.rb
|
110
112
|
- lib/hostconnect/builders/agent_info_builder.rb
|
111
113
|
- lib/hostconnect/builders/pax_details_builder.rb
|
@@ -124,6 +126,7 @@ files:
|
|
124
126
|
- lib/hostconnect/coercion.rb
|
125
127
|
- lib/hostconnect/core_extensions/string.rb
|
126
128
|
- lib/hostconnect/core_extensions/symbol.rb
|
129
|
+
- lib/hostconnect/translation.rb
|
127
130
|
- lib/hostconnect/responses/agent_info.rb
|
128
131
|
- lib/hostconnect/responses/get_services.rb
|
129
132
|
- lib/hostconnect/responses/list_bookings.rb
|
@@ -176,9 +179,9 @@ files:
|
|
176
179
|
- spec/responses/add_service_spec.rb
|
177
180
|
- spec/responses/ping_spec.rb
|
178
181
|
- spec/responses/get_locations_spec.rb
|
182
|
+
- spec/translation_spec.rb
|
179
183
|
- spec/coercion_spec.rb
|
180
184
|
- Manifest
|
181
|
-
- hostconnect.gemspec
|
182
185
|
has_rdoc: true
|
183
186
|
homepage: http://www.github.com/Chrononaut/hostconnect/
|
184
187
|
post_install_message:
|