defra_ruby_area 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/defra_ruby/area/area.rb +20 -0
- data/lib/defra_ruby/area/services/base_area_service.rb +11 -7
- data/lib/defra_ruby/area/version.rb +1 -1
- data/lib/defra_ruby/area.rb +1 -0
- data/spec/cassettes/public_face_area_invalid_blank.yml +4 -4
- data/spec/cassettes/public_face_area_invalid_coords.yml +4 -4
- data/spec/cassettes/public_face_area_valid.yml +7 -5
- data/spec/cassettes/water_management_area_invalid_blank.yml +4 -4
- data/spec/cassettes/water_management_area_invalid_coords.yml +4 -4
- data/spec/cassettes/water_management_area_valid.yml +7 -5
- data/spec/defra_ruby/area/area_spec.rb +29 -0
- data/spec/defra_ruby/area/response_spec.rb +3 -2
- data/spec/defra_ruby/area/services/public_face_area_service_spec.rb +1 -1
- data/spec/defra_ruby/area/services/water_management_area_service_spec.rb +1 -1
- data/spec/examples.txt +24 -0
- metadata +18 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c70a4243bf5fb3a988ebf2dee7ff7757758f605
|
4
|
+
data.tar.gz: 6730c29aedc4227152101469d4325c36024f9522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85798b2577feb39b9853390f0bf243f271c4d7657a45769d88a1a35fea8cd38202b2b7a2a2464ee66ddda00207edf659d21c0b3a9adfed6e56fbc0fe430873b4
|
7
|
+
data.tar.gz: bd9622f05d43ae590337b841d9e99b4e7e82ab327014ef2b6642fa87746daa085dbeb6b4640f82aac6f89d8c9245c15413a770c5a868a2d84c89e06f703ad9c3
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ response.error
|
|
40
40
|
If the call is successful (the query did not error and a match was found) then
|
41
41
|
|
42
42
|
- `successful?()` will be `true`
|
43
|
-
- `area` will contain the long name of the matching administrative boundary
|
43
|
+
- `area` will contain an instance of `DefraRuby::Area::Area`. It contains the code, short name and long name of the matching administrative boundary
|
44
44
|
- `error` will be `nil`
|
45
45
|
|
46
46
|
If the call is unsuccessful (the query errored or no match was found) then
|
@@ -49,9 +49,9 @@ If the call is unsuccessful (the query errored or no match was found) then
|
|
49
49
|
- `area` will be `nil`
|
50
50
|
- `error` will contain the error
|
51
51
|
|
52
|
-
If
|
52
|
+
If it's a runtime error, or an error when calling the WFS `error` will contain whatever error was raised.
|
53
53
|
|
54
|
-
If
|
54
|
+
If it's because no match was found `error` will contain an instance of `DefraRuby::Area::NoMatchError`.
|
55
55
|
|
56
56
|
### Environment Agency and Natural England Public Face Areas
|
57
57
|
|
@@ -62,7 +62,7 @@ easting = 408_602.61
|
|
62
62
|
northing = 257_535.31
|
63
63
|
response = DefraRuby::Area::PublicFaceAreaService.run(easting, northing)
|
64
64
|
|
65
|
-
puts response.area if response.successful? # West Midlands
|
65
|
+
puts response.area.long_name if response.successful? # West Midlands
|
66
66
|
```
|
67
67
|
|
68
68
|
### Water Management Areas
|
@@ -74,7 +74,7 @@ easting = 408_602.61
|
|
74
74
|
northing = 257_535.31
|
75
75
|
response = DefraRuby::Area::WaterManagementAreaService.run(easting, northing)
|
76
76
|
|
77
|
-
puts response.area if response.successful? # Staffordshire Warwickshire and West Midlands
|
77
|
+
puts response.area.long_name if response.successful? # Staffordshire Warwickshire and West Midlands
|
78
78
|
```
|
79
79
|
|
80
80
|
## Web Feature Services
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DefraRuby
|
4
|
+
module Area
|
5
|
+
class Area
|
6
|
+
attr_reader :code, :long_name, :short_name
|
7
|
+
|
8
|
+
def initialize(code, long_name, short_name)
|
9
|
+
@code = code
|
10
|
+
@long_name = long_name
|
11
|
+
@short_name = short_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def matched?
|
15
|
+
"#{@code}#{@long_name}#{@short_name}" != ""
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -32,7 +32,7 @@ module DefraRuby
|
|
32
32
|
timeout: DefraRuby::Area.configuration.timeout
|
33
33
|
)
|
34
34
|
area = parse_xml(response)
|
35
|
-
raise NoMatchError
|
35
|
+
raise NoMatchError unless area.matched?
|
36
36
|
|
37
37
|
{ area: area }
|
38
38
|
end
|
@@ -44,12 +44,16 @@ module DefraRuby
|
|
44
44
|
|
45
45
|
def parse_xml(response)
|
46
46
|
xml = Nokogiri::XML(response)
|
47
|
-
|
47
|
+
Area.new(
|
48
|
+
xml.xpath(response_xml_path(:code)).text,
|
49
|
+
xml.xpath(response_xml_path(:long_name)).text,
|
50
|
+
xml.xpath(response_xml_path(:short_name)).text
|
51
|
+
)
|
48
52
|
end
|
49
53
|
|
50
54
|
# XML path to the value we wish to extract in the WFS query response.
|
51
|
-
def response_xml_path
|
52
|
-
"//wfs:FeatureCollection/gml:featureMember/#{type_name}/ms
|
55
|
+
def response_xml_path(property)
|
56
|
+
"//wfs:FeatureCollection/gml:featureMember/#{type_name}/ms:#{property}"
|
53
57
|
end
|
54
58
|
|
55
59
|
# Domain where the WFS is hosted
|
@@ -126,10 +130,10 @@ module DefraRuby
|
|
126
130
|
# https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType
|
127
131
|
#
|
128
132
|
# In our case the administrative boundary features contain a number of
|
129
|
-
# properties, but we are only interested in +long_name+
|
130
|
-
#
|
133
|
+
# properties, but we are only interested in +code+, +long_name+ and
|
134
|
+
# +short_name+.
|
131
135
|
def property_name
|
132
|
-
"long_name"
|
136
|
+
"code,long_name,short_name"
|
133
137
|
end
|
134
138
|
|
135
139
|
# SRS stands for Spatial Reference System. It can also be known as a
|
data/lib/defra_ruby/area.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E,%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E,%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip, deflate
|
14
14
|
User-Agent:
|
15
|
-
- rest-client/2.0.2 (darwin18.
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Fri, 09 Aug 2019 17:08:26 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -45,5 +45,5 @@ http_interactions:
|
|
45
45
|
<ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
|
46
46
|
</ogc:ServiceExceptionReport>
|
47
47
|
http_version:
|
48
|
-
recorded_at:
|
48
|
+
recorded_at: Fri, 09 Aug 2019 17:08:26 GMT
|
49
49
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip, deflate
|
14
14
|
User-Agent:
|
15
|
-
- rest-client/2.0.2 (darwin18.
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Fri, 09 Aug 2019 17:08:26 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -48,5 +48,5 @@ http_interactions:
|
|
48
48
|
</gml:boundedBy>
|
49
49
|
</wfs:FeatureCollection>
|
50
50
|
http_version:
|
51
|
-
recorded_at:
|
51
|
+
recorded_at: Fri, 09 Aug 2019 17:08:26 GMT
|
52
52
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip, deflate
|
14
14
|
User-Agent:
|
15
|
-
- rest-client/2.0.2 (darwin18.
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,11 +23,11 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Fri, 09 Aug 2019 17:08:33 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
30
|
-
- '
|
30
|
+
- '1693'
|
31
31
|
Connection:
|
32
32
|
- keep-alive
|
33
33
|
Cache-Control:
|
@@ -50,11 +50,13 @@ http_interactions:
|
|
50
50
|
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23">
|
51
51
|
<ms:OBJECTID>23</ms:OBJECTID>
|
52
52
|
<ms:long_name>West Midlands</ms:long_name>
|
53
|
+
<ms:short_name>West Midlands</ms:short_name>
|
54
|
+
<ms:code>WMD</ms:code>
|
53
55
|
<ms:st_area_shape_>14543741870.84492</ms:st_area_shape_>
|
54
56
|
<ms:st_perimeter_shape_>1043376.795941756</ms:st_perimeter_shape_>
|
55
57
|
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
56
58
|
</gml:featureMember>
|
57
59
|
</wfs:FeatureCollection>
|
58
60
|
http_version:
|
59
|
-
recorded_at:
|
61
|
+
recorded_at: Fri, 09 Aug 2019 17:08:34 GMT
|
60
62
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E,%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E,%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip, deflate
|
14
14
|
User-Agent:
|
15
|
-
- rest-client/2.0.2 (darwin18.
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Fri, 09 Aug 2019 17:08:21 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -45,5 +45,5 @@ http_interactions:
|
|
45
45
|
<ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
|
46
46
|
</ogc:ServiceExceptionReport>
|
47
47
|
http_version:
|
48
|
-
recorded_at:
|
48
|
+
recorded_at: Fri, 09 Aug 2019 17:08:21 GMT
|
49
49
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip, deflate
|
14
14
|
User-Agent:
|
15
|
-
- rest-client/2.0.2 (darwin18.
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Fri, 09 Aug 2019 17:08:14 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -48,5 +48,5 @@ http_interactions:
|
|
48
48
|
</gml:boundedBy>
|
49
49
|
</wfs:FeatureCollection>
|
50
50
|
http_version:
|
51
|
-
recorded_at:
|
51
|
+
recorded_at: Fri, 09 Aug 2019 17:08:14 GMT
|
52
52
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=long_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip, deflate
|
14
14
|
User-Agent:
|
15
|
-
- rest-client/2.0.2 (darwin18.
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,11 +23,11 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Fri, 09 Aug 2019 17:08:14 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
30
|
-
- '
|
30
|
+
- '1530'
|
31
31
|
Connection:
|
32
32
|
- keep-alive
|
33
33
|
Cache-Control:
|
@@ -50,11 +50,13 @@ http_interactions:
|
|
50
50
|
<ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.15">
|
51
51
|
<ms:OBJECTID>15</ms:OBJECTID>
|
52
52
|
<ms:long_name>Staffordshire Warwickshire and West Midlands</ms:long_name>
|
53
|
+
<ms:short_name>Staffs Warks and West Mids</ms:short_name>
|
54
|
+
<ms:code>STWKWM</ms:code>
|
53
55
|
<ms:st_area_shape_>6460280400.1</ms:st_area_shape_>
|
54
56
|
<ms:st_perimeter_shape_>759189.708848595</ms:st_perimeter_shape_>
|
55
57
|
</ms:Administrative_Boundaries_Water_Management_Areas>
|
56
58
|
</gml:featureMember>
|
57
59
|
</wfs:FeatureCollection>
|
58
60
|
http_version:
|
59
|
-
recorded_at:
|
61
|
+
recorded_at: Fri, 09 Aug 2019 17:08:14 GMT
|
60
62
|
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module DefraRuby
|
6
|
+
module Area
|
7
|
+
RSpec.describe Area do
|
8
|
+
describe "#matched?" do
|
9
|
+
context "when no attributes are populated" do
|
10
|
+
let(:subject) { described_class.new(nil, nil, nil) }
|
11
|
+
|
12
|
+
it "returns false" do
|
13
|
+
expect(subject.matched?).to eq(false)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#matched?" do
|
19
|
+
context "when at least one attribute is populated" do
|
20
|
+
let(:subject) { described_class.new("foo", nil, nil) }
|
21
|
+
|
22
|
+
it "returns true" do
|
23
|
+
expect(subject.matched?).to eq(true)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -6,7 +6,7 @@ module DefraRuby
|
|
6
6
|
module Area
|
7
7
|
RSpec.describe Response do
|
8
8
|
subject(:response) { described_class.new(response_exe) }
|
9
|
-
let(:successful) { -> { { area: "Gallifrey" } } }
|
9
|
+
let(:successful) { -> { { area: Area.new("GFY", "Planet Gallifrey", "Gallifrey") } } }
|
10
10
|
let(:errored) { -> { raise "Boom!" } }
|
11
11
|
|
12
12
|
describe "#successful?" do
|
@@ -40,7 +40,8 @@ module DefraRuby
|
|
40
40
|
let(:response_exe) { successful }
|
41
41
|
|
42
42
|
it "returns an area" do
|
43
|
-
expect(response.area).to
|
43
|
+
expect(response.area).to be_instance_of(Area)
|
44
|
+
expect(response.area.short_name).to eq("Gallifrey")
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
@@ -18,7 +18,7 @@ module DefraRuby
|
|
18
18
|
response = described_class.run(easting, northing)
|
19
19
|
expect(response).to be_a(Response)
|
20
20
|
expect(response.successful?).to eq(true)
|
21
|
-
expect(response.area).to eq("West Midlands")
|
21
|
+
expect(response.area.long_name).to eq("West Midlands")
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -18,7 +18,7 @@ module DefraRuby
|
|
18
18
|
response = described_class.run(easting, northing)
|
19
19
|
expect(response).to be_a(Response)
|
20
20
|
expect(response.successful?).to eq(true)
|
21
|
-
expect(response.area).to eq("Staffordshire Warwickshire and West Midlands")
|
21
|
+
expect(response.area.long_name).to eq("Staffordshire Warwickshire and West Midlands")
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
data/spec/examples.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
-------------------------------------------------------------------------------- | ------ | --------------- |
|
3
|
+
./spec/defra_ruby/area/area_spec.rb[1:1:1:1] | passed | 0.00027 seconds |
|
4
|
+
./spec/defra_ruby/area/area_spec.rb[1:2:1:1] | passed | 0.00024 seconds |
|
5
|
+
./spec/defra_ruby/area/configuration_spec.rb[1:1] | passed | 0.00337 seconds |
|
6
|
+
./spec/defra_ruby/area/response_spec.rb[1:1:1:1] | passed | 0.00025 seconds |
|
7
|
+
./spec/defra_ruby/area/response_spec.rb[1:1:2:1] | passed | 0.00412 seconds |
|
8
|
+
./spec/defra_ruby/area/response_spec.rb[1:2:1:1] | passed | 0.00017 seconds |
|
9
|
+
./spec/defra_ruby/area/response_spec.rb[1:2:2:1] | passed | 0.00725 seconds |
|
10
|
+
./spec/defra_ruby/area/response_spec.rb[1:3:1:1] | passed | 0.0029 seconds |
|
11
|
+
./spec/defra_ruby/area/response_spec.rb[1:3:2:1] | passed | 0.00023 seconds |
|
12
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:1:1] | passed | 0.03685 seconds |
|
13
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:2:1:1] | passed | 0.06383 seconds |
|
14
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:2:2:1] | passed | 0.03793 seconds |
|
15
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:1:1] | passed | 0.06819 seconds |
|
16
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:2:1] | passed | 0.02928 seconds |
|
17
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:1:1] | passed | 0.03675 seconds |
|
18
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:2:1:1] | passed | 0.03188 seconds |
|
19
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:2:2:1] | passed | 0.03399 seconds |
|
20
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:1:1] | passed | 0.02733 seconds |
|
21
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:2:1] | passed | 0.04418 seconds |
|
22
|
+
./spec/defra_ruby/area_spec.rb[1:1:1] | passed | 0.00637 seconds |
|
23
|
+
./spec/defra_ruby/area_spec.rb[1:2:1:1] | passed | 0.00344 seconds |
|
24
|
+
./spec/defra_ruby/area_spec.rb[1:2:2:1] | passed | 0.00018 seconds |
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defra_ruby_area
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Defra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- bin/setup
|
194
194
|
- lib/defra_ruby.rb
|
195
195
|
- lib/defra_ruby/area.rb
|
196
|
+
- lib/defra_ruby/area/area.rb
|
196
197
|
- lib/defra_ruby/area/configuration.rb
|
197
198
|
- lib/defra_ruby/area/no_match_error.rb
|
198
199
|
- lib/defra_ruby/area/response.rb
|
@@ -206,11 +207,13 @@ files:
|
|
206
207
|
- spec/cassettes/water_management_area_invalid_blank.yml
|
207
208
|
- spec/cassettes/water_management_area_invalid_coords.yml
|
208
209
|
- spec/cassettes/water_management_area_valid.yml
|
210
|
+
- spec/defra_ruby/area/area_spec.rb
|
209
211
|
- spec/defra_ruby/area/configuration_spec.rb
|
210
212
|
- spec/defra_ruby/area/response_spec.rb
|
211
213
|
- spec/defra_ruby/area/services/public_face_area_service_spec.rb
|
212
214
|
- spec/defra_ruby/area/services/water_management_area_service_spec.rb
|
213
215
|
- spec/defra_ruby/area_spec.rb
|
216
|
+
- spec/examples.txt
|
214
217
|
- spec/spec_helper.rb
|
215
218
|
- spec/support/defra_ruby_area.rb
|
216
219
|
- spec/support/dotenv.rb
|
@@ -244,21 +247,23 @@ signing_key:
|
|
244
247
|
specification_version: 4
|
245
248
|
summary: Defra ruby on rails EA administrative area lookup
|
246
249
|
test_files:
|
247
|
-
- spec/
|
248
|
-
- spec/cassettes/public_face_area_invalid_coords.yml
|
249
|
-
- spec/cassettes/public_face_area_valid.yml
|
250
|
-
- spec/cassettes/water_management_area_invalid_blank.yml
|
251
|
-
- spec/cassettes/water_management_area_invalid_coords.yml
|
252
|
-
- spec/cassettes/water_management_area_valid.yml
|
250
|
+
- spec/spec_helper.rb
|
253
251
|
- spec/defra_ruby/area/configuration_spec.rb
|
252
|
+
- spec/defra_ruby/area/area_spec.rb
|
254
253
|
- spec/defra_ruby/area/response_spec.rb
|
255
|
-
- spec/defra_ruby/area/services/public_face_area_service_spec.rb
|
256
254
|
- spec/defra_ruby/area/services/water_management_area_service_spec.rb
|
255
|
+
- spec/defra_ruby/area/services/public_face_area_service_spec.rb
|
257
256
|
- spec/defra_ruby/area_spec.rb
|
258
|
-
- spec/
|
257
|
+
- spec/examples.txt
|
258
|
+
- spec/cassettes/water_management_area_invalid_coords.yml
|
259
|
+
- spec/cassettes/public_face_area_invalid_coords.yml
|
260
|
+
- spec/cassettes/water_management_area_invalid_blank.yml
|
261
|
+
- spec/cassettes/public_face_area_valid.yml
|
262
|
+
- spec/cassettes/water_management_area_valid.yml
|
263
|
+
- spec/cassettes/public_face_area_invalid_blank.yml
|
259
264
|
- spec/support/defra_ruby_area.rb
|
260
|
-
- spec/support/dotenv.rb
|
261
|
-
- spec/support/pry.rb
|
262
|
-
- spec/support/shared_examples/handle_request_errors.rb
|
263
265
|
- spec/support/simplecov.rb
|
264
266
|
- spec/support/vcr.rb
|
267
|
+
- spec/support/pry.rb
|
268
|
+
- spec/support/dotenv.rb
|
269
|
+
- spec/support/shared_examples/handle_request_errors.rb
|