oembed_client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -57,6 +57,8 @@ class OembedClient
57
57
 
58
58
  def json
59
59
  @json ||= MultiJson.decode(response)
60
+ rescue
61
+ @json = {}
60
62
  end
61
63
 
62
64
  def embed_html
@@ -64,7 +66,7 @@ class OembedClient
64
66
  end
65
67
 
66
68
  def embed_url
67
- json['html']
69
+ json['url']
68
70
  end
69
71
 
70
72
  %w(photo video link rich).each do |embed_type|
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{oembed_client}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Brian Landau}]
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "oembed_client.gemspec",
29
29
  "test/fixtures/vcr_cassettes/flickr_response.yml",
30
30
  "test/fixtures/vcr_cassettes/response.yml",
31
+ "test/fixtures/vcr_cassettes/youtube_bad_response.yml",
31
32
  "test/fixtures/vcr_cassettes/youtube_response.yml",
32
33
  "test/helper.rb",
33
34
  "test/test_oembed_client.rb"
@@ -0,0 +1,28 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://www.youtube.com:80/oembed?format=json&iframe=1&maxwidth=520&url=http://www.youtube.com/bogus
6
+ body: !!null
7
+ headers: !!null
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 404
11
+ message: Not Found
12
+ headers:
13
+ date:
14
+ - Mon, 10 Oct 2011 04:01:40 GMT
15
+ server:
16
+ - Apache
17
+ x-content-type-options:
18
+ - nosniff
19
+ expires:
20
+ - Tue, 27 Apr 1971 19:44:06 EST
21
+ cache-control:
22
+ - no-cache
23
+ content-type:
24
+ - text/html; charset=utf-8
25
+ transfer-encoding:
26
+ - chunked
27
+ body: 404 Not Found
28
+ http_version: '1.1'
@@ -13,7 +13,7 @@ class TestOembedClient < Test::Unit::TestCase
13
13
  VCR.eject_cassette
14
14
  end
15
15
 
16
- context 'for existing YouTube client' do
16
+ context 'for existing YouTube client with good response' do
17
17
  setup do
18
18
  VCR.insert_cassette('youtube_response')
19
19
  @client = YoutubeOembedClient.new('http://www.youtube.com/watch?v=4r7wHMg5Yjg')
@@ -43,5 +43,31 @@ class TestOembedClient < Test::Unit::TestCase
43
43
  VCR.eject_cassette
44
44
  end
45
45
  end
46
+
47
+ context 'for existing YouTube client with bad response' do
48
+ setup do
49
+ VCR.insert_cassette('youtube_bad_response')
50
+ @client = YoutubeOembedClient.new('http://www.youtube.com/bogus')
51
+ end
52
+
53
+ should 'correctly report that it is not any type' do
54
+ assert !@client.video?
55
+ assert !@client.photo?
56
+ assert !@client.link?
57
+ assert !@client.rich?
58
+ end
59
+
60
+ should 'return nil for embed html' do
61
+ assert_nil @client.embed_html
62
+ end
63
+
64
+ should 'return nil for title' do
65
+ assert_nil @client.title
66
+ end
67
+
68
+ teardown do
69
+ VCR.eject_cassette
70
+ end
71
+ end
46
72
  end
47
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oembed_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &2153235200 !ruby/object:Gem::Requirement
16
+ requirement: &2153345380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153235200
24
+ version_requirements: *2153345380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &2153234720 !ruby/object:Gem::Requirement
27
+ requirement: &2153344900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153234720
35
+ version_requirements: *2153344900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2153234240 !ruby/object:Gem::Requirement
38
+ requirement: &2153344420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153234240
46
+ version_requirements: *2153344420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &2153233760 !ruby/object:Gem::Requirement
49
+ requirement: &2153343940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153233760
57
+ version_requirements: *2153343940
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &2153233280 !ruby/object:Gem::Requirement
60
+ requirement: &2153343460 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153233280
68
+ version_requirements: *2153343460
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &2153232800 !ruby/object:Gem::Requirement
71
+ requirement: &2153342980 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153232800
79
+ version_requirements: *2153342980
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: vcr
82
- requirement: &2153232320 !ruby/object:Gem::Requirement
82
+ requirement: &2153342500 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2153232320
90
+ version_requirements: *2153342500
91
91
  description: A simple abstract oEmbed Client for ruby.
92
92
  email: brianjlandau@gmail.com
93
93
  executables: []
@@ -107,6 +107,7 @@ files:
107
107
  - oembed_client.gemspec
108
108
  - test/fixtures/vcr_cassettes/flickr_response.yml
109
109
  - test/fixtures/vcr_cassettes/response.yml
110
+ - test/fixtures/vcr_cassettes/youtube_bad_response.yml
110
111
  - test/fixtures/vcr_cassettes/youtube_response.yml
111
112
  - test/helper.rb
112
113
  - test/test_oembed_client.rb
@@ -125,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
126
  version: '0'
126
127
  segments:
127
128
  - 0
128
- hash: -1844644635861407919
129
+ hash: 672231047159475518
129
130
  required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  none: false
131
132
  requirements: