gdsapi-v2-ruby 0.1.5 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ff2a9d3f5c0b12dda418eb41bc168c4f4513e44
4
- data.tar.gz: 4e5473b5c5a5981b4c4cb6c62f63d25305d3b6a2
3
+ metadata.gz: 0052cbbae7288138715bddeb75ad007bf8de07e6
4
+ data.tar.gz: 8b77e9103fa3276566c3e8bb6579702affa48620
5
5
  SHA512:
6
- metadata.gz: 4cde6b233ead8939f2ef22ace8f9e57774de549731051515bc4a8d2da076b645cdee4355ed577375d564cd253c5d147d101dc514932f74f9b52da72d9592cf79
7
- data.tar.gz: b5017a76bea5b7dcf8b715c169a118c58d8bb7e05990663ba70ad39c9165988ca163e351b1b1a41de2fbb86d8434e2c7b83e79bc4e4ad614be5420a9454544f9
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
- args = {
24
- id: country['id'],
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
- parsed_locations = grouped_locations.map do |mod, hash_locations|
23
- parsed_locations = hash_locations.map do |location|
24
- args = {
25
- id: location['id'],
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
- Hash[parsed_locations]
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
@@ -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 :type, Type.optional
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 :type, Type.optional
14
- attribute :sub_type, Type.optional
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
@@ -1,3 +1,3 @@
1
1
  module Gdsapi
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.1"
3
3
  end
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.5
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-19 00:00:00.000000000 Z
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: