reddavis-embedit 0.0.6 → 0.0.7

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/media.rb CHANGED
@@ -6,10 +6,10 @@ module Embedit
6
6
 
7
7
  def initialize(url)
8
8
  @valid = true #Innocent until proven guilty
9
- @oembed_providers = Providers.new.sites
9
+ @oembed_providers = Providers.new.sites
10
10
  find_provider(url)
11
- rescue #Horrible hack, but flickrs poor status headers == :(
12
- @valid = false #if it breaks, its gotta be invalid, I suggest removing when debugging
11
+ #rescue #Horrible hack, but flickrs poor status headers == :(
12
+ # @valid = false #if it breaks, its gotta be invalid, I suggest removing when debugging
13
13
  end
14
14
 
15
15
  def title
@@ -38,7 +38,7 @@ module Embedit
38
38
  #Find a provider
39
39
  def find_provider(url)
40
40
  return @valid = false unless Validate.new(url).valid?
41
-
41
+
42
42
  @oembed_providers.keys.each do |key| #First search oembed providers for a match
43
43
  if url.match(/(\.|\/)#{key}\./) #URL can be www.vimeo.com || http://vimeo.com
44
44
  return @media_data = Oembed.new(url, key)
@@ -0,0 +1,27 @@
1
+ # TODO Having problems with using in rails (files not being found), need to look into. But works perfectly find with www.pandastream.com
2
+ module Embedit
3
+
4
+ class Player
5
+
6
+ attr_reader :title, :url, :format
7
+
8
+ def initialize(url)
9
+ @url = url
10
+ end
11
+
12
+ def html(size = {})
13
+ self.html = @url # Reset measurements, incase if hmtl is called twice on the same object
14
+ @html.gsub!(/400/, size[:width].to_s) unless size[:width].nil?
15
+ @html.gsub!(/300/, size[:height].to_s) unless size[:height].nil?
16
+ @html
17
+ end
18
+
19
+ def html=(url)
20
+ @html = %(<embed src="http://s3.amazonaws.com/panda-test/player.swf" width="400" height="300"
21
+ allowfullscreen="true" allowscriptaccess="always"
22
+ flashvars="&displayheight=300&file=#{url}&width=400&height=300" />)
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -12,14 +12,14 @@ class Validate
12
12
  private
13
13
 
14
14
  def check_url
15
- if check_url_supported == true && check_response == true #We first check that the url is one actually supported by Embedit
15
+ if (check_url_supported == true && check_response == true) || (File.extname(@url) != "" || nil && check_url_supported) #We first check that the url is one actually supported by Embedit
16
16
  return true
17
17
  end
18
18
  end
19
19
 
20
20
  def check_response
21
21
  true if open(@url) #Header codes are annoying, just check that the page works, the check with Embed::Media will narrow down more
22
- rescue
22
+ rescue
23
23
  false
24
24
  end
25
25
 
@@ -35,7 +35,7 @@ class Validate
35
35
  return true
36
36
  elsif @url.match(/share\.ovi\.com/)
37
37
  return true
38
- elsif File.extname(@url).match(/\.flv/)
38
+ elsif File.extname(@url) != "" || nil
39
39
  return true
40
40
  end
41
41
  return false #Return false if all else fail
data/lib/embedit.rb CHANGED
@@ -16,8 +16,7 @@ require 'embedit/validate'
16
16
  require 'embedit/player/player'
17
17
 
18
18
  # Oembed
19
-
20
- #puts a = Embedit::Media.new('http://www.vimeo.com/1263763').html
19
+ #puts a = Embedit::Media.new('http://www.vimeo.com/1260077').title
21
20
 
22
21
  #puts b = Embedit::Media.new('http://www.flickr.com/photos/reddavis999/2692043113/').html #valid? #.valid #.html(:height => 200)
23
22
 
@@ -31,7 +30,7 @@ require 'embedit/player/player'
31
30
 
32
31
  # YouTUBE
33
32
 
34
- #puts g = Embedit::Media.new("http://www.youtube.com/watch?v=j3TOT1lnVTA").valid?
33
+ #puts g = Embedit::Media.new("http://www.youtube.com/watch?v=j3TOT1lnVTA").html
35
34
 
36
35
  # OVI
37
36
 
@@ -43,4 +42,6 @@ require 'embedit/player/player'
43
42
 
44
43
  # Flash Player
45
44
 
46
- #puts a = Embedit::Media.new('../video.flv').html(:height => 900)
45
+ #puts a = Embedit::Media.new('../test.flv').html
46
+
47
+ #puts File.exists?(File.expand_path('test.flv'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddavis-embedit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
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-09-26 04:19:14 -07:00
12
+ date: 2008-09-28 07:15:59 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -32,6 +32,7 @@ files:
32
32
  - lib/embedit/exceptions.rb
33
33
  - lib/embedit/validate.rb
34
34
  - lib/embedit/ovi/ovi.rb
35
+ - lib/embedit/player/player.rb
35
36
  - spec/spec_helper.rb
36
37
  - spec/oembed_spec.rb
37
38
  - spec/youtube_spec.rb