ruby-oembed 0.8.9 → 0.8.10

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: c357d1b21f61f7339b29510045ad103a0bfa209b
4
- data.tar.gz: eb8ddb9df50702ae4778f6993e6d772a1ef66ad0
3
+ metadata.gz: 19f03cd61c559b50759c1b31807479d1f5b76ff0
4
+ data.tar.gz: 725aa020d12e61232d57668f0514340c83751319
5
5
  SHA512:
6
- metadata.gz: 44f5346456a227c3d5293eece8348eb871118aea8b2a9183946a6c69c6d123eba8a1fbdd6c7e2c0f2b5be7d51e4477d1b8ce57948058f252f4b43a74821afe81
7
- data.tar.gz: 89d25a9740658a0dc18277eba8927e3cd32af1d5dc8548c16632374ab88d6d22d179798eaca6c1681a572f2089a87519165465963ed952f369a9115fe4076099
6
+ metadata.gz: a94c2ae8693c6a320acbe086652dac2edecfa51aea4e1387f609c18483cab7f35c478f4d35ecb789e1879073fdb9dca7b7717994936aca9fb326533916ab6dea
7
+ data.tar.gz: ad9fb9b7ea01016180b828261063f66ca72cad65f71fbc9ce1874b163a5795bd97064f8506188f2625a923658e441c5e96a809fc149ff4804b19a5efd4f589c8
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,10 @@
1
1
  = CHANGELOG
2
2
 
3
+ == 0.8.10 - 6 August 2014
4
+
5
+ * Add support for specifying a Provider#get `:timeout`; Pull #35 (Blake Thomson)
6
+ * Upgrade to RSpec 3.x
7
+
3
8
  == 0.8.9 - 15 September 2013
4
9
 
5
10
  * SoundCloud provider supports https URLs; Pull #30 (Greg Tangey)
@@ -78,6 +78,7 @@ module OEmbed
78
78
  # The query parameter should be a Hash of values which will be
79
79
  # sent as query parameters in this request to the Provider endpoint. The
80
80
  # following special cases apply to the query Hash:
81
+ # :timeout:: specifies the timeout (in seconds) for the http request.
81
82
  # :format:: overrides this Provider's default request format.
82
83
  # :url:: will be ignored, replaced by the url param.
83
84
  def get(url, query = {})
@@ -96,6 +97,8 @@ module OEmbed
96
97
  raise OEmbed::NotFound, url unless include?(url)
97
98
 
98
99
  query = query.merge({:url => ::CGI.escape(url)})
100
+ query.delete(:timeout)
101
+
99
102
  # TODO: move this code exclusively into the get method, once build is private.
100
103
  this_format = (query[:format] ||= @format.to_s).to_s
101
104
 
@@ -130,6 +133,7 @@ module OEmbed
130
133
  http = Net::HTTP.new(uri.host, uri.port)
131
134
  http.use_ssl = uri.scheme == 'https'
132
135
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
136
+ http.read_timeout = http.open_timeout = query[:timeout] if query[:timeout]
133
137
 
134
138
  %w{scheme userinfo host port registry}.each { |method| uri.send("#{method}=", nil) }
135
139
  res = http.request(Net::HTTP::Get.new(uri.to_s))
@@ -2,7 +2,7 @@ module OEmbed
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- PATCH = 9
5
+ PATCH = 10
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
 
8
8
  class << self
data/ruby-oembed.gemspec CHANGED
@@ -16,13 +16,13 @@ Gem::Specification.new do |s|
16
16
  s.email = "arisbartee@gmail.com"
17
17
  s.homepage = "http://github.com/judofyr/ruby-oembed"
18
18
  s.licenses = ["MIT"]
19
-
19
+
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = s.files.grep(%r{^(test|spec|features,integration_test)/})
22
-
22
+
23
23
  s.rdoc_options = ["--main", "README.rdoc", "--title", "ruby-oembed-#{OEmbed::Version}", "--inline-source", "--exclude", "tasks", "CHANGELOG.rdoc"]
24
24
  s.extra_rdoc_files = s.files.grep(%r{\.rdoc$}) + %w{LICENSE}
