learn-web 1.0.0 → 1.0.1

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: e70d0afd562568b60b04dd6b98dc3632bfc3a324
4
- data.tar.gz: 7e0a34bd00481a59d275fe269b5727c01e74922c
3
+ metadata.gz: b69195430cc8009d33e548d7ec4e0b2b72ed8c88
4
+ data.tar.gz: 87a125fadd0cdf323b68e8dbaff937ea8ecb3e7c
5
5
  SHA512:
6
- metadata.gz: ba74673a402c700f519d06645c7616a6e00060736727de585425ea95ea35f4a7c16ddcd8f841393be9de36fc5f2e5e359ea67fffc4faf679efc44f67acdbbb0c
7
- data.tar.gz: 91cbb33c7c69e3ed11726c585d8ef77b62d403f2ab69ed7be455a556a85bbd444cf4adf8b0e6520bc09a2a50fd40a9520dbb51a53e99172d7937a7291a0c10ad
6
+ metadata.gz: 0cf5d80f0170154a9b55a4886918751146b7c6003915361013f7eea71d18baaae7a89aba8cfdb4a03161fc50a5da38e258101f2bad3e243000ec9e71ec640a46
7
+ data.tar.gz: 765dd246a8a23bee2f12e7466263c92dba87848f9f6763c710252cd47f6415f041f6a069ea4237bc65e7541dee8a28fb37dd1c591f6c7de056ff0d99a8acadb0
@@ -1,4 +1,5 @@
1
1
  require 'learn_web/client/lesson/current_lesson'
2
+ require 'learn_web/client/lesson/next_lesson'
2
3
 
3
4
  module LearnWeb
4
5
  class Client
@@ -7,6 +8,10 @@ module LearnWeb
7
8
  "#{API_ROOT}/users/current_lesson"
8
9
  end
9
10
 
11
+ def next_lesson_endpoint
12
+ "#{API_ROOT}/users/next_lesson"
13
+ end
14
+
10
15
  def current_lesson
11
16
  response = @conn.get do |req|
12
17
  req.url current_lesson_endpoint
@@ -15,6 +20,15 @@ module LearnWeb
15
20
 
16
21
  LearnWeb::Client::Lesson::CurrentLesson.new(response)
17
22
  end
23
+
24
+ def next_lesson
25
+ response = @conn.get do |req|
26
+ req.url next_lesson_endpoint
27
+ req.headers['Authorization'] = "Bearer #{token}"
28
+ end
29
+
30
+ LearnWeb::Client::Lesson::NextLesson.new(response)
31
+ end
18
32
  end
19
33
  end
20
34
  end
@@ -0,0 +1,38 @@
1
+ module LearnWeb
2
+ class Client
3
+ module Lesson
4
+ class NextLesson
5
+ attr_reader :response
6
+ attr_accessor :data, :id, :title, :link, :github_repo, :forked_repo,
7
+ :assessments, :lab
8
+
9
+ include LearnWeb::AttributePopulatable
10
+
11
+ def initialize(response)
12
+ @response = response
13
+
14
+ parse!
15
+ 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
+ end
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module LearnWeb
2
- VERSION = "1.0.0"
2
+ VERSION = '1.0.1'
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.0.0
4
+ version: 1.0.1
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-05-28 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,6 +86,7 @@ files:
86
86
  - lib/learn_web/client/fork/request.rb
87
87
  - lib/learn_web/client/lesson.rb
88
88
  - lib/learn_web/client/lesson/current_lesson.rb
89
+ - lib/learn_web/client/lesson/next_lesson.rb
89
90
  - lib/learn_web/client/pull_request.rb
90
91
  - lib/learn_web/client/pull_request/response.rb
91
92
  - lib/learn_web/client/user.rb