reddavis-embedit 0.1.1 → 0.1.2

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/lib/embedit.rb CHANGED
@@ -45,6 +45,18 @@ end
45
45
 
46
46
  #puts a = Embedit::Media.new('http://twitter.com/kastner/statuses/939873832').html
47
47
 
48
+ # Seven Load
49
+
50
+ #puts a = Embedit::Media.new('http://en.sevenload.com/videos/3uxhIev-Funny-animal-clips').html
51
+
48
52
  # MySpace Pictures
49
53
 
50
- #puts a = Embedit::Media.new('http://viewmorepics.myspace.com/index.cfm?fuseaction=viewImage&friendID=152417109&albumID=0&imageID=8797852').html(:height => 20)
54
+ #puts a = Embedit::Media.new('http://viewmorepics.myspace.com/index.cfm?fuseaction=viewImage&friendID=152417109&albumID=0&imageID=8797852').html(:height => 20)
55
+
56
+ # College Humor
57
+
58
+ #puts a = Embedit::Media.new('http://www.collegehumor.com/picture:1832904').html
59
+
60
+ # Google Video
61
+
62
+ #puts a = Embedit::Media.new('http://video.google.com/videoplay?docid=-1944827568401901581&hl=en').title
@@ -11,11 +11,11 @@ module Embedit
11
11
 
12
12
  def html(options={})
13
13
  options.reverse_merge!(:width=>400, :height=>326)
