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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c4202a54f8cf1c9b61c4494b55f81e3c9e39fe9141a9026205a658033bc563b8
|
4
|
+
data.tar.gz: 37eeae9989bb2317061cd8892fd16c3dcc91010172b7572e5e2000c724c54560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
111
|
-
|
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
|
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.
|
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:
|
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.
|
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
|