25
-
25
+
26
26
  s.require_paths = ["lib"]
27
27
  s.rubygems_version = "1.8.19"
28
28
  s.summary = "oEmbed for Ruby"
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.add_development_dependency(%q<json>, [">= 0"])
36
36
  s.add_development_dependency(%q<xml-simple>, [">= 0"])
37
37
  s.add_development_dependency(%q<nokogiri>, [">= 0"])
38
- s.add_development_dependency(%q<rspec>, [">= 2.0"])
38
+ s.add_development_dependency(%q<rspec>, ["~> 3.0"])
39
39
  s.add_development_dependency(%q<vcr>, ["~> 1.0"])
40
40
  s.add_development_dependency(%q<fakeweb>, [">= 0"])
41
41
  else
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  s.add_dependency(%q<json>, [">= 0"])
44
44
  s.add_dependency(%q<xml-simple>, [">= 0"])
45
45
  s.add_dependency(%q<nokogiri>, [">= 0"])
46
- s.add_dependency(%q<rspec>, [">= 2.0"])
46
+ s.add_dependency(%q<rspec>, ["~> 3.0"])
47
47
  s.add_dependency(%q<vcr>, ["~> 1.0"])
48
48
  s.add_dependency(%q<fakeweb>, [">= 0"])
49
49
  end
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
52
52
  s.add_dependency(%q<json>, [">= 0"])
53
53
  s.add_dependency(%q<xml-simple>, [">= 0"])
54
54
  s.add_dependency(%q<nokogiri>, [">= 0"])
55
- s.add_dependency(%q<rspec>, [">= 2.0"])
55
+ s.add_dependency(%q<rspec>, ["~> 3.0"])
56
56
  s.add_dependency(%q<vcr>, ["~> 1.0"])
57
57
  s.add_dependency(%q<fakeweb>, [">= 0"])
58
58
  end
@@ -58,60 +58,58 @@ describe OEmbed::Provider do
58
58
  it "should allow no URI schema to be given" do
59
59
  provier = OEmbed::Provider.new("http://foo.com/oembed")
60
60
 
61
- provier.include?("http://foo.com/1").should be_true
62
- provier.include?("http://bar.foo.com/1").should be_true
63
- provier.include?("http://bar.foo.com/show/1").should be_true
64
- provier.include?("https://bar.foo.com/1").should be_true
65
- provier.include?("http://asdf.com/1").should be_true
66
- provier.include?("asdf").should be_true
61
+ provier.include?("http://foo.com/1").should be_truthy
62
+ provier.include?("http://bar.foo.com/1").should be_truthy
63
+ provier.include?("http://bar.foo.com/show/1").should be_truthy
64
+ provier.include?("https://bar.foo.com/1").should be_truthy
65
+ provier.include?("http://asdf.com/1").should be_truthy
66
+ provier.include?("asdf").should be_truthy
67
67
  end
68
68
 
69
69
  it "should allow a String as a URI schema" do
70
70
  provier = OEmbed::Provider.new("http://foo.com/oembed")
71
71
  provier << "http://bar.foo.com/*"
72
72
 
73
- provier.include?("http://bar.foo.com/1").should be_true
74
- provier.include?("http://bar.foo.com/show/1").should be_true
73
+ provier.include?("http://bar.foo.com/1").should be_truthy
74
+ provier.include?("http://bar.foo.com/show/1").should be_truthy
75
75
 
76
- provier.include?("https://bar.foo.com/1").should be_false
77
- provier.include?("http://foo.com/1").should be_false
76
+ provier.include?("https://bar.foo.com/1").should be_falsey
77
+ provier.include?("http://foo.com/1").should be_falsey
78
78
  end
79
79
 
80
80
  it "should allow multiple path wildcards in a String URI schema" do
81
81
  provier = OEmbed::Provider.new("http://foo.com/oembed")
82
82
  provier << "http://bar.foo.com/*/show/*"
83
83
 
