kosapi_client 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bac1e9014ebfe31cb9d5be57bb61a75ee7301bb7
4
- data.tar.gz: 70a1e0029c8fca1bf04fcf84e87cddd7a843e046
2
+ SHA256:
3
+ metadata.gz: c4202a54f8cf1c9b61c4494b55f81e3c9e39fe9141a9026205a658033bc563b8
4
+ data.tar.gz: 37eeae9989bb2317061cd8892fd16c3dcc91010172b7572e5e2000c724c54560
5
5
  SHA512:
6
- metadata.gz: 1b468d6c89c156918444e21f755457ea5747ec0a0dbd4c3a215908d0a0e5a6cf08caad4b44063a0b415d302f679f5ca982d80106ca82309ca3e4f8cc6daaf46a
7
- data.tar.gz: 436b109ae00c71e174e22cf670005aad463287ee899cbbf82044955d0966bf979063ca3ceb00dcc0b13c44db97d47f71488ee43a94465d863d4f2f30bc55e590
6
+ metadata.gz: c3705daa6950381659b87db8bd6efa07e0999d1d914187e5b1756f78c430a71bdff03f546f6d4dbe4073e8797b699a1630f195d2d202361f2c976e1d960ea267
7
+ data.tar.gz: 3711b2272ceaff9864f3bc9dc77573dddd55cdfe3726a779caef4fb402d8e3be7c8ce069d8ecb5a3faed6f273928a0e156ff090203dfc17fb056ab84153a204f
@@ -1,7 +1,6 @@
1
1
  module KOSapiClient
2
2
  module Entity
3
3
  class Coursin < BaseEntity
4
- # TODO: Add capacity
5
4
 
6
5
  # XXX: This is really ugly hack! The problem is that "semester" is both
7
6
  # element and attribute, and they are mapped into single Ruby attribute.
@@ -13,6 +12,27 @@ module KOSapiClient
13
12
  map_data :instructors, [Link], element: :teacher, path: :instructors
14
13
  map_data :lecturers, [Link], element: :teacher, path: :lecturers
15
14
 
15
+ map_data :instance_capacity, Integer, reader: ->(source_hash, _key) do
16
+ retrieve_capacity('instance', source_hash)
17
+ end
18
+ map_data :tutorial_capacity, Integer, reader: ->(source_hash, _key) do
19
+ retrieve_capacity('tutorial', source_hash)
20
+ end
21
+
22
+ alias_method :capacity, :instance_capacity
23
+
24
+ class << self
25
+ private
26
+
27
+ def retrieve_capacity(type, source_hash)
28
+ capacity = source_hash[:capacity]
29
+ return unless capacity
30
+
31
+ capacity = [capacity] unless capacity.is_a? Array
32
+ element = capacity.find { |el| el[:of] == type }
33
+ element[:__content__] if element
34
+ end
35
+ end
16
36
  end
17
37
  end
18
38
  end
@@ -107,8 +107,11 @@ module KOSapiClient
107
107
  end
108
108
 
109
109
  def retrieve_value(source_hash, key, mapping_options)
110
- path = mapping_options[:path]
111
- if path
110
+ if (reader = mapping_options[:reader])
111
+ return reader.call(source_hash, key)
112
+ end
113
+
114
+ if (path = mapping_options[:path])
112
115
  parent_element = source_hash[path]
113
116
  else
114
117
  parent_element = source_hash
@@ -1,3 +1,3 @@
1
1
  module KOSapiClient
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kosapi_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tibor Szolár
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-18 00:00:00.000000000 Z
11
+ date: 2019-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -325,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
325
  version: '0'
326
326
  requirements: []
327
327
  rubyforge_project:
328
- rubygems_version: 2.6.11
328
+ rubygems_version: 2.7.3
329
329
  signing_key:
330
330
  specification_version: 4
331
331
  summary: Simple Ruby client library for accessing KOSapi service resources