mcfearsome-viddler 0.2.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.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ doc
2
+ log/*.log
data/History.txt ADDED
@@ -0,0 +1,23 @@
1
+ == 0.2.4 2008-10-20
2
+ * 1 enhancement:
3
+ * Added dimensions to video
4
+
5
+ == 0.2.2 2008-04-19
6
+
7
+ * 1 enhancement:
8
+ * Viddler::Video#embed_code method now can receive hash with options
9
+
10
+ == 0.2.1 2008-04-19
11
+
12
+ * 1 bug fix:
13
+ * Fixing compatibility of <tt>viddler.videos.upload</tt> method with Rails
14
+
15
+ == 0.2.0 2008-04-18
16
+
17
+ * 1 major enhancement:
18
+ * Implemented <tt>videos.getRecordToken</tt> method
19
+
20
+ == 0.1.0 2008-04-17
21
+
22
+ * 1 major enhancement:
23
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Ilya Sabanin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,35 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ lib/ext/array.rb
9
+ lib/ext/hash.rb
10
+ lib/ext/open_struct.rb
11
+ lib/viddler.rb
12
+ lib/viddler/api_spec.rb
13
+ lib/viddler/base.rb
14
+ lib/viddler/comment.rb
15
+ lib/viddler/request.rb
16
+ lib/viddler/user.rb
17
+ lib/viddler/version.rb
18
+ lib/viddler/video.rb
19
+ script/console
20
+ script/destroy
21
+ script/generate
22
+ script/txt2html
23
+ setup.rb
24
+ tasks/deployment.rake
25
+ tasks/environment.rake
26
+ tasks/website.rake
27
+ test/test_helper.rb
28
+ test/test_viddler.rb
29
+ test/viddler.yml.sample
30
+ viddler.gemspec
31
+ website/index.html
32
+ website/index.txt
33
+ website/javascripts/rounded_corners_lite.inc.js
34
+ website/stylesheets/screen.css
35
+ website/template.html.erb
data/README.txt ADDED
@@ -0,0 +1,75 @@
1
+ = Viddler.rb
2
+
3
+ * Rubyforge profile: http://viddler.rubyforge.com
4
+ * Source code: http://github.com/iSabanin/viddler
5
+ * Tracker: http://ilya_sabanin.lighthouseapp.com/projects/10110-viddler-rb/overview
6
+
7
+ == DESCRIPTION:
8
+
9
+ Ruby wrapper around Viddler.com[http://www.viddler.com] API.
10
+
11
+ == FEATURES:
12
+
13
+ Currently implemented API methods:
14
+
15
+ * viddler.videos.getRecordToken
16
+ * viddler.users.register
17
+ * viddler.users.auth
18
+ * viddler.users.getProfile
19
+ * viddler.users.setProfile
20
+ * viddler.users.setOptions
21
+ * viddler.videos.upload
22
+ * viddler.videos.getStatus
23
+ * viddler.videos.getDetails
24
+ * viddler.videos.getDetailsByUrl
25
+ * viddler.videos.setDetails
26
+ * viddler.videos.getByUser
27
+ * viddler.videos.getByTag
28
+ * viddler.videos.getFeatured
29
+
30
+ == NOT YET IMPLEMENTED:
31
+
32
+ * Wrapper for video permissions.
33
+
34
+ == REQUIREMENTS:
35
+
36
+ * active_support[http://rubyforge.org/projects/activesupport/]
37
+ * rest-client[http://rubyforge.org/projects/rest-client/]
38
+ * mime-types[http://rubyforge.org/projects/mime-types/]
39
+
40
+ == INSTALL:
41
+
42
+ * sudo gem install viddler
43
+
44
+ == CONTACT:
45
+
46
+ * ilya dot sabanin at gmail.com
47
+
48
+ == CONTRIBUTORS:
49
+
50
+ * Kyle Slattery
51
+
52
+ == LICENSE:
53
+
54
+ (The MIT License)
55
+
56
+ Copyright (c) 2008 Ilya Sabanin
57
+
58
+ Permission is hereby granted, free of charge, to any person obtaining
59
+ a copy of this software and associated documentation files (the
60
+ 'Software'), to deal in the Software without restriction, including
61
+ without limitation the rights to use, copy, modify, merge, publish,
62
+ distribute, sublicense, and/or sell copies of the Software, and to
63
+ permit persons to whom the Software is furnished to do so, subject to
64
+ the following conditions:
65
+
66
+ The above copyright notice and this permission notice shall be
67
+ included in all copies or substantial portions of the Software.
68
+
69
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
70
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
72
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
73
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
74
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
75
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/config/hoe.rb ADDED
@@ -0,0 +1,70 @@
1
+ require 'viddler/version'
2
+
3
+ AUTHOR = 'Ilya Sabanin' # can also be an array of Authors
4
+ EMAIL = 'ilya.sabanin@gmail.com'
5
+ DESCRIPTION = 'Ruby wrapper around Viddler.com API.'
6
+ GEM_NAME = 'viddler' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'viddler' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "unknown"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = YAML.load(`svn info`)['Revision']
34
+ VERS = Viddler::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'viddler documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.developer(AUTHOR, EMAIL)
52
+ p.description = DESCRIPTION
53
+ p.summary = DESCRIPTION
54
+ p.url = HOMEPATH
55
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
56
+ p.test_globs = ["test/**/test_*.rb"]
57
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
58
+
59
+ # == Optional
60
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+
63
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
+
65
+ end
66
+
67
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
69
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
70
+ $hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen active_support rest_client mime/types].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
data/lib/ext/array.rb ADDED
@@ -0,0 +1,18 @@
1
+ class Array #:nodoc:
2
+
3
+ # Extraceted from Ruby Facets:
4
+ # Converts a two-element associative array into a hash.
5
+ def to_h(arrayed=nil)
6
+ h = {}
7
+ if arrayed
8
+ each{ |k,*v| h[k] = v }
9
+ else
10
+ ary = []
11
+ each do |a|
12
+ Array===a ? ary.concat(a) : ary << a
13
+ end
14
+ h = Hash[*ary]
15
+ end
16
+ h
17
+ end
18
+ end
data/lib/ext/hash.rb ADDED
@@ -0,0 +1,28 @@
1
+ class Hash #:nodoc:
2
+
3
+ def assert_required_keys(keys)
4
+ for key in keys
5
+ raise(ArgumentError, "Missing required key(s): #{key}") unless self.keys.include?(key)
6
+ end
7
+ true
8
+ end
9
+
10
+ # Extracted from Ruby Facets:
11
+ # Operator for remove hash paris. If another hash is given the pairs are only removed if both key and value are equal. If an array is given then matching keys are removed.
12
+ def -(other)
13
+ h = self.dup
14
+ if other.respond_to?(:to_ary)
15
+ other.to_ary.each do |k|
16
+ h.delete(k)
17
+ end
18
+ else
19
+ other.each do |k,v|
20
+ if h.key?(k)
21
+ h.delete(k) if v == h[k]
22
+ end
23
+ end
24
+ end
25
+ h
26
+ end
27
+
28
+ end
@@ -0,0 +1,7 @@
1
+ class OpenStruct #:nodoc:
2
+
3
+ def table
4
+ @table
5
+ end
6
+
7
+ end
@@ -0,0 +1,94 @@
1
+ module Viddler #:nodoc:
2
+
3
+ class ApiSpec #:nodoc:
4
+
5
+ USERS_REGISTER_ATTRS = {
6
+ :required => [
7
+ :user,
8
+ :email,
9
+ :fname,
10
+ :lname,
11
+ :password,
12
+ :question,
13
+ :answer,
14
+ :lang,
15
+ :termsaccepted
16
+ ],
17
+ :optional => [
18
+ :company
19
+ ]
20
+ }
21
+
22
+ USERS_SETPROFILE_ATTRS = {
23
+ :optional => [
24
+ :first_name,
25
+ :last_name,
26
+ :about_me,
27
+ :birthdate,
28
+ :gender,
29
+ :company,
30
+ :city
31
+ ]
32
+ }
33
+
34
+ USERS_SETOPTIONS_ATTRS = {
35
+ :optional => [
36
+ :show_account,
37
+ :tagging_enabled,
38
+ :commenting_enabled,
39
+ :show_related_videos,
40
+ :embedding_enabled,
41
+ :clicking_through_enabled,
42
+ :email_this_enabled,
43
+ :trackbacks_enabled,
44
+ :favourites_enabled,
45
+ :custom_logo_enabled
46
+ ]
47
+ }
48
+
49
+ VIDEOS_UPLOAD_ATTRS = {
50
+ :required => [
51
+ :title,
52
+ :description,
53
+ :tags,
54
+ :file,
55
+ :make_public
56
+ ]
57
+ }
58
+
59
+ VIDEOS_SETDETAILS_ATTRS = {
60
+ :optional => [
61
+ :title,
62
+ :description,
63
+ :tags,
64
+ :view_perm,
65
+ :view_users,
66
+ :view_use_secret,
67
+ :embed_perm,
68
+ :embed_users,
69
+ :commenting_perm,
70
+ :tagging_perm,
71
+ :download_perm,
72
+ :download_users
73
+ ]
74
+ }
75
+
76
+ def self.check_attributes(viddler_method, attributes)
77
+ valid_attributes = viddler_method_to_const(viddler_method)
78
+ required = valid_attributes[:required] || Array.new
79
+ optional = valid_attributes[:optional] || Array.new
80
+
81
+ attributes.assert_valid_keys(required + optional)
82
+ attributes.assert_required_keys(required)
83
+ end
84
+
85
+ protected
86
+
87
+ def self.viddler_method_to_const(method)
88
+ const_name = method.gsub('.', '_').upcase
89
+ const_get("#{const_name}_ATTRS")
90
+ end
91
+
92
+ end
93
+
94
+ end