kosapi_client 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +22 -0
  3. data/README.md +89 -0
  4. data/kosapi_client.gemspec +38 -0
  5. data/lib/kosapi_client/api_client.rb +1 -0
  6. data/lib/kosapi_client/entity/division.rb +13 -0
  7. data/lib/kosapi_client/entity/exam.rb +3 -1
  8. data/lib/kosapi_client/entity/id.rb +0 -1
  9. data/lib/kosapi_client/entity/parallel.rb +0 -1
  10. data/lib/kosapi_client/entity.rb +1 -0
  11. data/lib/kosapi_client/oauth2_http_adapter.rb +9 -4
  12. data/lib/kosapi_client/request_builder.rb +0 -1
  13. data/lib/kosapi_client/resource/course_events_builder.rb +1 -1
  14. data/lib/kosapi_client/resource/courses_builder.rb +7 -0
  15. data/lib/kosapi_client/resource/exams_builder.rb +1 -1
  16. data/lib/kosapi_client/resource/parallels_builder.rb +0 -1
  17. data/lib/kosapi_client/version.rb +1 -1
  18. metadata +25 -99
  19. data/bin/console +0 -15
  20. data/bin/setup +0 -23
  21. data/spec/integration/course_events_spec.rb +0 -13
  22. data/spec/integration/courses_spec.rb +0 -28
  23. data/spec/integration/exams_spec.rb +0 -20
  24. data/spec/integration/parallels_spec.rb +0 -68
  25. data/spec/kosapi_client/api_client_spec.rb +0 -22
  26. data/spec/kosapi_client/configuration_spec.rb +0 -30
  27. data/spec/kosapi_client/entity/base_entity_spec.rb +0 -20
  28. data/spec/kosapi_client/entity/base_person_spec.rb +0 -19
  29. data/spec/kosapi_client/entity/boolean_spec.rb +0 -23
  30. data/spec/kosapi_client/entity/course_event_spec.rb +0 -30
  31. data/spec/kosapi_client/entity/data_mappings_spec.rb +0 -154
  32. data/spec/kosapi_client/entity/enum_spec.rb +0 -20
  33. data/spec/kosapi_client/entity/id_spec.rb +0 -13
  34. data/spec/kosapi_client/entity/link_spec.rb +0 -89
  35. data/spec/kosapi_client/entity/ml_string_spec.rb +0 -52
  36. data/spec/kosapi_client/entity/parallel_spec.rb +0 -18
  37. data/spec/kosapi_client/entity/result_page_spec.rb +0 -42
  38. data/spec/kosapi_client/entity/teacher_timetable_slot_spec.rb +0 -19
  39. data/spec/kosapi_client/entity/timetable_slot_spec.rb +0 -22
  40. data/spec/kosapi_client/hash_utils_spec.rb +0 -20
  41. data/spec/kosapi_client/http_client_spec.rb +0 -30
  42. data/spec/kosapi_client/kosapi_client_spec.rb +0 -57
  43. data/spec/kosapi_client/kosapi_response_spec.rb +0 -96
  44. data/spec/kosapi_client/oauth2_http_adapter_spec.rb +0 -25
  45. data/spec/kosapi_client/request_builder_delegator_spec.rb +0 -72
  46. data/spec/kosapi_client/request_builder_spec.rb +0 -80
  47. data/spec/kosapi_client/resource/courses_builder_spec.rb +0 -20
  48. data/spec/kosapi_client/resource/parallels_builder_spec.rb +0 -49
  49. data/spec/kosapi_client/resource_mapper_spec.rb +0 -33
  50. data/spec/kosapi_client/response_converter_spec.rb +0 -58
  51. data/spec/kosapi_client/response_links_spec.rb +0 -52
  52. data/spec/kosapi_client/response_preprocessor_spec.rb +0 -51
  53. data/spec/kosapi_client/url_builder_spec.rb +0 -44
  54. data/spec/spec_helper.rb +0 -40
  55. data/spec/support/client_helpers.rb +0 -11
  56. data/spec/support/helpers.rb +0 -7
  57. data/spec/support/shared_examples_for_fluent_api.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46750e332cf19232187a8a9e5c66b9fa128e246a
4
- data.tar.gz: 8d9a60a7399406d633ddb03bbadd51bc151b8372
3
+ metadata.gz: f487f91043e5b0941cceb0848db870e7c21d4f22
4
+ data.tar.gz: 2ebfc29ba496aed0cd7d103332bbfba30ea266f3
5
5
  SHA512:
