appolo 1.1.1 → 1.2.2
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 +4 -4
- data/lib/Appolo.rb +23 -15
- data/lib/Appolo/Models/main_model/student.rb +5 -1
- data/lib/Appolo/Models/result.rb +21 -0
- data/lib/Appolo/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a8dce19c2f19fd5335d2a1118e9c06a5f706132
|
4
|
+
data.tar.gz: e37dc28eaa44895a5104527f717fea6e32b128c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 170b6d32b06d178eaceb1e64aa8da24a4836c6ffce1862e59be3b6137a47ec8bc9ede5a1a47362701814c90be1abdf3f947102e6cf647b1dd5c3ad8933c6a467
|
7
|
+
data.tar.gz: cfb7f57bc1d21431c20e7df831726933c5cc78e3a8ac2a4a6364064c5c9516684d8c67db8a79ff2a3d42abf829413391024b2ebb19038bdcc33f64bb5f59e091
|
data/lib/Appolo.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative '../lib/Appolo/Models/main_model/classes'
|
|
6
6
|
require_relative '../lib/Appolo/Models/main_model/program'
|
7
7
|
require_relative '../lib/Appolo/Models/main_model/courses'
|
8
8
|
require_relative '../lib/Appolo/Models/main_model/lective_semester'
|
9
|
-
|
9
|
+
require_relative '../lib/Appolo/Models/result'
|
10
10
|
require 'json'
|
11
11
|
|
12
12
|
##
|
@@ -52,6 +52,11 @@ module Appolo
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
def self.build_result(result,error)
|
56
|
+
Result.new(result, error)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
55
60
|
public
|
56
61
|
|
57
62
|
##
|
@@ -69,7 +74,7 @@ module Appolo
|
|
69
74
|
end
|
70
75
|
$all_students
|
71
76
|
rescue => e
|
72
|
-
|
77
|
+
$all_students
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
@@ -89,7 +94,7 @@ module Appolo
|
|
89
94
|
end
|
90
95
|
$all_teachers
|
91
96
|
rescue => e
|
92
|
-
|
97
|
+
$all_teachers
|
93
98
|
end
|
94
99
|
end
|
95
100
|
|
@@ -109,7 +114,7 @@ module Appolo
|
|
109
114
|
end
|
110
115
|
$all_programs
|
111
116
|
rescue => e
|
112
|
-
|
117
|
+
$all_programs
|
113
118
|
end
|
114
119
|
end
|
115
120
|
|
@@ -129,7 +134,7 @@ module Appolo
|
|
129
134
|
end
|
130
135
|
$all_courses
|
131
136
|
rescue => e
|
132
|
-
|
137
|
+
$all_courses
|
133
138
|
end
|
134
139
|
end
|
135
140
|
|
@@ -149,7 +154,7 @@ module Appolo
|
|
149
154
|
end
|
150
155
|
$all_lective_sem
|
151
156
|
rescue => e
|
152
|
-
|
157
|
+
$all_lective_sem
|
153
158
|
end
|
154
159
|
end
|
155
160
|
|
@@ -169,7 +174,7 @@ module Appolo
|
|
169
174
|
end
|
170
175
|
$all_classes
|
171
176
|
rescue => e
|
172
|
-
|
177
|
+
$all_classes
|
173
178
|
end
|
174
179
|
end
|
175
180
|
|
@@ -177,12 +182,12 @@ module Appolo
|
|
177
182
|
# Return a single instance of Teacher based upon the +id+ given.
|
178
183
|
|
179
184
|
def self.get_teacher_by_id(id)
|
180
|
-
return $all_teachers[id] unless $all_teachers.count == 0
|
185
|
+
#return $all_teachers[id] unless $all_teachers.count == 0
|
181
186
|
begin
|
182
187
|
response = RestClient.get TEACHERS_API_LINK + id.to_s
|
183
188
|
Teacher.new(verify_response response)
|
184
189
|
rescue => e
|
185
|
-
|
190
|
+
e
|
186
191
|
end
|
187
192
|
end
|
188
193
|
|
@@ -191,12 +196,12 @@ module Appolo
|
|
191
196
|
# Return a single instance of Classes based upon the +id+ given.
|
192
197
|
|
193
198
|
def self.get_class_by_id(id)
|
194
|
-
return $all_classes[id] unless $all_classes.count == 0
|
199
|
+
#return $all_classes[id] unless $all_classes.count == 0
|
195
200
|
begin
|
196
201
|
response = RestClient.get CLASSES_API_LINK + id.to_s
|
197
202
|
Classes.new(verify_response response)
|
198
203
|
rescue => e
|
199
|
-
|
204
|
+
e
|
200
205
|
end
|
201
206
|
end
|
202
207
|
|
@@ -204,22 +209,25 @@ module Appolo
|
|
204
209
|
# Return a single instance of Student based upon the +id+ given.
|
205
210
|
|
206
211
|
def self.get_student_by_id(id)
|
207
|
-
return $all_students[id] unless $all_students.count == 0
|
212
|
+
#return $all_students[id] unless $all_students.count == 0
|
208
213
|
begin
|
209
214
|
response = RestClient.get STUDENTS_API_LINK + id.to_s
|
210
215
|
Student.new(verify_response response)
|
211
216
|
rescue => e
|
212
|
-
|
217
|
+
e
|
213
218
|
end
|
214
219
|
end
|
215
220
|
|
221
|
+
##
|
222
|
+
# Return a single instance of program based upon the +id+ given.
|
223
|
+
|
216
224
|
def self.get_program_by_id(id)
|
217
|
-
return $all_programs[id] unless $all_programs.count == 0
|
225
|
+
#return $all_programs[id] unless $all_programs.count == 0
|
218
226
|
begin
|
219
227
|
response = RestClient.get PROGRAMS_API_LINK + id.to_s
|
220
228
|
Program.new(verify_response response)
|
221
229
|
rescue => e
|
222
|
-
|
230
|
+
e
|
223
231
|
end
|
224
232
|
end
|
225
233
|
|
@@ -12,7 +12,11 @@ class Student < Element
|
|
12
12
|
attr_reader :number, :name, :academic_email, :github_username
|
13
13
|
attr_reader :avatar_url, :program, :students
|
14
14
|
|
15
|
-
def initialize(json_str)
|
15
|
+
def initialize(json_str = nil)
|
16
|
+
if json_str.nil?
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
16
20
|
json_data = Appolo.check_json_info json_str
|
17
21
|
|
18
22
|
super(json_data[ModelUtils::ID],
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Result
|
2
|
+
|
3
|
+
attr_reader :result, :error, :message
|
4
|
+
|
5
|
+
def initialize(result, error)
|
6
|
+
@result = result
|
7
|
+
@error = error
|
8
|
+
|
9
|
+
@message = @error.message unless @error.nil?
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_result
|
14
|
+
@result.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"Has Result: #{has_result} Has Error: #{@has_error}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/Appolo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appolo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Gabriel
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/Appolo/Models/main_model/student.rb
|
121
121
|
- lib/Appolo/Models/main_model/teacher.rb
|
122
122
|
- lib/Appolo/Models/model_utils.rb
|
123
|
+
- lib/Appolo/Models/result.rb
|
123
124
|
- lib/Appolo/Models/secondary/avatar_url.rb
|
124
125
|
- lib/Appolo/Models/secondary/lecture.rb
|
125
126
|
- lib/Appolo/Models/secondary/links.rb
|