learn-web 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/learn_web.rb +1 -0
- data/lib/learn_web/client/lesson.rb +14 -0
- data/lib/learn_web/client/lesson/current_lesson.rb +1 -19
- data/lib/learn_web/client/lesson/current_status.rb +20 -0
- data/lib/learn_web/client/lesson/next_lesson.rb +1 -19
- data/lib/learn_web/response_parsable.rb +26 -0
- data/lib/learn_web/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35681d6a319de7327b2f46690d87860ce0acd1b2
|
4
|
+
data.tar.gz: 8d9af970a0af4dec7ee53896e21810da1a773431
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83f2519b3265e5094bf6d0947bdd5ab2ce6f7f2c5bade326fdbdfcb7c2ade3426c1f0bdc72ebc3a4f3f27f6e8566c0b04896b680d4d94f5e31721cdd6650d00
|
7
|
+
data.tar.gz: 7f0eb8fc1c5bc5277b2ab09ac9174e739a40d82e2d051446433ebe3839cc10a790b765fa513c3c81889cecadf712e3baa49d1e0f4207148715bd6868a5537101
|
data/lib/learn_web.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'learn_web/client/lesson/current_lesson'
|
2
|
+
require 'learn_web/client/lesson/current_status'
|
2
3
|
require 'learn_web/client/lesson/next_lesson'
|
3
4
|
|
4
5
|
module LearnWeb
|
@@ -12,6 +13,10 @@ module LearnWeb
|
|
12
13
|
"#{API_ROOT}/users/next_lesson"
|
13
14
|
end
|
14
15
|
|
16
|
+
def current_status_endpoint
|
17
|
+
"#{API_ROOT}/users/current_lesson/status"
|
18
|
+
end
|
19
|
+
|
15
20
|
def current_lesson
|
16
21
|
response = get(
|
17
22
|
current_lesson_endpoint,
|
@@ -30,6 +35,15 @@ module LearnWeb
|
|
30
35
|
|
31
36
|
LearnWeb::Client::Lesson::NextLesson.new(response)
|
32
37
|
end
|
38
|
+
|
39
|
+
def current_status
|
40
|
+
response = get(
|
41
|
+
current_status_endpoint,
|
42
|
+
headers: { 'Authorization' => "Bearer #{token}" }
|
43
|
+
)
|
44
|
+
|
45
|
+
LearnWeb::Client::Lesson::CurrentStatus.new(response)
|
46
|
+
end
|
33
47
|
end
|
34
48
|
end
|
35
49
|
end
|
@@ -7,31 +7,13 @@ module LearnWeb
|
|
7
7
|
:assessments, :lab
|
8
8
|
|
9
9
|
include LearnWeb::AttributePopulatable
|
10
|
+
include LearnWeb::ResponseParsable
|
10
11
|
|
11
12
|
def initialize(response)
|
12
13
|
@response = response
|
13
14
|
|
14
15
|
parse!
|
15
16
|
end
|
16
|
-
|
17
|
-
def parse!
|
18
|
-
case response.status
|
19
|
-
when 200
|
20
|
-
self.data = Oj.load(response.body, symbol_keys: true)
|
21
|
-
populate_attributes!
|
22
|
-
when 401
|
23
|
-
puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset"
|
24
|
-
exit
|
25
|
-
when 500
|
26
|
-
puts "Something went wrong. Please try again."
|
27
|
-
exit
|
28
|
-
else
|
29
|
-
puts "Something when wrong. Please try again."
|
30
|
-
exit
|
31
|
-
end
|
32
|
-
|
33
|
-
self
|
34
|
-
end
|
35
17
|
end
|
36
18
|
end
|
37
19
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LearnWeb
|
2
|
+
class Client
|
3
|
+
module Lesson
|
4
|
+
class CurrentStatus
|
5
|
+
attr_reader :response
|
6
|
+
attr_accessor :data, :title, :lights, :started, :students_working,
|
7
|
+
:median_completion_time
|
8
|
+
|
9
|
+
include LearnWeb::AttributePopulatable
|
10
|
+
include LearnWeb::ResponseParsable
|
11
|
+
|
12
|
+
def initialize(response)
|
13
|
+
@response = response
|
14
|
+
|
15
|
+
parse!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -7,31 +7,13 @@ module LearnWeb
|
|
7
7
|
:assessments, :lab
|
8
8
|
|
9
9
|
include LearnWeb::AttributePopulatable
|
10
|
+
include LearnWeb::ResponseParsable
|
10
11
|
|
11
12
|
def initialize(response)
|
12
13
|
@response = response
|
13
14
|
|
14
15
|
parse!
|
15
16
|
end
|
16
|
-
|
17
|
-
def parse!
|
18
|
-
case response.status
|
19
|
-
when 200
|
20
|
-
self.data = Oj.load(response.body, symbol_keys: true)
|
21
|
-
populate_attributes!
|
22
|
-
when 401
|
23
|
-
puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset"
|
24
|
-
exit
|
25
|
-
when 500
|
26
|
-
puts "Something went wrong. Please try again."
|
27
|
-
exit
|
28
|
-
else
|
29
|
-
puts "Something when wrong. Please try again."
|
30
|
-
exit
|
31
|
-
end
|
32
|
-
|
33
|
-
self
|
34
|
-
end
|
35
17
|
end
|
36
18
|
end
|
37
19
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module LearnWeb
|
2
|
+
module ResponseParsable
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
def parse!
|
6
|
+
case response.status
|
7
|
+
when 200
|
8
|
+
self.data = Oj.load(response.body, symbol_keys: true)
|
9
|
+
populate_attributes!
|
10
|
+
when 401
|
11
|
+
puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset"
|
12
|
+
exit
|
13
|
+
when 500
|
14
|
+
puts "Something went wrong. Please try again."
|
15
|
+
exit
|
16
|
+
else
|
17
|
+
puts "Something when wrong. Please try again."
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/learn_web/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: learn-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/learn_web/client/fork/request.rb
|
90
90
|
- lib/learn_web/client/lesson.rb
|
91
91
|
- lib/learn_web/client/lesson/current_lesson.rb
|
92
|
+
- lib/learn_web/client/lesson/current_status.rb
|
92
93
|
- lib/learn_web/client/lesson/next_lesson.rb
|
93
94
|
- lib/learn_web/client/pull_request.rb
|
94
95
|
- lib/learn_web/client/pull_request/response.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- lib/learn_web/client/user/me.rb
|
98
99
|
- lib/learn_web/client/validate_repo.rb
|
99
100
|
- lib/learn_web/client/validate_repo/slug.rb
|
101
|
+
- lib/learn_web/response_parsable.rb
|
100
102
|
- lib/learn_web/version.rb
|
101
103
|
homepage: https://learn.co
|
102
104
|
licenses:
|