learn-web 1.0.5 → 1.1.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/client.rb +4 -0
- data/lib/learn_web/client/connection.rb +13 -0
- data/lib/learn_web/client/environment.rb +1 -3
- data/lib/learn_web/client/fork.rb +5 -5
- data/lib/learn_web/client/lesson.rb +9 -9
- data/lib/learn_web/client/pull_request.rb +5 -6
- data/lib/learn_web/client/request.rb +40 -0
- data/lib/learn_web/client/user.rb +4 -4
- data/lib/learn_web/client/user/me.rb +3 -3
- data/lib/learn_web/client/validate_repo.rb +5 -5
- data/lib/learn_web/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bc55f9891c64b1405c9055bbc8d69a0f41b8195
|
4
|
+
data.tar.gz: b5c05c586e2386262b0d5536dff54f9801d62347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1980895824514add35d587a5e1267eec635f536cbc270dfc0aad8644da29cb61951bd842dd2b49c510f9505fde146920beaf682450497dd9ba4ce0364fa0e00b
|
7
|
+
data.tar.gz: 206fbfe990b713e1d514efde193c45706d086338c1588a1907dc6e1773643c24577cc265e371c0e34739b6729d95eadbe6ded281eb719d0c6241e9166875a85a
|
data/lib/learn_web/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'learn_web/client/request'
|
2
|
+
require 'learn_web/client/connection'
|
1
3
|
require 'learn_web/client/user'
|
2
4
|
require 'learn_web/client/pull_request'
|
3
5
|
require 'learn_web/client/lesson'
|
@@ -12,6 +14,8 @@ module LearnWeb
|
|
12
14
|
LEARN_URL = 'https://learn.co'
|
13
15
|
API_ROOT = '/api/v1'
|
14
16
|
|
17
|
+
include LearnWeb::Client::Request
|
18
|
+
include LearnWeb::Client::Connection
|
15
19
|
include LearnWeb::Client::PullRequest
|
16
20
|
include LearnWeb::Client::Lesson
|
17
21
|
include LearnWeb::Client::ValidateRepo
|
@@ -8,11 +8,11 @@ module LearnWeb
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def fork_repo(repo_name:)
|
11
|
-
response =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
response = post(
|
12
|
+
fork_endpoint,
|
13
|
+
headers: { 'Authorization' => "Bearer #{token}" },
|
14
|
+
params: { 'repo_name' => repo_name }
|
15
|
+
)
|
16
16
|
|
17
17
|
LearnWeb::Client::Fork::Request.new(response)
|
18
18
|
end
|
@@ -13,20 +13,20 @@ module LearnWeb
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def current_lesson
|
16
|
-
response =
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
response = get(
|
17
|
+
current_lesson_endpoint,
|
18
|
+
headers: { 'Authorization' => "Bearer #{token}" }
|
19
|
+
)
|
20
20
|
|
21
21
|
LearnWeb::Client::Lesson::CurrentLesson.new(response)
|
22
22
|
end
|
23
23
|
|
24
24
|
def next_lesson
|
25
|
-
response =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
response = get(
|
26
|
+
next_lesson_endpoint,
|
27
|
+
headers: { 'Authorization' => "Bearer #{token}" },
|
28
|
+
params: { 'dir_name' => File.basename(FileUtils.pwd) }
|
29
|
+
)
|
30
30
|
|
31
31
|
LearnWeb::Client::Lesson::NextLesson.new(response)
|
32
32
|
end
|
@@ -8,12 +8,11 @@ module LearnWeb
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def issue_pull_request(repo_name:, branch_name:)
|
11
|
-
response =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
11
|
+
response = post(
|
12
|
+
pr_endpoint,
|
13
|
+
headers: { 'Authorization' => "Bearer #{token}" },
|
14
|
+
params: { 'repo_name' => repo_name, 'branch_name' => branch_name }
|
15
|
+
)
|
17
16
|
|
18
17
|
LearnWeb::Client::PullRequest::Response.new(response)
|
19
18
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module LearnWeb
|
2
|
+
class Client
|
3
|
+
module Request
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def request(method, url, options = {})
|
8
|
+
begin
|
9
|
+
@conn.send(method) do |req|
|
10
|
+
req.url url
|
11
|
+
build_request(req, options)
|
12
|
+
end
|
13
|
+
rescue Faraday::ConnectionFailed
|
14
|
+
puts "Connection error. Please try again."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_request(request, options)
|
19
|
+
build_headers(request, options[:headers])
|
20
|
+
build_params(request, options[:params])
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_headers(request, headers)
|
24
|
+
if headers
|
25
|
+
headers.each do |header, value|
|
26
|
+
request.headers[header] = value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_params(request, params)
|
32
|
+
if params
|
33
|
+
params.each do |param, value|
|
34
|
+
request.params[param] = value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -8,10 +8,10 @@ module LearnWeb
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def me
|
11
|
-
response =
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
response = get(
|
12
|
+
me_endpoint,
|
13
|
+
headers: { 'Authorization' => "Bearer #{token}" }
|
14
|
+
)
|
15
15
|
|
16
16
|
LearnWeb::Client::User::Me.new(response, silent_output: silent_output)
|
17
17
|
end
|
@@ -24,13 +24,13 @@ module LearnWeb
|
|
24
24
|
case response.status
|
25
25
|
when 401
|
26
26
|
puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset"
|
27
|
-
exit
|
27
|
+
exit 1
|
28
28
|
when 500
|
29
29
|
puts "Something went wrong. Please try again."
|
30
|
-
exit
|
30
|
+
exit 1
|
31
31
|
else
|
32
32
|
puts "Something went wrong. Please try again."
|
33
|
-
exit
|
33
|
+
exit 1
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -8,11 +8,11 @@ module LearnWeb
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def validate_repo_slug(repo_slug:)
|
11
|
-
response =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
response = post(
|
12
|
+
validate_repo_slug_endpoint,
|
13
|
+
headers: { 'Authorization' => "Bearer #{token}" },
|
14
|
+
params: { 'repo_slug' => repo_slug }
|
15
|
+
)
|
16
16
|
|
17
17
|
LearnWeb::Client::ValidateRepo::Slug.new(response)
|
18
18
|
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.0
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/learn_web.rb
|
83
83
|
- lib/learn_web/attribute_populatable.rb
|
84
84
|
- lib/learn_web/client.rb
|
85
|
+
- lib/learn_web/client/connection.rb
|
85
86
|
- lib/learn_web/client/environment.rb
|
86
87
|
- lib/learn_web/client/environment/setup_list.rb
|
87
88
|
- lib/learn_web/client/fork.rb
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- lib/learn_web/client/lesson/next_lesson.rb
|
92
93
|
- lib/learn_web/client/pull_request.rb
|
93
94
|
- lib/learn_web/client/pull_request/response.rb
|
95
|
+
- lib/learn_web/client/request.rb
|
94
96
|
- lib/learn_web/client/user.rb
|
95
97
|
- lib/learn_web/client/user/me.rb
|
96
98
|
- lib/learn_web/client/validate_repo.rb
|
@@ -116,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
118
|
version: '0'
|
117
119
|
requirements: []
|
118
120
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.4.
|
121
|
+
rubygems_version: 2.4.8
|
120
122
|
signing_key:
|
121
123
|
specification_version: 4
|
122
124
|
summary: An interface to Learn.co
|