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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bc55f9891c64b1405c9055bbc8d69a0f41b8195
4
- data.tar.gz: b5c05c586e2386262b0d5536dff54f9801d62347
3
+ metadata.gz: 35681d6a319de7327b2f46690d87860ce0acd1b2
4
+ data.tar.gz: 8d9af970a0af4dec7ee53896e21810da1a773431
5
5
  SHA512:
6
- metadata.gz: 1980895824514add35d587a5e1267eec635f536cbc270dfc0aad8644da29cb61951bd842dd2b49c510f9505fde146920beaf682450497dd9ba4ce0364fa0e00b
7
- data.tar.gz: 206fbfe990b713e1d514efde193c45706d086338c1588a1907dc6e1773643c24577cc265e371c0e34739b6729d95eadbe6ded281eb719d0c6241e9166875a85a
6
+ metadata.gz: a83f2519b3265e5094bf6d0947bdd5ab2ce6f7f2c5bade326fdbdfcb7c2ade3426c1f0bdc72ebc3a4f3f27f6e8566c0b04896b680d4d94f5e31721cdd6650d00
7
+ data.tar.gz: 7f0eb8fc1c5bc5277b2ab09ac9174e739a40d82e2d051446433ebe3839cc10a790b765fa513c3c81889cecadf712e3baa49d1e0f4207148715bd6868a5537101
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
 
5
5
  require 'learn_web/version'
6
6
  require 'learn_web/attribute_populatable'
7
+ require 'learn_web/response_parsable'
7
8
  require 'learn_web/client'
8
9
 
9
10
  module LearnWeb
@@ -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
@@ -1,3 +1,3 @@
1
1
  module LearnWeb
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
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.1.0
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-01 00:00:00.000000000 Z
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: