et 0.6.0 → 0.6.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: 6e414688a6eb0fc5a464071284eaad87cf914f16
4
- data.tar.gz: 647e0fbd0c9fadbe733f480e4d29db3d06e6a18a
3
+ metadata.gz: fc9070225e55bddacb4e001dc623f86641bfc8c9
4
+ data.tar.gz: 6bc4ab6648a4dfab9bf3ac949c341edab3c1e444
5
5
  SHA512:
6
- metadata.gz: f8b87ae613c19d680bc2219b596e980351f04ddf9baee09efc1ce1624f9885e150db28312b8430c983ceccb90e78a701128afb8868607274dd6bcbdcf5515ec0
7
- data.tar.gz: 7cdb0f85e3fecc7aa82431e8d3e1cda5d745b65582ccfbefe8539868ab29e19e5ea161796e7d54c12d2ab6c7d019185d0f380e78e31208add0ec1a747e5d74b2
6
+ metadata.gz: 9b6c5e8708f547f96a2a4e33bff090655cb9dbc051dea2d9fe2ff3727b0f1df35f3796304a205b1bbd2d02907273c2055e58987eee86b7502c85f84894c6efa8
7
+ data.tar.gz: d9b1be81739512f93c0884295a461a240a13b27484276b71bc4bf083b3bebde665ad708f9b213a937d8639ace58e32cd5bc23be908f85dfc4a944c135f13a996
@@ -15,16 +15,16 @@ module ET
15
15
  end
16
16
 
17
17
  def list_lessons
18
- resp = nil
19
- api_client.with_ssl_fallback do |client|
20
- resp = client.get('/lessons.json', :submittable => 1)
18
+ response = nil
19
+ api_client.open do |client|
20
+ response = client.get('/lessons.json', :submittable => 1)
21
21
  end
22
- resp.body['lessons']
22
+ response.body['lessons']
23
23
  end
24
24
 
25
25
  def get_lesson(slug)
26
26
  resp = nil
27
- api_client.with_ssl_fallback do |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).with_ssl_fallback do |client|
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.with_ssl_fallback do |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 with_ssl_fallback(&block)
12
+ def open(&block)
13
13
  begin
14
14
  block.call(@connection)
15
- rescue OpenSSL::SSL::SSLError => e
15
+ rescue Faraday::SSLError => e
16
16
  if operating_system.platform_family?(:windows)
17
17
  block.call(@fallback_connection)
18
18
  else
@@ -1,3 +1,3 @@
1
1
  module ET
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -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(:with_ssl_fallback).and_yield(client)
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(:with_ssl_fallback).and_yield(client)
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(:with_ssl_fallback).and_yield(client)
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(:with_ssl_fallback).and_yield(client)
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.with_ssl_fallback{|client| client.get('/') }}.
16
- to raise_error(OpenSSL::SSL::SSLError)
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.with_ssl_fallback do |client|
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.0
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-10-21 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry