youtube_it 0.0.1

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,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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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 = YouTubeIt::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
@@ -0,0 +1,78 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{youtube_it}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mauro Torres & Kyle Ginavan"]
12
+ s.date = %q{2010-07-06}
13
+ s.description = %q{the one stop shop for working with youtube apis}
14
+ s.email = %q{maurotorres@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.txt"
17
+ ]
18
+ s.files = [
19
+ "History.txt",
20
+ "Manifest.txt",
21
+ "README.txt",
22
+ "Rakefile",
23
+ "TODO.txt",
24
+ "VERSION",
25
+ "lib/youtube_it.rb",
26
+ "lib/youtube_it/chain_io.rb",
27
+ "lib/youtube_it/client.rb",
28
+ "lib/youtube_it/model/author.rb",
29
+ "lib/youtube_it/model/category.rb",
30
+ "lib/youtube_it/model/contact.rb",
31
+ "lib/youtube_it/model/content.rb",
32
+ "lib/youtube_it/model/playlist.rb",
33
+ "lib/youtube_it/model/rating.rb",
34
+ "lib/youtube_it/model/thumbnail.rb",
35
+ "lib/youtube_it/model/user.rb",
36
+ "lib/youtube_it/model/video.rb",
37
+ "lib/youtube_it/parser.rb",
38
+ "lib/youtube_it/record.rb",
39
+ "lib/youtube_it/request/base_search.rb",
40
+ "lib/youtube_it/request/standard_search.rb",
41
+ "lib/youtube_it/request/user_search.rb",
42
+ "lib/youtube_it/request/video_search.rb",
43
+ "lib/youtube_it/request/video_upload.rb",
44
+ "lib/youtube_it/response/video_search.rb",
45
+ "lib/youtube_it/version.rb",
46
+ "pkg/youtube_it-0.0.1.gem",
47
+ "test/helper.rb",
48
+ "test/test.mov",
49
+ "test/test_chain_io.rb",
50
+ "test/test_client.rb",
51
+ "test/test_video.rb",
52
+ "test/test_video_search.rb",
53
+ "youtube_it.gemspec"
54
+ ]
55
+ s.homepage = %q{http://github.com/kylejginavan/youtube_it}
56
+ s.rdoc_options = ["--charset=UTF-8"]
57
+ s.require_paths = ["lib"]
58
+ s.rubygems_version = %q{1.3.6}
59
+ s.summary = %q{the one stop shop for working with youtube apis}
60
+ s.test_files = [
61
+ "test/helper.rb",
62
+ "test/test_chain_io.rb",
63
+ "test/test_client.rb",
64
+ "test/test_video.rb",
65
+ "test/test_video_search.rb"
66
+ ]
67
+
68
+ if s.respond_to? :specification_version then
69
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
70
+ s.specification_version = 3
71
+
72
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
73
+ else
74
+ end
75
+ else
76
+ end
77
+ end
78
+
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: youtube_it
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Mauro Torres & Kyle Ginavan
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-06 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: the one stop shop for working with youtube apis
22
+ email: maurotorres@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.txt
29
+ files:
30
+ - History.txt
31
+ - Manifest.txt
32
+ - README.txt
33
+ - Rakefile
34
+ - TODO.txt
35
+ - VERSION
36
+ - lib/youtube_it.rb
37
+ - lib/youtube_it/chain_io.rb
38
+ - lib/youtube_it/client.rb
39
+ - lib/youtube_it/model/author.rb
40
+ - lib/youtube_it/model/category.rb
41
+ - lib/youtube_it/model/contact.rb
42
+ - lib/youtube_it/model/content.rb
43
+ - lib/youtube_it/model/playlist.rb
44
+ - lib/youtube_it/model/rating.rb
45
+ - lib/youtube_it/model/thumbnail.rb
46
+ - lib/youtube_it/model/user.rb
47
+ - lib/youtube_it/model/video.rb
48
+ - lib/youtube_it/parser.rb
49
+ - lib/youtube_it/record.rb
50
+ - lib/youtube_it/request/base_search.rb
51
+ - lib/youtube_it/request/standard_search.rb
52
+ - lib/youtube_it/request/user_search.rb
53
+ - lib/youtube_it/request/video_search.rb
54
+ - lib/youtube_it/request/video_upload.rb
55
+ - lib/youtube_it/response/video_search.rb
56
+ - lib/youtube_it/version.rb
57
+ - pkg/youtube_it-0.0.1.gem
58
+ - test/helper.rb
59
+ - test/test.mov
60
+ - test/test_chain_io.rb
61
+ - test/test_client.rb
62
+ - test/test_video.rb
63
+ - test/test_video_search.rb
64
+ - youtube_it.gemspec
65
+ has_rdoc: true
66
+ homepage: http://github.com/kylejginavan/youtube_it
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --charset=UTF-8
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.6
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: the one stop shop for working with youtube apis
95
+ test_files:
96
+ - test/helper.rb
97
+ - test/test_chain_io.rb
98
+ - test/test_client.rb
99
+ - test/test_video.rb
100
+ - test/test_video_search.rb