netshade-oembed_links 0.1.7 → 0.1.8
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/README.txt +1 -1
- data/lib/oembed_links/response.rb +4 -3
- data/lib/oembed_links.rb +2 -2
- data/oembed_links.gemspec +1 -1
- data/spec/oembed_links_spec.rb +7 -1
- metadata +1 -1
data/README.txt
CHANGED
@@ -62,7 +62,7 @@ OEmbed.transform("Here is a link to amazon http://www.amazon.com/Complete-Aubrey
|
|
62
62
|
end
|
63
63
|
|
64
64
|
|
65
|
-
To get started quickly in Rails
|
65
|
+
To get started quickly in Rails:
|
66
66
|
|
67
67
|
Copy the included oembed_links_example.yml file to RAILS_ROOT/config/oembed_links.yml,
|
68
68
|
add a dependency to the gem in your environment.rb ( config.gem "oembed_links" )
|
@@ -80,6 +80,10 @@ class OEmbed
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
def has_rendered?
|
84
|
+
!@rendered.nil?
|
85
|
+
end
|
86
|
+
|
83
87
|
private
|
84
88
|
|
85
89
|
# Needlessly stupid priority for rendering.
|
@@ -95,9 +99,6 @@ class OEmbed
|
|
95
99
|
end
|
96
100
|
end
|
97
101
|
|
98
|
-
def has_rendered?
|
99
|
-
!@rendered.nil?
|
100
|
-
end
|
101
102
|
|
102
103
|
def render_content(*args, &block)
|
103
104
|
options = (args.last.is_a?(Hash)) ? args.last : { }
|
data/lib/oembed_links.rb
CHANGED
@@ -352,7 +352,7 @@ class OEmbed
|
|
352
352
|
txt.gsub!(u, response.to_s)
|
353
353
|
else
|
354
354
|
yield(response, u)
|
355
|
-
txt.gsub!(u, response.rendered_content)
|
355
|
+
(response.has_rendered?) ? txt.gsub!(u, response.rendered_content) : txt
|
356
356
|
end
|
357
357
|
else
|
358
358
|
if block.nil?
|
@@ -360,7 +360,7 @@ class OEmbed
|
|
360
360
|
else
|
361
361
|
response = OEmbed::Response.new("", u, {})
|
362
362
|
yield(response, u)
|
363
|
-
txt.gsub!(u, response.rendered_content)
|
363
|
+
(response.has_rendered?) ? txt.gsub!(u, response.rendered_content) : txt
|
364
364
|
end
|
365
365
|
end
|
366
366
|
end
|
data/oembed_links.gemspec
CHANGED
data/spec/oembed_links_spec.rb
CHANGED
@@ -166,7 +166,13 @@ describe OEmbed, "transforming functions" do
|
|
166
166
|
r.hedgehog? { |v| "hedgey"}
|
167
167
|
r.from?(:test2) { |t| "test2" }
|
168
168
|
r.matches?(/baz/) { |m| "regex" }
|
169
|
-
end.should == "foo"
|
169
|
+
end.should == "http://test1.net/foo"
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should transform only urls which have registered providers" do
|
173
|
+
OEmbed.transform("http://test1.net/foo and http://not.a.valid.url.host/fake are urls") do |r, url|
|
174
|
+
r.video? { |v| "video" }
|
175
|
+
end.should == "video and http://not.a.valid.url.host/fake are urls"
|
170
176
|
end
|
171
177
|
|
172
178
|
it "should pass control to the .none? block if no scheme matched" do
|