netshade-oembed_links 0.1.2 → 0.1.3

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.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.1.3 / 2008-10-16
2
+
3
+ * 1 minor enhancement
4
+
5
+ * refactored no matching scheme into .none? matcher
6
+
1
7
  === 0.1.2 / 2008-10-16
2
8
 
3
9
  * 1 minor enhancement
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
3
 
4
- Hoe.new('oembed_links', "0.1.2") do |p|
4
+ Hoe.new('oembed_links', "0.1.3") do |p|
5
5
  p.summary = ""
6
6
  p.url = 'http://indystar.com/'
7
7
  p.description = "Easy OEmbed integration for Ruby (and Rails)."
data/lib/oembed_links.rb CHANGED
@@ -358,7 +358,9 @@ class OEmbed
358
358
  if block.nil?
359
359
  txt
360
360
  else
361
- txt.gsub!(u, yield(nil, u))
361
+ response = OEmbed::Response.new("", u, {})
362
+ yield(response, u)
363
+ txt.gsub!(u, response.rendered_content)
362
364
  end
363
365
  end
364
366
  end
@@ -7,7 +7,7 @@ class OEmbed
7
7
  def initialize(provider, url, response_object)
8
8
  @provider = provider
9
9
  @url = url
10
- @response = response_object
10
+ @response = response_object || {}
11
11
  @rendered_via_provider = @rendered_via_regex = @rendered_via_type = false
12
12
  @rendered = nil
13
13
  end
@@ -22,6 +22,14 @@ class OEmbed
22
22
  @rendered || self.to_s
23
23
  end
24
24
 
25
+
26
+ # Case where url has not matched at all
27
+ def none?(*args, &block)
28
+ if @response.keys.empty? && !has_rendered?
29
+ return render_content(*args, &block)
30
+ end
31
+ end
32
+
25
33
  # Test if this response has been returned from
26
34
  # the given provider_name.
27
35
  def from?(provider_name, *args, &block)
data/oembed_links.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{oembed_links}
3
- s.version = "0.1.2"
3
+ s.version = "0.1.3"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Indianapolis Star MD&D"]
@@ -122,6 +122,7 @@ describe OEmbed, "transforming functions" do
122
122
 
123
123
  it "should always give priority to provider conditional blocks" do
124
124
  OEmbed.transform("http://test1.net/foo") do |r, url|
125
+ r.none? { "none" }
125
126
  r.any? { |a| "any" }
126
127
  r.video? { |v| "video" }
127
128
  r.from?(:test1) { |t| "test1" }
@@ -131,6 +132,7 @@ describe OEmbed, "transforming functions" do
131
132
 
132
133
  it "should always give priority regex conditional blocks over all others except provider" do
133
134
  OEmbed.transform("http://test1.net/foo") do |r, url|
135
+ r.none? { "none" }
134
136
  r.any? { |a| "any" }
135
137
  r.video? { |v| "video" }
136
138
  r.matches?(/./) { |m| "regex" }
@@ -144,6 +146,7 @@ describe OEmbed, "transforming functions" do
144
146
 
145
147
  it "should recognize the type of content and handle the conditional block appropriately" do
146
148
  OEmbed.transform("http://test1.net/foo") do |r, url|
149
+ r.none? { "none" }
147
150
  r.any? { |a| "any" }
148
151
  r.video? { |v| "video" }
149
152
  end.should == "video"
@@ -166,6 +169,16 @@ describe OEmbed, "transforming functions" do
166
169
  end.should == "foo"
167
170
  end
168
171
 
172
+ it "should pass control to the .none? block if no scheme matched" do
173
+ OEmbed.transform("http://not.a.valid.url.host/fake") do |r, url|
174
+ r.none? { "nomatch" }
175
+ r.audio? { |a| "audio" }
176
+ r.hedgehog? { |v| "hedgey"}
177
+ r.from?(:test2) { |t| "test2" }
178
+ r.matches?(/baz/) { |m| "regex" }
179
+ end.should == "nomatch"
180
+ end
181
+
169
182
  it "should allow templates to be used to process the output" do
170
183
  url_provides({
171
184
  "url" => "template!"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netshade-oembed_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indianapolis Star MD&D