reddavis-oembed-with-ruby 0.0.2 → 0.0.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/README +10 -4
- data/lib/oembed-with-ruby.rb +6 -6
- data/lib/oembed/media.rb +25 -5
- metadata +2 -2
data/README
CHANGED
@@ -6,11 +6,17 @@ a = Oembed::Media('put the url here')
|
|
6
6
|
|
7
7
|
You are then given attributes such as...
|
8
8
|
|
9
|
-
a.title
|
10
|
-
a.media_url - link to the media
|
11
|
-
a.html - a flash player, (only for videos)
|
12
|
-
a.format - video/photo
|
9
|
+
a.title
|
13
10
|
|
11
|
+
a.media_url - link to the media
|
12
|
+
|
13
|
+
a.html - a flash player for videos and a <img> tag for pictures
|
14
|
+
html allows you to specify a height and/or width...
|
15
|
+
a.html(:width => 200, :height => 1000)
|
16
|
+
|
17
|
+
a.format - video/photo
|
18
|
+
|
19
|
+
========================================================================================================================
|
14
20
|
|
15
21
|
Services Supported
|
16
22
|
|
data/lib/oembed-with-ruby.rb
CHANGED
@@ -9,14 +9,14 @@ require 'oembed/providers'
|
|
9
9
|
require 'oembed/media'
|
10
10
|
|
11
11
|
|
12
|
-
puts a = Oembed::Media.new('http://www.vimeo.com/1263763').
|
12
|
+
#puts a = Oembed::Media.new('http://www.vimeo.com/1263763').html(:width => 800, :height => 100)
|
13
13
|
|
14
|
-
#puts b = Oembed::Media.new('http://www.flickr.com/photos/davidgutierrez/2135724493/').
|
14
|
+
#puts b = Oembed::Media.new('http://www.flickr.com/photos/davidgutierrez/2135724493/').html(:height => 200)
|
15
15
|
|
16
|
-
#puts c = Oembed::Media.new('http://www.viddler.com/explore/winelibrarytv/videos/142/').
|
16
|
+
#puts c = Oembed::Media.new('http://www.viddler.com/explore/winelibrarytv/videos/142/').html(:height => 200, :width => 500)
|
17
17
|
|
18
|
-
#puts d = Oembed::Media.new('http://qik.com/video/141977').
|
18
|
+
#puts d = Oembed::Media.new('http://qik.com/video/141977').html(:height => 50)
|
19
19
|
|
20
|
-
#puts e = Oembed::Media.new('http://pownce.com/dburka/notes/2951118/').
|
20
|
+
#puts e = Oembed::Media.new('http://pownce.com/dburka/notes/2951118/').html(:height => 200)
|
21
21
|
|
22
|
-
#puts f = Oembed::Media.new('http://revision3.com/trs/blockoland/').html
|
22
|
+
#puts f = Oembed::Media.new('http://revision3.com/trs/blockoland/').html(:height => 500)
|
data/lib/oembed/media.rb
CHANGED
@@ -2,7 +2,7 @@ module Oembed
|
|
2
2
|
|
3
3
|
class Media < Providers
|
4
4
|
|
5
|
-
attr_accessor :title, :media_url, :
|
5
|
+
attr_accessor :title, :media_url, :format, :html
|
6
6
|
|
7
7
|
def initialize(url)
|
8
8
|
@format = 'json'
|
@@ -11,6 +11,18 @@ module Oembed
|
|
11
11
|
get_info
|
12
12
|
end
|
13
13
|
|
14
|
+
def html(size = {})
|
15
|
+
if @format == 'photo'
|
16
|
+
@html.insert(-2, " height=#{size[:height]} ") unless size[:height].nil?
|
17
|
+
@html.insert(-2, " width=#{size[:width]}") unless size[:width].nil?
|
18
|
+
else
|
19
|
+
@html.gsub!(/height="\d+"/, %{height="#{size[:height].to_s}"}) unless size[:height].nil?
|
20
|
+
@html.gsub!(/width="\d+"/, %{width="#{size[:width].to_s}"}) unless size[:width].nil?
|
21
|
+
end
|
22
|
+
@html
|
23
|
+
end
|
24
|
+
#width="504" height="380"
|
25
|
+
private
|
14
26
|
def get_info
|
15
27
|
find_provider
|
16
28
|
url = URI.parse(@base_url + @url)
|
@@ -23,16 +35,17 @@ module Oembed
|
|
23
35
|
@title = parsed_data['title']
|
24
36
|
@media_url = parsed_data['url']
|
25
37
|
@format = parsed_data['type']
|
26
|
-
@html = parsed_data['html']
|
38
|
+
@html = @format == 'video' ? parsed_data['html'] : %{<img src='#{@media_url}' alt='#{@title}'>}
|
27
39
|
end
|
28
|
-
|
29
40
|
|
30
|
-
private
|
31
41
|
#find Oembed provider - set in ../providers.yaml
|
32
42
|
def find_provider
|
33
43
|
@sites.keys.each do |key|
|
34
|
-
|
44
|
+
unless @url.match(/#{key}/).nil?
|
35
45
|
@base_url = prepare_url(@sites[key])
|
46
|
+
else
|
47
|
+
raise TypeError, "URL was not an Oembed provider"
|
48
|
+
#check_for_other_service
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|
@@ -46,5 +59,12 @@ module Oembed
|
|
46
59
|
end
|
47
60
|
end
|
48
61
|
|
62
|
+
def check_for_other_service
|
63
|
+
|
64
|
+
#if @url.match(/youtube/)
|
65
|
+
#Oembed::YouTube.new(@url)
|
66
|
+
#end
|
67
|
+
end
|
68
|
+
|
49
69
|
end
|
50
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reddavis-oembed-with-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Red Davis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-25 13:45:39 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|