onebox 1.0.0

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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +476 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +3 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +92 -0
  11. data/Rakefile +22 -0
  12. data/lib/onebox.rb +33 -0
  13. data/lib/onebox/engine.rb +93 -0
  14. data/lib/onebox/engine/amazon_onebox.rb +25 -0
  15. data/lib/onebox/engine/bliptv_onebox.rb +26 -0
  16. data/lib/onebox/engine/clikthrough_onebox.rb +23 -0
  17. data/lib/onebox/engine/college_humor_onebox.rb +26 -0
  18. data/lib/onebox/engine/dailymotion_onebox.rb +26 -0
  19. data/lib/onebox/engine/dotsub_onebox.rb +25 -0
  20. data/lib/onebox/engine/example_onebox.rb +25 -0
  21. data/lib/onebox/engine/flickr_onebox.rb +25 -0
  22. data/lib/onebox/engine/funny_or_die_onebox.rb +26 -0
  23. data/lib/onebox/engine/html.rb +11 -0
  24. data/lib/onebox/engine/hulu_onebox.rb +26 -0
  25. data/lib/onebox/engine/nfb_onebox.rb +25 -0
  26. data/lib/onebox/engine/open_graph.rb +11 -0
  27. data/lib/onebox/engine/qik_onebox.rb +23 -0
  28. data/lib/onebox/engine/revision3_onebox.rb +26 -0
  29. data/lib/onebox/engine/slideshare_onebox.rb +25 -0
  30. data/lib/onebox/engine/sound_cloud_onebox.rb +25 -0
  31. data/lib/onebox/engine/stack_exchange_onebox.rb +23 -0
  32. data/lib/onebox/engine/ted_onebox.rb +25 -0
  33. data/lib/onebox/engine/viddler_onebox.rb +26 -0
  34. data/lib/onebox/engine/vimeo_onebox.rb +26 -0
  35. data/lib/onebox/engine/wikipedia_onebox.rb +24 -0
  36. data/lib/onebox/engine/yfrog_onebox.rb +25 -0
  37. data/lib/onebox/matcher.rb +13 -0
  38. data/lib/onebox/preview.rb +31 -0
  39. data/lib/onebox/version.rb +3 -0
  40. data/onebox.gemspec +36 -0
  41. data/spec/fixtures/amazon.response +3098 -0
  42. data/spec/fixtures/android.response +138 -0
  43. data/spec/fixtures/apple.response +391 -0
  44. data/spec/fixtures/bliptv.response +724 -0
  45. data/spec/fixtures/clickthrough.response +1472 -0
  46. data/spec/fixtures/clikthrough.response +1472 -0
  47. data/spec/fixtures/collegehumor.response +1272 -0
  48. data/spec/fixtures/dailymotion.response +575 -0
  49. data/spec/fixtures/dotsub.response +1257 -0
  50. data/spec/fixtures/example.response +50 -0
  51. data/spec/fixtures/flickr.response +1292 -0
  52. data/spec/fixtures/funnyordie.response +2010 -0
  53. data/spec/fixtures/gist.response +282 -0
  54. data/spec/fixtures/github_blob.response +706 -0
  55. data/spec/fixtures/github_commit.response +881 -0
  56. data/spec/fixtures/github_pullrequest.response +1619 -0
  57. data/spec/fixtures/hulu.response +339 -0
  58. data/spec/fixtures/image.response +0 -0
  59. data/spec/fixtures/imgur.response +892 -0
  60. data/spec/fixtures/kinomap.response +299 -0
  61. data/spec/fixtures/nfb.response +810 -0
  62. data/spec/fixtures/opengraph.response +27 -0
  63. data/spec/fixtures/qik.response +371 -0
  64. data/spec/fixtures/revision3.response +985 -0
  65. data/spec/fixtures/rottentomatoes_fresh.response +3275 -0
  66. data/spec/fixtures/rottentomatoes_incomplete.response +2313 -0
  67. data/spec/fixtures/rottentomatoes_rotten.response +3549 -0
  68. data/spec/fixtures/slideshare.response +1745 -0
  69. data/spec/fixtures/soundcloud.response +1409 -0
  70. data/spec/fixtures/stackexchange.response +1889 -0
  71. data/spec/fixtures/ted.response +1341 -0
  72. data/spec/fixtures/twitter.response +1712 -0
  73. data/spec/fixtures/viddler.response +442 -0
  74. data/spec/fixtures/video.response +0 -0
  75. data/spec/fixtures/vimeo.response +571 -0
  76. data/spec/fixtures/wikipedia.response +1236 -0
  77. data/spec/fixtures/wikipedia_redirected.response +899 -0
  78. data/spec/fixtures/yfrog.response +464 -0
  79. data/spec/lib/onebox/engine/amazon_spec.rb +34 -0
  80. data/spec/lib/onebox/engine/bliptv_spec.rb +34 -0
  81. data/spec/lib/onebox/engine/clikthrough_spec.rb +26 -0
  82. data/spec/lib/onebox/engine/college_humor_spec.rb +34 -0
  83. data/spec/lib/onebox/engine/dailymotion_spec.rb +36 -0
  84. data/spec/lib/onebox/engine/dotsub_spec.rb +36 -0
  85. data/spec/lib/onebox/engine/example_spec.rb +18 -0
  86. data/spec/lib/onebox/engine/flickr_spec.rb +30 -0
  87. data/spec/lib/onebox/engine/funny_or_die_spec.rb +34 -0
  88. data/spec/lib/onebox/engine/hulu_spec.rb +34 -0
  89. data/spec/lib/onebox/engine/nfb_spec.rb +35 -0
  90. data/spec/lib/onebox/engine/qik_spec.rb +35 -0
  91. data/spec/lib/onebox/engine/revision3_spec.rb +36 -0
  92. data/spec/lib/onebox/engine/slideshare_spec.rb +30 -0
  93. data/spec/lib/onebox/engine/sound_cloud_spec.rb +36 -0
  94. data/spec/lib/onebox/engine/stack_exchange_spec.rb +27 -0
  95. data/spec/lib/onebox/engine/ted_spec.rb +30 -0
  96. data/spec/lib/onebox/engine/viddler_spec.rb +36 -0
  97. data/spec/lib/onebox/engine/vimeo_spec.rb +34 -0
  98. data/spec/lib/onebox/engine/wikipedia_spec.rb +30 -0
  99. data/spec/lib/onebox/engine/yfrog_spec.rb +30 -0
  100. data/spec/lib/onebox/engine_spec.rb +78 -0
  101. data/spec/lib/onebox/matcher_spec.rb +20 -0
  102. data/spec/lib/onebox/preview_spec.rb +21 -0
  103. data/spec/lib/onebox_spec.rb +49 -0
  104. data/spec/spec_helper.rb +26 -0
  105. data/spec/support/html_spec_helper.rb +17 -0
  106. data/templates/amazon.handlebars +9 -0
  107. data/templates/bliptv.handlebars +10 -0
  108. data/templates/clickthrough.handlebars +8 -0
  109. data/templates/clikthrough.handlebars +8 -0
  110. data/templates/collegehumor.handlebars +9 -0
  111. data/templates/dailymotion.handlebars +9 -0
  112. data/templates/dotsub.handlebars +9 -0
  113. data/templates/flickr.handlebars +8 -0
  114. data/templates/funnyordie.handlebars +9 -0
  115. data/templates/hulu.handlebars +9 -0
  116. data/templates/nfb.handlebars +8 -0
  117. data/templates/qik.handlebars +7 -0
  118. data/templates/revision3.handlebars +9 -0
  119. data/templates/slideshare.handlebars +8 -0
  120. data/templates/soundcloud.handlebars +9 -0
  121. data/templates/stackexchange.handlebars +7 -0
  122. data/templates/ted.handlebars +8 -0
  123. data/templates/viddler.handlebars +9 -0
  124. data/templates/vimeo.handlebars +9 -0
  125. data/templates/wikipedia.handlebars +8 -0
  126. data/templates/yfrog.handlebars +8 -0
  127. metadata +447 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88403edb6cdc6198f956ebbbfa444ab6855098df