14
- %{<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=#{doc_id}&hl=en&fs=true" style="width:#{options[:width]}px;height:#{options[:height]}px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"> </embed>}
14
+ %{<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=-#{doc_id}&hl=en&fs=true" style="width:#{options[:width]}px;height:#{options[:height]}px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"> </embed>}
15
15
  end
16
16
 
17
17
  def doc_id
18
- @url[/video\.google\.com\/videoplay\?docid=(\w+)/,1]
18
+ @url[/video\.google\.com\/videoplay\?docid=-(\w+)/,1]
19
19
  end
20
20
 
21
21
  def title
@@ -25,8 +25,8 @@ module Embedit
25
25
  end
26
26
 
27
27
  def self.match(url)
28
- url.match(/video\.google\.com\/videoplay\?docid=(\w+)/)
28
+ url.match(/video\.google\.com\/videoplay\?docid=-(\w+)/)
29
29
  end
30
30
  end
31
31
 
32
- end
32
+ end
@@ -0,0 +1,29 @@
1
+ module Embedit
2
+
3
+ class Mp3
4
+
5
+ attr_reader :title, :url, :format
6
+
7
+ def initialize(url)
8
+ @url = url
9
+ @format = "audio"
10
+ @title = url.split('/').last
11
+ self.html = url
12
+ end
13
+
14
+ def html(options = {})
15
+ @html.gsub!(/height="\d+"/, %{height="#{options[:height].to_s}"}) unless options[:height].nil?
16
+ @html.gsub!(/width="\d+"/, %{width="#{options[:width].to_s}"}) unless options[:width].nil?
17
+ @html
18
+ end
19
+
20
+ def html=(url)
21
+ @html = %{<embed src="http://s3.amazonaws.com/panda-test/player.swf" width="400" height="20" allowfullscreen="true" allowscriptaccess="always" flashvars="&displayheight=20&file=#{url}&width=400&height=20" />}
22
+ end
23
+
24
+ def self.match(url)
25
+ url.match(/(.+\.mp3$)/)
26
+ end
27
+ end
28
+
29
+ end
@@ -13,11 +13,7 @@ module Embedit
13
13
  def html(options = {})
14
14
  options.reverse_merge!({:width=>445,:height=>364})
15
15
  %{
16
- <object type="application/x-shockwave-flash" data="http://#{lang}.sevenload.com/pl/#{video_id}/#{options[:width]}x#{options[:height]}/swf" width="#{options[:width]}" height="#{options[:height]}">
17
- <param name="allowFullscreen" value="true" />
18
- <param name="allowScriptAccess" value="always" />
19
- <param name="movie" value="http://#{lang}.sevenload.com/pl/#{video_id}/#{options[:width]}x#{options[:height]}/swf" />
20
- </object>
16
+ <script type="text/javascript" src="http://#{lang}.sevenload.com/pl/#{video_id}/#{options[:width]}x#{options[:height]}"></script>
21
17
  }
22
18
  end
23
19
 
@@ -45,3 +41,11 @@ module Embedit
45
41
  end
46
42
 
47
43
  end
44
+
45
+
46
+
47
+ #<object type="application/x-shockwave-flash" data="http://#{lang}.sevenload.com/pl/#{video_id}/#{options[:width]}x#{options[:height]}/swf" width="#{options[:width]}" height="#{options[:height]}">
48
+ # <param name="allowFullscreen" value="true" />
49
+ # <param name="allowScriptAccess" value="always" />
50
+ # <param name="movie" value="http://#{lang}.sevenload.com/pl/#{video_id}/#{options[:width]}x#{options[:height]}/swf" />
51
+ #</object>
@@ -0,0 +1,29 @@
1
+ module Embedit
2
+
3
+ class Swf
4
+
5
+ attr_reader :title, :url, :format
6
+
7
+ def initialize(url)
8
+ @url = url
9
+ @format = "rich"
10
+ @title = url.split('/').last
11
+ self.html = url
12
+ end
13
+
14
+ def html(options = {})
15
+ @html.gsub!(/height="\d+"/, %{height="#{options[:height].to_s}"}) unless options[:height].nil?
16
+ @html.gsub!(/width="\d+"/, %{width="#{options[:width].to_s}"}) unless options[:width].nil?
17
+ @html
18
+ end
19
+
20
+ def html=(url)
21
+ @html = %{<embed width="400" height="300" quality="high" src="#{url}" type="application/x-shockwave-flash" allowfullscreen="true"/>}
22
+ end
23
+
24
+ def self.match(url)
25
+ url.match(/(.+\.swf$)/)
26
+ end
27
+ end
28
+
29
+ end
data/spec/mp3_spec.rb ADDED
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "MP3" do
4
+
5
+ it "should show true on valid url" do
6
+ Embedit::Media.new("http://s13a.non-standard.net/sec/c7c56166740ab9310ee70f132b9bf897/48fa0f08/archive/509/3/8dfbd9231557c6e6b1ad62f1549afb62.mp3").should be_valid
7
+ end
8
+
9
+ it "should return filename as title" do
10
+ Embedit::Media.new("http://s13a.non-standard.net/sec/c7c56166740ab9310ee70f132b9bf897/48fa0f08/archive/509/3/8dfbd9231557c6e6b1ad62f1549afb62.mp3").title.should eql("8dfbd9231557c6e6b1ad62f1549afb62.mp3")
11
+ end
12
+
13
+ it "should show format as audio" do
14
+ Embedit::Media.new("http://s13a.non-standard.net/sec/c7c56166740ab9310ee70f132b9bf897/48fa0f08/archive/509/3/8dfbd9231557c6e6b1ad62f1549afb62.mp3").format.should eql("audio")
15
+ end
16
+
17
+ it "should accept width and height options for embeded code" do
18
+ embed = Embedit::Media.new("http://s13a.non-standard.net/sec/c7c56166740ab9310ee70f132b9bf897/48fa0f08/archive/509/3/8dfbd9231557c6e6b1ad62f1549afb62.mp3").html(:width=>200, :height => 100)
19
+ embed.match(/width="200"/).should_not be_nil
20
+ embed.match(/height="100"/).should_not be_nil
21
+ end
22
+
23
+ it "should return correct the embed code" do
24
+ Embedit::Media.new("http://s13a.non-standard.net/sec/c7c56166740ab9310ee70f132b9bf897/48fa0f08/archive/509/3/8dfbd9231557c6e6b1ad62f1549afb62.mp3").html.should eql('<embed src="http://s3.amazonaws.com/panda-test/player.swf" width="400" height="20" allowfullscreen="true" allowscriptaccess="always" flashvars="&displayheight=20&file=http://s13a.non-standard.net/sec/c7c56166740ab9310ee70f132b9bf897/48fa0f08/archive/509/3/8dfbd9231557c6e6b1ad62f1549afb62.mp3&width=400&height=20" />')
25
+ end
26
+
27
+ end
data/spec/swf_spec.rb ADDED
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "SWF" do
4
+
5
+ it "should show true on valid url" do
6
+ Embedit::Media.new("http://v1.dothegreenthing.com/games/upgrade_circle/main.swf").should be_valid
7
+ end
8
+
9
+ it "should return filename as title" do
10
+ Embedit::Media.new("http://v1.dothegreenthing.com/games/upgrade_circle/main.swf").title.should eql("main.swf")
11
+ end
12
+
13
+ it "should show format as rich" do
14
+ Embedit::Media.new("http://v1.dothegreenthing.com/games/upgrade_circle/main.swf").format.should eql("rich")
15
+ end
16
+
17
+ it "should accept width and height options for embeded code" do
18
+ embed = Embedit::Media.new("http://v1.dothegreenthing.com/games/upgrade_circle/main.swf").html(:width=>200, :height => 100)
19
+ embed.match(/width="200"/).should_not be_nil
20
+ embed.match(/height="100"/).should_not be_nil
21
+ end
22
+
23
+ it "should return correct the embed code" do
24
+ Embedit::Media.new("http://v1.dothegreenthing.com/games/upgrade_circle/main.swf").html.should eql('<embed width="400" height="300" quality="high" src="http://v1.dothegreenthing.com/games/upgrade_circle/main.swf" type="application/x-shockwave-flash" allowfullscreen="true"/>')
25
+ end
26
+
27
+ end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddavis-embedit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Red Davis
8
8
  - Michael Bumann
9
+ - James Smith
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2008-10-02 17:51:39 -07:00
14
+ date: 2008-10-18 21:55:02 -07:00
14
15
  default_executable:
15
16
  dependencies: []
16
17
 
@@ -36,6 +37,8 @@ files:
36
37
  - lib/embedit/providers/sevenload_video.rb
37
38
  - lib/embedit/providers/twitter.rb
38
39
  - lib/embedit/providers/youtube.rb
40
+ - lib/embedit/providers/mp3.rb
41
+ - lib/embedit/providers/swf.rb
39
42
  - lib/embedit/validate.rb
40
43
  - lib/embedit.rb
41
44
  - README
@@ -46,6 +49,8 @@ files:
46
49
  - spec/sevenload_video_spec.rb
47
50
  - spec/twitter_spec.rb
48
51
  - spec/youtube_spec.rb
52
+ - spec/mp3_spec.rb
53
+ - spec/swf_spec.rb
49
54
  has_rdoc: false
50
55
  homepage: http://github.com/reddavis/embedit
51
56
  post_install_message:
@@ -80,3 +85,5 @@ test_files:
80
85
  - spec/sevenload_video_spec.rb
81
86
  - spec/twitter_spec.rb
82
87
  - spec/youtube_spec.rb
88
+ - spec/mp3_spec.rb
89
+ - spec/swf_spec.rb