6
- metadata.gz: 424aeb28f513261f67bdb98783d22fcf6dbc536f80f652386c9d666b5a9d437e49c92951d4bce03c71dd9ddeb8c518a2f1c23e760eba260a6fce530f1a3c03d7
7
- data.tar.gz: 8b55b7666492503cf2d382475b4dead2d3f4dc0a9e4aff95df143339e9c3e5613a582a6d77555c1c3d261406baa4880142e2d29ec68a410477902474335e23fe
6
+ metadata.gz: 9783ca343bf7b53992dc66c6fb7e9a355cd849f60f03142181d14c7cc6c5df2d75895889e162b2c2ab717824b5bb2f8808bc32d50d763fa60b302d17a58be59f
7
+ data.tar.gz: d313ba2e37f42be9ec83cb8fdc0bd59b5f32c08072383911662dc333bef366ab91a39dc62f3b6b7f4f9e9cd2a9fafa9316a2a427e986831ff8f896d3015ddc7f
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013-2017 Czech Technical University in Prague.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # KOSapi Client
2
+
3
+ [![Gem Version](https://img.shields.io/gem/v/kosapi_client.svg)](rubygems)
4
+ [![Build Status](http://img.shields.io/travis/cvut/kosapi_client.rb.svg)][travis]
5
+ [![Dependency Status](http://img.shields.io/gemnasium/cvut/kosapi_client.rb.svg)][gemnasium]
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/cvut/kosapi_client.rb.svg)][codeclimate]
7
+ [![Coverage Status](https://img.shields.io/coveralls/cvut/kosapi_client.rb.svg)][coveralls]
8
+ [![Inline docs](http://inch-ci.org/github/cvut/kosapi_client.rb.svg)](http://inch-ci.org/github/cvut/kosapi_client.rb)
9
+
10
+ [rubygems]: https://rubygems.org/gems/kosapi_client
11
+ [travis]: http://travis-ci.org/cvut/kosapi_client.rb
12
+ [gemnasium]: https://gemnasium.com/cvut/kosapi_client.rb
13
+ [codeclimate]: https://codeclimate.com/github/cvut/kosapi_client.rb
14
+ [coveralls]: https://coveralls.io/r/cvut/kosapi_client.rb
15
+
16
+ A simple Ruby client library for [KOSapi RESTful service](https://kosapi.fit.cvut.cz).
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ gem 'kosapi_client', github: 'cvut/kosapi_client.rb'
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ ## Basic usage
29
+
30
+ ```ruby
31
+ # Creates a new instance of client with OAuth2 credentials
32
+ client = KOSapiClient.new({ client_id: OAUTH_CLIENT_ID, client_secret: OAUTH_SECRET })
33
+
34
+ # Retrieves first page of all course events
35
+ course_events_page = client.course_events
36
+ course_events_page.each { |event| do_stuff_with_event(event) }
37
+
38
+ # Fetches page of parallels according to API parameters
39
+ parallels_page = client.parallels.offset(0).limit(50).query('course.department' => '18*')
40
+
41
+ # Finds all parallels related to parallel with id = 42
42
+ client.parallels.find(42).related
43
+ ```
44
+
45
+ ## Configuration
46
+
47
+ KOSapiClient can be created and configured in two ways.
48
+ The simple way is to call `KOSapiClient.new`, which returns an ApiClient instance.
49
+
50
+ ```ruby
51
+ client = KOSapiClient.new({ client_id: OAUTH_CLIENT_ID, client_secret: OAUTH_SECRET })
52
+ client.parallels.find(42)
53
+ ```
54
+
55
+ The other way is to configure client using `KOSapiClient.configure` and setting options inside a block.
56
+ In addition to returning the client instance from `configure`, the client is also stored in `KOSapiClient` singleton property and its methods can be accessed by calling them on `KOSapiClient` directly.
57
+ This approach is more suitable for configuring client inside an initializer.
58
+
59
+ ```ruby
60
+ KOSapiClient.configure do |c|
61
+ c.client_id = ENV['KOSAPI_OAUTH_CLIENT_ID']
62
+ c.client_secret = ENV['KOSAPI_OAUTH_CLIENT_SECRET']
63
+ end
64
+
65
+ KOSapiClient.parallels.find(42)
66
+ ```
67
+
68
+ ## Development
69
+
70
+ Run `bin/setup` script to setup dependencies and create `.env` file. You will need to obtain access to KOSapi.
71
+
72
+ ### OAuth Credentials
73
+
74
+ You will need a KOSapi OAuth credentials from the [Apps Manager](https://auth.fit.cvut.cz/manager/) to run integration specs.
75
+
76
+ OAuth credentials need to be exposed as environment variables `KOSAPI_OAUTH_CLIENT_ID` and `KOSAPI_OAUTH_CLIENT_SECRET`. If you put them into `.env` file, the test suite will load them for you automatically:
77
+
78
+ ```
79
+ KOSAPI_OAUTH_CLIENT_ID=xxx-xxxx-xxxx
80
+ KOSAPI_OAUTH_CLIENT_SECRET=yyyyyyyyy
81
+ ```
82
+
83
+ ### Contributing
84
+
85
+ Bug reports and pull requests are welcome on GitHub at [cvut/kosapi_client.rb](https://github.com/cvut/kosapi_client.rb). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
86
+
87
+ ## License
88
+
89
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/kosapi_client/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'kosapi_client'
6
+ spec.version = KOSapiClient::VERSION
7
+ spec.authors = ['Tibor Szolár']
8
+ spec.email = 'szolatib@fit.cvut.cz'
9
+ spec.description = 'REST client for KOSapi service'
10
+ spec.summary = 'Simple Ruby client library for accessing KOSapi service resources'
11
+ spec.homepage = 'https://github.com/cvut/kosapi_client.rb'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = Dir['lib/**/*', '*.gemspec', 'LICENSE', 'README*']
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.required_ruby_version = '>= 2.0.0'
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'rake'
21
+ spec.add_development_dependency 'rspec'
22
+ spec.add_development_dependency 'rspec-given'
23
+ spec.add_development_dependency 'dotenv'
24
+ spec.add_development_dependency 'vcr', '~> 3.0'
25
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
26
+ spec.add_development_dependency 'guard-rspec'
27
+ spec.add_development_dependency 'coveralls'
28
+ spec.add_development_dependency 'fuubar', '~> 2.2.0'
29
+ spec.add_development_dependency 'simplecov'
30
+
31
+ spec.add_runtime_dependency 'oauth2', '~> 1.4'
32
+ spec.add_runtime_dependency 'faraday', '~> 0.9'
33
+ spec.add_runtime_dependency 'corefines', '~> 1.6'
34
+ spec.add_runtime_dependency 'escape_utils', '~> 1.0' unless RUBY_PLATFORM == 'java' # used for uri_template
35
+ spec.add_runtime_dependency 'uri_template', '~> 0.7.0'
36
+ # Required for correct XML namespace handling (MultiXML, oauth2).
37
+ spec.add_runtime_dependency 'ox', '~> 2.1'
38
+ end
@@ -8,6 +8,7 @@ module KOSapiClient
8
8
  # accessible resources definition
9
9
  resource :courses
10
10
  resource :course_events
11
+ resource :divisions
11
12
  resource :parallels
12
13
  resource :exams
13
14
  resource :teachers
@@ -0,0 +1,13 @@
1
+ module KOSapiClient
2
+ module Entity
3
+ class Division < BaseEntity
4
+
5
+ map_data :abbrev, MLString
6
+ map_data :code
7
+ map_data :name, MLString
8
+ map_data :parent, Link
9
+ map_data :division_type, Enum
10
+
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ require 'date'
2
+
1
3
  module KOSapiClient
2
4
  module Entity
3
5
  class Exam < BaseEntity
@@ -18,7 +20,7 @@ module KOSapiClient
18
20
  map_data :start_date, Time
19
21
  map_data :substitutes, Enum
20
22
  map_data :superior, Link
21
- map_data :term_type, Enum
23
+ map_data :term_type, Enum
22
24
 
23
25
  end
24
26
  end
@@ -10,4 +10,3 @@ module KOSapiClient
10
10
  end
11
11
  end
12
12
  end
13
-
@@ -17,4 +17,3 @@ module KOSapiClient
17
17
  end
18
18
  end
19
19
  end
20
-
@@ -9,6 +9,7 @@ require 'kosapi_client/entity/base_entity'
9
9
  require 'kosapi_client/entity/result_page'
10
10
  require 'kosapi_client/entity/course_event'
11
11
  require 'kosapi_client/entity/course'
12
+ require 'kosapi_client/entity/division'
12
13
  require 'kosapi_client/entity/teacher_timetable_slot'
13
14
  require 'kosapi_client/entity/timetable_slot'
14
15
  require 'kosapi_client/entity/parallel'
@@ -3,8 +3,8 @@ require 'oauth2'
3
3
  module KOSapiClient
4
4
  class OAuth2HttpAdapter
5
5
 
6
- DEFAULT_AUTH_URL = 'https://auth.fit.cvut.cz/oauth/oauth/authorize'
7
- DEFAULT_TOKEN_URL = 'https://auth.fit.cvut.cz/oauth/oauth/token'
6
+ DEFAULT_AUTH_URL = 'https://auth.fit.cvut.cz/oauth/authorize'
7
+ DEFAULT_TOKEN_URL = 'https://auth.fit.cvut.cz/oauth/token'
8
8
 
9
9
  attr_reader :base_url
10
10
 
@@ -14,7 +14,13 @@ module KOSapiClient
14
14
  auth_url = opts[:auth_url] || DEFAULT_AUTH_URL
15
15
  token_url = opts[:token_url] || DEFAULT_TOKEN_URL
16
16
  MultiXml.parser = :ox # make sure to use Ox because of different namespace handling in other MultiXML parsers
17
- @client = OAuth2::Client.new(credentials[:client_id], credentials[:client_secret], site: base_url, authorize_url: auth_url, token_url: token_url)
17
+ @client = OAuth2::Client.new(
18
+ credentials[:client_id],
19
+ credentials[:client_secret],
20
+ auth_scheme: :basic_auth,
21
+ site: base_url,
22
+ authorize_url: auth_url,
23
+ token_url: token_url)
18
24
  end
19
25
 
20
26
  def send_request(verb, url, options = {})
@@ -33,4 +39,3 @@ module KOSapiClient
33
39
  end
34
40
  end
35
41
  end
36
-
@@ -56,4 +56,3 @@ module KOSapiClient
56
56
 
57
57
  end
58
58
  end
59
-
@@ -10,4 +10,4 @@ module KOSapiClient
10
10
 
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -7,6 +7,13 @@ module KOSapiClient
7
7
  self
8
8
  end
9
9
 
10
+ # Selects courses scheduled in the specified semester(s).
11
+ def sem(*semesters)
12
+ @url_builder.set_query_param(:sem, semesters.join(','))
13
+ self
14
+ end
15
+
16
+ alias semester sem
10
17
  end
11
18
  end
12
19
  end
@@ -10,4 +10,4 @@ module KOSapiClient
10
10
 
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -17,4 +17,3 @@ module KOSapiClient
17
17
  end
18
18
  end
19
19
  end
20
-
@@ -1,3 +1,3 @@
1
1
  module KOSapiClient
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.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.5.0
4
+ version: 0.6.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: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -168,16 +168,16 @@ dependencies:
168
168
  name: oauth2
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">="
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: '1.4'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ">="
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
180
+ version: '1.4'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: faraday
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -210,54 +210,53 @@ dependencies:
210
210
  name: escape_utils
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - ">="
213
+ - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '0'
215
+ version: '1.0'
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ">="
220
+ - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '0'
222
+ version: '1.0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: uri_template
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ">="
227
+ - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '0'
229
+ version: 0.7.0
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">="
234
+ - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '0'
236
+ version: 0.7.0
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: ox
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - ">="
241
+ - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: '0'
243
+ version: '2.1'
244
244
  type: :runtime
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
- - - ">="
248
+ - - "~>"
249
249
  - !ruby/object:Gem::Version
250
- version: '0'
250
+ version: '2.1'
251
251
  description: REST client for KOSapi service
252
252
  email: szolatib@fit.cvut.cz
253
- executables:
254
- - console
255
- - setup
253
+ executables: []
256
254
  extensions: []
257
255
  extra_rdoc_files: []
258
256
  files:
259
- - bin/console
260
- - bin/setup
257
+ - LICENSE
258
+ - README.md
259
+ - kosapi_client.gemspec
261
260
  - lib/kosapi_client.rb
262
261
  - lib/kosapi_client/api_client.rb
263
262
  - lib/kosapi_client/configuration.rb
@@ -269,6 +268,7 @@ files:
269
268
  - lib/kosapi_client/entity/course.rb
270
269
  - lib/kosapi_client/entity/course_event.rb
271
270
  - lib/kosapi_client/entity/data_mappings.rb
271
+ - lib/kosapi_client/entity/division.rb
272
272
  - lib/kosapi_client/entity/enum.rb
273
273
  - lib/kosapi_client/entity/exam.rb
274
274
  - lib/kosapi_client/entity/id.rb
@@ -300,43 +300,6 @@ files:
300
300
  - lib/kosapi_client/response_preprocessor.rb
301
301
  - lib/kosapi_client/url_builder.rb
302
302
  - lib/kosapi_client/version.rb
303
- - spec/integration/course_events_spec.rb
304
- - spec/integration/courses_spec.rb
305
- - spec/integration/exams_spec.rb
306
- - spec/integration/parallels_spec.rb
307
- - spec/kosapi_client/api_client_spec.rb
308
- - spec/kosapi_client/configuration_spec.rb
309
- - spec/kosapi_client/entity/base_entity_spec.rb
310
- - spec/kosapi_client/entity/base_person_spec.rb
311
- - spec/kosapi_client/entity/boolean_spec.rb
312
- - spec/kosapi_client/entity/course_event_spec.rb
313
- - spec/kosapi_client/entity/data_mappings_spec.rb
314
- - spec/kosapi_client/entity/enum_spec.rb
315
- - spec/kosapi_client/entity/id_spec.rb
316
- - spec/kosapi_client/entity/link_spec.rb
317
- - spec/kosapi_client/entity/ml_string_spec.rb
318
- - spec/kosapi_client/entity/parallel_spec.rb
319
- - spec/kosapi_client/entity/result_page_spec.rb
320
- - spec/kosapi_client/entity/teacher_timetable_slot_spec.rb
321
- - spec/kosapi_client/entity/timetable_slot_spec.rb
322
- - spec/kosapi_client/hash_utils_spec.rb
323
- - spec/kosapi_client/http_client_spec.rb
324
- - spec/kosapi_client/kosapi_client_spec.rb
325
- - spec/kosapi_client/kosapi_response_spec.rb
326
- - spec/kosapi_client/oauth2_http_adapter_spec.rb
327
- - spec/kosapi_client/request_builder_delegator_spec.rb
328
- - spec/kosapi_client/request_builder_spec.rb
329
- - spec/kosapi_client/resource/courses_builder_spec.rb
330
- - spec/kosapi_client/resource/parallels_builder_spec.rb
331
- - spec/kosapi_client/resource_mapper_spec.rb
332
- - spec/kosapi_client/response_converter_spec.rb
333
- - spec/kosapi_client/response_links_spec.rb
334
- - spec/kosapi_client/response_preprocessor_spec.rb
335
- - spec/kosapi_client/url_builder_spec.rb
336
- - spec/spec_helper.rb
337
- - spec/support/client_helpers.rb
338
- - spec/support/helpers.rb
339
- - spec/support/shared_examples_for_fluent_api.rb
340
303
  homepage: https://github.com/cvut/kosapi_client.rb
341
304
  licenses:
342
305
  - MIT
@@ -357,45 +320,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
357
320
  version: '0'
358
321
  requirements: []
359
322
  rubyforge_project:
360
- rubygems_version: 2.5.1
323
+ rubygems_version: 2.6.11
361
324
  signing_key:
362
325
  specification_version: 4
363
326
  summary: Simple Ruby client library for accessing KOSapi service resources
364
- test_files:
365
- - spec/integration/course_events_spec.rb
366
- - spec/integration/courses_spec.rb
367
- - spec/integration/exams_spec.rb
368
- - spec/integration/parallels_spec.rb
369
- - spec/kosapi_client/api_client_spec.rb
370
- - spec/kosapi_client/configuration_spec.rb
371
- - spec/kosapi_client/entity/base_entity_spec.rb
372
- - spec/kosapi_client/entity/base_person_spec.rb
373
- - spec/kosapi_client/entity/boolean_spec.rb
374
- - spec/kosapi_client/entity/course_event_spec.rb
375
- - spec/kosapi_client/entity/data_mappings_spec.rb
376
- - spec/kosapi_client/entity/enum_spec.rb
377
- - spec/kosapi_client/entity/id_spec.rb
378
- - spec/kosapi_client/entity/link_spec.rb
379
- - spec/kosapi_client/entity/ml_string_spec.rb
380
- - spec/kosapi_client/entity/parallel_spec.rb
381
- - spec/kosapi_client/entity/result_page_spec.rb
382
- - spec/kosapi_client/entity/teacher_timetable_slot_spec.rb
383
- - spec/kosapi_client/entity/timetable_slot_spec.rb
384
- - spec/kosapi_client/hash_utils_spec.rb
385
- - spec/kosapi_client/http_client_spec.rb
386
- - spec/kosapi_client/kosapi_client_spec.rb
387
- - spec/kosapi_client/kosapi_response_spec.rb
388
- - spec/kosapi_client/oauth2_http_adapter_spec.rb
389
- - spec/kosapi_client/request_builder_delegator_spec.rb
390
- - spec/kosapi_client/request_builder_spec.rb
391
- - spec/kosapi_client/resource/courses_builder_spec.rb
392
- - spec/kosapi_client/resource/parallels_builder_spec.rb
393
- - spec/kosapi_client/resource_mapper_spec.rb
394
- - spec/kosapi_client/response_converter_spec.rb
395
- - spec/kosapi_client/response_links_spec.rb
396
- - spec/kosapi_client/response_preprocessor_spec.rb
397
- - spec/kosapi_client/url_builder_spec.rb
398
- - spec/spec_helper.rb
399
- - spec/support/client_helpers.rb
400
- - spec/support/helpers.rb
401
- - spec/support/shared_examples_for_fluent_api.rb
327
+ test_files: []
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "dotenv"
5
- require "kosapi_client"
6
-
7
- Dotenv.load
8
-
9
- KOSapiClient.configure do |c|
10
- c.client_id = ENV['KOSAPI_OAUTH_CLIENT_ID']
11
- c.client_secret = ENV['KOSAPI_OAUTH_CLIENT_SECRET']
12
- end
13
-
14
- require "irb"
15
- IRB.start
data/bin/setup DELETED
@@ -1,23 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- echo "You will need OAuth credentials to access KOSapi and run integration tests."
6
- echo "Register new project at https://auth.fit.cvut.cz/manager/ with readonly access to KOSapi
7
- and enter client ID and secret for your default service account."
8
-
9
- echo -n "Client ID (KOSAPI_OAUTH_CLIENT_ID): "
10
- read client_id
11
- echo -n "Client secret (KOSAPI_OAUTH_CLIENT_SECRET): "
12
- read client_secret
13
-
14
- script_path=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
15
- env_file=$(realpath "$script_path/../.env")
16
- echo "Writing credentials to $env_file"
17
- cat << EOF > "$env_file"
18
- KOSAPI_OAUTH_CLIENT_ID=$client_id
19
- KOSAPI_OAUTH_CLIENT_SECRET=$client_secret
20
- EOF
21
-
22
- echo "Running bundle install"
23
- bundle install
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Course events resource', :vcr, :integration do
4
- subject(:client) { create_kosapi_client }
5
-
6
- it 'returns course events' do
7
- expect(client.course_events.offset(0).limit(10).count).to be 10
8
- end
9
-
10
- it 'returns course event attendees' do
11
- expect(client.course_events.find(220200484405).attendees.count).to be > 0
12
- end
13
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Courses resource', :vcr, :integration do
4
- let(:credentials) { { client_id: ENV['KOSAPI_OAUTH_CLIENT_ID'], client_secret: ENV['KOSAPI_OAUTH_CLIENT_SECRET'] } }
5
- subject(:client) { KOSapiClient.new(credentials) }
6
-
7
-
8
- it 'downloads courses data' do
9
- page = client.courses.offset(0).limit(15).query(department: '18*')
10
- expect(page.items.count).to eq 15
11
- end
12
-
13
- it 'provides courses data details' do
14
- page = client.courses.offset(20).query(department: '18*', completion: 'EXAM').detail
15
- expect(page.items.last.description).not_to be_nil
16
- end
17
-
18
- it 'parses entry title' do
19
- page = client.courses
20
- expect(page.items.first.title).not_to be_nil
21
- end
22
-
23
- it 'parses empty response' do
24
- page = client.courses.offset(1000000)
25
- expect(page.items).to eq []
26
- end
27
-
28
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Exams resource', :vcr, :integration do
4
-
5
- subject(:client) { create_kosapi_client }
6
-
7
- it 'fetches exams' do
8
- expect(client.exams.offset(0).limit(10).count).to be > 0
9
- end
10
-
11
- it 'fetches exam students' do
12
- expect(client.exams.find(193156727405).attendees.count).to be > 0
13
- end
14
-
15
- it 'allows multiple examiners' do
16
- exam = client.exams.find(613664749005)
17
- expect(exam.examiners.count).to be 2
18
- expect(exam.examiners.first.link_id).to eq 'zhoufjar'
19
- end
20
- end