ruby-oembed 0.10.0 → 0.10.1

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.
@@ -0,0 +1,44 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+ require 'support/shared_examples_for_providers'
3
+
4
+ describe 'OEmbed::Providers::Twitter' do
5
+ before(:all) do
6
+ VCR.insert_cassette('OEmbed_Providers_Twitter')
7
+ end
8
+ after(:all) do
9
+ VCR.eject_cassette
10
+ end
11
+
12
+ include OEmbedSpecHelper
13
+
14
+ let(:provider_class) { OEmbed::Providers::Twitter }
15
+
16
+ expected_valid_urls = %w(
17
+ https://twitter.com/RailsGirlsSoC/status/702136612822634496
18
+ https://www.twitter.com/bpoweski/status/71633762
19
+ )
20
+ expected_invalid_urls = %w(
21
+ http://twitter.com/RailsGirlsSoC/status/702136612822634496
22
+ https://twitter.es/FCBarcelona_es/status/734194638697959424
23
+ )
24
+
25
+ it_should_behave_like(
26
+ "an OEmbed::Proviers instance",
27
+ expected_valid_urls,
28
+ expected_invalid_urls
29
+ )
30
+
31
+ context "using XML" do
32
+ expected_valid_urls.each do |valid_url|
33
+ context "given the valid URL #{valid_url}" do
34
+ describe ".get" do
35
+ it "should encounter a 400 error" do
36
+ expect {
37
+ provider_class.get(valid_url, :format=>:xml)
38
+ }.to raise_error(OEmbed::UnknownResponse, /\b400\b/)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,15 @@
1
1
  require 'rubygems'
2
+
2
3
  require 'vcr'
4
+ VCR.config do |c|
5
+ c.default_cassette_options = { :record => :new_episodes }
6
+ c.cassette_library_dir = 'spec/cassettes'
7
+ c.stub_with :fakeweb
8
+ end
9
+
10
+ require 'coveralls'
11
+ Coveralls.wear!
12
+
3
13
  require File.dirname(__FILE__) + '/../lib/oembed'
4
14
 
5
15
  RSpec.configure do |config|
@@ -0,0 +1,39 @@
1
+ RSpec.shared_examples "an OEmbed::Proviers instance" do |expected_valid_urls, expected_invalid_urls|
2
+ expected_valid_urls.each do |valid_url|
3
+ context "given the valid URL #{valid_url}" do
4
+ describe ".include?" do
5
+ it "should be true" do
6
+ expect(provider_class.include?(valid_url)).to be_truthy
7
+ end
8
+ end
9
+
10
+ describe ".get" do
11
+ it "should return a response" do
12
+ response = nil
13
+ expect {
14
+ response = provider_class.get(valid_url)
15
+ }.to_not raise_error
16
+ expect(response).to be_a(OEmbed::Response)
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ expected_invalid_urls.each do |invalid_url|
23
+ context "given the invalid URL #{invalid_url}" do
24
+ describe ".include?" do
25
+ it "should be false" do
26
+ expect(provider_class.include?(invalid_url)).to be_falsey
27
+ end
28
+ end
29
+
30
+ describe ".get" do
31
+ it "should not find a response" do
32
+ expect {
33
+ provider_class.get(invalid_url)
34
+ }.to raise_error(OEmbed::NotFound)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-oembed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Holm
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-19 00:00:00.000000000 Z
14
+ date: 2016-05-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -114,14 +114,14 @@ dependencies:
114
114
  description: An oEmbed consumer library written in Ruby, letting you easily get embeddable
115
115
  HTML representations of supported web pages, based on their URLs. See http://oembed.com
116
116
  for more information about the protocol.
117
- email: arisbartee@gmail.com
117
+ email: webmaster@wrightkuhns.com
118
118
  executables: []
119
119
  extensions: []
120
120
  extra_rdoc_files:
121
121
  - CHANGELOG.rdoc
122
- - README.rdoc
123
122
  - LICENSE
124
123
  files:
124
+ - ".coveralls.yml"
125
125
  - ".gitignore"
126
126
  - ".travis.yml"
127
127
  - ".yardopts"
