viki 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +79 -31
- data/lib/viki/api_object.rb +1 -1
- data/lib/viki/client.rb +3 -2
- data/lib/viki/version.rb +1 -1
- data/spec/request_spec.rb +29 -1
- metadata +45 -15
data/README.md
CHANGED
@@ -3,48 +3,96 @@ A Viki wrapper gem for the Viki V3 API. This gem is currently under active devel
|
|
3
3
|
Full documentation for API V3 may be found at [dev.viki.com](http://dev.viki.com/api "Viki API V3 Docs")
|
4
4
|
|
5
5
|
|
6
|
-
|
6
|
+
Installation
|
7
7
|
----------
|
8
|
+
Manually `gem install viki` or add `gem 'viki'` to Gemfile
|
8
9
|
|
9
|
-
|
10
|
+
How to use
|
11
|
+
----------
|
12
|
+
Add to your .rb
|
13
|
+
|
14
|
+
require 'viki'
|
15
|
+
|
16
|
+
Initialization
|
17
|
+
|
18
|
+
viki = Viki.new('your_client_id', 'your_client_secret')
|
19
|
+
|
20
|
+
|
21
|
+
Responses will be returned in a `Viki::APIObject`.
|
22
|
+
|
23
|
+
For results that are paginated. You can use the `APIObject`'s `next` and `prev` methods to retrieve the next and previous 25 records respectively.
|
10
24
|
|
11
25
|
```
|
12
|
-
|
13
|
-
|
14
|
-
client.movie(id).subtitles(lang)
|
15
|
-
client.movie(id).hardsubs
|
26
|
+
viki.movies
|
27
|
+
movies = viki.get #return records in a Viki::APIObject
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
movies.content #content of the API call in JSON format
|
30
|
+
movies.count #total number of possible results in the endpoint
|
31
|
+
|
32
|
+
movies2 = movies.next #next 25 records
|
33
|
+
movies = movies2.prev #prev 25 records
|
34
|
+
```
|
23
35
|
|
24
|
-
client.music_videos(params)
|
25
|
-
client.music_videos(id, params)
|
26
|
-
client.music_videos(id).subtitles(lang)
|
27
|
-
client.music_videos(id).hardsubs * implementation waiting on valid examples
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
Examples
|
38
|
+
----------
|
39
|
+
* Results will always be returned in JSON format.
|
40
|
+
* All URL endpoints in the following examples should include an `access_token` parameter.
|
41
|
+
* Refer to the [API V3 documentation](http://dev.viki.com/api "Viki API V3 Docs") for all endpoints.
|
32
42
|
|
43
|
+
### List Movies
|
44
|
+
URL
|
33
45
|
|
34
|
-
|
35
|
-
|
36
|
-
client.newsclips(id).subtitles(lang)
|
37
|
-
client.newsclips(id).hardsubs(lang)
|
46
|
+
without parameter filters
|
47
|
+
http://www.viki.com/api/v3/movies.json
|
38
48
|
|
49
|
+
with parameter filters
|
50
|
+
http://www.viki.com/api/v3/movies.json?genre=2
|
39
51
|
|
40
|
-
|
41
|
-
client.artist(id, params)
|
42
|
-
client.artists(id).music_videos(params)
|
52
|
+
Your ruby application
|
43
53
|
|
44
|
-
|
54
|
+
viki.movies.get #without parameter filters
|
55
|
+
viki.movies(genre: 2).get #with parameter filters
|
45
56
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
57
|
+
### Show Movie
|
58
|
+
URL
|
59
|
+
|
60
|
+
http://www.viki.com/api/v3/movies/71459.json
|
61
|
+
|
62
|
+
Your ruby application
|
63
|
+
|
64
|
+
viki.movies(71459).get
|
65
|
+
|
66
|
+
### Subtitles
|
67
|
+
URL
|
68
|
+
|
69
|
+
http://www.viki.com/api/v3/movies/71459/subtitles/en.json
|
70
|
+
|
71
|
+
Your ruby application
|
72
|
+
|
73
|
+
viki.movies(71459).subtitles('en').get
|
74
|
+
|
75
|
+
### Show Episode
|
76
|
+
URL
|
77
|
+
|
78
|
+
http://www.viki.com/api/v3/series/6004/episodes/61168.json
|
79
|
+
|
80
|
+
Your ruby application
|
81
|
+
|
82
|
+
viki.series(6004).episodes(61168).get
|
83
|
+
|
84
|
+
### List Newscasts
|
85
|
+
|
86
|
+
URL
|
87
|
+
|
88
|
+
without parameter filters
|
89
|
+
http://www.viki.com/api/v3/newscasts.json
|
90
|
+
|
91
|
+
with parameter filters
|
92
|
+
http://www.viki.com/api/v3/newscasts.json?language=ko
|
93
|
+
|
94
|
+
Your ruby application
|
95
|
+
|
96
|
+
viki.newscasts.get #without parameter filter
|
97
|
+
viki.newscasts(language: 'ko').get #with parameter filter
|
50
98
|
|
data/lib/viki/api_object.rb
CHANGED
data/lib/viki/client.rb
CHANGED
@@ -7,7 +7,8 @@ module Viki
|
|
7
7
|
class Client
|
8
8
|
Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
|
9
9
|
URL_NAMESPACES = [:movies, :series, :episodes, :music_videos, :newscasts, :newsclips,
|
10
|
-
:artists, :featured, :coming_soon, :subtitles, :hardsubs
|
10
|
+
:artists, :featured, :coming_soon, :subtitles, :hardsubs, :genres, :countries,
|
11
|
+
:search, :languages]
|
11
12
|
|
12
13
|
def initialize(client_id, client_secret)
|
13
14
|
@client_id = client_id
|
@@ -30,7 +31,7 @@ module Viki
|
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
33
|
-
def method_missing(name, *args
|
34
|
+
def method_missing(name, *args)
|
34
35
|
@call_chain ||= []
|
35
36
|
raise NoMethodError if not URL_NAMESPACES.include? name
|
36
37
|
|
data/lib/viki/version.rb
CHANGED
data/spec/request_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe "Viki" do
|
|
11
11
|
it "should retrieve an access token when the Viki object is configured and initialized" do
|
12
12
|
VCR.use_cassette "auth" do
|
13
13
|
client = Viki.new(client_id, client_secret)
|
14
|
-
client.access_token.should == '
|
14
|
+
client.access_token.should == '7e5c411d19aaa60f9a5d18d7cf3c44ae9cf7e28d5ccee84e1a4b699cb7ab07fc'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -137,5 +137,33 @@ describe "Viki" do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
+
describe ".next" do
|
141
|
+
it "should invoke direct_request with a next_url" do
|
142
|
+
VCR.use_cassette("movies/list/pg2", :record => :new_episodes) do
|
143
|
+
movies = client.movies.get
|
144
|
+
next_url = movies.instance_variable_get(:@next_url)
|
145
|
+
movies.should_receive(:direct_request).with(next_url)
|
146
|
+
movies.next
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe ".prev" do
|
152
|
+
it "should invoke direct_request with previous_url" do
|
153
|
+
VCR.use_cassette("movies/list/pg2", :record => :new_episodes) do
|
154
|
+
movies_pg1 = client.movies.get
|
155
|
+
movies_pg2 = movies_pg1.next
|
156
|
+
previous_url = movies_pg2.instance_variable_get(:@previous_url)
|
157
|
+
movies_pg2.should_receive(:direct_request).with(previous_url)
|
158
|
+
movies_pg2.prev
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe ".method_missing" do
|
164
|
+
it "should raise NoMethodError if a method that is not on the whitelist is called" do
|
165
|
+
expect { client.does_not_exist }.should raise_error(NoMethodError)
|
166
|
+
end
|
167
|
+
end
|
140
168
|
end
|
141
169
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-06-
|
14
|
+
date: 2012-06-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
18
|
-
requirement:
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,10 +23,15 @@ dependencies:
|
|
23
23
|
version: 2.10.0
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ~>
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 2.10.0
|
27
32
|
- !ruby/object:Gem::Dependency
|
28
33
|
name: vcr
|
29
|
-
requirement:
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
30
35
|
none: false
|
31
36
|
requirements:
|
32
37
|
- - ~>
|
@@ -34,10 +39,15 @@ dependencies:
|
|
34
39
|
version: 2.2.2
|
35
40
|
type: :development
|
36
41
|
prerelease: false
|
37
|
-
version_requirements:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.2.2
|
38
48
|
- !ruby/object:Gem::Dependency
|
39
49
|
name: webmock
|
40
|
-
requirement:
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
41
51
|
none: false
|
42
52
|
requirements:
|
43
53
|
- - ~>
|
@@ -45,10 +55,15 @@ dependencies:
|
|
45
55
|
version: 1.8.7
|
46
56
|
type: :development
|
47
57
|
prerelease: false
|
48
|
-
version_requirements:
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.8.7
|
49
64
|
- !ruby/object:Gem::Dependency
|
50
65
|
name: excon
|
51
|
-
requirement:
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
52
67
|
none: false
|
53
68
|
requirements:
|
54
69
|
- - ~>
|
@@ -56,10 +71,15 @@ dependencies:
|
|
56
71
|
version: 0.9.6
|
57
72
|
type: :development
|
58
73
|
prerelease: false
|
59
|
-
version_requirements:
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.9.6
|
60
80
|
- !ruby/object:Gem::Dependency
|
61
81
|
name: httparty
|
62
|
-
requirement:
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
63
83
|
none: false
|
64
84
|
requirements:
|
65
85
|
- - ~>
|
@@ -67,10 +87,15 @@ dependencies:
|
|
67
87
|
version: 0.8.3
|
68
88
|
type: :runtime
|
69
89
|
prerelease: false
|
70
|
-
version_requirements:
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.8.3
|
71
96
|
- !ruby/object:Gem::Dependency
|
72
97
|
name: multi_json
|
73
|
-
requirement:
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
74
99
|
none: false
|
75
100
|
requirements:
|
76
101
|
- - ~>
|
@@ -78,7 +103,12 @@ dependencies:
|
|
78
103
|
version: 1.3.6
|
79
104
|
type: :runtime
|
80
105
|
prerelease: false
|
81
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.3.6
|
82
112
|
description: Viki-gem is an official wrapper gem for the Viki V3 API.
|
83
113
|
email:
|
84
114
|
- engineering@viki.com
|
@@ -126,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
156
|
version: '0'
|
127
157
|
requirements: []
|
128
158
|
rubyforge_project: viki
|
129
|
-
rubygems_version: 1.8.
|
159
|
+
rubygems_version: 1.8.24
|
130
160
|
signing_key:
|
131
161
|
specification_version: 3
|
132
162
|
summary: A thin wrapper around the Viki V3 API
|