onebox 1.2.9 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/engine.rb +2 -0
- data/lib/onebox/engine/amazon_onebox.rb +2 -6
- data/lib/onebox/engine/audio_onebox.rb +15 -0
- data/lib/onebox/engine/github_blob_onebox.rb +16 -11
- data/lib/onebox/engine/video_onebox.rb +14 -0
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +11 -2
- data/lib/onebox/engine/wikipedia_onebox.rb +9 -8
- data/lib/onebox/engine/youtube_onebox.rb +3 -2
- data/lib/onebox/matcher.rb +4 -0
- data/lib/onebox/version.rb +1 -1
- data/spec/fixtures/wikipedia.response +314 -984
- data/spec/lib/onebox/engine/wikipedia_onebox_spec.rb +3 -3
- data/spec/lib/onebox/matcher_spec.rb +38 -0
- data/spec/lib/onebox/preview_spec.rb +2 -2
- data/spec/lib/onebox_spec.rb +1 -1
- data/templates/githubblob.mustache +1 -1
- metadata +44 -42
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Onebox::Engine::WikipediaOnebox do
|
4
4
|
before(:all) do
|
5
|
-
@link = "http://en.wikipedia.org/wiki/
|
5
|
+
@link = "http://en.wikipedia.org/wiki/Billy_Jack"
|
6
6
|
end
|
7
7
|
|
8
8
|
include_context "engines"
|
@@ -10,11 +10,11 @@ describe Onebox::Engine::WikipediaOnebox do
|
|
10
10
|
|
11
11
|
describe "#to_html" do
|
12
12
|
it "includes article image" do
|
13
|
-
expect(html).to include("
|
13
|
+
expect(html).to include("Billy_Jack_poster.jpg")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "includes summary" do
|
17
|
-
expect(html).to include("
|
17
|
+
expect(html).to include("Billy Jack is a 1971 action/drama")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,5 +1,43 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
+
class TestEngine
|
4
|
+
def self.===(uri)
|
5
|
+
true
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
describe Onebox::Matcher do
|
4
10
|
|
11
|
+
describe "oneboxed" do
|
12
|
+
|
13
|
+
describe "with a path" do
|
14
|
+
let(:url) { "http://party.time.made.up-url.com/beep/boop" }
|
15
|
+
let(:matcher) { Onebox::Matcher.new(url) }
|
16
|
+
|
17
|
+
it "finds an engine" do
|
18
|
+
matcher.stubs(:ordered_engines).returns([TestEngine])
|
19
|
+
matcher.oneboxed.should_not be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "without a path" do
|
24
|
+
let(:url) { "http://party.time.made.up-url.com/" }
|
25
|
+
let(:matcher) { Onebox::Matcher.new(url) }
|
26
|
+
|
27
|
+
it "doesn't find an engine" do
|
28
|
+
matcher.stubs(:ordered_engines).returns([TestEngine])
|
29
|
+
matcher.oneboxed.should be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "without a path but has a query string" do
|
34
|
+
let(:url) { "http://party.time.made.up-url.com/?article_id=1234" }
|
35
|
+
let(:matcher) { Onebox::Matcher.new(url) }
|
36
|
+
|
37
|
+
it "it finds an engine" do
|
38
|
+
matcher.stubs(:ordered_engines).returns([TestEngine])
|
39
|
+
matcher.oneboxed.should_not be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
5
43
|
end
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Onebox::Preview do
|
4
4
|
|
5
5
|
before do
|
6
|
-
fake("http://www.amazon.com", response("amazon"))
|
6
|
+
fake("http://www.amazon.com/product", response("amazon"))
|
7
7
|
FakeWeb.register_uri(:get, "http://www.amazon.com/404-url", status: 404)
|
8
8
|
FakeWeb.register_uri(:get, "http://www.amazon.com/500-url", status: 500)
|
9
9
|
FakeWeb.register_uri(:get, "http://www.amazon.com/error-url", status: 500)
|
@@ -12,7 +12,7 @@ describe Onebox::Preview do
|
|
12
12
|
FakeWeb.register_uri(:get, "http://www.amazon.com/error-connecting", exception: Errno::ECONNREFUSED)
|
13
13
|
end
|
14
14
|
|
15
|
-
let(:preview) { described_class.new("http://www.amazon.com") }
|
15
|
+
let(:preview) { described_class.new("http://www.amazon.com/product") }
|
16
16
|
|
17
17
|
describe "#to_s" do
|
18
18
|
it "returns some html if given a valid url" do
|
data/spec/lib/onebox_spec.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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,230 +10,230 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '1.7'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '1.7'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: mustache
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '0.99'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0.99'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: nokogiri
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 1.6.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ~>
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 1.6.1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: hexpress
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ~>
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '1.2'
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '1.2'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: moneta
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0.7'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ~>
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0.7'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: bundler
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ~>
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '1.3'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ~>
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '1.3'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: rake
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ~>
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '10.0'
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '10.0'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rspec
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ~>
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '2.14'
|
120
120
|
type: :development
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - ~>
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '2.14'
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: coveralls
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0.6'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- -
|
138
|
+
- - ~>
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0.6'
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: yard
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- -
|
145
|
+
- - ~>
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0.8'
|
148
148
|
type: :development
|
149
149
|
prerelease: false
|
150
150
|
version_requirements: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- -
|
152
|
+
- - ~>
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0.8'
|
155
155
|
- !ruby/object:Gem::Dependency
|
156
156
|
name: fakeweb
|
157
157
|
requirement: !ruby/object:Gem::Requirement
|
158
158
|
requirements:
|
159
|
-
- -
|
159
|
+
- - ~>
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '1.3'
|
162
162
|
type: :development
|
163
163
|
prerelease: false
|
164
164
|
version_requirements: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
|
-
- -
|
166
|
+
- - ~>
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '1.3'
|
169
169
|
- !ruby/object:Gem::Dependency
|
170
170
|
name: pry
|
171
171
|
requirement: !ruby/object:Gem::Requirement
|
172
172
|
requirements:
|
173
|
-
- -
|
173
|
+
- - ~>
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0.9'
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
178
|
version_requirements: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
|
-
- -
|
180
|
+
- - ~>
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0.9'
|
183
183
|
- !ruby/object:Gem::Dependency
|
184
184
|
name: mocha
|
185
185
|
requirement: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
|
-
- -
|
187
|
+
- - ~>
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0.14'
|
190
190
|
type: :development
|
191
191
|
prerelease: false
|
192
192
|
version_requirements: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
|
-
- -
|
194
|
+
- - ~>
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0.14'
|
197
197
|
- !ruby/object:Gem::Dependency
|
198
198
|
name: rubocop
|
199
199
|
requirement: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
|
-
- -
|
201
|
+
- - ~>
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0.11'
|
204
204
|
type: :development
|
205
205
|
prerelease: false
|
206
206
|
version_requirements: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
|
-
- -
|
208
|
+
- - ~>
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0.11'
|
211
211
|
- !ruby/object:Gem::Dependency
|
212
212
|
name: twitter
|
213
213
|
requirement: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
|
-
- -
|
215
|
+
- - ~>
|
216
216
|
- !ruby/object:Gem::Version
|
217
217
|
version: '4.8'
|
218
218
|
type: :development
|
219
219
|
prerelease: false
|
220
220
|
version_requirements: !ruby/object:Gem::Requirement
|
221
221
|
requirements:
|
222
|
-
- -
|
222
|
+
- - ~>
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '4.8'
|
225
225
|
- !ruby/object:Gem::Dependency
|
226
226
|
name: guard-rspec
|
227
227
|
requirement: !ruby/object:Gem::Requirement
|
228
228
|
requirements:
|
229
|
-
- -
|
229
|
+
- - ~>
|
230
230
|
- !ruby/object:Gem::Version
|
231
231
|
version: 4.2.8
|
232
232
|
type: :development
|
233
233
|
prerelease: false
|
234
234
|
version_requirements: !ruby/object:Gem::Requirement
|
235
235
|
requirements:
|
236
|
-
- -
|
236
|
+
- - ~>
|
237
237
|
- !ruby/object:Gem::Version
|
238
238
|
version: 4.2.8
|
239
239
|
- !ruby/object:Gem::Dependency
|
@@ -259,11 +259,11 @@ executables: []
|
|
259
259
|
extensions: []
|
260
260
|
extra_rdoc_files: []
|
261
261
|
files:
|
262
|
-
-
|
263
|
-
-
|
264
|
-
-
|
265
|
-
-
|
266
|
-
-
|
262
|
+
- .gitignore
|
263
|
+
- .rspec
|
264
|
+
- .rubocop.yml
|
265
|
+
- .ruby-gemset
|
266
|
+
- .travis.yml
|
267
267
|
- Gemfile
|
268
268
|
- Guardfile
|
269
269
|
- LICENSE.txt
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- lib/onebox.rb
|
273
273
|
- lib/onebox/engine.rb
|
274
274
|
- lib/onebox/engine/amazon_onebox.rb
|
275
|
+
- lib/onebox/engine/audio_onebox.rb
|
275
276
|
- lib/onebox/engine/classic_google_maps_onebox.rb
|
276
277
|
- lib/onebox/engine/github_blob_onebox.rb
|
277
278
|
- lib/onebox/engine/github_commit_onebox.rb
|
@@ -285,6 +286,7 @@ files:
|
|
285
286
|
- lib/onebox/engine/stack_exchange_onebox.rb
|
286
287
|
- lib/onebox/engine/standard_embed.rb
|
287
288
|
- lib/onebox/engine/twitter_status_onebox.rb
|
289
|
+
- lib/onebox/engine/video_onebox.rb
|
288
290
|
- lib/onebox/engine/whitelisted_generic_onebox.rb
|
289
291
|
- lib/onebox/engine/wikipedia_onebox.rb
|
290
292
|
- lib/onebox/engine/youtube_onebox.rb
|
@@ -354,17 +356,17 @@ require_paths:
|
|
354
356
|
- lib
|
355
357
|
required_ruby_version: !ruby/object:Gem::Requirement
|
356
358
|
requirements:
|
357
|
-
- -
|
359
|
+
- - '>='
|
358
360
|
- !ruby/object:Gem::Version
|
359
361
|
version: '0'
|
360
362
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
361
363
|
requirements:
|
362
|
-
- -
|
364
|
+
- - '>='
|
363
365
|
- !ruby/object:Gem::Version
|
364
366
|
version: '0'
|
365
367
|
requirements: []
|
366
368
|
rubyforge_project:
|
367
|
-
rubygems_version: 2.
|
369
|
+
rubygems_version: 2.0.6
|
368
370
|
signing_key:
|
369
371
|
specification_version: 4
|
370
372
|
summary: A gem for turning URLs into previews.
|