agiley-youtube-g 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,134 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestVideoSearch < Test::Unit::TestCase
4
+
5
+ def test_should_build_basic_query_url
6
+ request = YouTubeG::Request::VideoSearch.new(:query => "penguin")
7
+ assert_equal "http://gdata.youtube.com/feeds/api/videos?vq=penguin", request.url
8
+ end
9
+
10
+ def test_should_build_multiword_metasearch_query_url
11
+ request = YouTubeG::Request::VideoSearch.new(:query => 'christina ricci')
12
+ assert_equal "http://gdata.youtube.com/feeds/api/videos?vq=christina+ricci", request.url
13
+ end
14
+
15
+ def test_should_build_video_id_url
16
+ request = YouTubeG::Request::VideoSearch.new(:video_id => 'T7YazwP8GtY')
17
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/T7YazwP8GtY", request.url
18
+ end
19
+
20
+ def test_should_build_one_tag_querl_url
21
+ request = YouTubeG::Request::VideoSearch.new(:tags => ['panther'])
22
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/panther/", request.url
23
+ end
24
+
25
+ def test_should_build_multiple_tags_query_url
26
+ request = YouTubeG::Request::VideoSearch.new(:tags => ['tiger', 'leopard'])
27
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/tiger/leopard/", request.url
28
+ end
29
+
30
+ def test_should_build_one_category_query_url
31
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:news])
32
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/", request.url
33
+ end
34
+
35
+ def test_should_build_multiple_categories_query_url
36
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:news, :sports])
37
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/Sports/", request.url
38
+ end
39
+
40
+ def test_should_build_categories_and_tags_query_url
41
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:news, :sports], :tags => ['soccer', 'football'])
42
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/Sports/soccer/football/", request.url
43
+ end
44
+
45
+ def test_should_build_categories_and_tags_url_with_max_results
46
+ request = YouTubeG::Request::VideoSearch.new(:categories => [:music], :tags => ['classic', 'rock'], :max_results => 2)
47
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/Music/classic/rock/?max-results=2", request.url
48
+ end
49
+
50
+ def test_should_build_author_query_url
51
+ request = YouTubeG::Request::VideoSearch.new(:author => "davidguetta")
52
+ assert_equal "http://gdata.youtube.com/feeds/api/videos?author=davidguetta", request.url
53
+ end
54
+ # -- Standard Feeds --------------------------------------------------------------------------------
55
+
56
+ def test_should_build_url_for_most_viewed
57
+ request = YouTubeG::Request::StandardSearch.new(:most_viewed)
58
+ assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed", request.url
59
+ end
60
+
61
+ def test_should_build_url_for_top_rated_for_today
62
+ request = YouTubeG::Request::StandardSearch.new(:top_rated, :time => :today)
63
+ assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today", request.url
64
+ end
65
+
66
+ def test_should_build_url_for_most_viewed_offset_and_max_results_without_time
67
+ request = YouTubeG::Request::StandardSearch.new(:top_rated, :offset => 5, :max_results => 10)
68
+ assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?max-results=10&start-index=5", request.url
69
+ end
70
+
71
+ def test_should_build_url_for_most_viewed_offset_and_max_results_with_time
72
+ request = YouTubeG::Request::StandardSearch.new(:top_rated, :offset => 5, :max_results => 10, :time => :today)
73
+ assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?max-results=10&start-index=5&time=today", request.url
74
+ end
75
+
76
+ def test_should_raise_exception_for_invalid_type
77
+ assert_raise RuntimeError do
78
+ request = YouTubeG::Request::StandardSearch.new(:most_viewed_yo)
79
+ end
80
+ end
81
+
82
+ # -- Complex Video Queries -------------------------------------------------------------------------
83
+
84
+ def test_should_build_url_for_boolean_or_case_for_categories
85
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports] })
86
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/", request.url
87
+ end
88
+
89
+ def test_should_build_url_for_boolean_or_and_exclude_case_for_categories
90
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] })
91
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/", request.url
92
+ end
93
+
94
+ def test_should_build_url_for_exclude_case_for_tags
95
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] },
96
+ :tags => { :include => ['football'], :exclude => ['soccer'] })
97
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/football/-soccer/", request.url
98
+ end
99
+
100
+ def test_should_build_url_for_either_case_for_tags
101
+ request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] },
102
+ :tags => { :either => ['soccer', 'football', 'donkey'] })
103
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/soccer%7Cfootball%7Cdonkey/", request.url
104
+ end
105
+
106
+ def test_should_build_url_for_query_search_with_categories_excluded
107
+ request = YouTubeG::Request::VideoSearch.new(:query => 'bench press',
108
+ :categories => { :exclude => [:comedy, :entertainment] },
109
+ :max_results => 10)
110
+ assert_equal "http://gdata.youtube.com/feeds/api/videos/-/-Comedy/-Entertainment/?max-results=10&vq=bench+press", request.url
111
+ end
112
+
113
+ # -- User Queries ---------------------------------------------------------------------------------
114
+
115
+ def test_should_build_url_for_videos_by_user
116
+ request = YouTubeG::Request::UserSearch.new(:user => 'liz')
117
+ assert_equal "http://gdata.youtube.com/feeds/api/users/liz/uploads", request.url
118
+ end
119
+
120
+ def test_should_build_url_for_videos_by_user_paginate_and_order
121
+ request = YouTubeG::Request::UserSearch.new(:user => 'liz', :offset => 20, :max_results => 10, :order_by => 'published')
122
+ assert_equal "http://gdata.youtube.com/feeds/api/users/liz/uploads?max-results=10&orderby=published&start-index=20", request.url
123
+ end
124
+
125
+ def test_should_build_url_for_favorite_videos_by_user
126
+ request = YouTubeG::Request::UserSearch.new(:favorites, :user => 'liz')
127
+ assert_equal "http://gdata.youtube.com/feeds/api/users/liz/favorites", request.url
128
+ end
129
+
130
+ def test_should_build_url_for_favorite_videos_by_user_paginate
131
+ request = YouTubeG::Request::UserSearch.new(:favorites, :user => 'liz', :offset => 20, :max_results => 10)
132
+ assert_equal "http://gdata.youtube.com/feeds/api/users/liz/favorites?max-results=10&start-index=20", request.url
133
+ end
134
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: agiley-youtube-g
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 2
10
+ version: 0.6.2
11
+ platform: ruby
12
+ authors:
13
+ - Shane Vitarana
14
+ - Walter Korman
15
+ - Aman Gupta
16
+ - Filip H.F. Slagter
17
+ - msp
18
+ autorequire:
19
+ bindir: bin
20
+ cert_chain: []
21
+
22
+ date: 2010-08-27 00:00:00 +02:00
23
+ default_executable:
24
+ dependencies:
25
+ - !ruby/object:Gem::Dependency
26
+ name: builder
27
+ prerelease: false
28
+ requirement: &id001 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ hash: 3
34
+ segments:
35
+ - 0
36
+ version: "0"
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: hoe
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 49
48
+ segments:
49
+ - 1
50
+ - 8
51
+ - 3
52
+ version: 1.8.3
53
+ type: :development
54
+ version_requirements: *id002
55
+ description: "youtube-g is a pure Ruby client for the YouTube GData API. It provides an easy way to access the latest YouTube video search results from your own programs. In comparison with the earlier Youtube search interfaces, this new API and library offers much-improved flexibility around executing complex search queries to obtain well-targeted video search results. More detail on the underlying source Google-provided API is available at: http://code.google.com/apis/youtube/overview.html"
56
+ email: sebastian@agiley.se
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.txt
65
+ - TODO.txt
66
+ files:
67
+ - History.txt
68
+ - Manifest.txt
69
+ - README.txt
70
+ - Rakefile
71
+ - TODO.txt
72
+ - lib/youtube_g.rb
73
+ - lib/youtube_g/chain_io.rb
74
+ - lib/youtube_g/client.rb
75
+ - lib/youtube_g/model/author.rb
76
+ - lib/youtube_g/model/category.rb
77
+ - lib/youtube_g/model/contact.rb
78
+ - lib/youtube_g/model/content.rb
79
+ - lib/youtube_g/model/playlist.rb
80
+ - lib/youtube_g/model/rating.rb
81
+ - lib/youtube_g/model/thumbnail.rb
82
+ - lib/youtube_g/model/user.rb
83
+ - lib/youtube_g/model/video.rb
84
+ - lib/youtube_g/parser.rb
85
+ - lib/youtube_g/record.rb
86
+ - lib/youtube_g/request/base_search.rb
87
+ - lib/youtube_g/request/standard_search.rb
88
+ - lib/youtube_g/request/user_search.rb
89
+ - lib/youtube_g/request/video_search.rb
90
+ - lib/youtube_g/request/video_upload.rb
91
+ - lib/youtube_g/response/video_search.rb
92
+ - lib/youtube_g/version.rb
93
+ - test/helper.rb
94
+ - test/test_chain_io.rb
95
+ - test/test_client.rb
96
+ - test/test_video.rb
97
+ - test/test_video_search.rb
98
+ - lib/youtube_g/model/comment.rb
99
+ - lib/youtube_g/request/comments_search.rb
100
+ - lib/youtube_g/response/comments_search.rb
101
+ has_rdoc: true
102
+ homepage: http://rubyforge.org/projects/youtube-g/
103
+ licenses: []
104
+
105
+ post_install_message:
106
+ rdoc_options:
107
+ - --main
108
+ - README.txt
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ requirements: []
130
+
131
+ rubyforge_project: youtube-g
132
+ rubygems_version: 1.3.7
133
+ signing_key:
134
+ specification_version: 2
135
+ summary: Ruby client for the YouTube GData API
136
+ test_files:
137
+ - test/test_chain_io.rb
138
+ - test/test_client.rb
139
+ - test/test_video.rb
140
+ - test/test_video_search.rb