appolo 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appolo.gemspec +7 -6
- data/README.md +1 -0
- data/lib/Appolo/Models/element.rb +18 -0
- data/lib/Appolo/Models/main_model/classes.rb +15 -12
- data/lib/Appolo/Models/main_model/courses.rb +19 -16
- data/lib/Appolo/Models/main_model/lective_semester.rb +12 -15
- data/lib/Appolo/Models/main_model/program.rb +35 -13
- data/lib/Appolo/Models/main_model/student.rb +15 -12
- data/lib/Appolo/Models/main_model/teacher.rb +16 -18
- data/lib/Appolo/Models/model_utils.rb +1 -1
- data/lib/Appolo/Models/{lecture.rb → secondary/lecture.rb} +1 -1
- data/lib/Appolo/Models/secondary/links.rb +28 -0
- data/lib/Appolo/Models/secondary/news_item.rb +17 -0
- data/lib/Appolo/Models/{resource.rb → secondary/resource.rb} +1 -1
- data/lib/Appolo/version.rb +1 -1
- data/lib/Appolo.rb +17 -7
- metadata +31 -16
- data/lib/Appolo/Models/links.rb +0 -28
- /data/lib/Appolo/Models/{avatar_url.rb → secondary/avatar_url.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c6bd7fbebc71c62bf43de47bedd14eea09be9ba
|
4
|
+
data.tar.gz: dc11a28359fcfeb8e60b179d85b6b4c4ce601014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22989f4723378dc4426fdb03d88e9e873a3d62e46dac472d25187e576ff7aa501cebc48277a1adad66a9ca81c540c2434e0d8275d4fce3e69e34cea6d5d9a6bc
|
7
|
+
data.tar.gz: ac5e0ba1a806812e55609607ec310489b114ae3a437d8fe66c58c2900c1cca0a6dfc86f7762b2856d1567d88bc5b84a17d7117db0cad0994e54d919c3b5e06e3
|
data/Appolo.gemspec
CHANGED
@@ -10,7 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["pedrogabriel@protonmail.ch"]
|
11
11
|
|
12
12
|
spec.summary = %q{Provides easy access to Thoth web API}
|
13
|
-
spec.description = %q{Ruby gem that provides quick and easy access to the web api of Thoth WebApp
|
13
|
+
spec.description = %q{Ruby gem that provides quick and easy access to the web api of Thoth WebApp -
|
14
|
+
https://adeetc.thothapp.com/}
|
14
15
|
spec.homepage = "https://github.com/CaptainGabriel/AppoloGem"
|
15
16
|
spec.license = "MIT"
|
16
17
|
|
@@ -19,12 +20,12 @@ Gem::Specification.new do |spec|
|
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
21
|
spec.require_paths = ["lib"]
|
21
22
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
25
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
|
28
|
+
spec.add_development_dependency 'json', '~> 1.8', '>= 1.8.3'
|
28
29
|
|
29
30
|
|
30
31
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Appolo
|
2
2
|
[![Code Climate](https://codeclimate.com/github/CaptainGabriel/AppoloGem/badges/gpa.svg)](https://codeclimate.com/github/CaptainGabriel/AppoloGem)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/appolo.svg)](http://badge.fury.io/rb/appolo)
|
3
4
|
|
4
5
|
Ruby gem that provides quick and easy access to the web api of [Thoth WebApp](https://adeetc.thothapp.com)
|
5
6
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'secondary/links'
|
2
|
+
|
3
|
+
##
|
4
|
+
# This class represent the top abstraction of an element.
|
5
|
+
# Specifies common behavior.
|
6
|
+
class Element
|
7
|
+
|
8
|
+
attr_reader :id, :short_name, :links
|
9
|
+
|
10
|
+
##
|
11
|
+
# initializes the common behavior this class specifies.
|
12
|
+
def initialize (id, s_name, links, type_for_links)
|
13
|
+
@id = id
|
14
|
+
@short_name = s_name
|
15
|
+
@links = Links.new(links, type_for_links)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'rest-client'
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
5
|
-
require_relative '
|
6
|
-
require_relative '
|
7
|
-
require_relative '
|
3
|
+
require_relative '../model_utils'
|
4
|
+
require_relative '../secondary/links'
|
5
|
+
require_relative '../secondary/avatar_url'
|
6
|
+
require_relative '../secondary/lecture'
|
7
|
+
require_relative '../secondary/resource'
|
8
8
|
require_relative 'program'
|
9
|
+
require_relative '../element'
|
9
10
|
|
10
|
-
class Classes
|
11
|
+
class Classes < Element
|
11
12
|
|
12
|
-
|
13
|
+
@@type_of_links = 'classes'
|
13
14
|
|
14
|
-
attr_reader :
|
15
|
+
attr_reader :full_name, :course_unit_short_name, :main_teacher, :main_teacher_short_name
|
15
16
|
attr_reader :course_unit_id, :lective_semester_id, :main_teacher_id, :max_group_size
|
16
|
-
attr_reader :main_teacher, :links
|
17
17
|
|
18
18
|
##
|
19
19
|
# Initiate an instance of Classes based upon +json_info*
|
@@ -21,16 +21,20 @@ class Classes
|
|
21
21
|
def initialize(json_info)
|
22
22
|
json_data = ModelUtils::check_json_info json_info
|
23
23
|
|
24
|
-
|
24
|
+
super(json_data[ModelUtils::ID],
|
25
|
+
json_data[ModelUtils::CLASS_NAME],
|
26
|
+
json_data[ModelUtils::LINKS],
|
27
|
+
@@type_of_links)
|
28
|
+
|
25
29
|
@full_name = json_data[ModelUtils::FULL_NAME]
|
26
30
|
@course_unit_short_name = json_data[ModelUtils::COURSE_UNIT_SHORT_NAME]
|
27
|
-
@class_name = json_data[ModelUtils::CLASS_NAME]
|
28
31
|
@main_teacher_short_name = json_data[ModelUtils::MAIN_TEACHER_SHORT_NAME]
|
29
32
|
@course_unit_id = json_data[ModelUtils::COURSE_UNIT_ID]
|
30
33
|
@lective_semester_id = json_data[ModelUtils::LECTIVE_SEMESTER_ID]
|
31
34
|
@main_teacher_id = json_data[ModelUtils::MAIN_TEACHER_ID]
|
32
35
|
@max_group_size = json_data[ModelUtils::MAX_GROUP_SIZE]
|
33
36
|
|
37
|
+
#TODO aceder ao Links do super e retirar de la´ o link respectivo
|
34
38
|
teacher_self_link = json_data[ModelUtils::LINKS]
|
35
39
|
teacher_self_link = teacher_self_link[ModelUtils::MAIN_TEACHER]
|
36
40
|
unless teacher_self_link.nil?
|
@@ -39,7 +43,6 @@ class Classes
|
|
39
43
|
@main_teacher = Teacher.new teacher_self_response
|
40
44
|
end
|
41
45
|
|
42
|
-
@links = Links.new(json_data[ModelUtils::LINKS], TYPE)
|
43
46
|
end
|
44
47
|
|
45
48
|
##
|
@@ -1,20 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
TYPE = 'courseunits'
|
1
|
+
require_relative '../element'
|
2
|
+
require_relative '../model_utils'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
class CourseUnit < Element
|
5
|
+
|
6
|
+
@@type_of_links = 'courseunits'
|
8
7
|
|
9
|
-
|
10
|
-
@id = json_info[ModelUtils::ID]
|
11
|
-
@short_name = json_info[ModelUtils::SHORT_NAME]
|
12
|
-
@name = json_info[ModelUtils::NAME]
|
13
|
-
@links = Links.new json_info[ModelUtils::LINKS], TYPE
|
14
|
-
#@programs = TODO
|
15
|
-
end
|
8
|
+
attr_reader :name, :programs
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
def initialize(json_info)
|
11
|
+
super(json_info[ModelUtils::ID],
|
12
|
+
json_info[ModelUtils::SHORT_NAME],
|
13
|
+
json_info[ModelUtils::LINKS],
|
14
|
+
@@type_of_links)
|
15
|
+
@name = json_info[ModelUtils::NAME]
|
16
|
+
|
17
|
+
#@programs = TODO
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
"#{@id} - #{@short_name}"
|
22
|
+
end
|
20
23
|
end
|
@@ -1,29 +1,26 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '
|
1
|
+
require_relative '../model_utils'
|
2
|
+
require_relative '../secondary/links'
|
3
|
+
require_relative '../element'
|
3
4
|
|
4
|
-
class LectiveSemester
|
5
|
+
class LectiveSemester < Element
|
5
6
|
|
6
|
-
attr_reader :
|
7
|
-
attr_reader :links
|
7
|
+
attr_reader :start_year, :term, :term_name
|
8
8
|
|
9
|
-
|
9
|
+
@@type_of_links = 'lectiveSemesters'
|
10
10
|
|
11
11
|
def initialize(json_str)
|
12
|
-
|
13
|
-
json_data = json_str
|
14
|
-
else
|
15
|
-
json_data = JSON.parse json_str
|
16
|
-
end
|
12
|
+
json_data = ModelUtils.check_json_info json_str
|
17
13
|
|
18
|
-
|
19
|
-
|
14
|
+
super(json_data[ModelUtils::LECTIVE_ID],
|
15
|
+
json_data[ModelUtils::SHORT_NAME],
|
16
|
+
json_data[ModelUtils::LINKS],
|
17
|
+
@@type_of_links)
|
20
18
|
@start_year = json_data[ModelUtils::START_YEAR]
|
21
19
|
@term = json_data[ModelUtils::TERM]
|
22
20
|
@term_name = json_data[ModelUtils::TERM_NAME]
|
23
|
-
@links = Links.new json_data[ModelUtils::LINKS], TYPE
|
24
21
|
end
|
25
22
|
|
26
23
|
def to_s
|
27
|
-
"#{@
|
24
|
+
"#{@id} - #{@short_name} : #{@term_name} #{@start_year}"
|
28
25
|
end
|
29
26
|
end
|
@@ -1,20 +1,42 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '
|
3
|
-
|
1
|
+
require_relative '../element'
|
2
|
+
require_relative '../model_utils'
|
3
|
+
require_relative 'courses'
|
4
4
|
|
5
|
+
class Program < Element
|
5
6
|
|
6
|
-
|
7
|
+
attr_reader :full_name, :course_units
|
7
8
|
|
8
|
-
|
9
|
+
@@type_for_links = 'programs'
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def initialize(data)
|
12
|
+
json_data = ModelUtils::check_json_info data
|
13
|
+
|
14
|
+
super(json_data[ModelUtils::ID],
|
15
|
+
json_data[ModelUtils::SHORT_NAME],
|
16
|
+
json_data[ModelUtils::LINKS],
|
17
|
+
@@type_for_links)
|
18
|
+
|
19
|
+
@full_name = (json_data[ModelUtils::FULL_NAME] || json_data[ModelUtils::NAME])
|
20
|
+
|
21
|
+
@course_units = get_course_units json_data[ModelUtils::COURSE_UNIT]
|
22
|
+
end
|
16
23
|
|
17
|
-
|
18
|
-
|
24
|
+
def to_s
|
25
|
+
"#{@id} - #{@full_name}"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def get_course_units(info)
|
30
|
+
courses_temp = info
|
31
|
+
to_return = []
|
32
|
+
if courses_temp.nil?
|
33
|
+
return to_return
|
34
|
+
end
|
35
|
+
courses_temp.each do |course|
|
36
|
+
stub = CourseUnit.new course
|
37
|
+
to_return.push stub
|
19
38
|
end
|
39
|
+
to_return
|
40
|
+
end
|
41
|
+
|
20
42
|
end
|
@@ -1,34 +1,37 @@
|
|
1
1
|
require 'json'
|
2
|
-
require_relative '
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
2
|
+
require_relative '../model_utils'
|
3
|
+
require_relative '../secondary/links'
|
4
|
+
require_relative '../secondary/avatar_url'
|
5
5
|
require_relative 'program'
|
6
|
+
require_relative '../element'
|
6
7
|
|
7
|
-
class Student
|
8
|
+
class Student < Element
|
8
9
|
|
9
|
-
|
10
|
+
@@type_for_links = 'students'
|
10
11
|
|
11
|
-
attr_reader :
|
12
|
-
attr_reader :avatar_url, :program, :
|
12
|
+
attr_reader :number, :name, :academic_email, :github_username
|
13
|
+
attr_reader :avatar_url, :program, :students
|
13
14
|
|
14
15
|
def initialize(json_str)
|
15
16
|
json_data = Appolo.check_json_info json_str
|
16
17
|
|
17
|
-
|
18
|
+
super(json_data[ModelUtils::ID],
|
19
|
+
json_data[ModelUtils::SHORT_NAME],
|
20
|
+
json_data[ModelUtils::LINKS],
|
21
|
+
@@type_for_links)
|
22
|
+
|
18
23
|
@number = json_data[ModelUtils::NUMBER]
|
19
|
-
@short_name = json_data[ModelUtils::SHORT_NAME]
|
20
24
|
@name = json_data[ModelUtils::NAME] || json_data[ModelUtils::FULL_NAME]
|
21
25
|
@academic_email = json_data[ModelUtils::ACADEMIC_EMAIL]
|
22
26
|
@github_username = json_data[ModelUtils::GITHUB_USERNAME]
|
23
27
|
|
24
28
|
program_info = json_data[ModelUtils::PROGRAM]
|
25
|
-
@program = Program.new(program_info
|
29
|
+
@program = Program.new(program_info) unless program_info.nil?
|
26
30
|
@avatar_url = AvatarUrl.new(json_data[ModelUtils::AVATAR_URL])
|
27
|
-
@links = Links.new(json_data[ModelUtils::LINKS], TYPE)
|
28
31
|
end
|
29
32
|
|
30
33
|
def to_s
|
31
|
-
"#{@
|
34
|
+
"#{@id} : Number #{@number.to_s} - #{@short_name}"
|
32
35
|
end
|
33
36
|
|
34
37
|
end
|
@@ -1,29 +1,27 @@
|
|
1
1
|
require 'json'
|
2
|
-
require_relative '
|
2
|
+
require_relative '../secondary/links'
|
3
|
+
require_relative '../model_utils'
|
4
|
+
require_relative '../element'
|
3
5
|
|
4
|
-
class Teacher
|
6
|
+
class Teacher < Element
|
5
7
|
|
6
|
-
|
8
|
+
@@type_of_links = 'teachers'
|
7
9
|
|
8
|
-
attr_reader :
|
9
|
-
attr_reader :avatar_url, :links
|
10
|
+
attr_reader :number, :name, :academic_email, :avatar_url
|
10
11
|
|
11
12
|
|
12
13
|
def initialize(json_info)
|
13
|
-
|
14
|
-
json_data = json_info
|
15
|
-
else
|
16
|
-
json_data = JSON.parse json_info
|
17
|
-
end
|
18
|
-
|
19
|
-
@id = json_data[ModelUtils::ID]
|
20
|
-
@number = json_data[ModelUtils::NUMBER]
|
21
|
-
@short_name = json_data[ModelUtils::SHORT_NAME]
|
22
|
-
@name = json_data[ModelUtils::NAME]
|
23
|
-
@academic_email = json_data[ModelUtils::ACADEMIC_EMAIL]
|
24
|
-
@links = Links.new(json_data[ModelUtils::LINKS], TYPE)
|
25
|
-
@avatar_url = AvatarUrl.new(json_data[ModelUtils::AVATAR_URL])
|
14
|
+
json_data = Appolo.check_json_info json_info
|
26
15
|
|
16
|
+
super(json_data[ModelUtils::ID],
|
17
|
+
json_data[ModelUtils::SHORT_NAME],
|
18
|
+
json_data[ModelUtils::LINKS],
|
19
|
+
@@type_of_links)
|
20
|
+
|
21
|
+
@number = json_data[ModelUtils::NUMBER]
|
22
|
+
@name = json_data[ModelUtils::NAME]
|
23
|
+
@academic_email = json_data[ModelUtils::ACADEMIC_EMAIL]
|
24
|
+
@avatar_url = AvatarUrl.new(json_data[ModelUtils::AVATAR_URL])
|
27
25
|
end
|
28
26
|
|
29
27
|
|
@@ -22,7 +22,7 @@ module ModelUtils
|
|
22
22
|
CLASS_ID = 'classId'
|
23
23
|
MAIN_TEACHER_SHORT_NAME = 'mainTeacherShortName'
|
24
24
|
COURSE_UNIT_ID = 'courseUnitId'
|
25
|
-
COURSE_UNIT = '
|
25
|
+
COURSE_UNIT = 'courseUnits'
|
26
26
|
LECTIVE_SEMESTER_ID = 'lectiveSemesterId'
|
27
27
|
MAIN_TEACHER_ID = 'mainTeacherId'
|
28
28
|
MAX_GROUP_SIZE = 'maxGroupSize'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../model_utils'
|
2
|
+
|
3
|
+
class Links
|
4
|
+
|
5
|
+
attr_reader :self, :root, :type, :main_teacher, :course_unit,
|
6
|
+
:lective_semester, :classes, :pages, :participants,
|
7
|
+
:groups, :lectures, :news_items, :work_items, :resources
|
8
|
+
|
9
|
+
|
10
|
+
def initialize(links, tpe)
|
11
|
+
@self = links[ModelUtils::SELF]
|
12
|
+
@root = links[ModelUtils::ROOT]
|
13
|
+
@type = links[tpe]
|
14
|
+
|
15
|
+
@main_teacher = links[ModelUtils::MAIN_TEACHER]
|
16
|
+
@course_unit = links[ModelUtils::COURSE_UNIT]
|
17
|
+
@lective_semester = links[ModelUtils::LECTIVE_SEMESTER]
|
18
|
+
@classes = links[ModelUtils::CLASSES]
|
19
|
+
@pages = links[ModelUtils::PAGES]
|
20
|
+
@participants = links[ModelUtils::PARTICIPANTS]
|
21
|
+
@groups = links[ModelUtils::GROUPS]
|
22
|
+
@lectures = links[ModelUtils::LECTURES]
|
23
|
+
@news_items = links[ModelUtils::NEWS_ITEMS]
|
24
|
+
@work_items = links[ModelUtils::WORK_ITEMS]
|
25
|
+
@resources = links[ModelUtils::RESOURCES]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class NewsItem
|
3
|
+
attr_reader :id, :content, :date_created, :title
|
4
|
+
|
5
|
+
def initialize json_str
|
6
|
+
json_data = Appolo.check_json_info json_str
|
7
|
+
|
8
|
+
@id = json_data[ModelUtils::ID]
|
9
|
+
@content = json_data[ModelUtils::CONTENT]
|
10
|
+
@date_created = json_data[ModelUtils::CREATED_WHEN]
|
11
|
+
@title = json_data[ModelUtils::TITLE]
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
"#{@id} - NewsItem : #{@title} - #{@date_created}"
|
16
|
+
end
|
17
|
+
end
|
data/lib/Appolo/version.rb
CHANGED
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
|
+
|
10
10
|
require 'json'
|
11
11
|
|
12
12
|
##
|
@@ -39,7 +39,7 @@ module Appolo
|
|
39
39
|
COURSES_API_LINK = 'https://adeetc.thothapp.com/api/v1/courseunits/'
|
40
40
|
LECTIVE_SEMESTERS_API_LINK = 'https://adeetc.thothapp.com/api/v1/lectivesemesters'
|
41
41
|
|
42
|
-
|
42
|
+
#TODO should raise exception when not 200
|
43
43
|
def self.verify_response(resp)
|
44
44
|
(resp.code == 200) ? resp : nil
|
45
45
|
end
|
@@ -145,7 +145,7 @@ module Appolo
|
|
145
145
|
lective_temp = JSON.parse(valid_resp)[LECTIVESEM_API_CODENAME]
|
146
146
|
lective_temp.each do |lec_sem|
|
147
147
|
stub = LectiveSemester.new lec_sem
|
148
|
-
$all_lective_sem[stub.
|
148
|
+
$all_lective_sem[stub.id] = stub
|
149
149
|
end
|
150
150
|
$all_lective_sem
|
151
151
|
rescue => e
|
@@ -177,9 +177,10 @@ module Appolo
|
|
177
177
|
# Return a single instance of Teacher based upon the +id+ given.
|
178
178
|
|
179
179
|
def self.get_teacher_by_id(id)
|
180
|
+
return $all_teachers[id] unless $all_teachers.count == 0
|
180
181
|
begin
|
181
182
|
response = RestClient.get TEACHERS_API_LINK + id.to_s
|
182
|
-
Teacher.new
|
183
|
+
Teacher.new(verify_response response)
|
183
184
|
rescue => e
|
184
185
|
nil
|
185
186
|
end
|
@@ -190,9 +191,10 @@ module Appolo
|
|
190
191
|
# Return a single instance of Classes based upon the +id+ given.
|
191
192
|
|
192
193
|
def self.get_class_by_id(id)
|
194
|
+
return $all_classes[id] unless $all_classes.count == 0
|
193
195
|
begin
|
194
196
|
response = RestClient.get CLASSES_API_LINK + id.to_s
|
195
|
-
Classes.new
|
197
|
+
Classes.new(verify_response response)
|
196
198
|
rescue => e
|
197
199
|
nil
|
198
200
|
end
|
@@ -205,12 +207,20 @@ module Appolo
|
|
205
207
|
return $all_students[id] unless $all_students.count == 0
|
206
208
|
begin
|
207
209
|
response = RestClient.get STUDENTS_API_LINK + id.to_s
|
208
|
-
Student.new
|
210
|
+
Student.new(verify_response response)
|
209
211
|
rescue => e
|
210
212
|
nil
|
211
213
|
end
|
212
214
|
end
|
213
215
|
|
214
|
-
|
216
|
+
def self.get_program_by_id(id)
|
217
|
+
return $all_programs[id] unless $all_programs.count == 0
|
218
|
+
begin
|
219
|
+
response = RestClient.get PROGRAMS_API_LINK + id.to_s
|
220
|
+
Program.new(verify_response response)
|
221
|
+
rescue => e
|
222
|
+
nil
|
223
|
+
end
|
224
|
+
end
|
215
225
|
|
216
226
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appolo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Gabriel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,46 +42,59 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rest-client
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
59
62
|
- - ">="
|
60
63
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
64
|
+
version: 1.8.0
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '1.8'
|
66
72
|
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
74
|
+
version: 1.8.0
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: json
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.8'
|
73
82
|
- - ">="
|
74
83
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
84
|
+
version: 1.8.3
|
76
85
|
type: :development
|
77
86
|
prerelease: false
|
78
87
|
version_requirements: !ruby/object:Gem::Requirement
|
79
88
|
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.8'
|
80
92
|
- - ">="
|
81
93
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
-
description:
|
84
|
-
WebApp
|
94
|
+
version: 1.8.3
|
95
|
+
description: |-
|
96
|
+
Ruby gem that provides quick and easy access to the web api of Thoth WebApp -
|
97
|
+
https://adeetc.thothapp.com/
|
85
98
|
email:
|
86
99
|
- pedrogabriel@protonmail.ch
|
87
100
|
executables: []
|
@@ -99,9 +112,7 @@ files:
|
|
99
112
|
- bin/example.rb
|
100
113
|
- bin/setup
|
101
114
|
- lib/Appolo.rb
|
102
|
-
- lib/Appolo/Models/
|
103
|
-
- lib/Appolo/Models/lecture.rb
|
104
|
-
- lib/Appolo/Models/links.rb
|
115
|
+
- lib/Appolo/Models/element.rb
|
105
116
|
- lib/Appolo/Models/main_model/classes.rb
|
106
117
|
- lib/Appolo/Models/main_model/courses.rb
|
107
118
|
- lib/Appolo/Models/main_model/lective_semester.rb
|
@@ -109,7 +120,11 @@ files:
|
|
109
120
|
- lib/Appolo/Models/main_model/student.rb
|
110
121
|
- lib/Appolo/Models/main_model/teacher.rb
|
111
122
|
- lib/Appolo/Models/model_utils.rb
|
112
|
-
- lib/Appolo/Models/
|
123
|
+
- lib/Appolo/Models/secondary/avatar_url.rb
|
124
|
+
- lib/Appolo/Models/secondary/lecture.rb
|
125
|
+
- lib/Appolo/Models/secondary/links.rb
|
126
|
+
- lib/Appolo/Models/secondary/news_item.rb
|
127
|
+
- lib/Appolo/Models/secondary/resource.rb
|
113
128
|
- lib/Appolo/version.rb
|
114
129
|
homepage: https://github.com/CaptainGabriel/AppoloGem
|
115
130
|
licenses:
|
data/lib/Appolo/Models/links.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require_relative 'model_utils'
|
2
|
-
|
3
|
-
class Links
|
4
|
-
|
5
|
-
attr_reader :self, :root, :type, :main_teacher, :course_unit,
|
6
|
-
:lective_semester, :classes, :pages, :participants,
|
7
|
-
:groups, :lectures, :news_items, :work_items, :resources
|
8
|
-
|
9
|
-
|
10
|
-
def initialize(links, tpe)
|
11
|
-
@self = links[ModelUtils::SELF]
|
12
|
-
@root = links[ModelUtils::ROOT]
|
13
|
-
@type = links[tpe]
|
14
|
-
|
15
|
-
@main_teacher = links[ModelUtils::MAIN_TEACHER]
|
16
|
-
@course_unit = links[ModelUtils::COURSE_UNIT]
|
17
|
-
@lective_semester = links[ModelUtils::LECTIVE_SEMESTER]
|
18
|
-
@classes = links[ModelUtils::CLASSES]
|
19
|
-
@pages = links[ModelUtils::PAGES]
|
20
|
-
@participants = links[ModelUtils::PARTICIPANTS]
|
21
|
-
@groups = links[ModelUtils::GROUPS]
|
22
|
-
@lectures = links[ModelUtils::LECTURES]
|
23
|
-
@news_items = links[ModelUtils::NEWS_ITEMS]
|
24
|
-
@work_items = links[ModelUtils::WORK_ITEMS]
|
25
|
-
@resources = links[ModelUtils::RESOURCES]
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
File without changes
|