et 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/et/api.rb +7 -7
- data/lib/et/fallback_connection.rb +2 -2
- data/lib/et/version.rb +1 -1
- data/spec/lib/api_spec.rb +5 -5
- data/spec/lib/fallback_connection_spec.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc9070225e55bddacb4e001dc623f86641bfc8c9
|
4
|
+
data.tar.gz: 6bc4ab6648a4dfab9bf3ac949c341edab3c1e444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b6c5e8708f547f96a2a4e33bff090655cb9dbc051dea2d9fe2ff3727b0f1df35f3796304a205b1bbd2d02907273c2055e58987eee86b7502c85f84894c6efa8
|
7
|
+
data.tar.gz: d9b1be81739512f93c0884295a461a240a13b27484276b71bc4bf083b3bebde665ad708f9b213a937d8639ace58e32cd5bc23be908f85dfc4a944c135f13a996
|
data/lib/et/api.rb
CHANGED
@@ -15,16 +15,16 @@ module ET
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def list_lessons
|
18
|
-
|
19
|
-
api_client.
|
20
|
-
|
18
|
+
response = nil
|
19
|
+
api_client.open do |client|
|
20
|
+
response = client.get('/lessons.json', :submittable => 1)
|
21
21
|
end
|
22
|
-
|
22
|
+
response.body['lessons']
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_lesson(slug)
|
26
26
|
resp = nil
|
27
|
-
api_client.
|
27
|
+
api_client.open do |client|
|
28
28
|
resp = client.get(lesson_url(slug), :submittable => 1)
|
29
29
|
end
|
30
30
|
resp.body['lesson']
|
@@ -34,7 +34,7 @@ module ET
|
|
34
34
|
response = nil
|
35
35
|
dest = random_filename
|
36
36
|
|
37
|
-
download_client(url).
|
37
|
+
download_client(url).open do |client|
|
38
38
|
response = client.get(URI(url).path)
|
39
39
|
end
|
40
40
|
if response.status == 200
|
@@ -51,7 +51,7 @@ module ET
|
|
51
51
|
submission_file = lesson.archive!
|
52
52
|
io = Faraday::UploadIO.new(submission_file, "application/x-tar")
|
53
53
|
resp = nil
|
54
|
-
api_client.
|
54
|
+
api_client.open do |client|
|
55
55
|
resp = client.post(submission_url(lesson.slug),
|
56
56
|
"submission" => { "archive" => io})
|
57
57
|
end
|
@@ -9,10 +9,10 @@ module ET
|
|
9
9
|
@fallback_connection = Faraday.new(opts.merge(:ssl => {:verify => false}))
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def open(&block)
|
13
13
|
begin
|
14
14
|
block.call(@connection)
|
15
|
-
rescue
|
15
|
+
rescue Faraday::SSLError => e
|
16
16
|
if operating_system.platform_family?(:windows)
|
17
17
|
block.call(@fallback_connection)
|
18
18
|
else
|
data/lib/et/version.rb
CHANGED
data/spec/lib/api_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe ET::API do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
allow_any_instance_of(ET::FallbackConnection).to receive(:
|
23
|
+
allow_any_instance_of(ET::FallbackConnection).to receive(:open).and_yield(client)
|
24
24
|
|
25
25
|
results = api.list_lessons
|
26
26
|
|
@@ -46,14 +46,14 @@ describe ET::API do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
allow_any_instance_of(ET::FallbackConnection).
|
49
|
-
to receive(:
|
49
|
+
to receive(:open).and_yield(client)
|
50
50
|
|
51
51
|
result = api.get_lesson("rock-paper-scissors")
|
52
52
|
|
53
53
|
expect(result['title']).to eq("Rock, Paper, Scissors")
|
54
54
|
expect(result['archive_url']).to eq('http://example.com/rock-paper-scissors.tar.gz')
|
55
55
|
end
|
56
|
-
end
|
56
|
+
end
|
57
57
|
|
58
58
|
context 'downloading files' do
|
59
59
|
it 'returns nil when a 404 is encountered' do
|
@@ -69,7 +69,7 @@ describe ET::API do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
allow_any_instance_of(ET::FallbackConnection).
|
72
|
-
to receive(:
|
72
|
+
to receive(:open).and_yield(client)
|
73
73
|
|
74
74
|
expect(api.download_file("http://example.com/#{filename}")).to be_nil
|
75
75
|
end
|
@@ -91,7 +91,7 @@ describe ET::API do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
allow_any_instance_of(ET::FallbackConnection).
|
94
|
-
to receive(:
|
94
|
+
to receive(:open).and_yield(client)
|
95
95
|
allow(Dir).to receive(:mktmpdir).and_return(path)
|
96
96
|
allow(SecureRandom).to receive(:hex).and_return(filename)
|
97
97
|
|
@@ -10,10 +10,10 @@ describe ET::FallbackConnection do
|
|
10
10
|
expect(ET::OperatingSystem).to receive(:new).and_return(dbl_os)
|
11
11
|
|
12
12
|
allow_any_instance_of(Faraday::Connection).
|
13
|
-
to receive(:get).and_raise(OpenSSL::SSL::SSLError)
|
14
|
-
|
15
|
-
expect{ cnn.
|
16
|
-
to raise_error(
|
13
|
+
to receive(:get).and_raise(Faraday::SSLError.new(OpenSSL::SSL::SSLError))
|
14
|
+
|
15
|
+
expect{ cnn.open {|client| client.get('/') }}.
|
16
|
+
to raise_error(Faraday::SSLError)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'swallows the exception for windows machines and reissues' do
|
@@ -25,7 +25,7 @@ describe ET::FallbackConnection do
|
|
25
25
|
allow_any_instance_of(Faraday::Connection).to receive(:get) do |*args|
|
26
26
|
if args[0].ssl.verify != false
|
27
27
|
#simulate a windows SSL verification failed
|
28
|
-
raise OpenSSL::SSL::SSLError
|
28
|
+
raise Faraday::SSLError.new(OpenSSL::SSL::SSLError.new)
|
29
29
|
elsif args[0].ssl.verify == false
|
30
30
|
#flip the switch that the request was reissued without SSL verification
|
31
31
|
called_twice = true
|
@@ -33,7 +33,7 @@ describe ET::FallbackConnection do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
cnn.
|
36
|
+
cnn.open do |client|
|
37
37
|
client.get('/')
|
38
38
|
end
|
39
39
|
expect(called_twice).to be(true)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: et
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Sheehan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|