netshade-oembed_links 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
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 (< 2.2. oembed_links doesn't work in 2.2 yet, when rendering w/ Rails templates):
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{oembed_links}
3
- s.version = "0.1.7"
3
+ s.version = "0.1.8"
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"]
@@ -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
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.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indianapolis Star MD&D