muri 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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+
data/README.rdoc CHANGED
@@ -6,6 +6,8 @@ MURI Currently supports:
6
6
  * Youtube
7
7
  * Vimeo
8
8
  * Flickr
9
+ * Imageshack
10
+ * Photobucket
9
11
 
10
12
  == Installation & basic usage
11
13
 
@@ -20,18 +22,23 @@ Using muri is just as easy!
20
22
  a.media_id # 'blahblahblah'
21
23
  a.media_url # 'http://www.youtube.com/watch?v=blahblahblah' (flickr media_url's provide the flic.kr/p/ID short url)
22
24
  a.original_url # 'http://www.youtube.com/watch?v=blahblahblah&feature=rec-LGOUT-exp_fresh+div-1r-1-HM'
23
- a.uri # Parsed URI object for 'http://www.youtube.com/watch?v=blahblahblah&feature=rec-LGOUT-exp_fresh+div-1r-1-HM'
25
+ a.uri # URI object for 'http://www.youtube.com/watch?v=blahblahblah&feature=rec-LGOUT-exp_fresh+div-1r-1-HM'
24
26
 
25
27
  Due to variations in information which can be gathered from a uri, some services provide more information than others. For example:
26
- * A direct media url for Youtube videos
27
- a.url # 'http://www.youtube.com/v/blahblahblah'
28
+ * All but Imageshack have a media_api_id, which is the ID which can be used in API calls to the related services. Typically the same as media_id.
29
+ a.media_api_id # 'blahblahblah'
30
+
31
+ * A direct media url for Youtube, Photobucket, and Flickr (http://img#{num}.imageshack.us/img#{num}/#{NUMBER}/#{IMAGENAME} format)
32
+ a.website # 'http://www.youtube.com/v/blahblahblah'
28
33
 
29
- * Media creator name for Flickr URI's (for uri's in the http://www.flickr.com/photos/USER/PHOTO-ID/ format)
30
- a.media_creator # 'bananastalktome'
34
+ * Content type for Imageshack, Photobucket and Flickr URI's (flickr in the http://farm#{num}.static.flickr.com/ format)
35
+ a.content_type # 'jpg' (Content Type also for Imageshack and Photobucket)
36
+
37
+ * Thumbnails URL for Youtube Photobucket, and Flickr (flickr in the http://farm#{num}.static.flickr.com/ format)
38
+ a.media_thumbnail
39
+
40
+ * Some additional information may be provided, which can be determined by looking through each filters code.
31
41
 
32
- * Media size and content type for Flickr URI's (for uri's in the http://farm3.static.flickr.com/NUMBERS/MORE-NUMBERS_LETTERS-AND-NUMBERS_SIZE-INDICATOR.jpg
33
- a.media_size # 'small'
34
- a.content_type # 'jpg'
35
42
 
36
43
  If an attribute is not present, muri returns +nil+.
37
44
 
data/Rakefile CHANGED
@@ -13,3 +13,9 @@ begin
13
13
  rescue LoadError
14
14
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
15
15
  end
16
+ require 'rake'
17
+ require 'spec/rake/spectask'
18
+
19
+ Spec::Rake::SpecTask.new('tests') do |t|
20
+ t.spec_files = FileList['test/*.rb']
21
+ end
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 2
4
+ :patch: 3
data/lib/muri/base.rb CHANGED
@@ -2,16 +2,18 @@ require 'uri'
2
2
  class Muri
3
3
  class NoParser < StandardError; end
4
4
 
5
- PARSERS = { }
5
+ PARSERS = {}
6
6
 
7
7
  include Filter::Youtube
8
8
  include Filter::Flickr
9
9
  include Filter::Vimeo
10
-
10
+ include Filter::Imageshack
11
+ include Filter::Photobucket
12
+
11
13
  def self.parse(url)
12
14
  self.new(url)
13
15
  end
14
-
16
+
15
17
  def initialize(url)
16
18
  @info = { }
17
19
  _parse(url)
@@ -36,7 +38,7 @@ class Muri
36
38
  end
37
39
 
38
40
  def parsers
39
- PARSERS.keys
41
+ PARSERS.keys
40
42
  end
41
43
 
42
44
  private
@@ -47,10 +49,10 @@ class Muri
47
49
  raw_url = "http://#{raw_url}"
48
50
  @url = URI.parse(raw_url)
49
51
  end
50
- if parse_function = PARSERS[@url.host]
52
+ if parser = determine_feed_parser
51
53
  @info[:uri] = @url
52
54
  @info[:original_url] = raw_url
53
- send(parse_function)
55
+ send(PARSERS[parser])
54
56
  else
55
57
  raise NoParser.new("No Transformer found for URL")
56
58
  end
@@ -59,6 +61,10 @@ class Muri
59
61
  #raise "failed #{e}"
60
62
  end
61
63
 
64
+ def determine_feed_parser
65
+ PARSERS.keys.detect {|klass| klass.parsable?(@url)}
66
+ end
67
+
62
68
  def method_missing(func, args = nil)
63
69
  if @info[func.to_sym] != nil
64
70
  @info[func.to_sym]
@@ -66,4 +72,36 @@ class Muri
66
72
  nil #super(func,args)
67
73
  end
68
74
  end
75
+
76
+ protected
77
+
78
+ #used by flickr. Ported from PHP.
79
+ def decode58(str)
80
+ decoded = 0
81
+ multi = 1
82
+ alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
83
+ while str.length > 0
84
+ digit = str[(str.length - 1),1]
85
+ decoded += multi * alphabet.index(digit)
86
+ multi = multi * alphabet.length
87
+ str.chop!
88
+ end
89
+
90
+ decoded
91
+ end
92
+
93
+ #used by flickr. Ported from PHP.
94
+ def encode58(str)
95
+ alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
96
+ base_count = alphabet.length
97
+ encoded = ''
98
+ while str >= base_count
99
+ div = str / base_count
100
+ mod = (str-(base_count * div.to_i))
101
+ encoded = alphabet[mod,1] + encoded
102
+ str = div.to_i
103
+ end
104
+ encoded = (alphabet[str,1] + encoded) if str
105
+ encoded
106
+ end
69
107
  end
@@ -4,70 +4,48 @@ class Muri
4
4
 
5
5
  def self.included(base)
6
6
  base.class_eval do
7
- self::PARSERS["www.flickr.com"] = "flickr_parse"
8
- self::PARSERS["farm3.static.flickr.com"] = "flickr_parse"
9
- self::PARSERS["farm2.static.flickr.com"] = "flickr_parse"
10
- self::PARSERS["farm1.static.flickr.com"] = "flickr_parse"
11
- self::PARSERS["flic.kr"] = "flickr_parse"
7
+ self::PARSERS[Muri::Filter::Flickr] = "flickr_parse"
12
8
  end
13
9
  end
14
10
 
15
11
  def flickr_parse
16
12
  @info[:service] = 'Flickr'
17
13
 
18
- if @url.path =~ /^\/photos\/([a-zA-Z0-9\@]*?)\/[^(?:sets)]([0-9]*)/i
19
- @info[:media_creator] = $1
14
+ if @url.path =~ /^\/photos\/([a-z0-9\@]*?)\/([^(?:sets)][0-9]*)/i
15
+ #@info[:media_creator] = $1
20
16
  @info[:media_id] = $2
21
- elsif (@url.host + @url.path) =~ /^farm([1-3])\.static.flickr.com\/([0-9]*?)\/([0-9]*?)\_([a-zA-Z0-9]*?)(\_[a-zA-Z]){0,1}\.([a-zA-Z]*)/i
17
+ elsif (@url.host + @url.path) =~ /^farm([1-3])\.static.flickr.com\/([0-9]*?)\/([0-9]*?)\_([a-z0-9]*?)(\_[a-z]){0,1}\.([a-z]*)/i
18
+ farm = $1
19
+ server_id = $2
22
20
  @info[:media_id] = $3
23
- if !$5.nil?
24
- @info[:media_size] = case $5.downcase
25
- when '_s' then 'small'
26
- when '_t' then 'thumbnail'
27
- when '_m' then 'medium'
28
- when '_b' then 'large'
29
- else nil
30
- end
31
- end
32
- @info[:content_type] = $6.downcase
33
- elsif (@url.host + @url.path) =~ /^flic\.kr\/p\/([a-zA-Z0-9]*)/i
21
+ media_secret = $4
22
+ # if !$5.nil?
23
+ # @info[:media_size] = case $5.downcase
24
+ # when '_s' then 'small'
25
+ # when '_t' then 'thumbnail'
26
+ # when '_m' then 'medium'
27
+ # when '_b' then 'large'
28
+ # else nil
29
+ # end
30
+ # end
31
+ # @info[:content_type] = $6
32
+ @info[:media_thumbnail] = "http://farm#{farm}.static.flickr.com/#{server_id}/#{@info[:media_id]}_#{media_secret}_t.jpg"
33
+ elsif (@url.host + @url.path) =~ /^flic\.kr\/p\/([a-z0-9]*)/i
34
34
  @info[:media_id] = self.decode58($1)
35
35
  end
36
36
 
37
37
  if self.parsed?
38
+ @info[:media_api_id] = @info[:media_id]
38
39
  @info[:media_url] = "http://flic.kr/p/" + self.encode58(@info[:media_id].to_i)
39
40
  end
40
41
 
41
42
  self
42
43
  end
43
44
 
44
- def decode58(str)
45
- decoded = 0
46
- multi = 1
47
- alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
48
- while str.length > 0
49
- digit = str[(str.length - 1),1]
50
- decoded += multi * alphabet.index(digit)
51
- multi = multi * alphabet.length
52
- str.chop!
53
- end
54
-
55
- decoded
56
- end
57
-
58
- def encode58(str)
59
- alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
60
- base_count = alphabet.length
61
- encoded = ''
62
- while str >= base_count
63
- div = str / base_count
64
- mod = (str-(base_count * div.to_i))
65
- encoded = alphabet[mod,1] + encoded
66
- str = div.to_i
67
- end
68
- encoded = alphabet[str,1] + encoded if str
69
- encoded
70
- end
45
+ def self.parsable?(uri)
46
+ uri.host =~ /^(www\.|)(flic\.kr|(farm[0-9]\.static\.|)(flickr)\.com)/i
47
+ end
48
+
71
49
 
72
50
  end
73
51
  end
@@ -0,0 +1,49 @@
1
+ class Muri
2
+ module Filter
3
+ module Imageshack
4
+
5
+ def self.included(base)
6
+ base.class_eval do
7
+ self::PARSERS[Muri::Filter::Imageshack] = "imageshack_parse"
8
+ end
9
+ end
10
+
11
+ def imageshack_parse
12
+ @info[:service] = 'Imageshack'
13
+
14
+ @url.host =~ /^img([0-9]*?)\.imageshack\.us/i
15
+ server_id = $1
16
+ url_common = "http://img#{server_id}.imageshack.us"
17
+
18
+ if @url.path =~ /^\/i\/([a-z0-9]*?)\.([a-z0-9]*?)\//i
19
+ @info[:media_id] = $1
20
+ @info[:content_type] = $2
21
+ elsif @url.path =~ /^\/img([0-9]*?)\/([0-9]*?)\/([a-z0-9]*?)\.([a-z0-9]*?)/i
22
+ content_path_id = $2
23
+ @info[:media_id] = $3
24
+ @info[:content_type] = $4
25
+ @info[:website] = "#{url_common}/img#{server_id}/#{content_server_id}/#{@info[:media_id]}.#{@info[:content_type]}"
26
+ end
27
+
28
+ # imageshack does not currently have API for retrieving individual video information
29
+ if self.parsed?
30
+ @info[:media_url] = "#{url_common}/i/#{@info[:media_id]}.#{@info[:content_type]}/"
31
+ end
32
+
33
+ self
34
+ end
35
+
36
+ def self.parsable?(uri)
37
+ uri.host =~ /^img([0-9]*?)\.imageshack\.us$/i #/^(img([0-9]*?)\.imageshack\.us)|(yfrog\.com)/i
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ # http://img178.imageshack.us/i/dsc01576lo7.jpg/
44
+ # http://img178.imageshack.us/img178/773/dsc01576lo7.jpg
45
+ # http://yfrog.com/4ydsc01576lo7j
46
+
47
+ # http://img30.imageshack.us/img30/4184/rush02.mp4
48
+ # http://img30.imageshack.us/i/rush02.mp4/
49
+ # http://yfrog.us/0urush02z
@@ -0,0 +1,77 @@
1
+ class Muri
2
+ module Filter
3
+ module Photobucket
4
+
5
+ def self.included(base)
6
+ base.class_eval do
7
+ self::PARSERS[Muri::Filter::Photobucket] = "photobucket_parse"
8
+ end
9
+ end
10
+
11
+ def photobucket_parse
12
+ @info[:service] = 'Photobucket'
13
+
14
+ @url.host =~ /^([a-z0-9]*?[^(media)])\.photobucket\.com/i
15
+ server_id = $1.gsub(/([a-z]*)/i,"")
16
+
17
+ if @url.path =~ /^\/albums\/(.*?)\/(.*?)\/((?:.*?\/)*)(.*?)\.(.*)/i
18
+ photobucket_id = $1
19
+ media_creator = $2
20
+ album = $3
21
+ @info[:media_id] = $4
22
+ @info[:content_type] = $5
23
+ url_common = "#{server_id}.photobucket.com/albums/#{photobucket_id}/#{media_creator}/#{album}"
24
+ direct_url_suffix = "#{url_common}#{@info[:media_id]}.#{@info[:content_type]}"
25
+
26
+ @info[:website] = "http://i#{direct_url_suffix}"
27
+ @info[:media_url] = "http://s#{url_common}?action=view&current=#{@info[:media_id]}.#{@info[:content_type]}"
28
+ elsif @url.path =~ /^\/groups\/(.*?)\/(.*?)\/(.*?)\.(.*)/i
29
+ group = $1
30
+ group_hash_value = $2
31
+ @info[:media_id] = $3
32
+ @info[:content_type] = $4
33
+ url_common = "#{server_id}.photobucket.com/groups/#{group}/#{group_hash_value}"
34
+ direct_url_suffix = "#{url_common}/#{@info[:media_id]}.#{@info[:content_type]}"
35
+
36
+ @info[:website] = "http://gi#{direct_url_suffix}"
37
+ @info[:media_url] = "http://gs#{url_common}/?action=view&current=#{@info[:media_id]}.#{@info[:content_type]}"
38
+ end
39
+
40
+ if self.parsed?
41
+ @info[:media_api_id] = @info[:media_url]
42
+ @info[:media_thumbnail] = "http://mobth#{direct_url_suffix}"
43
+ end
44
+
45
+ self
46
+ end
47
+
48
+ def self.parsable?(uri)
49
+ uri.host =~ /^([a-z0-9]*?[^(media)])\.photobucket\.com$/i
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ # http://gw0001.photobucket.com/groups/0001/F9P8EG7YR8/002new.jpg
56
+
57
+ # http://media.photobucket.com/image/searchterm/pbapi/file.jpg (search result)
58
+ # http://i244.photobucket.com/albums/gg17/pbapi/file.jpg (full view)
59
+ # http://media.photobucket.com/image/gg17/pbapi/?action=view&current=file.jpg (preview view)
60
+
61
+ # http://s244.photobucket.com/albums/gg17/pbapi/api-test/api-test-subalbum/?action=view&current=ThuOct15131605MDT2009.jpg (preview)
62
+ # http://i244.photobucket.com/albums/gg17/pbapi/api-test/api-test-subalbum/ThuOct15131605MDT2009.jpg (full view)
63
+
64
+ # http://i37.photobucket.com/albums/e87/hailiespence/shaun%20white/20060212104609990002.jpg
65
+ # http://media.photobucket.com/image/winter%20olympics/hailiespence/shaun%20white/20060212104609990002.jpg?o=12 (preview)
66
+
67
+ # http://gi0006.photobucket.com/groups/0006/G5PAK3TBQS/siamese_cat_.jpg
68
+ # http://gi0006.photobucket.com/groups/0006/G5PAK3TBQS/DSCF0015-1-1.jpg
69
+
70
+
71
+ # http://s434.photobucket.com/albums/qq63/atommy_polar/?action=view&current=Me.jpg&newest=1
72
+ # http://i434.photobucket.com/albums/qq63/atommy_polar/Me.jpg
73
+ # http://s434.photobucket.com/albums/qq63/atommy_polar/?action=view&current=Me.jpg
74
+
75
+ # http://pic.pbsrc.com/dev_help/WebHelpPublic/PhotobucketPublicHelp.htm -> Conventions -> URL Structures
76
+ # http://pic.photobucket.com/dev_help/WebHelpPublic/Content/Getting%20Started/Conventions.htm
77
+ # http://pic.pbsrc.com/dev_help/WebHelpPublic/Content/Getting%20Started/Web%20Authentication.htm
@@ -2,33 +2,36 @@ require 'cgi'
2
2
  class Muri
3
3
  module Filter
4
4
  module Vimeo
5
-
5
+
6
6
  def self.included(base)
7
7
  base.class_eval do
8
- self::PARSERS["vimeo.com"] = "vimeo_parse"
9
-
10
-
8
+ self::PARSERS[Muri::Filter::Vimeo] = "vimeo_parse"
11
9
  end
12
10
  end
13
- def vimeo_parse
14
- @info[:service] = 'Vimeo'
15
-
16
- if @url.path =~ /^\/([0-9]*)/
17
- @info[:media_id] = $1
18
- elsif (@url.path =~ /^\/moogaloop\.swf/i)
19
- params = CGI::parse(@url.query)
20
- if params.include?("clip_id")
21
- @info[:media_id] = params["clip_id"].first if (params["clip_id"].first =~ /([0-9]*)/)
22
- end
23
- end
24
-
25
- if self.parsed?
26
- @info[:media_url] = "http://vimeo.com/" + @info[:media_id].to_s
27
- end
28
-
29
- self
30
- end
11
+
12
+ def vimeo_parse
13
+ @info[:service] = 'Vimeo'
14
+
15
+ if @url.path =~ /^\/([0-9]*)/
16
+ @info[:media_id] = $1
17
+ elsif (@url.path =~ /^\/moogaloop\.swf/i)
18
+ params = CGI::parse(@url.query)
19
+ if params.include?("clip_id")
20
+ @info[:media_id] = params["clip_id"].first if (params["clip_id"].first =~ /([0-9]*)/)
21
+ end
22
+ end
23
+
24
+ if self.parsed?
25
+ @info[:media_api_id] = @info[:media_id]
26
+ @info[:media_url] = "http://vimeo.com/#{@info[:media_id]}"
27
+ end
28
+
29
+ self
30
+ end
31
31
 
32
+ def self.parsable?(uri)
33
+ uri.host =~ /^vimeo\.com$/i
34
+ end
32
35
 
33
36
  end
34
37
  end
@@ -4,30 +4,34 @@ class Muri
4
4
  module Youtube
5
5
 
6
6
  def self.included(base)
7
- base.class_eval do
8
- self::PARSERS["www.youtube.com"] = "youtube_parse"
9
- self::PARSERS["youtube.com"] = "youtube_parse"
7
+ base.class_eval do
8
+ self::PARSERS[Muri::Filter::Youtube] = "youtube_parse"
10
9
  end
11
10
  end
12
11
 
13
12
  def youtube_parse
14
13
  @info[:service] = 'Youtube'
14
+ url_common = "http://www.youtube.com"
15
15
 
16
16
  if (@url.path == "/watch") && !@url.query.nil?
17
17
  params = CGI::parse(@url.query)
18
18
  @info[:media_id] = params["v"].first
19
- elsif (@url.path =~ /\/v\/([a-zA-Z0-9\-\_]*)/i)
19
+ elsif (@url.path =~ /\/v\/([a-z0-9\-\_]*)/i)
20
20
  @info[:media_id] = $1
21
21
  end
22
22
 
23
23
  if self.parsed?
24
- @info[:media_url] = "http://www.youtube.com/watch?v=" + @info[:media_id]
25
- @info[:url] = "http://www.youtube.com/v/" + @info[:media_id]
24
+ @info[:media_url] = "#{url_common}/watch?v=#{@info[:media_id]}"
25
+ @info[:website] = "#{url_common}/v/#{@info[:media_id]}"
26
+ @info[:media_api_id] = @info[:media_id]
27
+ @info[:media_thumbnail] = "http://i.ytimg.com/vi/#{@info[:media_id]}/default.jpg"
26
28
  end
27
29
 
28
30
  self
29
31
  end
30
-
32
+ def self.parsable?(uri)
33
+ uri.host =~ /^(www\.|)youtube\.com$/i
34
+ end
31
35
  end
32
36
  end
33
37
  end
data/muri.gemspec CHANGED
@@ -5,33 +5,48 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muri}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["William Schneider"]
12
- s.date = %q{2010-02-24}
12
+ s.date = %q{2010-03-01}
13
13
  s.description = %q{Automatically get media information from the URL.}
14
14
  s.email = %q{bananastalktome@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
17
17
  ]
18
18
  s.files = [
19
- "README.rdoc",
19
+ ".gitignore",
20
+ "README.rdoc",
20
21
  "Rakefile",
21
22
  "VERSION.yml",
22
23
  "lib/muri.rb",
23
24
  "lib/muri/base.rb",
24
25
  "lib/muri/filter.rb",
25
26
  "lib/muri/filters/flickr.rb",
27
+ "lib/muri/filters/imageshack.rb",
28
+ "lib/muri/filters/photobucket.rb",
26
29
  "lib/muri/filters/vimeo.rb",
27
30
  "lib/muri/filters/youtube.rb",
28
- "muri.gemspec"
31
+ "muri.gemspec",
32
+ "test/flickr_test.rb",
33
+ "test/imageshack_test.rb",
34
+ "test/photobucket_test.rb",
35
+ "test/vimeo_test.rb",
36
+ "test/youtube_test.rb"
29
37
  ]
30
38
  s.homepage = %q{http://github.com/bananastalktome/muri/}
31
39
  s.rdoc_options = ["--charset=UTF-8"]
32
40
  s.require_paths = ["lib"]
33
41
  s.rubygems_version = %q{1.3.5}
34
42
  s.summary = %q{Media URI Parser}
43
+ s.test_files = [
44
+ "test/flickr_test.rb",
45
+ "test/imageshack_test.rb",
46
+ "test/photobucket_test.rb",
47
+ "test/vimeo_test.rb",
48
+ "test/youtube_test.rb"
49
+ ]
35
50
 
36
51
  if s.respond_to? :specification_version then
37
52
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -0,0 +1,35 @@
1
+ require 'lib/muri.rb'
2
+
3
+ shared_examples_for "Flickr parse" do
4
+ it "should be Flickr service" do
5
+ @a.service == 'Flickr'
6
+ end
7
+
8
+ it "should have media id" do
9
+ @a.media_id == '2088436532'
10
+ end
11
+
12
+ it "should have media url" do
13
+ @a.media_url == 'http://flic.kr/p/4bxMqq'
14
+ end
15
+
16
+ it "should have media api id" do
17
+ @a.media_api_id == '2088436532'
18
+ end
19
+ end
20
+ describe "Flickr parse first" do
21
+ before (:all) do
22
+ @a = Muri.parse 'http://www.flickr.com/photos/bananastalktome/2088436532/'
23
+ end
24
+ it_should_behave_like "Flickr parse"
25
+ end
26
+ describe "Flickr parse second" do
27
+ before (:all) do
28
+ @a = Muri.parse 'http://farm3.static.flickr.com/2178/2088436532_ee07b4474e_m.jpg'
29
+ end
30
+ it_should_behave_like "Flickr parse"
31
+
32
+ it "should have media thumbnail" do
33
+ @a.media_thumbnail == 'http://farm3.static.flickr.com/2178/2088436532_ee07b4474e_t.jpg'
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ require 'lib/muri.rb'
2
+
3
+ shared_examples_for "Imageshack parse" do
4
+ it "should be Imageshack service" do
5
+ @a.service == 'Imageshack'
6
+ end
7
+
8
+ it "should have media id" do
9
+ @a.media_id == 'dsc01576lo7'
10
+ end
11
+
12
+ it "should have media url" do
13
+ @a.media_url == 'http://img178.imageshack.us/i/dsc01576lo7.jpg/'
14
+ end
15
+
16
+ it "should have content_type" do
17
+ @a.content_type == 'jpg'
18
+ end
19
+ end
20
+ describe "Imageshack parse first" do
21
+ before (:all) do
22
+ @a = Muri.parse 'http://img178.imageshack.us/i/dsc01576lo7.jpg/'
23
+ end
24
+ it_should_behave_like "Imageshack parse"
25
+ end
26
+ describe "Imageshack parse second" do
27
+ before (:all) do
28
+ @a = Muri.parse 'http://img178.imageshack.us/img178/773/dsc01576lo7.jpg'
29
+ end
30
+ it_should_behave_like "Imageshack parse"
31
+
32
+ it "should have website" do
33
+ @a.website == 'http://img178.imageshack.us/img178/773/dsc01576lo7.jpg'
34
+ end
35
+ end
@@ -0,0 +1,67 @@
1
+ require 'lib/muri.rb'
2
+
3
+ shared_examples_for "Photobucket parse" do
4
+ it "should be Photobucket service" do
5
+ @a.service == 'Photobucket'
6
+ end
7
+ end
8
+ describe "Photobucket parse first" do
9
+ before (:all) do
10
+ @a = Muri.parse 'http://i244.photobucket.com/albums/gg17/pbapi/file.jpg'
11
+ end
12
+ it_should_behave_like "Photobucket parse"
13
+
14
+ it "should have media id" do
15
+ @a.media_id == 'file'
16
+ end
17
+
18
+ it "should have content type" do
19
+ @a.content_type == "jpg"
20
+ end
21
+
22
+ it "should have media url" do
23
+ @a.media_url == "http://s244.photobucket.com/albums/gg17/pbapi/?action=view&current=file.jpg"
24
+ end
25
+
26
+ it "should have website" do
27
+ @a.website == "http://i244.photobucket.com/albums/gg17/pbapi/file.jpg"
28
+ end
29
+
30
+ it "should have media api id" do
31
+ @a.media_api_id == "http://s244.photobucket.com/albums/gg17/pbapi/?action=view&current=file.jpg"
32
+ end
33
+
34
+ it "should have media thumbnail" do
35
+ @a.media_thumbnail == 'http://mobth244.photobucket.com/albums/gg17/pbapi/file.jpg'
36
+ end
37
+ end
38
+ describe "Photobucket parse second" do
39
+ before (:all) do
40
+ @a = Muri.parse 'http://gi0006.photobucket.com/groups/0006/G5PAK3TBQS/DSCF0015-1-1.jpg'
41
+ end
42
+ it_should_behave_like "Photobucket parse"
43
+
44
+ it "should have media id" do
45
+ @a.media_id == 'DSCF0015-1-1'
46
+ end
47
+
48
+ it "should have content type" do
49
+ @a.content_type == "jpg"
50
+ end
51
+
52
+ it "should have media url" do
53
+ @a.media_url == "http://gs0006.photobucket.com/groups/0006/G5PAK3TBQS/?action=view&current=DSCF0015-1-1.jpg"
54
+ end
55
+
56
+ it "should have website" do
57
+ @a.website == "http://gi0006.photobucket.com/groups/0006/G5PAK3TBQS/DSCF0015-1-1.jpg"
58
+ end
59
+
60
+ it "should have media thumbnail" do
61
+ @a.media_thumbnail == 'http://mobth0006.photobucket.com/groups/0006/G5PAK3TBQS/DSCF0015-1-1.jpg'
62
+ end
63
+
64
+ it "should have media api id" do
65
+ @a.media_api_id == "http://gs0006.photobucket.com/groups/0006/G5PAK3TBQS/?action=view&current=DSCF0015-1-1.jpg"
66
+ end
67
+ end
@@ -0,0 +1,31 @@
1
+ require 'lib/muri.rb'
2
+
3
+ shared_examples_for "Vimeo parse" do
4
+ it "should be Vimeo service" do
5
+ @a.service == 'Vimeo'
6
+ end
7
+
8
+ it "should have media id" do
9
+ @a.media_id == '7312128'
10
+ end
11
+
12
+ it "should have media url" do
13
+ @a.media_url == 'http://vimeo.com/7312128'
14
+ end
15
+
16
+ it "should have media api id" do
17
+ @a.media_api_id == '7312128'
18
+ end
19
+ end
20
+ describe "Vimeo parse first" do
21
+ before (:all) do
22
+ @a = Muri.parse 'http://vimeo.com/moogaloop.swf?clip_id=7312128&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1'
23
+ end
24
+ it_should_behave_like "Vimeo parse"
25
+ end
26
+ describe "Vimeo parse second" do
27
+ before (:all) do
28
+ @a = Muri.parse 'http://vimeo.com/7312128'
29
+ end
30
+ it_should_behave_like "Vimeo parse"
31
+ end
@@ -0,0 +1,39 @@
1
+ require 'lib/muri.rb'
2
+
3
+ shared_examples_for "Youtube parse" do
4
+ it "should be Youtube service" do
5
+ @a.service == 'Youtube'
6
+ end
7
+
8
+ it "should have media id" do
9
+ @a.media_id == '4CYDFoEz8rg'
10
+ end
11
+
12
+ it "should have media api id" do
13
+ @a.media_api_id == '4CYDFoEz8rg'
14
+ end
15
+
16
+ it "should have media url" do
17
+ @a.media_url == 'http://www.youtube.com/watch?v=4CYDFoEz8rg'
18
+ end
19
+
20
+ it "should have website" do
21
+ @a.website == 'http://www.youtube.com/v/4CYDFoEz8rg'
22
+ end
23
+
24
+ it "should have thumbnail" do
25
+ @a.media_thumbnail == 'http://i.ytimg.com/vi/4CYDFoEz8rg/default.jpg'
26
+ end
27
+ end
28
+ describe "Youtube parse first" do
29
+ before (:all) do
30
+ @a = Muri.parse 'http://www.youtube.com/v/4CYDFoEz8rg&hl=en_US&fs=1&'
31
+ end
32
+ it_should_behave_like "Youtube parse"
33
+ end
34
+ describe "Youtube parse second" do
35
+ before (:all) do
36
+ @a = Muri.parse 'http://www.youtube.com/watch?v=4CYDFoEz8rg'
37
+ end
38
+ it_should_behave_like "Youtube parse"
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Schneider
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-24 00:00:00 -08:00
12
+ date: 2010-03-01 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,6 +22,7 @@ extensions: []
22
22
  extra_rdoc_files:
23
23
  - README.rdoc
24
24
  files:
25
+ - .gitignore
25
26
  - README.rdoc
26
27
  - Rakefile
27
28
  - VERSION.yml
@@ -29,9 +30,16 @@ files:
29
30
  - lib/muri/base.rb
30
31
  - lib/muri/filter.rb
31
32
  - lib/muri/filters/flickr.rb
33
+ - lib/muri/filters/imageshack.rb
34
+ - lib/muri/filters/photobucket.rb
32
35
  - lib/muri/filters/vimeo.rb
33
36
  - lib/muri/filters/youtube.rb
34
37
  - muri.gemspec
38
+ - test/flickr_test.rb
39
+ - test/imageshack_test.rb
40
+ - test/photobucket_test.rb
41
+ - test/vimeo_test.rb
42
+ - test/youtube_test.rb
35
43
  has_rdoc: true
36
44
  homepage: http://github.com/bananastalktome/muri/
37
45
  licenses: []
@@ -60,5 +68,9 @@ rubygems_version: 1.3.5
60
68
  signing_key:
61
69
  specification_version: 3
62
70
  summary: Media URI Parser
63
- test_files: []
64
-
71
+ test_files:
72
+ - test/flickr_test.rb
73
+ - test/imageshack_test.rb
74
+ - test/photobucket_test.rb
75
+ - test/vimeo_test.rb
76
+ - test/youtube_test.rb