@@ -129,7 +129,7 @@ files:
129
129
  - Gemfile
130
130
  - Guardfile
131
131
  - LICENSE
132
- - README.rdoc
132
+ - README.md
133
133
  - Rakefile
134
134
  - integration_test/test.rb
135
135
  - integration_test/test_urls.csv
@@ -162,6 +162,8 @@ files:
162
162
  - ruby-oembed.gemspec
163
163
  - spec/cassettes/OEmbed_Provider.yml
164
164
  - spec/cassettes/OEmbed_ProviderDiscovery.yml
165
+ - spec/cassettes/OEmbed_Providers_Slideshare.yml
166
+ - spec/cassettes/OEmbed_Providers_Twitter.yml
165
167
  - spec/formatter/ducktype_backend_spec.rb
166
168
  - spec/formatter/json/.DS_Store
167
169
  - spec/formatter/json/jsongem_backend_spec.rb
@@ -172,11 +174,14 @@ files:
172
174
  - spec/formatter_spec.rb
173
175
  - spec/provider_discovery_spec.rb
174
176
  - spec/provider_spec.rb
177
+ - spec/providers/slideshare_spec.rb
178
+ - spec/providers/twitter_spec.rb
175
179
  - spec/providers_spec.rb
176
180
  - spec/response_spec.rb
177
181
  - spec/spec_helper.rb
178
182
  - spec/spec_helper_examples.yml
179
- homepage: http://github.com/judofyr/ruby-oembed
183
+ - spec/support/shared_examples_for_providers.rb
184
+ homepage: https://github.com/ruby-oembed/ruby-oembed
180
185
  licenses:
181
186
  - MIT
182
187
  metadata: {}
@@ -185,7 +190,7 @@ rdoc_options:
185
190
  - "--main"
186
191
  - README.rdoc
187
192
  - "--title"
188
- - ruby-oembed-0.10.0
193
+ - ruby-oembed-0.10.1
189
194
  - "--inline-source"
190
195
  - "--exclude"
191
196
  - tasks
@@ -204,13 +209,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
209
  version: '0'
205
210
  requirements: []
206
211
  rubyforge_project:
207
- rubygems_version: 2.4.7
212
+ rubygems_version: 2.5.1
208
213
  signing_key:
209
214
  specification_version: 3
210
215
  summary: oEmbed for Ruby
211
216
  test_files:
212
217
  - spec/cassettes/OEmbed_Provider.yml
213
218
  - spec/cassettes/OEmbed_ProviderDiscovery.yml
219
+ - spec/cassettes/OEmbed_Providers_Slideshare.yml
220
+ - spec/cassettes/OEmbed_Providers_Twitter.yml
214
221
  - spec/formatter/ducktype_backend_spec.rb
215
222
  - spec/formatter/json/.DS_Store
216
223
  - spec/formatter/json/jsongem_backend_spec.rb
@@ -221,7 +228,10 @@ test_files:
221
228
  - spec/formatter_spec.rb
222
229
  - spec/provider_discovery_spec.rb
223
230
  - spec/provider_spec.rb
231
+ - spec/providers/slideshare_spec.rb
232
+ - spec/providers/twitter_spec.rb
224
233
  - spec/providers_spec.rb
225
234
  - spec/response_spec.rb
226
235
  - spec/spec_helper.rb
227
236
  - spec/spec_helper_examples.yml
