chocolate_rain 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/chocolate_rain.gemspec +3 -4
- data/lib/chocolate_rain/daemon.rb +67 -0
- data/lib/chocolate_rain/ftp_files_and_upload.rb +54 -0
- data/lib/chocolate_rain/mail_rain/inbox.rb +39 -0
- data/lib/chocolate_rain/mail_rain/mail_handler.rb +53 -0
- data/lib/chocolate_rain/version.rb +1 -1
- data/lib/chocolate_rain/y_video.rb +49 -0
- data/lib/chocolate_rain.rb +45 -4
- metadata +22 -39
- data/generators/youtube_model/USAGE +0 -3
- data/generators/youtube_model/templates/config.yml +0 -6
- data/generators/youtube_model/templates/model.rb +0 -17
- data/generators/youtube_model/templates/unit_test.rb +0 -7
- data/generators/youtube_model/youtube_model_generator.rb +0 -15
- data/lib/.DS_Store +0 -0
- data/lib/gdata/auth/authsub.rb +0 -161
- data/lib/gdata/auth/clientlogin.rb +0 -102
- data/lib/gdata/client/apps.rb +0 -27
- data/lib/gdata/client/base.rb +0 -182
- data/lib/gdata/client/blogger.rb +0 -28
- data/lib/gdata/client/booksearch.rb +0 -28
- data/lib/gdata/client/calendar.rb +0 -58
- data/lib/gdata/client/contacts.rb +0 -28
- data/lib/gdata/client/doclist.rb +0 -28
- data/lib/gdata/client/finance.rb +0 -28
- data/lib/gdata/client/gbase.rb +0 -28
- data/lib/gdata/client/gmail.rb +0 -28
- data/lib/gdata/client/health.rb +0 -28
- data/lib/gdata/client/notebook.rb +0 -28
- data/lib/gdata/client/photos.rb +0 -29
- data/lib/gdata/client/spreadsheets.rb +0 -28
- data/lib/gdata/client/webmaster_tools.rb +0 -28
- data/lib/gdata/client/youtube.rb +0 -47
- data/lib/gdata/client.rb +0 -84
- data/lib/gdata/g_data.rb +0 -22
- data/lib/gdata/http/default_service.rb +0 -82
- data/lib/gdata/http/mime_body.rb +0 -95
- data/lib/gdata/http/request.rb +0 -74
- data/lib/gdata/http/response.rb +0 -44
- data/lib/gdata/http.rb +0 -18
- data/lib/youtube_helpers.rb +0 -58
- data/lib/youtube_model.rb +0 -341
@@ -1,28 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module GData
|
16
|
-
module Client
|
17
|
-
|
18
|
-
# Client class to wrap working with the Spreadsheets API.
|
19
|
-
class Spreadsheets < Base
|
20
|
-
|
21
|
-
def initialize(options = {})
|
22
|
-
options[:clientlogin_service] ||= 'wise'
|
23
|
-
options[:authsub_scope] ||= 'http://spreadsheets.google.com/feeds/'
|
24
|
-
super(options)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module GData
|
16
|
-
module Client
|
17
|
-
|
18
|
-
# Client class to wrap working with the Webmaster Tools API.
|
19
|
-
class WebmasterTools < Base
|
20
|
-
|
21
|
-
def initialize(options = {})
|
22
|
-
options[:clientlogin_service] ||= 'sitemaps'
|
23
|
-
options[:authsub_scope] ||= 'http://www.google.com/webmasters/tools/feeds/'
|
24
|
-
super(options)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/gdata/client/youtube.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module GData
|
16
|
-
module Client
|
17
|
-
|
18
|
-
# Client class to wrap working with the YouTube API. Sets some
|
19
|
-
# YouTube-specific options.
|
20
|
-
class YouTube < Base
|
21
|
-
|
22
|
-
# The YouTube developer key being used.
|
23
|
-
attr_accessor :developer_key
|
24
|
-
# The YouTube ClientID being used.
|
25
|
-
attr_accessor :client_id
|
26
|
-
|
27
|
-
def initialize(options = {})
|
28
|
-
options[:clientlogin_service] ||= 'youtube'
|
29
|
-
options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin'
|
30
|
-
options[:authsub_scope] ||= 'http://gdata.youtube.com'
|
31
|
-
options[:version] ||= '2'
|
32
|
-
super(options)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Custom prepare_headers to include the developer key and clientID
|
36
|
-
def prepare_headers
|
37
|
-
if @client_id
|
38
|
-
@headers['X-GData-Client'] = @client_id
|
39
|
-
end
|
40
|
-
if @developer_key
|
41
|
-
@headers['X-GData-Key'] = "key=#{@developer_key}"
|
42
|
-
end
|
43
|
-
super
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/lib/gdata/client.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'gdata/client/base'
|
16
|
-
require 'gdata/client/apps'
|
17
|
-
require 'gdata/client/blogger'
|
18
|
-
require 'gdata/client/booksearch'
|
19
|
-
require 'gdata/client/calendar'
|
20
|
-
require 'gdata/client/contacts'
|
21
|
-
require 'gdata/client/doclist'
|
22
|
-
require 'gdata/client/finance'
|
23
|
-
require 'gdata/client/gbase'
|
24
|
-
require 'gdata/client/gmail'
|
25
|
-
require 'gdata/client/health'
|
26
|
-
require 'gdata/client/notebook'
|
27
|
-
require 'gdata/client/photos'
|
28
|
-
require 'gdata/client/spreadsheets'
|
29
|
-
require 'gdata/client/webmaster_tools'
|
30
|
-
require 'gdata/client/youtube'
|
31
|
-
|
32
|
-
module GData
|
33
|
-
module Client
|
34
|
-
|
35
|
-
# Base class for GData::Client errors
|
36
|
-
class Error < RuntimeError
|
37
|
-
end
|
38
|
-
|
39
|
-
# Base class for errors raised due to requests
|
40
|
-
class RequestError < Error
|
41
|
-
|
42
|
-
# The Net::HTTPResponse that caused this error.
|
43
|
-
attr_accessor :response
|
44
|
-
|
45
|
-
# Creates a new RequestError from Net::HTTPResponse +response+ with a
|
46
|
-
# message containing the error code and response body.
|
47
|
-
def initialize(response)
|
48
|
-
@response = response
|
49
|
-
|
50
|
-
super "request error #{response.status_code}: #{response.body}"
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
class AuthorizationError < RequestError
|
56
|
-
end
|
57
|
-
|
58
|
-
class BadRequestError < RequestError
|
59
|
-
end
|
60
|
-
|
61
|
-
# An error caused by ClientLogin issuing a CAPTCHA error.
|
62
|
-
class CaptchaError < RuntimeError
|
63
|
-
# The token identifying the CAPTCHA
|
64
|
-
attr_reader :token
|
65
|
-
# The URL to the CAPTCHA image
|
66
|
-
attr_reader :url
|
67
|
-
|
68
|
-
def initialize(token, url)
|
69
|
-
@token = token
|
70
|
-
@url = url
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class ServerError < RequestError
|
75
|
-
end
|
76
|
-
|
77
|
-
class UnknownError < RequestError
|
78
|
-
end
|
79
|
-
|
80
|
-
class VersionConflictError < RequestError
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
data/lib/gdata/g_data.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'gdata/auth/clientlogin'
|
16
|
-
require 'gdata/auth/authsub'
|
17
|
-
|
18
|
-
module GData
|
19
|
-
module Auth
|
20
|
-
SOURCE_LIB_STRING = 'GoogleDataRubyUtil-'
|
21
|
-
end
|
22
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'net/http'
|
16
|
-
require 'net/https'
|
17
|
-
require 'uri'
|
18
|
-
|
19
|
-
module GData
|
20
|
-
module HTTP
|
21
|
-
|
22
|
-
# This is the default implementation of the HTTP layer that uses
|
23
|
-
# Net::HTTP. You could roll your own if you have different requirements
|
24
|
-
# or cannot use Net::HTTP for some reason.
|
25
|
-
class DefaultService
|
26
|
-
|
27
|
-
# Take a GData::HTTP::Request, execute the request, and return a
|
28
|
-
# GData::HTTP::Response object.
|
29
|
-
def make_request(request)
|
30
|
-
url = URI.parse(request.url)
|
31
|
-
http = Net::HTTP.new(url.host, url.port)
|
32
|
-
http.use_ssl = (url.scheme == 'https')
|
33
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
34
|
-
|
35
|
-
case request.method
|
36
|
-
when :get
|
37
|
-
req = Net::HTTP::Get.new(url.request_uri)
|
38
|
-
when :put
|
39
|
-
req = Net::HTTP::Put.new(url.request_uri)
|
40
|
-
when :post
|
41
|
-
req = Net::HTTP::Post.new(url.request_uri)
|
42
|
-
when :delete
|
43
|
-
req = Net::HTTP::Delete.new(url.request_uri)
|
44
|
-
else
|
45
|
-
raise ArgumentError, "Unsupported HTTP method specified."
|
46
|
-
end
|
47
|
-
|
48
|
-
case request.body
|
49
|
-
when String
|
50
|
-
req.body = request.body
|
51
|
-
when Hash
|
52
|
-
req.set_form_data(request.body)
|
53
|
-
when File
|
54
|
-
req.body_stream = request.body
|
55
|
-
request.chunked = true
|
56
|
-
when GData::HTTP::MimeBody
|
57
|
-
req.body_stream = request.body
|
58
|
-
request.chunked = true
|
59
|
-
else
|
60
|
-
req.body = request.body.to_s
|
61
|
-
end
|
62
|
-
|
63
|
-
request.headers.each do |key, value|
|
64
|
-
req[key] = value
|
65
|
-
end
|
66
|
-
|
67
|
-
request.calculate_length!
|
68
|
-
|
69
|
-
res = http.request(req)
|
70
|
-
|
71
|
-
response = Response.new
|
72
|
-
response.body = res.body
|
73
|
-
response.headers = Hash.new
|
74
|
-
res.each do |key, value|
|
75
|
-
response.headers[key] = value
|
76
|
-
end
|
77
|
-
response.status_code = res.code.to_i
|
78
|
-
return response
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
data/lib/gdata/http/mime_body.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
module GData
|
17
|
-
module HTTP
|
18
|
-
|
19
|
-
# Class acts as a virtual file handle to a MIME multipart message body
|
20
|
-
class MimeBody
|
21
|
-
|
22
|
-
# The MIME boundary being used.
|
23
|
-
attr_reader :boundary
|
24
|
-
|
25
|
-
# All fields are required, the entry should be a string and is assumed
|
26
|
-
# to be XML.
|
27
|
-
def initialize(entry, file, file_mime_type)
|
28
|
-
@boundary = "END_OF_PART_#{rand(64000)}"
|
29
|
-
entry = wrap_entry(entry, file_mime_type)
|
30
|
-
closing_boundary = MimeBodyString.new("\r\n--#{@boundary}--")
|
31
|
-
@parts = [entry, file, closing_boundary]
|
32
|
-
@current_part = 0
|
33
|
-
end
|
34
|
-
|
35
|
-
# Implement read so that this class can be treated as a stream.
|
36
|
-
def read(bytes_requested)
|
37
|
-
if @current_part >= @parts.length
|
38
|
-
return false
|
39
|
-
end
|
40
|
-
|
41
|
-
buffer = @parts[@current_part].read(bytes_requested)
|
42
|
-
|
43
|
-
until buffer.length == bytes_requested
|
44
|
-
@current_part += 1
|
45
|
-
next_buffer = self.read(bytes_requested - buffer.length)
|
46
|
-
break if not next_buffer
|
47
|
-
buffer += next_buffer
|
48
|
-
end
|
49
|
-
|
50
|
-
return buffer
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns the content type of the message including boundary.
|
54
|
-
def content_type
|
55
|
-
return "multipart/related; boundary=\"#{@boundary}\""
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
# Sandwiches the entry body into a MIME message
|
61
|
-
def wrap_entry(entry, file_mime_type)
|
62
|
-
wrapped_entry = "--#{@boundary}\r\n"
|
63
|
-
wrapped_entry += "Content-Type: application/atom+xml\r\n\r\n"
|
64
|
-
wrapped_entry += entry
|
65
|
-
wrapped_entry += "--#{@boundary}\r\n"
|
66
|
-
wrapped_entry += "Content-Type: #{file_mime_type}\r\n\r\n"
|
67
|
-
return MimeBodyString.new(wrapped_entry)
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
# Class makes a string into a stream-like object
|
73
|
-
class MimeBodyString
|
74
|
-
|
75
|
-
def initialize(source_string)
|
76
|
-
@string = source_string
|
77
|
-
@bytes_read = 0
|
78
|
-
end
|
79
|
-
|
80
|
-
# Implement read so that this class can be treated as a stream.
|
81
|
-
def read(bytes_requested)
|
82
|
-
if @bytes_read == @string.length
|
83
|
-
return false
|
84
|
-
elsif bytes_requested > @string.length - @bytes_read
|
85
|
-
bytes_requested = @string.length - @bytes_read
|
86
|
-
end
|
87
|
-
|
88
|
-
buffer = @string[@bytes_read, bytes_requested]
|
89
|
-
@bytes_read += bytes_requested
|
90
|
-
|
91
|
-
return buffer
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
data/lib/gdata/http/request.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require "rexml/document"
|
16
|
-
|
17
|
-
module GData
|
18
|
-
module HTTP
|
19
|
-
|
20
|
-
# Very simple class to hold everything about an HTTP request.
|
21
|
-
class Request
|
22
|
-
|
23
|
-
# The URL of the request.
|
24
|
-
attr_accessor :url
|
25
|
-
# The body of the request.
|
26
|
-
attr_accessor :body
|
27
|
-
# The HTTP method being used in the request.
|
28
|
-
attr_accessor :method
|
29
|
-
# The HTTP headers of the request.
|
30
|
-
attr_accessor :headers
|
31
|
-
|
32
|
-
# Only the URL itself is required, everything else is optional.
|
33
|
-
def initialize(url, options = {})
|
34
|
-
@url = url
|
35
|
-
options.each do |key, value|
|
36
|
-
self.send("#{key}=", value)
|
37
|
-
end
|
38
|
-
|
39
|
-
@method ||= :get
|
40
|
-
@headers ||= {}
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns whether or not a request is chunked.
|
44
|
-
def chunked?
|
45
|
-
if @headers['Transfer-Encoding'] == 'chunked'
|
46
|
-
return true
|
47
|
-
else
|
48
|
-
return false
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Sets if the request is using chunked transfer-encoding.
|
53
|
-
def chunked=(enabled)
|
54
|
-
if enabled
|
55
|
-
@headers['Transfer-Encoding'] = 'chunked'
|
56
|
-
else
|
57
|
-
@headers.delete('Transfer-Encoding')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Calculates and sets the length of the body.
|
62
|
-
def calculate_length!
|
63
|
-
if not @headers['Content-Length'] and not chunked? \
|
64
|
-
and method != :get and method != :delete
|
65
|
-
if @body
|
66
|
-
@headers['Content-Length'] = @body.length
|
67
|
-
else
|
68
|
-
@headers['Content-Length'] = 0
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
data/lib/gdata/http/response.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'gdata/client'
|
16
|
-
|
17
|
-
module GData
|
18
|
-
module HTTP
|
19
|
-
|
20
|
-
# An extremely simple class to hold the values of an HTTP response.
|
21
|
-
class Response
|
22
|
-
|
23
|
-
# The HTTP response code.
|
24
|
-
attr_accessor :status_code
|
25
|
-
# The body of the HTTP response.
|
26
|
-
attr_accessor :body
|
27
|
-
# The headers of the HTTP response.
|
28
|
-
attr_accessor :headers
|
29
|
-
|
30
|
-
# Converts the response body into a REXML::Document
|
31
|
-
def to_xml
|
32
|
-
if @body
|
33
|
-
begin
|
34
|
-
return REXML::Document.new(@body).root
|
35
|
-
rescue
|
36
|
-
raise GData::Client::Error, "Response body not XML."
|
37
|
-
end
|
38
|
-
else
|
39
|
-
return nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/gdata/http.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# Copyright (C) 2008 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'gdata/http/default_service'
|
16
|
-
require 'gdata/http/mime_body'
|
17
|
-
require 'gdata/http/request'
|
18
|
-
require 'gdata/http/response'
|
data/lib/youtube_helpers.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
module YouTubeModel # :nodoc:
|
2
|
-
module Helpers
|
3
|
-
# This helper returns the required html to embed a youtube video.
|
4
|
-
# You can customize it with the following options:
|
5
|
-
# * <tt>:border</tt> Specifies if the player is bordered or not.
|
6
|
-
# * <tt>:related</tt> Specifies if the player will include related videos.
|
7
|
-
# * <tt>:colors</tt> Array with the desired colors of the player.
|
8
|
-
# * <tt>:language</tt> Specifies the language of the player.
|
9
|
-
# * <tt>:width</tt> Specifies the player's width.
|
10
|
-
# * <tt>:height</tt> Specifies the player's height.
|
11
|
-
#
|
12
|
-
# Example:
|
13
|
-
# # in controller:
|
14
|
-
# @top_rated = YouTube.top_rated(:today)
|
15
|
-
#
|
16
|
-
# # in view:
|
17
|
-
# <% @top_rated.videos.each do |video| -%>
|
18
|
-
# <p><%= youtube_embed video, :border => true %></p>
|
19
|
-
# <% end -%>
|
20
|
-
def youtube_embed(video, options = {})
|
21
|
-
settings = {
|
22
|
-
:border => '0',
|
23
|
-
:rel => '0',
|
24
|
-
:color1 => '0x666666',
|
25
|
-
:color2 => '0x666666',
|
26
|
-
:hl => 'en',
|
27
|
-
:width => 425,
|
28
|
-
:height => 373
|
29
|
-
}.merge(options)
|
30
|
-
|
31
|
-
params = settings.to_query
|
32
|
-
%Q(
|
33
|
-
<object width="#{settings[:width]}" height="#{settings[:height]}">
|
34
|
-
<param name="movie" value="http://www.youtube.com/v/#{video.id}&#{params}"></param>
|
35
|
-
<param name="wmode" value="transparent"></param>
|
36
|
-
<embed src="http://www.youtube.com/v/#{video.id}&#{params}" type="application/x-shockwave-flash" wmode="transparent" width="#{settings[:width]}" height="#{settings[:height]}"></embed>
|
37
|
-
</object>
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Returns a link to the authentication Google page.
|
42
|
-
#
|
43
|
-
# Pass the new_<your-controller>_url or whatever url you use to the Upload's step 1
|
44
|
-
#
|
45
|
-
# Example:
|
46
|
-
# <%= link_to 'Upload a new video', youtube_auth_url(new_videos_url) %>
|
47
|
-
#
|
48
|
-
def youtube_auth_url(next_url)
|
49
|
-
params = {
|
50
|
-
:session => YT_CONFIG['auth_sub']['session'],
|
51
|
-
:secure => YT_CONFIG['auth_sub']['secure'],
|
52
|
-
:scope => 'http://gdata.youtube.com',
|
53
|
-
:next => next_url
|
54
|
-
}
|
55
|
-
"https://www.google.com/accounts/AuthSubRequest?#{params.to_query}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|