videolog 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +91 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +25 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/lib/videolog.rb +12 -0
- data/lib/videolog/auth.rb +24 -0
- data/lib/videolog/base.rb +62 -0
- data/lib/videolog/video.rb +9 -0
- data/test/fixtures/auth/failed_hash.txt +1 -0
- data/test/fixtures/auth/good_hash.txt +1 -0
- data/test/fixtures/base/get_failure.json +1 -0
- data/test/fixtures/base/get_success.json +1 -0
- data/test/fixtures/video/find.json +23 -0
- data/test/fixtures/video/unknown_video.json +1 -0
- data/test/helper.rb +51 -0
- data/test/videolog/auth_test.rb +33 -0
- data/test/videolog/base_test.rb +50 -0
- data/test/videolog/video_test.rb +23 -0
- data/test/videolog_test.rb +0 -0
- data/videolog.gemspec +83 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b16f880f42890744a1d05943f67cb4e35935a05f
|
4
|
+
data.tar.gz: 51ee84087d887cf889d999af157b5eea26378988
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53873bbf5b101359485e7091f410f3636f969eb39d434a229121492925ea8a12d7720bd191a3b3465277daf56e267d09b664938d1e829d582b795d7690e99374
|
7
|
+
data.tar.gz: f0f30468804c8439d78e61c6f50e165f1c32f81a2afa3b3cba06a3e3cb8dcd27d5ea041e9908fd943fb908e00187931804d0e483e188aa5bb38f9eb89736f411
|
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.0.1)
|
5
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
|
+
minitest (~> 4.2)
|
7
|
+
multi_json (~> 1.3)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 0.3.37)
|
10
|
+
addressable (2.3.5)
|
11
|
+
atomic (1.1.14)
|
12
|
+
builder (3.2.2)
|
13
|
+
crack (0.4.1)
|
14
|
+
safe_yaml (~> 0.9.0)
|
15
|
+
docile (1.1.1)
|
16
|
+
faraday (0.8.8)
|
17
|
+
multipart-post (~> 1.2.0)
|
18
|
+
git (1.2.6)
|
19
|
+
github_api (0.10.1)
|
20
|
+
addressable
|
21
|
+
faraday (~> 0.8.1)
|
22
|
+
hashie (>= 1.2)
|
23
|
+
multi_json (~> 1.4)
|
24
|
+
nokogiri (~> 1.5.2)
|
25
|
+
oauth2
|
26
|
+
hashie (2.0.5)
|
27
|
+
highline (1.6.20)
|
28
|
+
httparty (0.12.0)
|
29
|
+
json (~> 1.8)
|
30
|
+
multi_xml (>= 0.5.2)
|
31
|
+
httpauth (0.2.0)
|
32
|
+
i18n (0.6.5)
|
33
|
+
jeweler (1.8.8)
|
34
|
+
builder
|
35
|
+
bundler (~> 1.0)
|
36
|
+
git (>= 1.2.5)
|
37
|
+
github_api (= 0.10.1)
|
38
|
+
highline (>= 1.6.15)
|
39
|
+
nokogiri (= 1.5.10)
|
40
|
+
rake
|
41
|
+
rdoc
|
42
|
+
json (1.8.1)
|
43
|
+
jwt (0.1.8)
|
44
|
+
multi_json (>= 1.5)
|
45
|
+
minitest (4.7.5)
|
46
|
+
multi_json (1.8.2)
|
47
|
+
multi_xml (0.5.5)
|
48
|
+
multipart-post (1.2.0)
|
49
|
+
nokogiri (1.5.10)
|
50
|
+
oauth2 (0.9.2)
|
51
|
+
faraday (~> 0.8)
|
52
|
+
httpauth (~> 0.2)
|
53
|
+
jwt (~> 0.1.4)
|
54
|
+
multi_json (~> 1.0)
|
55
|
+
multi_xml (~> 0.5)
|
56
|
+
rack (~> 1.2)
|
57
|
+
rack (1.5.2)
|
58
|
+
rake (10.1.0)
|
59
|
+
rdoc (4.0.1)
|
60
|
+
json (~> 1.4)
|
61
|
+
safe_yaml (0.9.7)
|
62
|
+
shoulda (3.5.0)
|
63
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
64
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
65
|
+
shoulda-context (1.1.6)
|
66
|
+
shoulda-matchers (2.4.0)
|
67
|
+
activesupport (>= 3.0.0)
|
68
|
+
simplecov (0.8.2)
|
69
|
+
docile (~> 1.1.0)
|
70
|
+
multi_json
|
71
|
+
simplecov-html (~> 0.8.0)
|
72
|
+
simplecov-html (0.8.0)
|
73
|
+
thread_safe (0.1.3)
|
74
|
+
atomic
|
75
|
+
tzinfo (0.3.38)
|
76
|
+
webmock (1.16.0)
|
77
|
+
addressable (>= 2.2.7)
|
78
|
+
crack (>= 0.3.2)
|
79
|
+
|
80
|
+
PLATFORMS
|
81
|
+
ruby
|
82
|
+
|
83
|
+
DEPENDENCIES
|
84
|
+
bundler
|
85
|
+
httparty
|
86
|
+
jeweler
|
87
|
+
json
|
88
|
+
rdoc
|
89
|
+
shoulda
|
90
|
+
simplecov
|
91
|
+
webmock
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Rodrigo DeAlmeida
|
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/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= videolog
|
2
|
+
|
3
|
+
A Ruby interface to the Videolog API.
|
4
|
+
|
5
|
+
== Usage examples
|
6
|
+
|
7
|
+
# To find a cool video, by id.
|
8
|
+
video = Videolog::Video.new
|
9
|
+
video.find(715519)
|
10
|
+
|
11
|
+
== Contributing to videolog
|
12
|
+
|
13
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
14
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
15
|
+
* Fork the project.
|
16
|
+
* Start a feature/bugfix branch.
|
17
|
+
* Commit and push until you are happy with your contribution.
|
18
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
19
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
20
|
+
|
21
|
+
== Copyright
|
22
|
+
|
23
|
+
Copyright (c) 2013 Rodrigo DeAlmeida. See LICENSE.txt for
|
24
|
+
further details.
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "videolog"
|
18
|
+
gem.homepage = "http://github.com/rodrigoddalmeida/videolog"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "A Ruby interface to the Videolog API"
|
21
|
+
gem.description = "This gem makes it easy to integrate Videolog with Ruby projects."
|
22
|
+
gem.email = "rodrigoddalmeida@gmail.com"
|
23
|
+
gem.authors = ["Rodrigo DeAlmeida"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rdoc/task'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "videolog #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/lib/videolog.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
$:.unshift(File.dirname(__FILE__))
|
5
|
+
require 'videolog/base'
|
6
|
+
require 'videolog/auth'
|
7
|
+
require 'videolog/video'
|
8
|
+
|
9
|
+
module Videolog
|
10
|
+
class AuthorizationNeeded < StandardError; end;
|
11
|
+
class RequestFailed < StandardError; end;
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Videolog
|
2
|
+
class Auth < Videolog::Base
|
3
|
+
|
4
|
+
attr_accessor :auth_hash, :dev_token
|
5
|
+
|
6
|
+
def self.get_auth_hash(username, password)
|
7
|
+
response = post('/usuario/login', body: {
|
8
|
+
login: username,
|
9
|
+
senha: password
|
10
|
+
})
|
11
|
+
|
12
|
+
if response.body =~ /Autenticacao/
|
13
|
+
response.body[/Autenticacao=(?<auth_hash>.*)/, 'auth_hash']
|
14
|
+
else
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(options={})
|
20
|
+
@auth_hash = options[:auth_hash]
|
21
|
+
@dev_token = options[:dev_token]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Videolog
|
2
|
+
class Base
|
3
|
+
include HTTParty
|
4
|
+
ENDPOINT = "http://api.videolog.tv"
|
5
|
+
base_uri ENDPOINT
|
6
|
+
|
7
|
+
attr_reader :authorized
|
8
|
+
|
9
|
+
def self.get_json(path, options={}, &block)
|
10
|
+
response = get("#{path}.json", options, &block)
|
11
|
+
validate_response! response.parsed_response
|
12
|
+
response.parsed_response
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(auth_options={})
|
16
|
+
authorize(auth_options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_json(path, options={}, &block)
|
20
|
+
if authorized
|
21
|
+
headers = {'Token' => @auth.dev_token}
|
22
|
+
headers.merge!({'Autenticacao' => @auth.auth_hash}) unless @auth.auth_hash.nil?
|
23
|
+
options = {headers: headers}.merge(options)
|
24
|
+
end
|
25
|
+
|
26
|
+
self.class.get_json(path, options, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def authorize(options={}) # TODO: send some logic to Auth
|
30
|
+
@auth = Videolog::Auth.new
|
31
|
+
@authorized = false
|
32
|
+
|
33
|
+
unless options[:username].nil? && options[:password].nil?
|
34
|
+
@auth.auth_hash = Videolog::Auth.get_auth_hash(options[:username], options[:password])
|
35
|
+
end
|
36
|
+
|
37
|
+
unless options[:dev_token].nil?
|
38
|
+
@auth.dev_token = options[:dev_token]
|
39
|
+
@authorized = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def authorize!(options={})
|
44
|
+
authorize(options)
|
45
|
+
raise AuthorizationNeeded unless authorized
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def self.validate_response!(response)
|
51
|
+
status = response["status"]
|
52
|
+
if status and status == "error"
|
53
|
+
error_message = response["msg"]
|
54
|
+
if error_message.nil?
|
55
|
+
raise RequestFailed, "Error: no error message"
|
56
|
+
else
|
57
|
+
raise RequestFailed, "#{status}: #{error_message}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
LOGIN OU SENHA INCORRETOS
|
@@ -0,0 +1 @@
|
|
1
|
+
Autenticacao=1234567890
|
@@ -0,0 +1 @@
|
|
1
|
+
{"status": "error", "msg": "some error occurred."}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"status": "success"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"video":{
|
3
|
+
"ordem":2829,
|
4
|
+
"id_canal":11,
|
5
|
+
"thumb":"http://videolog.tv/video_thumb.php?video=715519",
|
6
|
+
"mobile":"S",
|
7
|
+
"url_mp4":"http://videos.videolog.tv/98/96/715519.mp4?epochTTL=9981044395200&token=033446ee7ce7954da848da6d75cf6f2b&ri=10485760&rs=600",
|
8
|
+
"duracao":"00:03:33",
|
9
|
+
"uri":"/video/715519.json",
|
10
|
+
"uri_videos_relacionados":"/video/715519/videosRelacionados.json",
|
11
|
+
"texto":"Rick Astley - Never Gonna Give You Up",
|
12
|
+
"visitas":0,
|
13
|
+
"sinc":3,
|
14
|
+
"usuario_id":681142,
|
15
|
+
"criacao":"2011-11-01T10:37:34",
|
16
|
+
"link":"http://videolog.tv/video.php?id=715519",
|
17
|
+
"privacidade":"0",
|
18
|
+
"titulo":"Rick Astley - Never Gonna Give You Up",
|
19
|
+
"embed":" <iframe width='560' height=315 src='http://embed.videolog.tv/v/index.php?id_video=715519&width=560&height=315&config_url=' scrolling='no' frameborder='0' allowfullscreen></iframe> <p><a href='http://videolog.tv/video.php?id=715519'>Rick Astley - Never Gonna Give You Up</a> por <a href='http://videolog.tv/amandoledonne'> amandoledonne </a> no <a href='http://videolog.tv'>Videolog.tv</a>.</p> ",
|
20
|
+
"uri_comentarios":"/video/715519/comentarios.json",
|
21
|
+
"id":715519
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"status": "error", "msg": null}
|
data/test/helper.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
13
|
+
end
|
14
|
+
require 'test/unit'
|
15
|
+
require 'shoulda'
|
16
|
+
require 'webmock/test_unit'
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
|
+
require 'videolog'
|
21
|
+
|
22
|
+
def fixture_file(filename)
|
23
|
+
return '' if filename == ''
|
24
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
25
|
+
File.read(file_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def videolog_api_url(path = "")
|
29
|
+
"#{Videolog::Base::ENDPOINT}#{path}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def stub_api_request(url, return_filename, request_options={}, content_type='application/json', status=200, method=:get)
|
33
|
+
options = { :body => fixture_file(return_filename) }
|
34
|
+
options.merge!({:headers => { 'Content-Type' => content_type }})
|
35
|
+
options.merge!({:status => status})
|
36
|
+
stub_request(method, videolog_api_url(url)).with(request_options).to_return(options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def stub_api_get(url, return_filename, request_options={}, content_type='application/json', status=nil)
|
40
|
+
stub_api_request(url, return_filename, request_options, content_type, status)
|
41
|
+
end
|
42
|
+
|
43
|
+
def stub_api_post(url, return_filename, request_options={}, content_type='application/json', status=nil)
|
44
|
+
stub_api_request(url, return_filename, request_options, content_type, status, :post)
|
45
|
+
end
|
46
|
+
|
47
|
+
class Test::Unit::TestCase
|
48
|
+
def setup
|
49
|
+
WebMock.disable_net_connect!
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class AuthTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "videolog auth" do
|
6
|
+
|
7
|
+
context ".new" do
|
8
|
+
should "initialize with the provided options" do
|
9
|
+
base = Videolog::Auth.new(auth_hash: '1234567890', dev_token: 'ABCDEF')
|
10
|
+
|
11
|
+
assert_equal '1234567890', base.auth_hash
|
12
|
+
assert_equal 'ABCDEF', base.dev_token
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context ".get_auth_hash" do
|
17
|
+
|
18
|
+
should "retrieve and return an auth hash" do
|
19
|
+
stub_api_post("/usuario/login", "auth/good_hash.txt", {body: "login=u&senha=p"}, "text/html")
|
20
|
+
auth_hash = Videolog::Auth.get_auth_hash("u", "p")
|
21
|
+
|
22
|
+
assert_equal '1234567890', auth_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
should "retrieve nil if unsuccessful" do
|
26
|
+
stub_api_post("/usuario/login", "auth/failed_hash.txt", {body: "login=u&senha=%3Ap"}, "text/html")
|
27
|
+
auth_hash = Videolog::Auth.get_auth_hash("u", ":p")
|
28
|
+
|
29
|
+
assert_nil auth_hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BaseTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "videolog base" do
|
6
|
+
|
7
|
+
context ".get_json" do
|
8
|
+
|
9
|
+
should "return a hash if the request is .json" do
|
10
|
+
stub_api_get("/get_success.json", "base/get_success.json")
|
11
|
+
get_request = Videolog::Base.get_json("/get_success")
|
12
|
+
|
13
|
+
assert_equal get_request.class, Hash
|
14
|
+
end
|
15
|
+
|
16
|
+
should "raise a RequestFailed" do
|
17
|
+
stub_api_get("/get_failure.json", "base/get_failure.json")
|
18
|
+
|
19
|
+
assert_raise Videolog::RequestFailed do
|
20
|
+
Videolog::Base.get_json("/get_failure")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "authorization" do
|
26
|
+
|
27
|
+
context "#authorize" do
|
28
|
+
should "not be authorized when no auth info is provided" do
|
29
|
+
base = Videolog::Base.new
|
30
|
+
|
31
|
+
assert_equal false, base.authorized
|
32
|
+
end
|
33
|
+
|
34
|
+
should "be authorized when no auth info is provided" do
|
35
|
+
base = Videolog::Base.new(dev_token: '12345678')
|
36
|
+
|
37
|
+
assert_equal true, base.authorized
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "#authorize!" do
|
42
|
+
should "raise error" do
|
43
|
+
assert_raise Videolog::AuthorizationNeeded do
|
44
|
+
Videolog::Base.new.authorize!
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class VideoTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "#find_video" do
|
6
|
+
|
7
|
+
should "retrieve info of the selected video" do
|
8
|
+
stub_api_get('/video/715519.json', 'video/find.json')
|
9
|
+
video = Videolog::Video.new.find("715519")
|
10
|
+
|
11
|
+
assert_equal Hash, video.class
|
12
|
+
assert_equal 715519, video['video']['id']
|
13
|
+
end
|
14
|
+
|
15
|
+
should "get an error if video doesn't exist" do
|
16
|
+
stub_api_get('/video/12345678.json', 'video/unknown_video.json')
|
17
|
+
|
18
|
+
assert_raise Videolog::RequestFailed do
|
19
|
+
Videolog::Video.new.find("12345678")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
File without changes
|
data/videolog.gemspec
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "videolog"
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Rodrigo DeAlmeida"]
|
12
|
+
s.date = "2013-12-10"
|
13
|
+
s.description = "This gem makes it easy to integrate Videolog with Ruby projects."
|
14
|
+
s.email = "rodrigoddalmeida@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/videolog.rb",
|
28
|
+
"lib/videolog/auth.rb",
|
29
|
+
"lib/videolog/base.rb",
|
30
|
+
"lib/videolog/video.rb",
|
31
|
+
"test/fixtures/auth/failed_hash.txt",
|
32
|
+
"test/fixtures/auth/good_hash.txt",
|
33
|
+
"test/fixtures/base/get_failure.json",
|
34
|
+
"test/fixtures/base/get_success.json",
|
35
|
+
"test/fixtures/video/find.json",
|
36
|
+
"test/fixtures/video/unknown_video.json",
|
37
|
+
"test/helper.rb",
|
38
|
+
"test/videolog/auth_test.rb",
|
39
|
+
"test/videolog/base_test.rb",
|
40
|
+
"test/videolog/video_test.rb",
|
41
|
+
"test/videolog_test.rb",
|
42
|
+
"videolog.gemspec"
|
43
|
+
]
|
44
|
+
s.homepage = "http://github.com/rodrigoddalmeida/videolog"
|
45
|
+
s.licenses = ["MIT"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = "2.0.3"
|
48
|
+
s.summary = "A Ruby interface to the Videolog API"
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
s.specification_version = 4
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
60
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
64
|
+
s.add_dependency(%q<json>, [">= 0"])
|
65
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
66
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
67
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
68
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
69
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
70
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
74
|
+
s.add_dependency(%q<json>, [">= 0"])
|
75
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
77
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
78
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
79
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
80
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: videolog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rodrigo DeAlmeida
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: shoulda
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: This gem makes it easy to integrate Videolog with Ruby projects.
|
126
|
+
email: rodrigoddalmeida@gmail.com
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files:
|
130
|
+
- LICENSE.txt
|
131
|
+
- README.rdoc
|
132
|
+
files:
|
133
|
+
- .document
|
134
|
+
- Gemfile
|
135
|
+
- Gemfile.lock
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.rdoc
|
138
|
+
- Rakefile
|
139
|
+
- VERSION
|
140
|
+
- lib/videolog.rb
|
141
|
+
- lib/videolog/auth.rb
|
142
|
+
- lib/videolog/base.rb
|
143
|
+
- lib/videolog/video.rb
|
144
|
+
- test/fixtures/auth/failed_hash.txt
|
145
|
+
- test/fixtures/auth/good_hash.txt
|
146
|
+
- test/fixtures/base/get_failure.json
|
147
|
+
- test/fixtures/base/get_success.json
|
148
|
+
- test/fixtures/video/find.json
|
149
|
+
- test/fixtures/video/unknown_video.json
|
150
|
+
- test/helper.rb
|
151
|
+
- test/videolog/auth_test.rb
|
152
|
+
- test/videolog/base_test.rb
|
153
|
+
- test/videolog/video_test.rb
|
154
|
+
- test/videolog_test.rb
|
155
|
+
- videolog.gemspec
|
156
|
+
homepage: http://github.com/rodrigoddalmeida/videolog
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.0.3
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: A Ruby interface to the Videolog API
|
180
|
+
test_files: []
|