84
- provier.include?("http://bar.foo.com/photo/show/1").should be_true
85
- provier.include?("http://bar.foo.com/video/show/2").should be_true
86
- provier.include?("http://bar.foo.com/help/video/show/2").should be_true
84
+ provier.include?("http://bar.foo.com/photo/show/1").should be_truthy
85
+ provier.include?("http://bar.foo.com/video/show/2").should be_truthy
86
+ provier.include?("http://bar.foo.com/help/video/show/2").should be_truthy
87
87
 
88
- provier.include?("https://bar.foo.com/photo/show/1").should be_false
89
- provier.include?("http://foo.com/video/show/2").should be_false
90
- provier.include?("http://bar.foo.com/show/1").should be_false
91
- provier.include?("http://bar.foo.com/1").should be_false
88
+ provier.include?("https://bar.foo.com/photo/show/1").should be_falsey
89
+ provier.include?("http://foo.com/video/show/2").should be_falsey
90
+ provier.include?("http://bar.foo.com/show/1").should be_falsey
91
+ provier.include?("http://bar.foo.com/1").should be_falsey
92
92
  end
93
93
 
94
- it "should NOT allow multiple domain wildcards in a String URI schema" do
94
+ it "should NOT allow multiple domain wildcards in a String URI schema", :pending => true do
95
95
  provier = OEmbed::Provider.new("http://foo.com/oembed")
96
96
 
97
- pending("We don't yet validate URL schema strings") do
98
- proc { provier << "http://*.com/*" }.
99
- should raise_error(ArgumentError)
100
- end
97
+ proc { provier << "http://*.com/*" }.
98
+ should raise_error(ArgumentError)
101
99
 
102
- provier.include?("http://foo.com/1").should be_false
100
+ provier.include?("http://foo.com/1").should be_falsey
103
101
  end
104
102
 
105
103
  it "should allow a sub-domain wildcard in String URI schema" do
106
104
  provier = OEmbed::Provider.new("http://foo.com/oembed")
107
105
  provier << "http://*.foo.com/*"
108
106
 
109
- provier.include?("http://bar.foo.com/1").should be_true
110
- provier.include?("http://foo.foo.com/2").should be_true
111
- provier.include?("http://foo.com/3").should be_true
107
+ provier.include?("http://bar.foo.com/1").should be_truthy
108
+ provier.include?("http://foo.foo.com/2").should be_truthy
109
+ provier.include?("http://foo.com/3").should be_truthy
112
110
 
113
- provier.include?("https://bar.foo.com/1").should be_false
114
- provier.include?("http://my.bar.foo.com/1").should be_false
111
+ provier.include?("https://bar.foo.com/1").should be_falsey
112
+ provier.include?("http://my.bar.foo.com/1").should be_falsey
115
113
 
116
114
  provier << "http://my.*.foo.com/*"
117
115
  end
@@ -120,48 +118,46 @@ describe OEmbed::Provider do
120
118
  provier = OEmbed::Provider.new("http://foo.com/oembed")
121
119
  provier << "http://*.my.*.foo.com/*"
122
120
 
123
- provier.include?("http://my.bar.foo.com/1").should be_true
124
- provier.include?("http://my.foo.com/2").should be_true
125
- provier.include?("http://bar.my.bar.foo.com/3").should be_true
121
+ provier.include?("http://my.bar.foo.com/1").should be_truthy
122
+ provier.include?("http://my.foo.com/2").should be_truthy
123
+ provier.include?("http://bar.my.bar.foo.com/3").should be_truthy
126
124
 
127
- provier.include?("http://bar.foo.com/1").should be_false
128
- provier.include?("http://foo.bar.foo.com/1").should be_false
125
+ provier.include?("http://bar.foo.com/1").should be_falsey
126
+ provier.include?("http://foo.bar.foo.com/1").should be_falsey
129
127
  end
130
128
 
131
- it "should NOT allow a scheme wildcard in a String URI schema" do
129
+ it "should NOT allow a scheme wildcard in a String URI schema", :pending => true do
132
130
  provier = OEmbed::Provider.new("http://foo.com/oembed")
133
131
 
134
- pending("We don't yet validate URL schema strings") do
135
- proc { provier << "*://foo.com/*" }.
136
- should raise_error(ArgumentError)
137
- end
132
+ proc { provier << "*://foo.com/*" }.
133
+ should raise_error(ArgumentError)
138
134
 
