nusmods 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -3
- data/README.md +33 -15
- data/lib/nusmods.rb +1 -14
- data/lib/nusmods/client.rb +4 -10
- data/lib/nusmods/endpoints.rb +1 -1
- data/lib/nusmods/version.rb +1 -1
- data/nusmods.gemspec +1 -3
- metadata +9 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ac41ee74ad59262404aaf3f1759626684bddcdd
|
4
|
+
data.tar.gz: 6ca47f3f3f368a8ed672a6888679350eca36712a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7d05f743eb270e61bbc24e48ee67d07d6982131597713b265c5021faf2d909e315a4c67862ea6126e61655e86457abd4b33b9386897328ef5f5e06f4413b12
|
7
|
+
data.tar.gz: d0179c45e3f8c548a681d80bd0e2fe4517c833f2374ae40b50cf4fd619178f55603635af3549df61eb9f203b27c217a92466058f53cd8601e0864c9752bc0075
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
A ruby wrapper for the NUSModsAPI
|
1
|
+
A ruby wrapper for the NUSModsAPI (v0.0.3)
|
2
2
|
---
|
3
3
|
|
4
4
|
### Disclaimer
|
5
5
|
|
6
6
|
This gem is not maintained by the creator of NUSMods.
|
7
7
|
|
8
|
-
NUSModsAPI repository: https://github.com/
|
8
|
+
NUSModsAPI repository: [https://github.com/nusmodifications/nusmods-api](https://github.com/nusmodifications/nusmods-api)
|
9
9
|
|
10
10
|
---
|
11
11
|
|
@@ -36,61 +36,79 @@ client = NUSMods::Client.new # => #<NUSMods::Client:0x007f85928efb10 @base_url=
|
|
36
36
|
All methods are set to retrieve the current AY's records if you do not provide
|
37
37
|
any parameters for year or semester.
|
38
38
|
|
39
|
+
Every response is either an `Array` or a `Hash` object.
|
40
|
+
|
41
|
+
Example:
|
42
|
+
```ruby
|
43
|
+
client.get_module_details("MA1101R").keys
|
44
|
+
=> ["ModuleCode", "ModuleTitle", "Department", "ModuleDescription",
|
45
|
+
"ModuleCredit", "Workload", "Prerequisite", "Preclusion", "ExamDate", "Types",
|
46
|
+
"Lecturers", "IVLE", "Timetable", "CorsBiddingStats", "LecturePeriods",
|
47
|
+
"TutorialPeriods"]
|
48
|
+
```
|
49
|
+
|
39
50
|
#### Faculty Departments
|
40
51
|
|
41
|
-
Retrieves the list of faculty departments/sub-departments
|
52
|
+
Retrieves the list of faculty departments/sub-departments in a `Hash`.
|
42
53
|
|
43
|
-
```
|
54
|
+
```ruby
|
44
55
|
client.get_faculty_departments(year = 2014, semester = 1)
|
56
|
+
|
57
|
+
# => {"Arts & Social Sciences"=>["Centre For Language Studies", "Chinese Studies", "Communications And New Media", "Dean's Office (Arts & Social Sc.)", ...
|
45
58
|
```
|
46
59
|
|
47
60
|
#### Lesson Types
|
48
61
|
|
49
|
-
Retrieves a list of the types of lessons
|
62
|
+
Retrieves a list of the types of lessons in a `Hash`. This API call is not tied to a
|
50
63
|
specific AY or semester.
|
51
64
|
|
52
65
|
```rb
|
53
66
|
client.get_lesson_types
|
67
|
+
# => {"DESIGN LECTURE"=>"Tutorial", "LABORATORY"=>"Tutorial", "LECTURE"=>"Lecture" ...
|
54
68
|
```
|
55
69
|
|
56
70
|
#### Module codes
|
57
71
|
|
58
|
-
Retrieves a list of all module codes offered in the semester
|
72
|
+
Retrieves a list of all module codes offered in the semester in an `Array`.
|
59
73
|
|
60
|
-
```
|
74
|
+
```ruby
|
61
75
|
client.get_module_codes(year = 2014, semester = 1)
|
76
|
+
# => ["ACC1002", "ACC1002X", "ACC2002", "ACC3601", "ACC3602", ...
|
62
77
|
```
|
63
78
|
|
64
79
|
#### Module codes with names
|
65
80
|
|
66
|
-
Retrieves a list of all module codes accompanied by their names
|
81
|
+
Retrieves a list of all module codes accompanied by their names in an `Array`.
|
67
82
|
|
68
|
-
```
|
83
|
+
```ruby
|
69
84
|
client.get_module_codes_with_names(year = 2014, semester = 1)
|
85
|
+
# => {"ACC1002"=>"Financial Accounting", "ACC1002X"=>"Financial Accounting", "ACC2002"=>"Managerial Accounting" ...
|
70
86
|
```
|
71
87
|
|
72
88
|
#### Module details
|
73
89
|
|
74
|
-
Retrieves all information about a specific module
|
90
|
+
Retrieves all information about a specific module in a `Hash`
|
75
91
|
|
76
|
-
```
|
92
|
+
```ruby
|
77
93
|
client.get_module_details("MA1101R", year = 2014, semester = 1)
|
94
|
+
# => {"ModuleCode"=>"MA1101R", "ModuleTitle"=>"Linear Algebra I", "Department"=>"Mathematics", ...
|
78
95
|
```
|
79
96
|
|
80
97
|
#### All modules
|
81
98
|
|
82
|
-
Retrieves all information about every module
|
99
|
+
Retrieves all information about every module in an `Array`.
|
83
100
|
Note: This retrieves a large dataset, so it will take a while. It is highly
|
84
101
|
suggested that you download a copy from the API directly and store it locally.
|
85
102
|
|
86
|
-
```
|
103
|
+
```ruby
|
87
104
|
client.get_modules(year = 2014, semester = 1)
|
105
|
+
# => [{ "ModuleCredit" => "4", "ModmavenTree" => { "name" => "ACC1002", "children" => [] }, "LockedModules" => [ "FIN3113", "ACC2002", "IS5116", "FIN2004", ...
|
88
106
|
```
|
89
107
|
|
90
|
-
For more details, see [
|
108
|
+
For exact response examples or more details, see [NUSMods API's README.][1]
|
91
109
|
|
92
110
|
|
93
|
-
[1]: https://github.com/
|
111
|
+
[1]: https://github.com/nusmodifications/nusmods-api/blob/master/README.md
|
94
112
|
|
95
113
|
|
96
114
|
### Tests:
|
data/lib/nusmods.rb
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
1
|
require 'nusmods/client'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
module NUSMods
|
8
|
-
class << self
|
9
|
-
|
10
|
-
## configure default
|
11
|
-
def configure
|
12
|
-
yield self
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
3
|
+
File.expand_path(File.dirname(__FILE__))
|
data/lib/nusmods/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
1
3
|
require 'nusmods/endpoints'
|
2
|
-
require 'active_support/notifications'
|
3
4
|
|
4
5
|
module NUSMods
|
5
6
|
class Client
|
@@ -12,17 +13,10 @@ module NUSMods
|
|
12
13
|
|
13
14
|
private
|
14
15
|
|
15
|
-
|
16
|
-
Faraday.new(url: @base_url) do |f|
|
17
|
-
f.response :json, :content_type => /\bjson$/
|
18
|
-
f.use :instrumentation
|
19
|
-
f.adapter Faraday.default_adapter
|
20
|
-
end
|
21
|
-
end
|
16
|
+
attr_accessor :conn
|
22
17
|
|
23
18
|
def get(url)
|
24
|
-
|
25
|
-
response.body
|
19
|
+
JSON.parse(HTTParty.get(@base_url + url).body)
|
26
20
|
end
|
27
21
|
|
28
22
|
# Converts a provided year to the API requirements
|
data/lib/nusmods/endpoints.rb
CHANGED
data/lib/nusmods/version.rb
CHANGED
data/nusmods.gemspec
CHANGED
metadata
CHANGED
@@ -1,55 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nusmods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jingwen Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: faraday_middleware
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: activesupport
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
24
|
+
- - ">="
|
53
25
|
- !ruby/object:Gem::Version
|
54
26
|
version: '0'
|
55
27
|
description: A ruby wrapper interface for NUSModsAPI.
|
@@ -58,7 +30,7 @@ executables: []
|
|
58
30
|
extensions: []
|
59
31
|
extra_rdoc_files: []
|
60
32
|
files:
|
61
|
-
- .rspec
|
33
|
+
- ".rspec"
|
62
34
|
- Gemfile
|
63
35
|
- README.md
|
64
36
|
- lib/nusmods.rb
|
@@ -78,17 +50,17 @@ require_paths:
|
|
78
50
|
- lib
|
79
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
52
|
requirements:
|
81
|
-
- -
|
53
|
+
- - ">="
|
82
54
|
- !ruby/object:Gem::Version
|
83
55
|
version: '0'
|
84
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
57
|
requirements:
|
86
|
-
- -
|
58
|
+
- - ">="
|
87
59
|
- !ruby/object:Gem::Version
|
88
60
|
version: '0'
|
89
61
|
requirements: []
|
90
62
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.2.2
|
92
64
|
signing_key:
|
93
65
|
specification_version: 4
|
94
66
|
summary: A ruby wrapper interface for NUSModsAPI.
|