tmm1-youtube-g 0.4.9 → 0.4.9.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,43 @@
1
+ class YouTubeG
2
+ module Request #:nodoc:
3
+ class BaseSearch #:nodoc:
4
+ attr_reader :url
5
+
6
+ private
7
+
8
+ def base_url #:nodoc:
9
+ "http://gdata.youtube.com/feeds/api/"
10
+ end
11
+
12
+ def set_instance_variables( variables ) #:nodoc:
13
+ variables.each do |key, value|
14
+ name = key.to_s
15
+ instance_variable_set("@#{name}", value) if respond_to?(name)
16
+ end
17
+ end
18
+
19
+ def build_query_params(params) #:nodoc:
20
+ # nothing to do if there are no params
21
+ return '' if (!params || params.empty?)
22
+
23
+ # build up the query param string, tacking on every key/value
24
+ # pair for which the value is non-nil
25
+ u = '?'
26
+ item_count = 0
27
+ params.keys.each do |key|
28
+ value = params[key]
29
+ next if value.nil?
30
+
31
+ u << '&' if (item_count > 0)
32
+ u << "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
33
+ item_count += 1
34
+ end
35
+
36
+ # if we found no non-nil values, we've got no params so just
37
+ # return an empty string
38
+ (item_count == 0) ? '' : u
39
+ end
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,40 @@
1
+ class YouTubeG
2
+ module Request #:nodoc:
3
+ class StandardSearch < BaseSearch #:nodoc:
4
+ attr_reader :max_results # max_results
5
+ attr_reader :order_by # orderby, ([relevance], viewCount, published, rating)
6
+ attr_reader :offset # start-index
7
+ attr_reader :time # time
8
+
9
+ TYPES = [ :top_rated, :top_favorites, :most_viewed, :most_popular,
10
+ :most_recent, :most_discussed, :most_linked, :most_responded,
11
+ :recently_featured, :watch_on_mobile ]
12
+
13
+ def initialize(type, options={})
14
+ if TYPES.include?(type)
15
+ @max_results, @order_by, @offset, @time = nil
16
+ set_instance_variables(options)
17
+ @url = base_url + type.to_s << build_query_params(to_youtube_params)
18
+ else
19
+ raise "Invalid type, must be one of: #{ TYPES.map { |t| t.to_s }.join(", ") }"
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def base_url #:nodoc:
26
+ super << "standardfeeds/"
27
+ end
28
+
29
+ def to_youtube_params #:nodoc:
30
+ {
31
+ 'max-results' => @max_results,
32
+ 'orderby' => @order_by,
33
+ 'start-index' => @offset,
34
+ 'time' => @time
35
+ }
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,18 @@
1
+ class YouTubeG
2
+ module Request #:nodoc:
3
+ class UserSearch < BaseSearch #:nodoc:
4
+ def initialize(params, options={})
5
+ @url = base_url
6
+ return @url << "#{options[:user]}/favorites" if params == :favorites
7
+ @url << "#{params[:user]}/uploads" if params[:user]
8
+ end
9
+
10
+ private
11
+
12
+ def base_url #:nodoc:
13
+ super << "users/"
14
+ end
15
+ end
16
+
17
+ end
18
+ end
data/youtube-g.gemspec ADDED
@@ -0,0 +1,51 @@
1
+ spec = Gem::Specification.new do |s|
2
+ s.name = 'youtube-g'
3
+ s.version = '0.4.9.1'
4
+ s.date = '2008-06-08'
5
+ s.summary = 'An object-oriented Ruby wrapper for the YouTube GData API'
6
+ s.email = "ruby-youtube-library@googlegroups.com"
7
+ s.homepage = "http://youtube-g.rubyforge.org/"
8
+ s.description = "An object-oriented Ruby wrapper for the YouTube GData API"
9
+ s.has_rdoc = true
10
+ s.authors = ["Shane Vitarana", "Walter Korman", "Aman Gupta", "Filip H.F. Slagter"]
11
+
12
+ # ruby -rpp -e "pp Dir['**/*.*'].map"
13
+ s.files = [
14
+ "History.txt",
15
+ "README.txt",
16
+ "TODO.txt",
17
+ "lib/youtube_g/client.rb",
18
+ "lib/youtube_g/logger.rb",
19
+ "lib/youtube_g/model/author.rb",
20
+ "lib/youtube_g/model/category.rb",
21
+ "lib/youtube_g/model/contact.rb",
22
+ "lib/youtube_g/model/content.rb",
23
+ "lib/youtube_g/model/playlist.rb",
24
+ "lib/youtube_g/model/rating.rb",
25
+ "lib/youtube_g/model/thumbnail.rb",
26
+ "lib/youtube_g/model/user.rb",
27
+ "lib/youtube_g/model/video.rb",
28
+ "lib/youtube_g/parser.rb",
29
+ "lib/youtube_g/record.rb",
30
+ "lib/youtube_g/request/base_search.rb",
31
+ "lib/youtube_g/request/standard_search.rb",
32
+ "lib/youtube_g/request/user_search.rb",
33
+ "lib/youtube_g/request/video_search.rb",
34
+ "lib/youtube_g/request/video_upload.rb",
35
+ "lib/youtube_g/response/video_search.rb",
36
+ "lib/youtube_g.rb",
37
+ "test/test_client.rb",
38
+ "test/test_video.rb",
39
+ "test/test_video_search.rb",
40
+ "youtube-g.gemspec"
41
+ ]
42
+
43
+ s.test_files = [
44
+ "test/test_client.rb",
45
+ "test/test_video.rb",
46
+ "test/test_video_search.rb"
47
+ ]
48
+
49
+ s.rdoc_options = ["--main", "README.txt"]
50
+ s.extra_rdoc_files = ["History.txt", "README.txt"]
51
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmm1-youtube-g
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Vitarana
@@ -24,15 +24,11 @@ extensions: []
24
24
 