139
- provier.include?("http://foo.com/1").should be_false
135
+ provier.include?("http://foo.com/1").should be_falsey
140
136
  end
141
137
 
142
138
  it "should allow a scheme other than http in a String URI schema" do
143
139
  provier = OEmbed::Provider.new("http://foo.com/oembed")
144
140
  provier << "https://foo.com/*"
145
141
 
146
- provier.include?("https://foo.com/1").should be_true
142
+ provier.include?("https://foo.com/1").should be_truthy
147
143
 
148
144
  gopher_url = "gopher://foo.com/1"
149
- provier.include?(gopher_url).should be_false
145
+ provier.include?(gopher_url).should be_falsey
150
146
  provier << "gopher://foo.com/*"
151
- provier.include?(gopher_url).should be_true
147
+ provier.include?(gopher_url).should be_truthy
152
148
  end
153
149
 
154
150
  it "should allow a Regexp as a URI schema" do
155
151
  provier = OEmbed::Provider.new("http://foo.com/oembed")
156
152
  provier << %r{^https?://([^\.]*\.)?foo.com/(show/)?\d+}
157
153
 
158
- provier.include?("http://bar.foo.com/1").should be_true
159
- provier.include?("http://bar.foo.com/show/1").should be_true
160
- provier.include?("http://foo.com/1").should be_true
161
- provier.include?("https://bar.foo.com/1").should be_true
154
+ provier.include?("http://bar.foo.com/1").should be_truthy
155
+ provier.include?("http://bar.foo.com/show/1").should be_truthy
156
+ provier.include?("http://foo.com/1").should be_truthy
157
+ provier.include?("https://bar.foo.com/1").should be_truthy
162
158
 
163
- provier.include?("http://bar.foo.com/video/1").should be_false
164
- provier.include?("gopher://foo.com/1").should be_false
159
+ provier.include?("http://bar.foo.com/video/1").should be_falsey
160
+ provier.include?("gopher://foo.com/1").should be_falsey
165
161
  end
166
162
 
167
163
  it "should by default use OEmbed::Formatter.default" do
@@ -204,8 +200,8 @@ describe OEmbed::Provider do
204
200
  end
205
201
 
206
202
  it "should match URLs" do
207
- @flickr.include?(example_url(:flickr)).should be_true
208
- @qik.include?(example_url(:qik)).should be_true
203
+ @flickr.include?(example_url(:flickr)).should be_truthy
204
+ @qik.include?(example_url(:qik)).should be_truthy
209
205
  end
210
206
 
211
207
  it "should raise error if the URL is invalid" do
@@ -218,13 +214,13 @@ describe OEmbed::Provider do
218
214
  uri = @flickr.send(:build, example_url(:flickr))
219
215
  uri.host.should == "www.flickr.com"
220
216
  uri.path.should == "/services/oembed/"
221
- uri.query.include?("format=#{@flickr.format}").should be_true
222
- uri.query.include?("url=#{CGI.escape 'http://flickr.com/photos/bees/2362225867/'}").should be_true
217
+ uri.query.include?("format=#{@flickr.format}").should be_truthy
218
+ uri.query.include?("url=#{CGI.escape 'http://flickr.com/photos/bees/2362225867/'}").should be_truthy
223
219
 
224
220
  uri = @qik.send(:build, example_url(:qik))
225
221
  uri.host.should == "qik.com"
226
222
  uri.path.should == "/api/oembed.xml"
227
- uri.query.include?("format=#{@qik.format}").should be_false
223
+ uri.query.include?("format=#{@qik.format}").should be_falsey
228
224
  uri.query.should == "url=#{CGI.escape 'http://qik.com/video/49565'}"
229
225
  end
230
226
 
@@ -235,10 +231,10 @@ describe OEmbed::Provider do
235
231
  :format => :xml,
236
232
  :another => "test")
237
233
 
238
- uri.query.include?("maxwidth=600").should be_true
239
- uri.query.include?("maxheight=200").should be_true
240
- uri.query.include?("format=xml").should be_true
241
- uri.query.include?("another=test").should be_true
234
+ uri.query.include?("maxwidth=600").should be_truthy
235
+ uri.query.include?("maxheight=200").should be_truthy
236
+ uri.query.include?("format=xml").should be_truthy
237
+ uri.query.include?("another=test").should be_truthy
242
238
  end