4
+ data.tar.gz: 0dbd27e20e524df654834fdfac709b3590cad2d2
5
+ SHA512:
6
+ metadata.gz: d5f8f6bcc6892fc0e6dff02e6264db3f8be631004353cf63ca2a6dbc0b07f07843549a4180a895a64c98b8a87be451e23b1520306485e3c5a73fd3b9d2b6acfb
7
+ data.tar.gz: 56927cce2f14d3b7149352f78ebfe3f8e91131fc1c17896f78855bf97924022b38ae373ef1ef2cb26855409c9b215a824b1943c198b71b72689323b778bb77a5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,476 @@
1
+ AllCops:
2
+ # Include gemspec and Rakefile
3
+ Includes:
4
+ - '**/*.gemspec'
5
+ - '**/Rakefile'
6
+ Excludes: []
7
+
8
+ # Use UTF-8 as the source file encoding.
9
+ Encoding:
10
+ Enabled: true
11
+
12
+ # Limit lines to 79 characters.
13
+ LineLength:
14
+ Enabled: true
15
+ Max: 180
16
+
17
+ # Avoid methods longer than 10 lines of code
18
+ MethodLength:
19
+ Enabled: true
20
+ CountComments: false # count full line comments?
21
+ Max: 10
22
+
23
+ # No hard tabs.
24
+ Tab:
25
+ Enabled: true
26
+
27
+ # Avoid trailing whitespace.
28
+ TrailingWhitespace:
29
+ Enabled: true
30
+
31
+ # Indent when as deep as case.
32
+ CaseIndentation:
33
+ Enabled: true
34
+
35
+ # Use empty lines between defs.
36
+ EmptyLineBetweenDefs:
37
+ Enabled: true
38
+
39
+ # Don't use several empty lines in a row.
40
+ EmptyLines:
41
+ Enabled: true
42
+
43
+ # Use spaces around operators.
44
+ SpaceAroundOperators:
45
+ Enabled: true
46
+
47
+ # Use spaces around { and before }.
48
+ SpaceAroundBraces:
49
+ Enabled: true
50
+
51
+ # No spaces after ( or before ).
52
+ SpaceInsideParens:
53
+ Enabled: true
54
+
55
+ # No spaces after [ or before ].
56
+ SpaceInsideBrackets:
57
+ Enabled: true
58
+
59
+ # Use spaces after commas.
60
+ SpaceAfterComma:
61
+ Enabled: true
62
+
63
+ # Use spaces after semicolons.
64
+ SpaceAfterSemicolon:
65
+ Enabled: true
66
+
67
+ # Use spaces after colons.
68
+ SpaceAfterColon:
69
+ Enabled: true
70
+
71
+ # Use spaces after if/elsif/unless/while/until/case/when.
72
+ SpaceAfterControlKeyword:
73
+ Enabled: true
74
+
75
+ # Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
76
+ # { :a => 1, :b => 2 }.
77
+ HashSyntax:
78
+ Enabled: true
79
+
80
+ # Use Unix-style line endings.
81
+ EndOfLine:
82
+ Enabled: true
83
+
84
+ # Add underscores to large numeric literals to improve their readability.
85
+ NumericLiterals:
86
+ Enabled: true
87
+
88
+ # Align the parameters of a method call if they span more than one line.
89
+ AlignParameters:
90
+ Enabled: true
91
+
92
+ # Use def with parentheses when there are arguments.
93
+ DefWithParentheses:
94
+ Enabled: true
95
+
96
+ # Omit the parentheses when the method doesn't accept any arguments.
97
+ DefWithoutParentheses:
98
+ Enabled: true
99
+
100
+ # Never use if x; .... Use the ternary operator instead.
101
+ IfWithSemicolon:
102
+ Enabled: true
103
+
104
+ # Never use then for multi-line if/unless.
105
+ MultilineIfThen:
106
+ Enabled: true
107
+
108
+ # Favor the ternary operator(?:) over if/then/else/end constructs.
109
+ OneLineConditional:
110
+ Enabled: true
111
+
112
+ # Avoid using {...} for multi-line blocks (multiline chaining is always ugly).
113
+ # Prefer {...} over do...end for single-line blocks.
114
+ Blocks:
115
+ Enabled: true
116
+
117
+ # Avoid parameter lists longer than three or four parameters.
118
+ ParameterLists:
119
+ Enabled: true
120
+ Max: 5
121
+ CountKeywordArgs: true
122
+
123
+
124
+ # Prefer ' strings when you don't need string interpolation or special symbols.
125
+ StringLiterals:
126
+ Enabled: false
127
+
128
+ # Avoid multi-line ?: (the ternary operator); use if/unless instead.
129
+ MultilineTernaryOperator:
130
+ Enabled: true
131
+
132
+ # Use one expression per branch in a ternary operator.
133
+ NestedTernaryOperator:
134
+ Enabled: true
135
+
136
+ # Never use unless with else. Rewrite these with the positive case first.
137
+ UnlessElse:
138
+ Enabled: true
139
+
140
+ # Use &&/|| instead of and/or.
141
+ AndOr:
142
+ Enabled: true
143
+
144
+ # Use when x then ... for one-line cases.
145
+ WhenThen:
146
+ Enabled: true
147
+
148
+ # Favor modifier if/unless usage when you have a single-line body.
149
+ IfUnlessModifier:
150
+ Enabled: true
151
+
152
+ # Favor modifier while/until usage when you have a single-line body.
153
+ WhileUntilModifier:
154
+ Enabled: true
155
+
156
+ # Favor unless over if for negative conditions (or control flow or).
157
+ FavorUnlessOverNegatedIf:
158
+ Enabled: true
159
+
160
+ # Favor until over while for negative conditions.
161
+ FavorUntilOverNegatedWhile:
162
+ Enabled: true
163
+
164
+ # Use spaces around the = operator when assigning default values in def params.
165
+ SpaceAroundEqualsInParameterDefault:
166
+ Enabled: false
167
+
168
+ # Use the new lambda literal syntax for single-line blocks.
169
+ Lambda:
170
+ Enabled: true
171
+
172
+ # Use proc instead of Proc.new.
173
+ Proc:
174
+ Enabled: true
175
+
176
+ # Don't use parentheses around the condition of an if/unless/while.
177
+ ParenthesesAroundCondition:
178
+ Enabled: true
179
+ AllowSafeAssignment: true
180
+
181
+ # Use snake_case for symbols, methods and variables.
182
+ MethodAndVariableSnakeCase:
183
+ Enabled: true
184
+
185
+ # Use CamelCase for classes and modules.
186
+ ClassAndModuleCamelCase:
187
+ Enabled: true
188
+
189
+ # Preferred collection methods.
190
+ CollectionMethods:
191
+ Enabled: true
192
+ PreferredMethods:
193
+ collect: 'map'
194
+ inject: 'reduce'
195
+ detect: 'find'
196
+ find_all: 'select'
197
+
198
+ # Prefer each over for.
199
+ AvoidFor:
200
+ Enabled: true
201
+
202
+ # Avoid Perl-style global variables.
203
+ AvoidPerlisms:
204
+ Enabled: true
205
+
206
+ # Avoid Perl-style regex back references.
207
+ AvoidPerlBackrefs:
208
+ Enabled: true
209
+
210
+ # Avoid the use of class variables.
211
+ AvoidClassVars:
212
+ Enabled: true
213
+
214
+ # Don't interpolate global, instance and class variables directly in strings.
215
+ VariableInterpolation:
216
+ Enabled: true
217
+
218
+ # Don't use semicolons to terminate expressions.
219
+ Semicolon:
220
+ Enabled: true
221
+ # For example; def area(height, width); height * width end
222
+ AllowAfterParameterListInOneLineMethods: false
223
+ # For example; def area(height, width) height * width; end
224
+ AllowBeforeEndInOneLineMethods: true
225
+
226
+ # Use sprintf instead of String#%.
227
+ FavorSprintf:
228
+ Enabled: true
229
+
230
+ # Use Array#join instead of Array#*.
231
+ FavorJoin:
232
+ Enabled: true
233
+
234
+ # Use alias_method instead of alias.
235
+ Alias:
236
+ Enabled: true
237
+
238
+ # Use ! instead of not.
239
+ Not:
240
+ Enabled: true
241
+
242
+ # Avoid using rescue in its modifier form.
243
+ RescueModifier:
244
+ Enabled: true
245
+
246
+ # Never use return in an ensure block.
247
+ EnsureReturn:
248
+ Enabled: true
249
+
250
+ # Don't suppress exception.
251
+ HandleExceptions:
252
+ Enabled: true
253
+
254
+ # Use only ascii symbols in identifiers.
255
+ AsciiIdentifiers:
256
+ Enabled: true
257
+
258
+ # Use only ascii symbols in comments.
259
+ AsciiComments:
260
+ Enabled: true
261
+
262
+ # Do not use block comments.
263
+ BlockComments:
264
+ Enabled: true
265
+
266
+ # Avoid rescuing the Exception class.
267
+ RescueException:
268
+ Enabled: true
269
+
270
+ # Prefer literals to Array.new/Hash.new/String.new.
271
+ EmptyLiteral:
272
+ Enabled: true
273
+
274
+ # When defining binary operators, name the argument other.
275
+ OpMethod:
276
+ Enabled: true
277
+
278
+ # Name reduce arguments |a, e| (accumulator, element)
279
+ ReduceArguments:
280
+ Enabled: true
281
+
282
+ # Use %r for regular expressions matching more than `MaxSlashes` '/'
283
+ # characters.
284
+ # Use %r only for regular expressions matching more than `MaxSlashes` '/'
285
+ # character.
286
+ RegexpLiteral:
287
+ Enabled: true
288
+ MaxSlashes: 1
289
+
290
+ # Use self when defining module/class methods.
291
+ ClassMethods:
292
+ Enabled: true
293
+
294
+ # Avoid single-line methods.
295
+ SingleLineMethods:
296
+ Enabled: true
297
+ AllowIfMethodIsEmpty: true
298
+
299
+ # Use %w or %W for arrays of words.
300
+ WordArray:
301
+ Enabled: true
302
+
303
+ # Use spaces inside hash literal braces - or don't.
304
+ SpaceInsideHashLiteralBraces:
305
+ Enabled: true
306
+ EnforcedStyleIsWithSpaces: true
307
+
308
+ # Avoid the use of line continuation (/).
309
+ LineContinuation:
310
+ Enabled: true
311
+
312
+ # Prefer attr_* methods to trivial readers/writers.
313
+ # TrivialAccessors doesn't require exact name matches and doesn't allow
314
+ # predicated methods by default.
315
+ TrivialAccessors:
316
+ Enabled: true
317
+ ExactNameMatch: true # this is not the best way, but currently rubocop does not support something better https://github.com/bbatsov/rubocop/issues/421
318
+ AllowPredicates: false
319
+
320
+ # Comments should start with a space.
321
+ LeadingCommentSpace:
322
+ Enabled: true
323
+
324
+ # Do not use :: for method call.
325
+ ColonMethodCall:
326
+ Enabled: true
327
+
328
+ # Do not introduce global variables.
329
+ AvoidGlobalVars:
330
+ Enabled: true
331
+
332
+ # The use of eval represents a serious security risk.
333
+ Eval:
334
+ Enabled: true
335
+
336
+ # Symbol literals should use snake_case.
337
+ SymbolName:
338
+ Enabled: true
339
+ AllowCamelCase: false
340
+
341
+
342
+ # Constants should use SCREAMING_SNAKE_CASE.
343
+ ConstantName:
344
+ Enabled: true
345
+
346
+ # Indent private/protected as deep as defs and keep blank lines around them.
347
+ AccessControl:
348
+ Enabled: true
349
+
350
+ # Use Kernel#loop with break rather than begin/end/until or begin/end/while for
351
+ # post-loop tests.
352
+ Loop:
353
+ Enabled: true
354
+
355
+ # Avoid excessive block nesting
356
+ BlockNesting:
357
+ Enabled: true
358
+ Max: 3
359
+
360
+ # Avoid explicit use of the case equality operator(===).
361
+ CaseEquality:
362
+ Enabled: true
363
+
364
+ # Document classes and non-namespace modules.
365
+ Documentation:
366
+ Enabled: false
367
+
368
+ # Do not use parentheses for method calls with no arguments.
369
+ MethodCallParentheses:
370
+ Enabled: true
371
+
372
+ # Checks for redundant do after while or until.
373
+ WhileUntilDo:
374
+ Enabled: true
375
+
376
+ # Checks for uses of character literals.
377
+ CharacterLiteral:
378
+ Enabled: true
379
+
380
+ # Avoid the use of BEGIN blocks.
381
+ BeginBlock:
382
+ Enabled: true
383
+
384
+ # Avoid the use of END blocks.
385
+ EndBlock:
386
+ Enabled: true
387
+
388
+ # Don't use return where it's not required.
389
+ RedundantReturn:
390
+ Enabled: true
391
+
392
+ # Don't use begin blocks when they are not needed.
393
+ RedundantBegin:
394
+ Enabled: true
395
+
396
+ # Don't use self where it's not needed.
397
+ RedundantSelf:
398
+ Enabled: true
399
+
400
+ # Checks the position of the dot in multi-line method calls.
401
+ DotPosition:
402
+ Enabled: true
403
+ Style: 'leading'
404
+
405
+ # Checks for uses of Module#attr.
406
+ Attr:
407
+ Enabled: true
408
+
409
+ #################### Lint ################################
410
+
411
+ # Don't use assignment in conditions.
412
+ AssignmentInCondition:
413
+ Enabled: true
414
+ AllowSafeAssignment: true
415
+
416
+
417
+ # Align ends correctly.
418
+ EndAlignment:
419
+ Enabled: true
420
+
421
+ # Align block ends correctly.
422
+ BlockAlignment:
423
+ Enabled: true
424
+
425
+ # Possible use of operator/literal/variable in void context.
426
+ Void:
427
+ Enabled: true
428
+
429
+ # Unreachable code.
430
+ UnreachableCode:
431
+ Enabled: true
432
+
433
+ # Unused local variable.
434
+ UnusedLocalVariable:
435
+ Enabled: true
436
+
437
+ # Do not use the same name as outer local variable
438
+ # for block arguments or block local variables.
439
+ ShadowingOuterLocalVariable:
440
+ Enabled: true
441
+
442
+ # END blocks should not be placed inside method definitions.
443
+ EndInMethod:
444
+ Enabled: true
445
+
446
+ # Checks of literals used in conditions.
447
+ LiteralInCondition:
448
+ Enabled: true
449
+
450
+ # Checks for empty ensure block.
451
+ EmptyEnsure:
452
+ Enabled: true
453
+
454
+ # Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
455
+ CommentAnnotation:
456
+ Enabled: true
457
+ Keywords:
458
+ - TODO
459
+ - FIXME
460
+ - OPTIMIZE
461
+ - HACK
462
+ - REVIEW
463
+
464
+ # Checks for useless assignment to a local variable.
465
+ UselessAssignment:
466
+ Enabled: true
467
+
468
+ # Checks for comparison of something with itself.
469
+ UselessComparison:
470
+ Enabled: true
471
+
472
+ ##################### Rails ##################################
473
+
474
+ # Use sexy validations.
475
+ Validation:
476
+ Enabled: true