bearcat 1.5.38 → 1.5.39
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/bearcat/client/reports.rb +10 -24
- data/lib/bearcat/version.rb +1 -1
- data/spec/bearcat/client/reports_spec.rb +2 -5
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 162fc05f04d1d475f69cdd6cab1d449539d288284cb89868487be991922da485
|
4
|
+
data.tar.gz: 936bfa6f545ce8bd7f0fe81c15f938d1232fcbdd3685869caae7e8c47ca7aba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63da23efc98f40c13824887429bd5df839054a6d0c28f14ce213745ad7811b2c453f34a9ee1e31871c42928017f9f1fee2d7a02744dc8880c621ba25a3efb6b1
|
7
|
+
data.tar.gz: 77094d36014b3ffded25baf37d58647877ae7689691f673bc2606407be493e1120f388437172ff43ebc2ccce0e55f20d32aeaa576b6ef49e239b4e2add0ca225
|
@@ -14,34 +14,20 @@ module Bearcat
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def download_report(url, save_location=nil)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
24
|
-
http.use_ssl = true if url.start_with?('https')
|
25
|
-
response = http.head(uri.to_s)
|
26
|
-
url = response['Location']
|
27
|
-
attempts += 1
|
28
|
-
end while attempts <= 5 && (response.code == '301' || response.code == '302' || response.code == '307')
|
29
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
30
|
-
http.use_ssl = true if uri.to_s.start_with?('https')
|
17
|
+
require 'open-uri'
|
18
|
+
open_uri_stream = URI.open(url, {
|
19
|
+
'User-Agent' => "Bearcat/#{Bearcat::VERSION} (#{RUBY_PLATFORM})",
|
20
|
+
'Authorization' => "Bearer #{config[:token]}"
|
21
|
+
})
|
22
|
+
|
31
23
|
if save_location
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
file.write(segment)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
24
|
+
save_location = save_location.path if save_location.respond_to?(:path)
|
25
|
+
IO.copy_stream(open_uri_stream, save_location)
|
26
|
+
save_location
|
39
27
|
else
|
40
|
-
|
41
|
-
CSV.parse(response.read_body, headers: true)
|
28
|
+
CSV.parse(open_uri_stream.read, headers: true)
|
42
29
|
end
|
43
30
|
end
|
44
|
-
|
45
31
|
end
|
46
32
|
end
|
47
33
|
end
|
data/lib/bearcat/version.rb
CHANGED
@@ -48,7 +48,6 @@ describe Bearcat::Client::Reports do
|
|
48
48
|
it 'downloads a report to disk' do
|
49
49
|
report = IO.read(fixture('file.csv'))
|
50
50
|
tempfile = Tempfile.new('report')
|
51
|
-
stub_request(:head, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
|
52
51
|
stub_request(:get,'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
|
53
52
|
@client.download_report('https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string', tempfile)
|
54
53
|
csv = CSV.read(tempfile, headers: true)
|
@@ -59,12 +58,10 @@ describe Bearcat::Client::Reports do
|
|
59
58
|
it 'follows redirects' do
|
60
59
|
report = IO.read(fixture('file.csv'))
|
61
60
|
tempfile = Tempfile.new('report')
|
62
|
-
stub_request(:
|
61
|
+
stub_request(:get, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string')
|
63
62
|
.to_return(status: 302, body: 'You are being redirected',headers: {'Location' => 'https://cluster1-files.instructure.com/files/1/download?download_frd=1&sf_verifier=verifier=1478139862&user_id=1&verifier=verifier'})
|
64
|
-
stub_request(:
|
63
|
+
stub_request(:get, 'https://cluster1-files.instructure.com/files/1/download?download_frd=1&sf_verifier=verifier=1478139862&user_id=1&verifier=verifier')
|
65
64
|
.to_return(status: 302, body: 'You are being redirected', headers: {'Location' => 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv'})
|
66
|
-
stub_request(:head, 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv')
|
67
|
-
.to_return(status: 200)
|
68
65
|
stub_request(:get, 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv')
|
69
66
|
.to_return(status: 200, body: report)
|
70
67
|
@client.download_report('https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string', tempfile)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bearcat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure CustomDev
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rake
|
@@ -429,10 +428,8 @@ files:
|
|
429
428
|
- spec/fixtures/user_page_views.json
|
430
429
|
- spec/fixtures/user_profile.json
|
431
430
|
- spec/helper.rb
|
432
|
-
homepage:
|
433
431
|
licenses: []
|
434
432
|
metadata: {}
|
435
|
-
post_install_message:
|
436
433
|
rdoc_options: []
|
437
434
|
require_paths:
|
438
435
|
- lib
|
@@ -447,8 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
447
444
|
- !ruby/object:Gem::Version
|
448
445
|
version: '0'
|
449
446
|
requirements: []
|
450
|
-
rubygems_version: 3.
|
451
|
-
signing_key:
|
447
|
+
rubygems_version: 3.6.7
|
452
448
|
specification_version: 4
|
453
449
|
summary: Canvas API
|
454
450
|
test_files:
|