msp-youtube-g 0.4.5

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.
@@ -0,0 +1,118 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'pp'
4
+
5
+ require 'youtube_g'
6
+
7
+ class TestVideoSearch < Test::Unit::TestCase
8
+
9
+ def test_should_build_basic_query_url
10
+ request = YouTubeG::Request::VideoSearch.new(:query => "penguin")
11
+ assert_equal "http://gdata.youtube.com/feeds/api/videos?vq=penguin", request.url
12
+ end
13
+
14
+ def test_should_build_multiword_metasearch_query_url
15
+ request = YouTubeG::Request::VideoSearch.new(:query => 'christina ricci')
16
+ assert_equal "http://gdata.youtube.com/feeds/api/videos?vq=christina+ricci", request.url
17
+ end
18
+
19
+ def test_should_build_video_id_url
20
+ request = YouTubeG::Request::VideoSearch.new(:video_id => 'T7YazwP8GtY')
21
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/T7YazwP8GtY", request.url
22
+ end
23
+
24
+ def test_should_build_one_tag_querl_url
25
+ request = YouTubeG::Request::VideoSearch.new(:tags => ['panther'])
26
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/panther/", request.url
27
+ end
28
+
29
+ def test_should_build_multiple_tags_query_url
30
+ request = YouTubeG::Request::VideoSearch.new(:tags => ['tiger', 'leopard'])
31
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/tiger/leopard/", request.url
32
+ end
33
+
34
+ def test_should_build_one_category_query_url
35
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:news])
36
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/", request.url
37
+ end
38
+
39
+ def test_should_build_multiple_categories_query_url
40
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:news, :sports])
41
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/Sports/", request.url
42
+ end
43
+
44
+ def test_should_build_categories_and_tags_query_url
45
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:news, :sports], :tags => ['soccer', 'football'])
46
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/Sports/soccer/football/", request.url
47
+ end
48
+
49
+ def test_should_build_categories_and_tags_url_with_max_results
50
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:music], :tags => ['classic', 'rock'], :max_results => 2)
51
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/Music/classic/rock/?max-results=2", request.url
52
+ end
53
+
54
+ def test_should_build_author_query_url
55
+ request = YouTubeG::Request::VideoSearch.new(:author => "davidguetta")
56
+ assert_equal "http://gdata.youtube.com/feeds/api/videos?author=davidguetta", request.url
57
+ end
58
+ # -- Standard Feeds --------------------------------------------------------------------------------
59
+
60
+ def test_should_build_url_for_most_viewed
61
+ request = YouTubeG::Request::StandardSearch.new(:most_viewed)
62
+ assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed", request.url
63
+ end
64
+
65
+ def test_should_raise_exception_for_invalid_type
66
+ assert_raise RuntimeError do
67
+ request = YouTubeG::Request::StandardSearch.new(:most_viewed_yo)
68
+ end
69
+ end
70
+
71
+ def test_should_build_url_for_top_rated_for_today
72
+ request = YouTubeG::Request::StandardSearch.new(:top_rated, :time => :today)
73
+ assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today", request.url
74
+ end
75
+
76
+ # -- Complex Video Queries -------------------------------------------------------------------------
77
+
78
+ def test_should_build_url_for_boolean_or_case_for_categories
79
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports] })
80
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/", request.url
81
+ end
82
+
83
+ def test_should_build_url_for_boolean_or_and_exclude_case_for_categories
84
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] })
85
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/", request.url
86
+ end
87
+
88
+ def test_should_build_url_for_exclude_case_for_tags
89
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] },
90
+ :tags => { :include => ['football'], :exclude => ['soccer'] })
91
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/football/-soccer/", request.url
92
+ end
93
+
94
+ def test_should_build_url_for_either_case_for_tags
95
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] },
96
+ :tags => { :either => ['soccer', 'football', 'donkey'] })
97
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/soccer%7Cfootball%7Cdonkey/", request.url
98
+ end
99
+
100
+ def test_should_build_url_for_query_search_with_categories_excluded
101
+ request = YouTubeG::Request::VideoSearch.new(:query => 'bench press',
102
+ :categories => { :exclude => [:comedy, :entertainment] },
103
+ :max_results => 10)
104
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/-Comedy/-Entertainment/?vq=bench+press&max-results=10", request.url
105
+ end
106
+
107
+ # -- User Queries ---------------------------------------------------------------------------------
108
+
109
+ def test_should_build_url_for_videos_by_user
110
+ request = YouTubeG::Request::UserSearch.new(:user => 'liz')
111
+ assert_equal "http://gdata.youtube.com/feeds/api/users/liz/uploads", request.url
112
+ end
113
+
114
+ def test_should_build_url_for_favorite_videos_by_user
115
+ request = YouTubeG::Request::UserSearch.new(:favorites, :user => 'liz')
116
+ assert_equal "http://gdata.youtube.com/feeds/api/users/liz/favorites", request.url
117
+ end
118
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: msp-youtube-g
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.5
5
+ platform: ruby
6
+ authors:
7
+ - Shane Vitarana
8
+ - Walter Korman
9
+ - Aman Gupta
10
+ - Filip H.F. Slagter
11
+ - msp
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2008-06-08 00:00:00 -07:00
17
+ default_executable:
18
+ dependencies: []
19
+
20
+ description: An object-oriented Ruby wrapper for the YouTube GData API
21
+ email: ruby-youtube-library@googlegroups.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files:
27
+ - History.txt
28
+ - Manifest.txt
29
+ - README.txt
30
+ files:
31
+ - History.txt
32
+ - Manifest.txt
33
+ - README.txt
34
+ - Rakefile
35
+ - TODO.txt
36
+ - lib/youtube_g.rb
37
+ - lib/youtube_g/client.rb
38
+ - lib/youtube_g/logger.rb
39
+ - lib/youtube_g/model/author.rb
40
+ - lib/youtube_g/model/category.rb
41
+ - lib/youtube_g/model/contact.rb
42
+ - lib/youtube_g/model/content.rb
43
+ - lib/youtube_g/model/playlist.rb
44
+ - lib/youtube_g/model/rating.rb
45
+ - lib/youtube_g/model/thumbnail.rb
46
+ - lib/youtube_g/model/user.rb
47
+ - lib/youtube_g/model/video.rb
48
+ - lib/youtube_g/parser.rb
49
+ - lib/youtube_g/record.rb
50
+ - lib/youtube_g/request/video_search.rb
51
+ - lib/youtube_g/request/video_upload.rb
52
+ - lib/youtube_g/response/video_search.rb
53
+ - test/test_client.rb
54
+ - test/test_video.rb
55
+ - test/test_video_search.rb
56
+ has_rdoc: true
57
+ homepage: http://youtube-g.rubyforge.org/
58
+ post_install_message:
59
+ rdoc_options:
60
+ - --main
61
+ - README.txt
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.2.0
80
+ signing_key:
81
+ specification_version: 2
82
+ summary: An object-oriented Ruby wrapper for the YouTube GData API
83
+ test_files:
84
+ - test/test_client.rb
85
+ - test/test_video.rb
86
+ - test/test_video_search.rb