25
25
  extra_rdoc_files:
26
26
  - History.txt
27
- - Manifest.txt
28
27
  - README.txt
29
28
  files:
30
29
  - History.txt
31
- - Manifest.txt
32
30
  - README.txt
33
- - Rakefile
34
31
  - TODO.txt
35
- - lib/youtube_g.rb
36
32
  - lib/youtube_g/client.rb
37
33
  - lib/youtube_g/logger.rb
38
34
  - lib/youtube_g/model/author.rb
@@ -46,12 +42,17 @@ files:
46
42
  - lib/youtube_g/model/video.rb
47
43
  - lib/youtube_g/parser.rb
48
44
  - lib/youtube_g/record.rb
45
+ - lib/youtube_g/request/base_search.rb
46
+ - lib/youtube_g/request/standard_search.rb
47
+ - lib/youtube_g/request/user_search.rb
49
48
  - lib/youtube_g/request/video_search.rb
50
49
  - lib/youtube_g/request/video_upload.rb
51
50
  - lib/youtube_g/response/video_search.rb
51
+ - lib/youtube_g.rb
52
52
  - test/test_client.rb
53
53
  - test/test_video.rb
54
54
  - test/test_video_search.rb
55
+ - youtube-g.gemspec
55
56
  has_rdoc: true
56
57
  homepage: http://youtube-g.rubyforge.org/
57
58
  post_install_message:
data/Manifest.txt DELETED
@@ -1,28 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- TODO.txt
6
- lib/youtube_g.rb
7
- lib/youtube_g/client.rb
8
- lib/youtube_g/logger.rb
9
- lib/youtube_g/model/author.rb
10
- lib/youtube_g/model/category.rb
11
- lib/youtube_g/model/contact.rb
12
- lib/youtube_g/model/content.rb
13
- lib/youtube_g/model/playlist.rb
14
- lib/youtube_g/model/rating.rb
15
- lib/youtube_g/model/thumbnail.rb
16
- lib/youtube_g/model/user.rb
17
- lib/youtube_g/model/video.rb
18
- lib/youtube_g/parser.rb
19
- lib/youtube_g/record.rb
20
- lib/youtube_g/request/base_search.rb
21
- lib/youtube_g/request/standard_search.rb
22
- lib/youtube_g/request/user_search.rb
23
- lib/youtube_g/request/video_search.rb
24
- lib/youtube_g/request/video_upload.rb
25
- lib/youtube_g/response/video_search.rb
26
- test/test_client.rb
27
- test/test_video.rb
28
- test/test_video_search.rb
data/Rakefile DELETED
@@ -1,25 +0,0 @@
1
- require 'rubygems'
2
- require 'hoe'
3
- require 'lib/youtube_g'
4
-
5
- Hoe.new('youtube-g', YouTubeG::VERSION) do |p|
6
- p.rubyforge_name = 'youtube-g'
7
- p.author = ["Shane Vitarana", "Walter Korman", "Aman Gupta", "Filip H.F. Slagter"]
8
- p.email = 'shanev@gmail.com'
9
- p.summary = 'Ruby client for the YouTube GData API'
10
- p.description = p.paragraphs_of('README.txt', 2..8).join("\n\n")
11
- p.url = 'http://rubyforge.org/projects/youtube-g/'
12
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
13
- p.remote_rdoc_dir = ''
14
- end
15
-
16
- desc 'Tag release'
17
- task :tag do
18
- svn_root = 'svn+ssh://drummr77@rubyforge.org/var/svn/youtube-g'
19
- sh %(svn cp #{svn_root}/trunk #{svn_root}/tags/release-#{YouTubeG::VERSION} -m "Tag YouTubeG release #{YouTubeG::VERSION}")
20
- end
21
-
22
- desc 'Load the library in an IRB session'
23
- task :console do
24
- sh %(irb -r lib/youtube_g.rb)
25
- end