rik 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +3 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/lib/rik/api.rb +61 -0
- data/lib/rik/client/session.rb +38 -0
- data/lib/rik/client/stream.rb +60 -0
- data/lib/rik/client/user.rb +49 -0
- data/lib/rik/client/video.rb +32 -0
- data/lib/rik/client.rb +28 -0
- data/lib/rik.rb +2 -0
- data/rik.gemspec +72 -0
- data/spec/client/stream_spec.rb +77 -0
- data/spec/client/user_spec.rb +71 -0
- data/spec/client/video_spec.rb +50 -0
- data/spec/rik_spec.rb +2 -0
- data/spec/spec_helper.rb +5 -0
- metadata +134 -0
data/.document
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "bundler", "~> 1.0.0"
|
10
|
+
gem "jeweler", "~> 1.6.2"
|
11
|
+
gem "rcov", ">= 0"
|
12
|
+
gem "rspec", ">= 0"
|
13
|
+
end
|
14
|
+
|
15
|
+
group :runtime do
|
16
|
+
gem "json"
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.2)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
json (1.5.2)
|
11
|
+
rake (0.9.2)
|
12
|
+
rcov (0.9.9)
|
13
|
+
rspec (2.5.0)
|
14
|
+
rspec-core (~> 2.5.0)
|
15
|
+
rspec-expectations (~> 2.5.0)
|
16
|
+
rspec-mocks (~> 2.5.0)
|
17
|
+
rspec-core (2.5.1)
|
18
|
+
rspec-expectations (2.5.0)
|
19
|
+
diff-lcs (~> 1.1.2)
|
20
|
+
rspec-mocks (2.5.0)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
bundler (~> 1.0.0)
|
27
|
+
jeweler (~> 1.6.2)
|
28
|
+
json
|
29
|
+
rcov
|
30
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Joel Jauregui
|
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,19 @@
|
|
1
|
+
= rik
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to rik
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* 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.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Joel Jauregui. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
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
|
+
|
13
|
+
require 'rake'
|
14
|
+
|
15
|
+
require 'jeweler'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
18
|
+
gem.name = "rik"
|
19
|
+
gem.homepage = "http://github.com/Burn0ut07/rik"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{Ruby bindings for Qik}
|
22
|
+
gem.description = %Q{Ruby bindings for Qik API, inspired by the twitter gem}
|
23
|
+
gem.email = "joel.jauregui@gmail.com"
|
24
|
+
gem.authors = ["Joel Jauregui"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec)
|
31
|
+
|
32
|
+
<<-eos
|
33
|
+
require 'rcov/rcovtask'
|
34
|
+
Rcov::RcovTask.new do |test|
|
35
|
+
test.libs << 'test'
|
36
|
+
test.pattern = 'test/**/test_*.rb'
|
37
|
+
test.verbose = true
|
38
|
+
test.rcov_opts << '--exclude "gems/*"'
|
39
|
+
end]
|
40
|
+
eos
|
41
|
+
|
42
|
+
task :test => :spec
|
43
|
+
task :default => :spec
|
44
|
+
|
45
|
+
<<-eos
|
46
|
+
require 'rdoc/task'
|
47
|
+
RDoc::Task.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "rik {version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
55
|
+
eos
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/rik/api.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Rik
|
6
|
+
|
7
|
+
class API
|
8
|
+
|
9
|
+
class Error < RuntimeError
|
10
|
+
attr_accessor :error
|
11
|
+
|
12
|
+
def initialize(error)
|
13
|
+
@error = error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
VALID_OPTIONS_KEYS = [
|
18
|
+
:apikey,
|
19
|
+
:login,
|
20
|
+
:password].freeze
|
21
|
+
|
22
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
23
|
+
|
24
|
+
BASE_URI = 'http://engine.qik.com/api/jsonrpc'.freeze
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@uri = URI.parse(BASE_URI)
|
28
|
+
reset
|
29
|
+
end
|
30
|
+
|
31
|
+
def call(method, *params)
|
32
|
+
body = {
|
33
|
+
:method => method,
|
34
|
+
:params => params || []
|
35
|
+
}.to_json
|
36
|
+
|
37
|
+
http = Net::HTTP.new(@uri.host, @uri.port)
|
38
|
+
request = Net::HTTP::Post.new("#{@uri.request_uri}?apikey=#{@apikey}")
|
39
|
+
|
40
|
+
request.body = body
|
41
|
+
response = http.request(request)
|
42
|
+
answer = JSON.parse(response.body)
|
43
|
+
|
44
|
+
if answer[0] == nil
|
45
|
+
raise Error.new(answer['fault']), answer['faultString']
|
46
|
+
end
|
47
|
+
|
48
|
+
answer[0]
|
49
|
+
end
|
50
|
+
|
51
|
+
def configure
|
52
|
+
yield self
|
53
|
+
end
|
54
|
+
|
55
|
+
def reset
|
56
|
+
@apikey = '94e147c9aff4392f'
|
57
|
+
@login = nil
|
58
|
+
@password = nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Rik
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module Session
|
5
|
+
private
|
6
|
+
|
7
|
+
def create
|
8
|
+
@session_id ||=
|
9
|
+
begin
|
10
|
+
@authorized = false
|
11
|
+
call 'qik.session.create'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
call 'qik.session.destroy', @session_id if @session_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def recreate
|
20
|
+
@session_id = nil
|
21
|
+
create
|
22
|
+
authorize(@login, @password)
|
23
|
+
@session_id
|
24
|
+
end
|
25
|
+
|
26
|
+
def authorize(login, password)
|
27
|
+
raise Exception.new('Already authorized!') if @authorized
|
28
|
+
# What happens if params nil?
|
29
|
+
@user_id = call 'qik.session.authorize', @session_id, login, password
|
30
|
+
@authorized = true
|
31
|
+
@auth_method = 'authorize'
|
32
|
+
@login = login
|
33
|
+
@password = password
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Rik
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module Stream
|
5
|
+
|
6
|
+
def subscribe_follow_streams(*args)
|
7
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
8
|
+
|
9
|
+
filter_shared = options[:filter_shared]
|
10
|
+
filter_shared = true if filter_shared.nil?
|
11
|
+
limit = options[:limit] || 10
|
12
|
+
|
13
|
+
call 'qik.stream.subscribe_follow_streams', create,
|
14
|
+
filter_shared, limit
|
15
|
+
|
16
|
+
rescue Rik::API::Error => error
|
17
|
+
STDERR << error
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def subscribe_own_user_streams(*args)
|
22
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
23
|
+
|
24
|
+
limit = options[:limit] || 10
|
25
|
+
|
26
|
+
call 'qik.stream.subscribe_own_user_streams', create, limit
|
27
|
+
end
|
28
|
+
|
29
|
+
def subscribe_public_streams(*args)
|
30
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
31
|
+
|
32
|
+
recent = options[:recent]
|
33
|
+
live = options[:live]
|
34
|
+
limit = options[:limit]
|
35
|
+
|
36
|
+
if recent || (!recent && !live)
|
37
|
+
call 'qik.stream.subscribe_public_recent', create, limit || 50
|
38
|
+
else
|
39
|
+
call 'qik.stream.subscribe_public_live', create, limit || 10
|
40
|
+
end
|
41
|
+
|
42
|
+
rescue Rik::API::Error => error
|
43
|
+
STDERR << error
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def subscribe_user_streams(*args)
|
48
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
49
|
+
|
50
|
+
username = args.first
|
51
|
+
|
52
|
+
do_public = options[:public] ? '_public' : ''
|
53
|
+
limit = options[:limit] || 10
|
54
|
+
|
55
|
+
call "qik.stream.subscribe#{do_public}_user_streams", create,
|
56
|
+
username, limit
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Rik
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module User
|
5
|
+
|
6
|
+
def followers(*args)
|
7
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
8
|
+
|
9
|
+
user = args.first || get_user_id
|
10
|
+
|
11
|
+
call 'qik.user.followers', user
|
12
|
+
rescue Rik::API::Error => error
|
13
|
+
STDERR << error
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def following(*args)
|
18
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
19
|
+
|
20
|
+
user = args.first || get_user_id
|
21
|
+
|
22
|
+
call 'qik.user.following', user
|
23
|
+
rescue Rik::API::Error => error
|
24
|
+
STDERR << error
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def public_profile(*args)
|
29
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
30
|
+
|
31
|
+
user = args.first || get_user_id
|
32
|
+
|
33
|
+
detailed = options[:detailed] ? '_detailed' : ''
|
34
|
+
by_id = user.is_a?(Numeric) ? '_by_id' : ''
|
35
|
+
|
36
|
+
call "qik.user.public#{detailed}_profile#{by_id}", user
|
37
|
+
rescue Rik::API::Error => error
|
38
|
+
STDERR << error
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def get_user_id
|
44
|
+
recreate if @user_id.nil?
|
45
|
+
@user_id
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Rik
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module Video
|
5
|
+
|
6
|
+
def public_user_streams(username)
|
7
|
+
call 'qik.stream.public_user_streams', username
|
8
|
+
|
9
|
+
rescue Rik::API::Error => error
|
10
|
+
STDERR << error
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def info(*args)
|
15
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
16
|
+
|
17
|
+
video_id = args.first
|
18
|
+
detailed = options[:detailed]
|
19
|
+
|
20
|
+
if detailed
|
21
|
+
call 'qik.stream.info', create, video_id
|
22
|
+
else
|
23
|
+
call 'qik.stream.public_info', video_id
|
24
|
+
end
|
25
|
+
|
26
|
+
rescue Rik::API::Error => error
|
27
|
+
STDERR << error
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/rik/client.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rik/api'
|
2
|
+
|
3
|
+
module Rik
|
4
|
+
class Client < API
|
5
|
+
|
6
|
+
require 'rik/client/session'
|
7
|
+
require 'rik/client/stream'
|
8
|
+
require 'rik/client/user'
|
9
|
+
require 'rik/client/video'
|
10
|
+
|
11
|
+
include Rik::Client::Session
|
12
|
+
include Rik::Client::Stream
|
13
|
+
include Rik::Client::User
|
14
|
+
include Rik::Client::Video
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
@authorized = false
|
19
|
+
@subscriptions = {}
|
20
|
+
@resub_handlers = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure
|
24
|
+
super
|
25
|
+
recreate
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/rik.rb
ADDED
data/rik.gemspec
ADDED
@@ -0,0 +1,72 @@
|
|
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 = %q{rik}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Joel Jauregui"]
|
12
|
+
s.date = %q{2011-06-22}
|
13
|
+
s.description = %q{Ruby bindings for Qik API, inspired by the twitter gem}
|
14
|
+
s.email = %q{joel.jauregui@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/rik.rb",
|
29
|
+
"lib/rik/api.rb",
|
30
|
+
"lib/rik/client.rb",
|
31
|
+
"lib/rik/client/session.rb",
|
32
|
+
"lib/rik/client/stream.rb",
|
33
|
+
"lib/rik/client/user.rb",
|
34
|
+
"lib/rik/client/video.rb",
|
35
|
+
"rik.gemspec",
|
36
|
+
"spec/client/stream_spec.rb",
|
37
|
+
"spec/client/user_spec.rb",
|
38
|
+
"spec/client/video_spec.rb",
|
39
|
+
"spec/rik_spec.rb",
|
40
|
+
"spec/spec_helper.rb"
|
41
|
+
]
|
42
|
+
s.homepage = %q{http://github.com/Burn0ut07/rik}
|
43
|
+
s.licenses = ["MIT"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = %q{1.6.2}
|
46
|
+
s.summary = %q{Ruby bindings for Qik}
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
55
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<json>, [">= 0"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
+
end
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<json>, [">= 0"])
|
66
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
67
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
68
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rik'
|
3
|
+
|
4
|
+
describe 'Module Rik::Client::Stream' do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@rik = Rik::Client.new
|
8
|
+
|
9
|
+
@rik.configure do |config|
|
10
|
+
config.login = 'videodot'
|
11
|
+
config.password = 'UCSDVdot'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#subscribe_public_streams' do
|
16
|
+
it 'should default to return recent streams' do
|
17
|
+
subs = @rik.subscribe_public_streams
|
18
|
+
subs.should_not be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should let you get live public' do
|
22
|
+
subs = @rik.subscribe_public_streams(:live => true)
|
23
|
+
subs.should_not be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should let you limit the amount' do
|
27
|
+
subs = @rik.subscribe_public_streams(:limit => 5)
|
28
|
+
subs.should_not be_nil
|
29
|
+
subs[1].length.should <= 5
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#subscribe_follow_streams' do
|
34
|
+
it 'should return streams of people I follow' do
|
35
|
+
subs = @rik.subscribe_follow_streams
|
36
|
+
subs.should_not be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should let me limit the streams' do
|
40
|
+
subs = @rik.subscribe_follow_streams(:limit => 5)
|
41
|
+
subs.should_not be_nil
|
42
|
+
subs[1].length.should <= 5
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should let me filter shared' do
|
46
|
+
subs = @rik.subscribe_follow_streams(:filter_shared => false)
|
47
|
+
subs.should_not be_nil
|
48
|
+
subs[0].should match(/;filter=False;/i)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#subscribe_user_streams' do
|
53
|
+
it 'should return streams of another user' do
|
54
|
+
subs = @rik.subscribe_user_streams('burn0ut07')
|
55
|
+
subs.should_not be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should be able to get only public' do
|
59
|
+
subs = @rik.subscribe_user_streams('burn0ut07', :public => true)
|
60
|
+
subs.should_not be_nil
|
61
|
+
subs[1].should have_at_least(3).length
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should be able to limit the streams' do
|
65
|
+
subs = @rik.subscribe_user_streams('burn0ut07', :limit => 1)
|
66
|
+
subs.should_not be_nil
|
67
|
+
subs[1].length.should <= 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#subscribe_own_user_streams' do
|
72
|
+
it 'should subscribe to own streams' do
|
73
|
+
subs = @rik.subscribe_own_user_streams
|
74
|
+
subs.should_not be_nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rik'
|
3
|
+
|
4
|
+
describe "Module Rik::Client::User" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@rik = Rik::Client.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#public_profile' do
|
11
|
+
it "returns the named users profile" do
|
12
|
+
user = @rik.public_profile('burn0ut07')
|
13
|
+
user.should_not be_nil
|
14
|
+
user['username'].should_not be_nil
|
15
|
+
user['full_name'].should_not be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can return detailed profile" do
|
19
|
+
user = @rik.public_profile('burn0ut07', :detailed => true)
|
20
|
+
user.should_not be_nil
|
21
|
+
user['live_channel'].should_not be_nil
|
22
|
+
user['premium'].should_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can return based on configured client" do
|
26
|
+
@rik.configure do |config|
|
27
|
+
config.login = 'videodot'
|
28
|
+
config.password = 'UCSDVdot'
|
29
|
+
end
|
30
|
+
|
31
|
+
user = @rik.public_profile
|
32
|
+
user.should_not be_nil
|
33
|
+
user['username'].should_not be_nil
|
34
|
+
user['full_name'].should_not be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#followers' do
|
39
|
+
it 'returns set of all following given user' do
|
40
|
+
followers = @rik.followers 8309434 # must pass user_id
|
41
|
+
followers.should_not be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'can return based on configured client' do
|
45
|
+
@rik.configure do |config|
|
46
|
+
config.login = 'videodot'
|
47
|
+
config.password = 'UCSDVdot'
|
48
|
+
end
|
49
|
+
|
50
|
+
followers = @rik.followers
|
51
|
+
followers.should_not be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#following' do
|
56
|
+
it 'returns set of users that given user follows' do
|
57
|
+
following = @rik.following 8309434 # must pass user_id
|
58
|
+
following.should_not be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'can return based on configured client' do
|
62
|
+
@rik.configure do |config|
|
63
|
+
config.login = 'videodot'
|
64
|
+
config.password = 'UCSDVdot'
|
65
|
+
end
|
66
|
+
|
67
|
+
following = @rik.following
|
68
|
+
following.should_not be_nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rik'
|
3
|
+
|
4
|
+
describe 'Module Rik::Client::Video' do
|
5
|
+
before(:each) do
|
6
|
+
@rik = Rik::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#info' do
|
10
|
+
it 'should be able to get public info on a video' do
|
11
|
+
videos = @rik.public_user_streams 'burn0ut07'
|
12
|
+
video = @rik.info(videos[0]['id'])
|
13
|
+
|
14
|
+
video.should_not be_nil
|
15
|
+
video.should have_at_least(1).length
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with username and password' do
|
19
|
+
before(:each) do
|
20
|
+
@rik.configure do |c|
|
21
|
+
c.login = 'videodot'
|
22
|
+
c.password = 'UCSDVdot'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should be able to get detailed info of public video' do
|
27
|
+
videos = @rik.public_user_streams 'burn0ut07'
|
28
|
+
video = @rik.info(videos[0]['id'], :detailed => true)
|
29
|
+
|
30
|
+
video.should_not be_nil
|
31
|
+
video.should have_at_least(1).length
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should be able to get private info on own video' do
|
35
|
+
video = @rik.info(30038511, :detailed => true)
|
36
|
+
|
37
|
+
video.should_not be_nil
|
38
|
+
video.should have_at_least(1).length
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#public_user_streams' do
|
44
|
+
it 'should get all public videos from a user' do
|
45
|
+
videos = @rik.public_user_streams 'burn0ut07'
|
46
|
+
videos.should_not be_nil
|
47
|
+
videos.should have_at_least(1).length
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/rik_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rik
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joel Jauregui
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-22 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: json
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: jeweler
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.6.2
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rcov
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
description: Ruby bindings for Qik API, inspired by the twitter gem
|
72
|
+
email: joel.jauregui@gmail.com
|
73
|
+
executables: []
|
74
|
+
|
75
|
+
extensions: []
|
76
|
+
|
77
|
+
extra_rdoc_files:
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.rdoc
|
80
|
+
files:
|
81
|
+
- .document
|
82
|
+
- .rspec
|
83
|
+
- Gemfile
|
84
|
+
- Gemfile.lock
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.rdoc
|
87
|
+
- Rakefile
|
88
|
+
- VERSION
|
89
|
+
- lib/rik.rb
|
90
|
+
- lib/rik/api.rb
|
91
|
+
- lib/rik/client.rb
|
92
|
+
- lib/rik/client/session.rb
|
93
|
+
- lib/rik/client/stream.rb
|
94
|
+
- lib/rik/client/user.rb
|
95
|
+
- lib/rik/client/video.rb
|
96
|
+
- rik.gemspec
|
97
|
+
- spec/client/stream_spec.rb
|
98
|
+
- spec/client/user_spec.rb
|
99
|
+
- spec/client/video_spec.rb
|
100
|
+
- spec/rik_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
has_rdoc: true
|
103
|
+
homepage: http://github.com/Burn0ut07/rik
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: -1563252108867835538
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: "0"
|
126
|
+
requirements: []
|
127
|
+
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 1.6.2
|
130
|
+
signing_key:
|
131
|
+
specification_version: 3
|
132
|
+
summary: Ruby bindings for Qik
|
133
|
+
test_files: []
|
134
|
+
|