Skip to content

Commit 099cb0b

Browse files
authored
DEV: Fix ruby warnings and whitespace issues (#470)
Included: * DEV: Disable unusual rspec settings * DEV: Fix some ruby warnings and whitespace * DEV: Remove stray `puts` * DEV: Use `File.exist?` over `File.exists?` * DEV: Fix the remaining warnings
1 parent 61fd073 commit 099cb0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+217
-212
lines changed

.rspec

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
--color
2-
--format documentation
3-
--fail-fast
4-
--backtrace
5-

lib/onebox/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def always_https
136136
end
137137

138138
def always_https?
139-
@https
139+
defined?(@https) ? @https : false
140140
end
141141
end
142142
end

lib/onebox/engine/allowlisted_generic_onebox.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,17 @@ def video_html
374374
escaped_image_src = ::Onebox::Helpers.normalize_url_for_output(data[:image])
375375

376376
<<-HTML
377-
<video title='#{data[:title]}'
378-
width='#{data[:video_width]}'
379-
height='#{data[:video_height]}'
380-
style='max-width:100%'
381-
poster='#{escaped_image_src}'
382-
controls=''>
383-
<source src='#{escaped_video_src}'>
384-
</video>
385-
HTML
377+
<video
378+
title='#{data[:title]}'
379+
width='#{data[:video_width]}'
380+
height='#{data[:video_height]}'
381+
style='max-width:100%'
382+
poster='#{escaped_image_src}'
383+
controls=''
384+
>
385+
<source src='#{escaped_video_src}'>
386+
</video>
387+
HTML
386388
end
387389

388390
def embedded_html

lib/onebox/engine/amazon_onebox.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class AmazonOnebox
1414
matches_regexp(/^https?:\/\/(?:www\.)?(?:smile\.)?(amazon|amzn)\.(?<tld>com|ca|de|it|es|fr|co\.jp|co\.uk|cn|in|com\.br|com\.mx|nl|pl|sa|sg|se|com\.tr|ae)\//)
1515

1616
def url
17+
@raw ||= nil
18+
1719
# If possible, fetch the cached HTML body immediately so we can
1820
# try to grab the canonical URL from that document,
1921
# rather than guess at the best URL structure to use
@@ -36,7 +38,7 @@ def url
3638
end
3739

3840
def tld
39-
@tld || @@matcher.match(@url)["tld"]
41+
@tld ||= @@matcher.match(@url)["tld"]
4042
end
4143

4244
def http_params

lib/onebox/engine/asciinema_onebox.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class AsciinemaOnebox
77
include StandardEmbed
88

99
always_https
10-
1110
matches_regexp(/^https?:\/\/asciinema\.org\/a\/[\p{Alnum}_\-]+$/)
1211

1312
def to_html

lib/onebox/engine/audioboom_onebox.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ def placeholder_html
1313
oembed = get_oembed
1414

1515
<<-HTML
16-
<img src="#{oembed.thumbnail_url}" style="max-width: #{oembed.width}px; max-height: #{oembed.height}px;" #{oembed.title_attr}>
16+
<img
17+
src="#{oembed.thumbnail_url}"
18+
style="max-width: #{oembed.width}px; max-height: #{oembed.height}px;"
19+
#{oembed.title_attr}
20+
>
1721
HTML
1822
end
1923

2024
def to_html
2125
get_oembed.html
2226
end
23-
2427
end
2528
end
2629
end

lib/onebox/engine/bandcamp_onebox.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ def to_html
2020
escaped_src = og.video_secure_url || og.video
2121

2222
<<-HTML
23-
<iframe src="#{escaped_src}"
24-
width="#{og.video_width}"
25-
height="#{og.video_height}"
26-
scrolling="no"
27-
frameborder="0"
28-
allowfullscreen>
29-
</iframe>
23+
<iframe
24+
src="#{escaped_src}"
25+
width="#{og.video_width}"
26+
height="#{og.video_height}"
27+
scrolling="no"
28+
frameborder="0"
29+
allowfullscreen
30+
></iframe>
3031
HTML
3132
end
32-
3333
end
3434
end
3535
end

lib/onebox/engine/cloudapp_onebox.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ def to_html
2525

2626
def link_html(og)
2727
<<-HTML
28-
<a href='#{og.url}' target='_blank' rel='noopener'>
29-
#{og.title}
30-
</a>
31-
HTML
28+
<a href='#{og.url}' target='_blank' rel='noopener'>
29+
#{og.title}
30+
</a>
31+
HTML
3232
end
3333

3434
def video_html(og)
3535
direct_src = ::Onebox::Helpers.normalize_url_for_output("#{og.get(:url)}/#{og.title}")
3636

3737
<<-HTML
38-
<video width='480' height='360' #{og.title_attr} controls loop>
39-
<source src='#{direct_src}' type='video/mp4'>
40-
</video>
41-
HTML
38+
<video width='480' height='360' #{og.title_attr} controls loop>
39+
<source src='#{direct_src}' type='video/mp4'>
40+
</video>
41+
HTML
4242
end
4343

4444
def image_html(og)
4545
<<-HTML
46-
<a href='#{og.url}' target='_blank' class='onebox' rel='noopener'>
47-
<img src='#{og.image}' #{og.title_attr} alt='CloudApp' width='480'>
48-
</a>
49-
HTML
46+
<a href='#{og.url}' target='_blank' class='onebox' rel='noopener'>
47+
<img src='#{og.image}' #{og.title_attr} alt='CloudApp' width='480'>
48+
</a>
49+
HTML
5050
end
5151
end
5252
end

lib/onebox/engine/coub_onebox.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def placeholder_html
1717
def to_html
1818
get_oembed.html
1919
end
20-
2120
end
2221
end
2322
end

lib/onebox/engine/facebook_media_onebox.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ def to_html
1414
metadata = get_twitter
1515
if metadata.present? && metadata[:card] == "player" && metadata[:player].present?
1616
<<-HTML
17-
<iframe src="#{metadata[:player]}"
18-
width="#{metadata[:player_width]}"
19-
height="#{metadata[:player_height]}"
20-
scrolling="no"
21-
frameborder="0"
22-
allowfullscreen>
23-
</iframe>
17+
<iframe
18+
src="#{metadata[:player]}"
19+
width="#{metadata[:player_width]}"
20+
height="#{metadata[:player_height]}"
21+
scrolling="no"
22+
frameborder="0"
23+
allowfullscreen
24+
></iframe>
2425
HTML
2526
else
2627
html = Onebox::Engine::AllowlistedGenericOnebox.new(@url, @timeout).to_html

0 commit comments

Comments
 (0)