Skip to content

Commit a7a5007

Browse files
authored
Rubocop fixes (#1204)
* Rubocop fixes * More rubo
1 parent c4643ec commit a7a5007

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ gem 'tabulo', '~> 2.8.1'
3434

3535
gem 'jwt', '~> 2.7.0'
3636

37-
gem 'aws-sdk-s3', '~> 1'
3837
gem 'aws-sdk-cloudfront', '~> 1'
38+
gem 'aws-sdk-s3', '~> 1'
3939

4040
group :development, :test do
4141
# Call 'byebug' anywhere in the code to stop execution and get a debugger console

app/controllers/playback_controller.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def deliver_resource
9898

9999
prefix = @recording.published? ? "published" : "unpublished"
100100
page = "index.html"
101-
cf_url = "#{ENV.fetch("CLOUDFRONT_URL")}/#{prefix}/#{@playback_format.format}/#{@recording.record_id}/#{page}"
101+
cf_url = "#{ENV.fetch('CLOUDFRONT_URL')}/#{prefix}/#{@playback_format.format}/#{@recording.record_id}/#{page}"
102102

103103
redirect_to cf_url, allow_other_host: true, status: :temporary_redirect
104104
else
@@ -114,27 +114,26 @@ def recording_not_found
114114
render "errors/recording_not_found", status: :not_found, formats: [:html]
115115
end
116116

117-
private
118117
def set_cf_signed_cookies!(format:, record_id:, published:, ttl: 5.minutes)
119118
base_prefix = published ? "published" : "unpublished"
120119
path_scope = "/#{base_prefix}/#{format}/#{record_id}/*"
121120

122121
cf_origin = ENV.fetch("CLOUDFRONT_URL")
123122

124-
pem = Base64.decode64(ENV["CF_PRIVATE_KEY_B64"])
123+
pem = Base64.decode64(ENV.fetch("CF_PRIVATE_KEY_B64", nil))
125124

126125
signer = Aws::CloudFront::CookieSigner.new(
127126
key_pair_id: ENV.fetch("CF_KEY_PAIR_ID"),
128127
private_key: OpenSSL::PKey::RSA.new(pem)
129128
)
130129

131-
expires_at = Time.now + (ttl.is_a?(Numeric) ? ttl : ttl.to_i)
130+
expires_at = Time.zone.now + (ttl.is_a?(Numeric) ? ttl : ttl.to_i)
132131

133132
policy_json = JSON.generate({
134133
"Statement" => [{
135-
"Resource" => "#{cf_origin}#{path_scope}",
134+
"Resource" => "#{cf_origin}#{path_scope}",
136135
"Condition" => { "DateLessThan" => { "AWS:EpochTime" => expires_at.to_i } }
137-
}]
136+
}]
138137
})
139138

140139
cf_cookies = signer.signed_cookie(nil, policy: policy_json)

lib/recording_importer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def self.import(filename, aws_client = nil)
5050
files = Dir.glob("#{directory}/**/*").select { |f| File.file?(f) }
5151
files.each do |file|
5252
content_type = Rack::Mime.mime_type(File.extname(file), "application/octet-stream")
53-
content_disposition = %w[.pdf .ogg].include?(File.extname(file)) ? "attachment" : nil
53+
attachment_file_types = %w[.pdf .ogg]
54+
content_disposition = attachment_file_types.include?(File.extname(file)) ? "attachment" : nil
5455

5556
object = Aws::S3::Object.new(ENV.fetch('S3_BUCKET_NAME'), "#{key}#{file}", client: aws_client)
5657
object.upload_file(file, content_type: content_type, content_disposition: content_disposition)

0 commit comments

Comments
 (0)