ldbws 1.0.0
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.
- checksums.yaml +7 -0
- data/.editorconfig +14 -0
- data/.envrc +1 -0
- data/.gitignore +8 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +79 -0
- data/LICENSE +21 -0
- data/Makefile +8 -0
- data/README.md +47 -0
- data/doc/LICENSE.html +93 -0
- data/doc/Ldbws/Request/GetDeparturesBoard.html +114 -0
- data/doc/Ldbws/Request/GetDeparturesBoardWithDetails.html +116 -0
- data/doc/Ldbws/Request/GetServiceDetails.html +105 -0
- data/doc/Ldbws/Request/GetStationBoard.html +120 -0
- data/doc/Ldbws/Request/GetStationBoardWithDetails.html +120 -0
- data/doc/Ldbws/Request.html +91 -0
- data/doc/Ldbws/ResponseTypes/BaseStationBoard.html +108 -0
- data/doc/Ldbws/ResponseTypes/CallingPoint.html +129 -0
- data/doc/Ldbws/ResponseTypes/Coach.html +114 -0
- data/doc/Ldbws/ResponseTypes/DepartureItem.html +108 -0
- data/doc/Ldbws/ResponseTypes/DepartureItemWithDetails.html +108 -0
- data/doc/Ldbws/ResponseTypes/DeparturesBoard.html +105 -0
- data/doc/Ldbws/ResponseTypes/DeparturesBoardWithDetails.html +105 -0
- data/doc/Ldbws/ResponseTypes/Formation.html +108 -0
- data/doc/Ldbws/ResponseTypes/LoadingCategory.html +105 -0
- data/doc/Ldbws/ResponseTypes/Location.html +105 -0
- data/doc/Ldbws/ResponseTypes/ServiceDetails.html +143 -0
- data/doc/Ldbws/ResponseTypes/ServiceItem.html +132 -0
- data/doc/Ldbws/ResponseTypes/ServiceItemWithCallingPoints.html +106 -0
- data/doc/Ldbws/ResponseTypes/StationBoard.html +107 -0
- data/doc/Ldbws/ResponseTypes/StationBoardWithDetails.html +107 -0
- data/doc/Ldbws/ResponseTypes/ToiletAvailability.html +108 -0
- data/doc/Ldbws/ResponseTypes.html +91 -0
- data/doc/Ldbws/Service.html +538 -0
- data/doc/Ldbws.html +149 -0
- data/doc/README_md.html +159 -0
- data/doc/created.rid +19 -0
- data/doc/css/fonts.css +167 -0
- data/doc/css/rdoc.css +662 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +165 -0
- data/doc/js/darkfish.js +84 -0
- data/doc/js/navigation.js +105 -0
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +110 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +229 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +299 -0
- data/ldbws.gemspec +25 -0
- data/lib/ldbws/request/base.rb +69 -0
- data/lib/ldbws/request/get_departures_board.rb +54 -0
- data/lib/ldbws/request/get_service_details.rb +29 -0
- data/lib/ldbws/request/get_station_board.rb +60 -0
- data/lib/ldbws/response_types/base.rb +34 -0
- data/lib/ldbws/response_types/calling_point.rb +40 -0
- data/lib/ldbws/response_types/departures_board.rb +39 -0
- data/lib/ldbws/response_types/formation.rb +49 -0
- data/lib/ldbws/response_types/parsing_functions.rb +177 -0
- data/lib/ldbws/response_types/service_details.rb +69 -0
- data/lib/ldbws/response_types/service_item.rb +77 -0
- data/lib/ldbws/response_types/station_board.rb +50 -0
- data/lib/ldbws/service.rb +218 -0
- data/lib/ldbws/utils.rb +60 -0
- data/lib/ldbws/version.rb +4 -0
- data/lib/ldbws.rb +13 -0
- data/spec/response_types/parsing_spec.rb +46 -0
- data/spec/spec_helper.rb +4 -0
- metadata +224 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
require "faraday"
|
|
2
|
+
require "nokogiri"
|
|
3
|
+
require "uri"
|
|
4
|
+
|
|
5
|
+
require "ldbws/request/get_departures_board"
|
|
6
|
+
require "ldbws/request/get_service_details"
|
|
7
|
+
require "ldbws/request/get_station_board"
|
|
8
|
+
require "ldbws/utils"
|
|
9
|
+
|
|
10
|
+
module Ldbws
|
|
11
|
+
# A wrapper around the National Rail Live Departure Boards Webservice (LDBWS) API.
|
|
12
|
+
#
|
|
13
|
+
# API methods are pretty much as-specified in {the documentation}[https://lite.realtime.nationalrail.co.uk/openldbws/],
|
|
14
|
+
# although methods on this class are specified using snake_case rather than the CamelCase used in the web service.
|
|
15
|
+
#
|
|
16
|
+
# === Usage example
|
|
17
|
+
#
|
|
18
|
+
# TL;DR:
|
|
19
|
+
#
|
|
20
|
+
# service = new Ldbws::Service( "YOUR-API-TOKEN" )
|
|
21
|
+
# departures = service.get_departure_board( crs: "CDF" )
|
|
22
|
+
#
|
|
23
|
+
# Will furnish you with a list of all departures from Cardiff Central. Other methods work pretty much as you’d expect
|
|
24
|
+
# if you’ve any familiarity with the service.
|
|
25
|
+
# Individual requests use Request[rdoc-ref:Request] objects to validate input parameters, and this is noted below. See
|
|
26
|
+
# the corresponding request object for each method for further information as to the parameters.
|
|
27
|
+
#
|
|
28
|
+
# === Side note
|
|
29
|
+
#
|
|
30
|
+
# The official documentation for this web service is… lacking. While an attempt has been made to elucidate on both the
|
|
31
|
+
# request parameters and response properties, it shouldn’t be taken as any kind of source of truth. Caveat emptor.
|
|
32
|
+
class Service
|
|
33
|
+
SERVICE_URI = URI("https://realtime.nationalrail.co.uk/OpenLDBWS/ldb12.asmx") # :nodoc:
|
|
34
|
+
|
|
35
|
+
# Creates a service object.
|
|
36
|
+
#
|
|
37
|
+
# === Parameters
|
|
38
|
+
# token:: the API token used to connect to the service
|
|
39
|
+
def initialize(token)
|
|
40
|
+
@token = token
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Retrieves a station departure board.
|
|
44
|
+
#
|
|
45
|
+
# Parameters are validated using GetStationBoard[rdoc-ref:Request::GetStationBoard], returns a
|
|
46
|
+
# StationBoard[rdoc-ref:ResponseTypes::StationBoard] object.
|
|
47
|
+
def get_departure_board(params)
|
|
48
|
+
request(
|
|
49
|
+
"http://thalesgroup.com/RTTI/2012-01-13/ldb/GetDepartureBoard",
|
|
50
|
+
Request::GetStationBoard.new(params)
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Retrieves a station arrival board.
|
|
55
|
+
#
|
|
56
|
+
# Parameters are validated using GetStationBoard[rdoc-ref:Request::GetStationBoard], returns a
|
|
57
|
+
# StationBoard[rdoc-ref:ResponseTypes::StationBoard] object.
|
|
58
|
+
def get_arrival_board(params)
|
|
59
|
+
request(
|
|
60
|
+
"http://thalesgroup.com/RTTI/2012-01-13/ldb/GetArrivalBoard",
|
|
61
|
+
Request::GetStationBoard.new(params)
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Retrieves a station arrival + departure board.
|
|
66
|
+
#
|
|
67
|
+
# Parameters are validated using GetStationBoard[rdoc-ref:Request::GetStationBoard], returns a
|
|
68
|
+
# StationBoard[rdoc-ref:ResponseTypes::StationBoard] object.
|
|
69
|
+
def get_arrival_departure_board(params)
|
|
70
|
+
request(
|
|
71
|
+
"http://thalesgroup.com/RTTI/2012-01-13/ldb/GetArrivalDepartureBoard",
|
|
72
|
+
Request::GetStationBoard.new(params)
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Retrieves a detailed station departure board.
|
|
77
|
+
#
|
|
78
|
+
# Parameters are validated using GetStationBoardWithDetails[rdoc-ref:Request:GetStationBoardWithDetails], returns a
|
|
79
|
+
# StationBoardWithDetails[rdoc-ref:ResponseTypes::StationBoardWithDetails] object.
|
|
80
|
+
def get_dep_board_with_details(params)
|
|
81
|
+
request(
|
|
82
|
+
"http://thalesgroup.com/RTTI/2015-05-14/ldb/GetDepBoardWithDetails",
|
|
83
|
+
Request::GetStationBoardWithDetails.new(params)
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Retrieves a detailed station arrival board.
|
|
88
|
+
#
|
|
89
|
+
# Parameters are validated using GetStationBoardWithDetails[rdoc-ref:Request:GetStationBoardWithDetails], returns a
|
|
90
|
+
# StationBoardWithDetails[rdoc-ref:ResponseTypes::StationBoardWithDetails] object.
|
|
91
|
+
def get_arr_board_with_details(params)
|
|
92
|
+
request(
|
|
93
|
+
"http://thalesgroup.com/RTTI/2015-05-14/ldb/GetArrBoardWithDetails",
|
|
94
|
+
Request::GetStationBoardWithDetails.new(params)
|
|
95
|
+
)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Retrieves a detailed station arrival + departures board.
|
|
99
|
+
#
|
|
100
|
+
# Parameters are validated using GetStationBoardWithDetails[rdoc-ref:Request:GetStationBoardWithDetails], returns a
|
|
101
|
+
# StationBoardWithDetails[rdoc-ref:ResponseTypes::StationBoardWithDetails] object.
|
|
102
|
+
def get_arr_dep_board_with_details(params)
|
|
103
|
+
request(
|
|
104
|
+
"http://thalesgroup.com/RTTI/2015-05-14/ldb/GetArrDepBoardWithDetails",
|
|
105
|
+
Request::GetStationBoardWithDetails.new(params)
|
|
106
|
+
)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Retrieves the next departures from one station to one or many others.
|
|
110
|
+
#
|
|
111
|
+
# Parameters are validated using GetDeparturesBoard[rdoc-ref:Request::GetDeparturesBoard], returns a
|
|
112
|
+
# DeparturesBoard[rdoc-ref:ResponseTypes::DeparturesBoard] object.
|
|
113
|
+
def get_next_departures(params)
|
|
114
|
+
request(
|
|
115
|
+
"http://thalesgroup.com/RTTI/2015-05-14/ldb/GetNextDepartures",
|
|
116
|
+
Request::GetDeparturesBoard.new(params)
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Retrieves the fastest departures from one station to one or many others.
|
|
121
|
+
#
|
|
122
|
+
# Parameters are validated using GetDeparturesBoard[rdoc-ref:Request::GetDeparturesBoard], returns a
|
|
123
|
+
# DeparturesBoard[rdoc-ref:ResponseTypes::DeparturesBoard] object.
|
|
124
|
+
def get_next_departures(params)
|
|
125
|
+
request(
|
|
126
|
+
"http://thalesgroup.com/RTTI/2015-05-14/ldb/GetFastestDepartures",
|
|
127
|
+
Request::GetDeparturesBoard.new(params)
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Retrieves detailed information about the next departures from one station to one or many others.
|
|
132
|
+
#
|
|
133
|
+
# Parameters are validated using GetDeparturesBoardWithDetails[rdoc-ref:Request::GetDeparturesBoardWithDetails],
|
|
134
|
+
# returns a DeparturesBoardWithDetails[rdoc-ref:ResponseTypes::DeparturesBoardWithDetails] object.
|
|
135
|
+
def get_next_departures_with_details(params)
|
|
136
|
+
request(
|
|
137
|
+
"http://thalesgroup.com/RTTI/2015-05-14/ldb/GetNextDeparturesWithDetails",
|
|
138
|
+
Request::GetDeparturesBoardWithDetails.new(params)
|
|
139
|
+
)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Retrieves detailed information about the fastest departures from one station to one or many others.
|
|
143
|
+
#
|
|
144
|
+
# Parameters are validated using GetDeparturesBoardWithDetails[rdoc-ref:Request::GetDeparturesBoardWithDetails],
|
|
145
|
+
# returns a DeparturesBoardWithDetails[rdoc-ref:ResponseTypes::DeparturesBoardWithDetails] object.
|
|
146
|
+
def get_fastest_departures_with_details(params)
|
|
147
|
+
request(
|
|
148
|
+
"http://thalesgroup.com/RTTI/2015-05-14/ldb/GetFastestDeparturesWithDetails",
|
|
149
|
+
Request::GetDeparturesBoardWithDetails.new(params)
|
|
150
|
+
)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Retrieves information about a specific service.
|
|
154
|
+
#
|
|
155
|
+
# Parameters are validated using GetServiceDetails[rdoc-ref:Request::GetServiceDetails], returns a
|
|
156
|
+
# ServiceDetails[rdoc-ref:ResponseTypes::ServiceDetails] object.
|
|
157
|
+
def get_service_details(params)
|
|
158
|
+
request(
|
|
159
|
+
"http://thalesgroup.com/RTTI/2012-01-13/ldb/GetServiceDetails",
|
|
160
|
+
Request::GetServiceDetails.new(params)
|
|
161
|
+
)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
alias_method :get_departure_board_with_details, :get_dep_board_with_details
|
|
165
|
+
alias_method :get_arrival_board_with_details, :get_arr_board_with_details
|
|
166
|
+
alias_method :get_arrival_departure_board_with_details, :get_arr_dep_board_with_details
|
|
167
|
+
|
|
168
|
+
private
|
|
169
|
+
|
|
170
|
+
def request(soap_action, request)
|
|
171
|
+
root_node = soap_action.split("/").last
|
|
172
|
+
soap_in = create_soap_request(request, root_node)
|
|
173
|
+
|
|
174
|
+
# Fire it off
|
|
175
|
+
soap_response = perform_soap_request(soap_action, soap_in)
|
|
176
|
+
|
|
177
|
+
# Parse
|
|
178
|
+
xml = Nokogiri::XML(soap_response)
|
|
179
|
+
xml.remove_namespaces!
|
|
180
|
+
|
|
181
|
+
response_node = xml.xpath("//#{root_node}Response").first
|
|
182
|
+
raise "Oh no" unless response_node
|
|
183
|
+
|
|
184
|
+
request.from_soap(response_node)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def create_soap_request(request, root_node)
|
|
188
|
+
Nokogiri::XML::Builder.new do |xml|
|
|
189
|
+
xml.Envelope(xmlns: "http://schemas.xmlsoap.org/soap/envelope/") {
|
|
190
|
+
xml.Header {
|
|
191
|
+
xml.AccessToken(xmlns: "http://thalesgroup.com/RTTI/2013-11-28/Token/types") {
|
|
192
|
+
xml.TokenValue @token
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
xml.Body {
|
|
196
|
+
xml.send("#{root_node}Request", xmlns: "http://thalesgroup.com/RTTI/2021-11-01/ldb/") {
|
|
197
|
+
request.to_soap(xml)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
end.to_xml
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def perform_soap_request(action, body)
|
|
205
|
+
uri = URI(SERVICE_URI)
|
|
206
|
+
|
|
207
|
+
conn = Faraday.new(
|
|
208
|
+
url: "#{uri.scheme}://#{uri.host}",
|
|
209
|
+
headers: {
|
|
210
|
+
'Content-Type': "text/xml",
|
|
211
|
+
'SOAPAction': action,
|
|
212
|
+
},
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
conn.post(uri.path, body).body
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
data/lib/ldbws/utils.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Utility functions for use within the library.
|
|
2
|
+
module Ldbws
|
|
3
|
+
module Utils # :nodoc: all
|
|
4
|
+
# Upcases the first letter of the passed string.
|
|
5
|
+
#
|
|
6
|
+
# === Parameters
|
|
7
|
+
# str:: the input string
|
|
8
|
+
def self.ucfirst(str)
|
|
9
|
+
str[0].upcase + str[1..]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Converts the passed string from CamelCase to snake_case
|
|
13
|
+
#
|
|
14
|
+
# === Parameters
|
|
15
|
+
# str:: the input string
|
|
16
|
+
# ucfirst:: [Boolean] whether or not to call [#ucfirst] as well
|
|
17
|
+
def self.to_snake_case(str, ucfirst = false)
|
|
18
|
+
output = str.to_s.gsub(/_([a-z])/) { $1.upcase }
|
|
19
|
+
|
|
20
|
+
ucfirst ? ucfirst(output) : output
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Deep converts a passed object as a hash.
|
|
24
|
+
#
|
|
25
|
+
# === Parameters
|
|
26
|
+
# value:: the value to convert
|
|
27
|
+
def self.deep_hashify_value(value)
|
|
28
|
+
if value.nil?
|
|
29
|
+
nil
|
|
30
|
+
elsif value.is_a?(Array)
|
|
31
|
+
value.map { |v| deep_hashify_value(v) }
|
|
32
|
+
elsif value.respond_to?(:to_h)
|
|
33
|
+
value.to_h
|
|
34
|
+
else
|
|
35
|
+
value
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Deep-serialises a hash to XML using Nokogiri
|
|
40
|
+
#
|
|
41
|
+
# === Parameters
|
|
42
|
+
# xml:: the instance of Nokogiri to build within
|
|
43
|
+
# hsh:: the hash to serialise
|
|
44
|
+
def self.deep_to_soap(xml, hsh)
|
|
45
|
+
hsh.each do |key, value|
|
|
46
|
+
key = to_snake_case(key)
|
|
47
|
+
|
|
48
|
+
if value.is_a?(Hash)
|
|
49
|
+
xml.send(key) { deep_to_soap(xml, value) }
|
|
50
|
+
elsif value.is_a?(Array)
|
|
51
|
+
xml.send(key) {
|
|
52
|
+
value.each { |v| deep_to_soap(xml, v) }
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
xml.send(key, value)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
data/lib/ldbws.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require "ldbws/service"
|
|
2
|
+
|
|
3
|
+
# Provides a Ruby abstraction around the UK’s Network Rail live departure board webservice (LDBWS). See
|
|
4
|
+
# Service[rdoc-ref:Ldbws::Service] for more information.
|
|
5
|
+
module Ldbws
|
|
6
|
+
# Helper method that returns an instance of [rdoc-ref:Service].
|
|
7
|
+
#
|
|
8
|
+
# === Parameters
|
|
9
|
+
# token:: the API token used to connect to the service
|
|
10
|
+
def self.service(token)
|
|
11
|
+
Service.new(token)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Ldbws::ResponseTypes::Base do
|
|
4
|
+
def parse_xml(xmlstr)
|
|
5
|
+
Nokogiri::XML::DocumentFragment.parse(xmlstr).children.first
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
context "simple parsing" do
|
|
9
|
+
class Test < Ldbws::ResponseTypes::Base
|
|
10
|
+
property :foo, String
|
|
11
|
+
collection :bar, "value", String
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "parses correctly when all values are present" do
|
|
15
|
+
xml = parse_xml("<test><foo>Content of foo</foo><bar><value>Bar 1</value><value>Bar 2</value></bar></test>")
|
|
16
|
+
example = Test.from_xml(xml)
|
|
17
|
+
|
|
18
|
+
expect(example.foo).to eq("Content of foo")
|
|
19
|
+
expect(example.bar.length).to eq(2)
|
|
20
|
+
expect(example.bar.join(",")).to eq("Bar 1,Bar 2")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "correctly handles empty collections" do
|
|
24
|
+
xml = parse_xml("<test><foo>Content of foo</foo><bar/></test>")
|
|
25
|
+
example = Test.from_xml(xml)
|
|
26
|
+
|
|
27
|
+
expect(example.foo).to eq("Content of foo")
|
|
28
|
+
expect(example.bar.length).to eq(0)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "correctly handles missing collections" do
|
|
32
|
+
xml = parse_xml("<test><foo>Content of foo</foo></test>")
|
|
33
|
+
example = Test.from_xml(xml)
|
|
34
|
+
|
|
35
|
+
expect(example.foo).to eq("Content of foo")
|
|
36
|
+
expect(example.bar.length).to eq(0)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "correctly handles empty nodes" do
|
|
40
|
+
xml = parse_xml("<test><foo/></test>")
|
|
41
|
+
example = Test.from_xml(xml)
|
|
42
|
+
|
|
43
|
+
expect(example.foo).to be_nil
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ldbws
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jon Pearse
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-04-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: dry-schema
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.13'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.13'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: faraday
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.7'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.7'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: nokogiri
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.14'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.14'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rdoc
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 6.5.0
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 6.5.0
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.11'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.11'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rufo
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.13.0
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.13.0
|
|
97
|
+
description:
|
|
98
|
+
email: hello@jonpearse.net
|
|
99
|
+
executables: []
|
|
100
|
+
extensions: []
|
|
101
|
+
extra_rdoc_files: []
|
|
102
|
+
files:
|
|
103
|
+
- ".editorconfig"
|
|
104
|
+
- ".envrc"
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- Gemfile
|
|
107
|
+
- Gemfile.lock
|
|
108
|
+
- LICENSE
|
|
109
|
+
- Makefile
|
|
110
|
+
- README.md
|
|
111
|
+
- doc/LICENSE.html
|
|
112
|
+
- doc/Ldbws.html
|
|
113
|
+
- doc/Ldbws/Request.html
|
|
114
|
+
- doc/Ldbws/Request/GetDeparturesBoard.html
|
|
115
|
+
- doc/Ldbws/Request/GetDeparturesBoardWithDetails.html
|
|
116
|
+
- doc/Ldbws/Request/GetServiceDetails.html
|
|
117
|
+
- doc/Ldbws/Request/GetStationBoard.html
|
|
118
|
+
- doc/Ldbws/Request/GetStationBoardWithDetails.html
|
|
119
|
+
- doc/Ldbws/ResponseTypes.html
|
|
120
|
+
- doc/Ldbws/ResponseTypes/BaseStationBoard.html
|
|
121
|
+
- doc/Ldbws/ResponseTypes/CallingPoint.html
|
|
122
|
+
- doc/Ldbws/ResponseTypes/Coach.html
|
|
123
|
+
- doc/Ldbws/ResponseTypes/DepartureItem.html
|
|
124
|
+
- doc/Ldbws/ResponseTypes/DepartureItemWithDetails.html
|
|
125
|
+
- doc/Ldbws/ResponseTypes/DeparturesBoard.html
|
|
126
|
+
- doc/Ldbws/ResponseTypes/DeparturesBoardWithDetails.html
|
|
127
|
+
- doc/Ldbws/ResponseTypes/Formation.html
|
|
128
|
+
- doc/Ldbws/ResponseTypes/LoadingCategory.html
|
|
129
|
+
- doc/Ldbws/ResponseTypes/Location.html
|
|
130
|
+
- doc/Ldbws/ResponseTypes/ServiceDetails.html
|
|
131
|
+
- doc/Ldbws/ResponseTypes/ServiceItem.html
|
|
132
|
+
- doc/Ldbws/ResponseTypes/ServiceItemWithCallingPoints.html
|
|
133
|
+
- doc/Ldbws/ResponseTypes/StationBoard.html
|
|
134
|
+
- doc/Ldbws/ResponseTypes/StationBoardWithDetails.html
|
|
135
|
+
- doc/Ldbws/ResponseTypes/ToiletAvailability.html
|
|
136
|
+
- doc/Ldbws/Service.html
|
|
137
|
+
- doc/README_md.html
|
|
138
|
+
- doc/created.rid
|
|
139
|
+
- doc/css/fonts.css
|
|
140
|
+
- doc/css/rdoc.css
|
|
141
|
+
- doc/fonts/Lato-Light.ttf
|
|
142
|
+
- doc/fonts/Lato-LightItalic.ttf
|
|
143
|
+
- doc/fonts/Lato-Regular.ttf
|
|
144
|
+
- doc/fonts/Lato-RegularItalic.ttf
|
|
145
|
+
- doc/fonts/SourceCodePro-Bold.ttf
|
|
146
|
+
- doc/fonts/SourceCodePro-Regular.ttf
|
|
147
|
+
- doc/images/add.png
|
|
148
|
+
- doc/images/arrow_up.png
|
|
149
|
+
- doc/images/brick.png
|
|
150
|
+
- doc/images/brick_link.png
|
|
151
|
+
- doc/images/bug.png
|
|
152
|
+
- doc/images/bullet_black.png
|
|
153
|
+
- doc/images/bullet_toggle_minus.png
|
|
154
|
+
- doc/images/bullet_toggle_plus.png
|
|
155
|
+
- doc/images/date.png
|
|
156
|
+
- doc/images/delete.png
|
|
157
|
+
- doc/images/find.png
|
|
158
|
+
- doc/images/loadingAnimation.gif
|
|
159
|
+
- doc/images/macFFBgHack.png
|
|
160
|
+
- doc/images/package.png
|
|
161
|
+
- doc/images/page_green.png
|
|
162
|
+
- doc/images/page_white_text.png
|
|
163
|
+
- doc/images/page_white_width.png
|
|
164
|
+
- doc/images/plugin.png
|
|
165
|
+
- doc/images/ruby.png
|
|
166
|
+
- doc/images/tag_blue.png
|
|
167
|
+
- doc/images/tag_green.png
|
|
168
|
+
- doc/images/transparent.png
|
|
169
|
+
- doc/images/wrench.png
|
|
170
|
+
- doc/images/wrench_orange.png
|
|
171
|
+
- doc/images/zoom.png
|
|
172
|
+
- doc/index.html
|
|
173
|
+
- doc/js/darkfish.js
|
|
174
|
+
- doc/js/navigation.js
|
|
175
|
+
- doc/js/navigation.js.gz
|
|
176
|
+
- doc/js/search.js
|
|
177
|
+
- doc/js/search_index.js
|
|
178
|
+
- doc/js/search_index.js.gz
|
|
179
|
+
- doc/js/searcher.js
|
|
180
|
+
- doc/js/searcher.js.gz
|
|
181
|
+
- doc/table_of_contents.html
|
|
182
|
+
- ldbws.gemspec
|
|
183
|
+
- lib/ldbws.rb
|
|
184
|
+
- lib/ldbws/request/base.rb
|
|
185
|
+
- lib/ldbws/request/get_departures_board.rb
|
|
186
|
+
- lib/ldbws/request/get_service_details.rb
|
|
187
|
+
- lib/ldbws/request/get_station_board.rb
|
|
188
|
+
- lib/ldbws/response_types/base.rb
|
|
189
|
+
- lib/ldbws/response_types/calling_point.rb
|
|
190
|
+
- lib/ldbws/response_types/departures_board.rb
|
|
191
|
+
- lib/ldbws/response_types/formation.rb
|
|
192
|
+
- lib/ldbws/response_types/parsing_functions.rb
|
|
193
|
+
- lib/ldbws/response_types/service_details.rb
|
|
194
|
+
- lib/ldbws/response_types/service_item.rb
|
|
195
|
+
- lib/ldbws/response_types/station_board.rb
|
|
196
|
+
- lib/ldbws/service.rb
|
|
197
|
+
- lib/ldbws/utils.rb
|
|
198
|
+
- lib/ldbws/version.rb
|
|
199
|
+
- spec/response_types/parsing_spec.rb
|
|
200
|
+
- spec/spec_helper.rb
|
|
201
|
+
homepage: https://github.com/jonpearse/ldbws-ruby
|
|
202
|
+
licenses:
|
|
203
|
+
- MIT
|
|
204
|
+
metadata: {}
|
|
205
|
+
post_install_message:
|
|
206
|
+
rdoc_options: []
|
|
207
|
+
require_paths:
|
|
208
|
+
- lib
|
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
|
+
requirements:
|
|
211
|
+
- - ">="
|
|
212
|
+
- !ruby/object:Gem::Version
|
|
213
|
+
version: '0'
|
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
|
+
requirements:
|
|
216
|
+
- - ">="
|
|
217
|
+
- !ruby/object:Gem::Version
|
|
218
|
+
version: '0'
|
|
219
|
+
requirements: []
|
|
220
|
+
rubygems_version: 3.4.6
|
|
221
|
+
signing_key:
|
|
222
|
+
specification_version: 4
|
|
223
|
+
summary: Interface to the Network Rail OpenLDBS web service
|
|
224
|
+
test_files: []
|