onebox 1.5.34 → 1.5.35
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2536f8a819505d60d5c3af20abdac0bdad30a66
|
4
|
+
data.tar.gz: 868fac1b2221457e904c53b02b4a8bdb5dfaa270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ff16c0bebe5aee99c4d8f6233ec6df20d09cf1a94046116ac4a7abb29b74c2a5bef4d38bbff5d604b83cf651a4c8035e2d72efed3c49eebbc1ea1587ad6b88e
|
7
|
+
data.tar.gz: e3e8cd1d52dd1b2cae80fecac4c1771ce729eb587f49afb41efb9db343a460f7e54c203a2827873c70924338f340072bf950c510dd5bb82119f912d89c23b2f1
|
@@ -2,10 +2,37 @@ module Onebox
|
|
2
2
|
module Engine
|
3
3
|
class PastebinOnebox
|
4
4
|
include Engine
|
5
|
-
include
|
5
|
+
include LayoutSupport
|
6
|
+
|
7
|
+
MAX_LINES = 10
|
6
8
|
|
7
9
|
matches_regexp(/^http?:\/\/pastebin\.com/)
|
8
10
|
|
11
|
+
private
|
12
|
+
|
13
|
+
def data
|
14
|
+
@data ||= {
|
15
|
+
title: 'pastebin.com',
|
16
|
+
link: link,
|
17
|
+
content: content,
|
18
|
+
truncated?: truncated?
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def content
|
23
|
+
lines.take(MAX_LINES).join("\n")
|
24
|
+
end
|
25
|
+
|
26
|
+
def truncated?
|
27
|
+
lines.size > MAX_LINES
|
28
|
+
end
|
29
|
+
|
30
|
+
def lines
|
31
|
+
return @lines if @lines
|
32
|
+
response = Onebox::Helpers.fetch_response("http://pastebin.com/raw/#{paste_key}", 1)
|
33
|
+
@lines = response.body.split("\n")
|
34
|
+
end
|
35
|
+
|
9
36
|
def paste_key
|
10
37
|
if uri.path =~ /\/raw\//
|
11
38
|
match = uri.path.match(/\/raw\/([^\/]+)/)
|
@@ -25,13 +52,6 @@ module Onebox
|
|
25
52
|
rescue
|
26
53
|
return nil
|
27
54
|
end
|
28
|
-
|
29
|
-
def to_html
|
30
|
-
return nil unless paste_key
|
31
|
-
response = Onebox::Helpers.fetch_response("http://pastebin.com/raw/#{paste_key}", 1)
|
32
|
-
return nil unless response && response.code.to_i == 200
|
33
|
-
return "<iframe src='//pastebin.com/embed_iframe/#{paste_key}' style='border:none;width:100%;max-height:100px;'></iframe>"
|
34
|
-
end
|
35
55
|
end
|
36
56
|
end
|
37
57
|
end
|
data/lib/onebox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -351,7 +351,6 @@ files:
|
|
351
351
|
- spec/fixtures/googleplayapp.response
|
352
352
|
- spec/fixtures/image.response
|
353
353
|
- spec/fixtures/meetup.response
|
354
|
-
- spec/fixtures/pastebin.response
|
355
354
|
- spec/fixtures/pubmed-xml.response
|
356
355
|
- spec/fixtures/pubmed.response
|
357
356
|
- spec/fixtures/slides.response
|
@@ -378,7 +377,6 @@ files:
|
|
378
377
|
- spec/lib/onebox/engine/html_spec.rb
|
379
378
|
- spec/lib/onebox/engine/image_onebox_spec.rb
|
380
379
|
- spec/lib/onebox/engine/json_spec.rb
|
381
|
-
- spec/lib/onebox/engine/pastebin_onebox.spec.rb
|
382
380
|
- spec/lib/onebox/engine/pubmed_onebox_spec.rb
|
383
381
|
- spec/lib/onebox/engine/slides_onebox_spec.rb
|
384
382
|
- spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
|
@@ -406,6 +404,7 @@ files:
|
|
406
404
|
- templates/githubissue.mustache
|
407
405
|
- templates/githubpullrequest.mustache
|
408
406
|
- templates/googleplayapp.mustache
|
407
|
+
- templates/pastebin.mustache
|
409
408
|
- templates/pubmed.mustache
|
410
409
|
- templates/stackexchange.mustache
|
411
410
|
- templates/twitterstatus.mustache
|
@@ -437,7 +436,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
437
436
|
version: '0'
|
438
437
|
requirements: []
|
439
438
|
rubyforge_project:
|
440
|
-
rubygems_version: 2.
|
439
|
+
rubygems_version: 2.5.1
|
441
440
|
signing_key:
|
442
441
|
specification_version: 4
|
443
442
|
summary: A gem for turning URLs into previews.
|
@@ -452,7 +451,6 @@ test_files:
|
|
452
451
|
- spec/fixtures/googleplayapp.response
|
453
452
|
- spec/fixtures/image.response
|
454
453
|
- spec/fixtures/meetup.response
|
455
|
-
- spec/fixtures/pastebin.response
|
456
454
|
- spec/fixtures/pubmed-xml.response
|
457
455
|
- spec/fixtures/pubmed.response
|
458
456
|
- spec/fixtures/slides.response
|
@@ -479,7 +477,6 @@ test_files:
|
|
479
477
|
- spec/lib/onebox/engine/html_spec.rb
|
480
478
|
- spec/lib/onebox/engine/image_onebox_spec.rb
|
481
479
|
- spec/lib/onebox/engine/json_spec.rb
|
482
|
-
- spec/lib/onebox/engine/pastebin_onebox.spec.rb
|
483
480
|
- spec/lib/onebox/engine/pubmed_onebox_spec.rb
|
484
481
|
- spec/lib/onebox/engine/slides_onebox_spec.rb
|
485
482
|
- spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
|
@@ -498,4 +495,3 @@ test_files:
|
|
498
495
|
- spec/lib/onebox_spec.rb
|
499
496
|
- spec/spec_helper.rb
|
500
497
|
- spec/support/html_spec_helper.rb
|
501
|
-
has_rdoc:
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::PastebinOnebox do
|
4
|
-
before do
|
5
|
-
fake("http://pastebin.com/raw/YH8wQDi8", response("pastebin.response"))
|
6
|
-
end
|
7
|
-
|
8
|
-
it "returns iframe with pastebin embed URL" do
|
9
|
-
expect(Onebox.preview('http://pastebin.com/YH8wQDi8').to_s).to match("<iframe src='//pastebin.com/embed_iframe/YH8wQDi8' style='border:none;width:100%;max-height:100px;'></iframe>")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "supports pastebin raw link" do
|
13
|
-
expect(Onebox.preview('http://pastebin.com/raw/YH8wQDi8').to_s).to match(/pastebin.com\/embed_iframe\/YH8wQDi8/)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "supports pastebin download link" do
|
17
|
-
expect(Onebox.preview('http://pastebin.com/download/YH8wQDi8').to_s).to match(/pastebin.com\/embed_iframe\/YH8wQDi8/)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "supports pastebin embed link" do
|
21
|
-
expect(Onebox.preview('http://pastebin.com/embed/YH8wQDi8').to_s).to match(/pastebin.com\/embed_iframe\/YH8wQDi8/)
|
22
|
-
end
|
23
|
-
end
|