237
+ - spec/support/shared_examples_for_providers.rb
data/README.rdoc DELETED
@@ -1,87 +0,0 @@
1
- = ruby-oembed http://stillmaintained.com/metavida/ruby-oembed.png
2
-
3
- An oEmbed consumer library written in Ruby, letting you easily get embeddable HTML representations of supported web pages, based on their URLs. See {oembed.com}[http://oembed.com] for more about the protocol.
4
-
5
- = Installation
6
-
7
- gem install ruby-oembed
8
-
9
- = Get Started
10
-
11
- == Providers
12
-
13
- Get information about a URL via an OEmbed::Provider. This library comes with many Providers built right in, to make your life easy.
14
-
15
- resource = OEmbed::Providers::Youtube.get("http://www.youtube.com/watch?v=2BYXBC8WQ5k")
16
- resource.video? #=> true
17
- resource.thumbnail_url #=> "http://i3.ytimg.com/vi/2BYXBC8WQ5k/hqdefault.jpg"
18
- resource.html #=> <<-HTML
19
- <object width="425" height="344">
20
- <param name="movie" value="http://www.youtube.com/v/2BYXBC8WQ5k?fs=1"></param>
21
- <param name="allowFullScreen" value="true"></param>
22
- <param name="allowscriptaccess" value="always"></param>
23
- <embed src="http://www.youtube.com/v/2BYXBC8WQ5k?fs=1" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"></embed>
24
- </object>
25
- HTML
26
-
27
- If you'd like to use a provider that isn't included in the library, it's easy to create one. Just provide the oEmbed API endpoint and URL scheme(s).
28
-
29
- my_provider = OEmbed::Provider.new("http://my.cool-service.com/api/oembed_endpoint.{format}")
30
- my_provider << "http://*.cool-service.com/image/*"
31
- my_provider << "http://*.cool-service.com/video/*"
32
- resource = my_provider.get("http://a.cool-service.com/video/1") #=> OEmbed::Response
33
- resource.provider.name #=> "My Cool Service"
34
-
35
- To use multiple Providers at once, simply register them.
36
-
37
- OEmbed::Providers.register(OEmbed::Providers::Youtube, my_provider)
38
- resource = OEmbed::Providers.get("http://www.youtube.com/watch?v=2BYXBC8WQ5k") #=> OEmbed::Response
39
- resource.type #=> "video"
40
- resource.provider.name #=> "Youtube"
41
-
42
- Last but not least, ruby-oembed supports both {oohEmbed}[http://oohembed.com] and {Embedly}[http://embed.ly]. These services are provider aggregators. Each supports a wide array of websites ranging from {Amazon.com}[http://www.amazon.com] to {xkcd}[http://www.xkcd.com].
43
-
44
- == Formatters
45
-
46
- This library works wonderfully on its own, but can get a speed boost by using 3rd party libraries to parse oEmbed data. To use a 3rd party Formatter, just be sure to require the library _before_ ruby-oembed.
47
-
48
- require 'json'
49
- require 'xmlsimple'
50
- require 'oembed'
51
-
52
- OEmbed::Formatter::JSON.backend #=> OEmbed::Formatter::JSON::Backends::JSONGem
53
- OEmbed::Formatter::XML.backend #=> OEmbed::Formatter::XML::Backends::XmlSimple
54
-
55
- The following, optional, backends are currently supported:
56
- * The {JSON implementation for Ruby}[http://flori.github.com/json/]
57
- * Rails' ActiveSupport::JSON (confirmed to work with Rails 3.0.x and should work with Rails 2.0+)
58
- * {XmlSimple}[http://xml-simple.rubyforge.org/]
59
-
60
- = Lend a Hand
61
-
62
- Code for the ruby-oembed library is {hosted on GitHub}[https://github.com/judofyr/ruby-oembed].
63
-
64
- # Get the code.
65
- git clone git://github.com/judofyr/ruby-oembed.git
66
- cd ruby-oembed
67
- # Install all development-related gems.
68
- gem install bundler
69
- bundle install
70
- # Run the tests.
71
- bundle exec rake
72
- # or run the test continually
73
- bundle exec guard
74
-
75
- If you encounter any bug, feel free to {create an Issue}[https://github.com/judofyr/ruby-oembed/issues].
76
-
77
- We gladly accept pull requests! Just {fork}[http://help.github.com/forking/] the library and commit your changes along with relevant tests. Once you're happy with the changes, {send a pull request}[http://help.github.com/pull-requests/].
78
-
79
- We do our best to {keep our tests green}[http://travis-ci.org/metavida/ruby-oembed] https://secure.travis-ci.org/metavida/ruby-oembed.png
80
-
81
- = Contributors
82
-
83
- Thanks to {all who have made contributions}[https://github.com/judofyr/ruby-oembed/contributors] to this gem, both large and small.
84
-
85
- = License
86
-
87
- This code is free to use under the terms of the MIT license.