243
239
 
244
240
  it "should build correctly when format is in the endpoint URL" do
@@ -250,11 +246,20 @@ describe OEmbed::Provider do
250
246
  provider = OEmbed::Provider.new('http://www.youtube.com/oembed?scheme=https')
251
247
  provider << 'http://*.youtube.com/*'
252
248
  url = 'http://youtube.com/watch?v=M3r2XDceM6A'
253
- provider.include?(url).should be_true
249
+ provider.include?(url).should be_truthy
254
250
 
255
251
  uri = provider.send(:build, url)
256
- uri.query.include?("scheme=https").should be_true
257
- uri.query.include?("url=#{CGI.escape url}").should be_true
252
+ uri.query.include?("scheme=https").should be_truthy
253
+ uri.query.include?("url=#{CGI.escape url}").should be_truthy
254
+ end
255
+
256
+ it "should not include the :timeout parameter in the query string" do
257
+ uri = @flickr.send(:build, example_url(:flickr),
258
+ :timeout => 5,
259
+ :another => "test")
260
+
261
+ uri.query.include?("timeout=5").should be_falsey
262
+ uri.query.include?("another=test").should be_truthy
258
263
  end
259
264
  end
260
265
 
@@ -364,5 +369,11 @@ describe OEmbed::Provider do
364
369
  and_return(valid_response(:json))
365
370
  @viddler.get(example_url(:viddler))
366
371
  end
372
+
373
+ it "handles the :timeout option" do
374
+ Net::HTTP.any_instance.should_receive(:open_timeout=).with(5)
375
+ Net::HTTP.any_instance.should_receive(:read_timeout=).with(5)
376
+ @flickr.get(example_url(:flickr), :timeout => 5)
377
+ end
367
378
  end
368
379
  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.8.9
4
+ version: 0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Holm
@@ -17,98 +17,98 @@ dependencies:
17
17
  name: rake
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: json
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: xml-simple
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - '>='
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - '>='
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: rspec
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: '2.0'
78
+ version: '3.0'
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: '2.0'
85
+ version: '3.0'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: vcr
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - ~>
90
+ - - "~>"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '1.0'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ~>
97
+ - - "~>"
98
98
  - !ruby/object:Gem::Version
99
99
  version: '1.0'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: fakeweb
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - '>='
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  type: :development
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  description: An oEmbed consumer library written in Ruby, letting you easily get embeddable
@@ -122,10 +122,10 @@ extra_rdoc_files:
122
122
  - README.rdoc
123
123
  - LICENSE
124
124
  files:
125
- - .gitignore
126
- - .rvmrc
127
- - .travis.yml
128
- - .yardopts
125
+ - ".gitignore"
126
+ - ".rvmrc"
127
+ - ".travis.yml"
128
+ - ".yardopts"
129
129
  - CHANGELOG.rdoc
130
130
  - Gemfile
131
131
  - LICENSE
@@ -181,29 +181,29 @@ licenses:
181
181
  metadata: {}
182
182
  post_install_message:
183
183
  rdoc_options:
184
- - --main
184
+ - "--main"
185
185
  - README.rdoc
186
- - --title
187
- - ruby-oembed-0.8.9
188
- - --inline-source
189
- - --exclude
186
+ - "--title"
187
+ - ruby-oembed-0.8.10
188
+ - "--inline-source"
189
+ - "--exclude"
190
190
  - tasks
191
191
  - CHANGELOG.rdoc
192
192
  require_paths:
193
193
  - lib
194
194
  required_ruby_version: !ruby/object:Gem::Requirement
195
195
  requirements:
196
- - - '>='
196
+ - - ">="
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  requirements:
201
- - - '>='
201
+ - - ">="
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0'
204
204
  requirements: []
205
205
  rubyforge_project:
206
- rubygems_version: 2.1.3
206
+ rubygems_version: 2.2.2
207
207
  signing_key:
208
208
  specification_version: 3
209
209
  summary: oEmbed for Ruby