gdsapi-v2-ruby 0.1.5 → 0.2.1
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 +4 -4
- data/lib/gdsapi.rb +2 -0
- data/lib/gdsapi/methods/get_countries.rb +3 -9
- data/lib/gdsapi/methods/get_locations.rb +8 -16
- data/lib/gdsapi/structs.rb +0 -2
- data/lib/gdsapi/structs/country.rb +1 -1
- data/lib/gdsapi/structs/location.rb +4 -2
- data/lib/gdsapi/structs/sub_type.rb +12 -0
- data/lib/gdsapi/structs/type.rb +12 -0
- data/lib/gdsapi/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0052cbbae7288138715bddeb75ad007bf8de07e6
|
4
|
+
data.tar.gz: 8b77e9103fa3276566c3e8bb6579702affa48620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef1a717d1bee8c09d686056c8ba6433bf96efec5196cd9f281d92c93e385fa7367b2ba5f8d8fd43ba8bca64a65317b144fe9b9b8bffd72df8f6efd946f389e68
|
7
|
+
data.tar.gz: 16636adb70824406126c67fe8517d189f383a0f3b1dd20359018f01b927aad3e4eb0e0c5289b0b4e1844282e3bb5e51f8e5c89a875cf559b96e47281fa1b2e84
|
data/lib/gdsapi.rb
CHANGED
@@ -12,6 +12,8 @@ require 'gdsapi/methods/get_points'
|
|
12
12
|
require 'gdsapi/structs/country'
|
13
13
|
require 'gdsapi/structs/location'
|
14
14
|
require 'gdsapi/structs/point'
|
15
|
+
require 'gdsapi/structs/type'
|
16
|
+
require 'gdsapi/structs/sub_type'
|
15
17
|
|
16
18
|
# This provides core package manifesto
|
17
19
|
## Possible error definitions are provided here
|
@@ -17,16 +17,10 @@ module Gdsapi
|
|
17
17
|
return [] if body.empty?
|
18
18
|
|
19
19
|
countries = body['countries']
|
20
|
-
types = body['types']
|
21
20
|
attributes = body['attributes']
|
22
|
-
countries.map do |country|
|
23
|
-
|
24
|
-
|
25
|
-
name: country['name'],
|
26
|
-
type: types.find { |type| type['id'] == country['type_id'] },
|
27
|
-
attributes: match_attributes(country['attributes'], attributes),
|
28
|
-
}
|
29
|
-
Gdsapi::Structs::Country.new args
|
21
|
+
countries.map! do |country|
|
22
|
+
country[:attributes] = match_attributes(country['attributes'], attributes)
|
23
|
+
Gdsapi::Structs::Country.new country.symbolize_keys
|
30
24
|
end
|
31
25
|
end
|
32
26
|
|
@@ -18,24 +18,16 @@ module Gdsapi
|
|
18
18
|
types = body['types']
|
19
19
|
attributes = body['attributes']
|
20
20
|
sub_types = body['subTypes']
|
21
|
-
grouped_locations = locations.group_by { |location| location['mod'] }
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
name: location['name'],
|
27
|
-
latitude: location['latitude'],
|
28
|
-
longitude: location['longitude'],
|
29
|
-
parent: location['parent'],
|
30
|
-
type: types.find { |type| type['id'] == location['type_id'] },
|
31
|
-
sub_type: sub_types.find { |sub_type| sub_type['id'] == location['sub_type_id'] },
|
32
|
-
attributes: match_attributes(location['attributes'], attributes),
|
33
|
-
}
|
34
|
-
Gdsapi::Structs::Location.new args
|
21
|
+
grouped_locations = locations.group_by { |location| modes[location['mod']] }
|
22
|
+
grouped_locations.each_value do |hash_locations|
|
23
|
+
hash_locations.map! do |location|
|
24
|
+
location[:attributes] = match_attributes(location['attributes'], attributes)
|
25
|
+
Gdsapi::Structs::Location.new location.symbolize_keys
|
35
26
|
end
|
36
|
-
[modes[mod], parsed_locations]
|
37
27
|
end
|
38
|
-
|
28
|
+
grouped_locations[:types] = types.map { |t| Gdsapi::Structs::Type.new(t.symbolize_keys) }
|
29
|
+
grouped_locations[:sub_types] = sub_types.map { |st| Gdsapi::Structs::SubType.new(st.symbolize_keys) }
|
30
|
+
grouped_locations
|
39
31
|
end
|
40
32
|
|
41
33
|
def path
|
data/lib/gdsapi/structs.rb
CHANGED
@@ -10,8 +10,6 @@ module Gdsapi
|
|
10
10
|
name: Structs::Coercible::String,
|
11
11
|
values: Structs::Array.member(Structs::Coercible::String)))
|
12
12
|
|
13
|
-
Type = Structs::Hash.symbolized(id: Structs::Coercible::Int, name: Structs::Coercible::String)
|
14
|
-
|
15
13
|
Parent = Structs::Hash.symbolized(id: Structs::Coercible::Int)
|
16
14
|
end
|
17
15
|
end
|
@@ -7,7 +7,7 @@ module Gdsapi
|
|
7
7
|
class Country < ::Dry::Struct
|
8
8
|
attribute :id, Structs::Coercible::Int
|
9
9
|
attribute :name, Structs::Coercible::String
|
10
|
-
attribute :
|
10
|
+
attribute :type_id, Structs::Coercible::Int
|
11
11
|
attribute :attributes, Attributes.optional
|
12
12
|
|
13
13
|
def attribute_by_id(id)
|
@@ -5,13 +5,15 @@
|
|
5
5
|
module Gdsapi
|
6
6
|
module Structs
|
7
7
|
class Location < ::Dry::Struct
|
8
|
+
constructor_type(:schema)
|
9
|
+
|
8
10
|
attribute :id, Structs::Coercible::Int
|
9
11
|
attribute :name, Structs::Coercible::String
|
10
12
|
attribute :latitude, Structs::Coercible::Float
|
11
13
|
attribute :longitude, Structs::Coercible::Float
|
12
14
|
attribute :parent, Parent.optional
|
13
|
-
attribute :
|
14
|
-
attribute :
|
15
|
+
attribute :type_id, Structs::Coercible::Int
|
16
|
+
attribute :sub_type_id, Structs::Coercible::Int.optional
|
15
17
|
attribute :attributes, Attributes.optional
|
16
18
|
|
17
19
|
def attribute_by_id(id)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## SubType struct
|
2
|
+
## Used when syncing geodata with GDS
|
3
|
+
## See [[Gdsapi::Methods::GetPoints]] for details
|
4
|
+
## Also see [http://demo.gillbus.com/v2/doc.html#получение-географии-получение-списка-остановок-get] for schema definition
|
5
|
+
module Gdsapi
|
6
|
+
module Structs
|
7
|
+
class SubType < ::Dry::Struct
|
8
|
+
attribute :id, Structs::Coercible::Int
|
9
|
+
attribute :name, Structs::Coercible::String
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## Type struct
|
2
|
+
## Used when syncing geodata with GDS
|
3
|
+
## See [[Gdsapi::Methods::GetPoints]] for details
|
4
|
+
## Also see [http://demo.gillbus.com/v2/doc.html#получение-географии-получение-списка-остановок-get] for schema definition
|
5
|
+
module Gdsapi
|
6
|
+
module Structs
|
7
|
+
class Type < ::Dry::Struct
|
8
|
+
attribute :id, Structs::Coercible::Int
|
9
|
+
attribute :name, Structs::Coercible::String
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/gdsapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gdsapi-v2-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Yurchenkov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -180,6 +180,8 @@ files:
|
|
180
180
|
- lib/gdsapi/structs/country.rb
|
181
181
|
- lib/gdsapi/structs/location.rb
|
182
182
|
- lib/gdsapi/structs/point.rb
|
183
|
+
- lib/gdsapi/structs/sub_type.rb
|
184
|
+
- lib/gdsapi/structs/type.rb
|
183
185
|
- lib/gdsapi/version.rb
|
184
186
|
homepage: https://busfor.ru
|
185
187
|
licenses:
|