vine_client 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/lib/vine_client.rb +2 -3
- data/lib/vine_client/client.rb +42 -15
- data/lib/vine_client/request.rb +3 -3
- data/vine_client.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0129b2ad30114abf275501ea7eb2ca911e9298e
|
4
|
+
data.tar.gz: a6fa8509f0568b2365449d7c85c6cacee9e0a3e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9cd8a7916b4c4d17b61c9630f915419c41f51d95ea8971590bf7d152a75ef44f16b5f2bd0f84f25f7d40d5fbce3f2da069199fd5c3e4b117b08e9f1b43e5cff
|
7
|
+
data.tar.gz: b5d8397bbbc2e6826813dfec23e384250615917ddc5f838623e09e7fb303e69e55e81d49dd659ac28e58f3307c8d9fa6ee71f7b32d55b004c61beef3caac7937
|
data/lib/vine_client.rb
CHANGED
data/lib/vine_client/client.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
|
1
3
|
module Vine
|
2
4
|
class Client
|
3
5
|
include Request
|
4
6
|
def initialize(name, pass)
|
5
|
-
result=login(name,pass)
|
6
|
-
@key=result['key']
|
7
|
-
@userId=result['userId']
|
7
|
+
result = login(name,pass)
|
8
|
+
@key = result['key']
|
9
|
+
@userId = result['userId']
|
8
10
|
end
|
9
11
|
|
10
12
|
def login(name, pass)
|
@@ -23,23 +25,23 @@ module Vine
|
|
23
25
|
get("/users/profiles/#{user_id}")
|
24
26
|
end
|
25
27
|
|
26
|
-
def search(keyword, page)
|
27
|
-
get("/users/search/#{keyword}?page=#{page}")
|
28
|
+
def search(keyword, page = nil)
|
29
|
+
result = get("/users/search/#{keyword}?page=#{page}")
|
30
|
+
method = lambda{|keyword, page| get("/users/search/#{keyword}?page=#{page}")}
|
31
|
+
ResultSet.new(result, keyword, method)
|
28
32
|
end
|
29
33
|
|
30
|
-
|
31
|
-
|
34
|
+
|
35
|
+
def timelines(page = nil, user_id=@userId)
|
36
|
+
result = get("/timelines/users/#{user_id}?page=#{page}")
|
37
|
+
method = lambda{|user_id, page| get("/timelines/users/#{user_id}?page=#{page}")}
|
38
|
+
ResultSet.new(result, user_id, method)
|
32
39
|
end
|
33
40
|
|
34
41
|
def tag(tag=nil, page=nil)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
get("/timelines/tags/#{tag}")
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
42
|
+
result = get("/timelines/tags/#{tag}?page=#{page}")
|
43
|
+
method = lambda{|tag, page| get("/timelines/tags/#{tag}?page=#{page}")}
|
44
|
+
ResultSet.new(result, tag, method)
|
43
45
|
end
|
44
46
|
|
45
47
|
def notifications(user_id=@userId)
|
@@ -54,4 +56,29 @@ module Vine
|
|
54
56
|
get("/timelines/posts/#{post_id}") if post_id
|
55
57
|
end
|
56
58
|
end
|
59
|
+
|
60
|
+
class ResultSet
|
61
|
+
include Request
|
62
|
+
attr_reader :records, :current_page
|
63
|
+
|
64
|
+
def call_method(method, optional_param, page)
|
65
|
+
result = method.call(optional_param, page)
|
66
|
+
ResultSet.new(result, optional_param, method)
|
67
|
+
end
|
68
|
+
|
69
|
+
def initialize(result, optional_param,method)
|
70
|
+
p method
|
71
|
+
@current_page = result.nextPage.nil? ? 1 : result.nextPage - 1
|
72
|
+
@records = result.records.map{|vine| Video.new(vine.to_hash)}
|
73
|
+
define_singleton_method(:next_page){ call_method(method, optional_param, @current_page + 1)} unless result.nextPage.nil?
|
74
|
+
define_singleton_method(:previous_page){ call_method(method ,optional_param, @current_page - 1)} unless result.previousPage.nil?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Video < Hashie::Mash
|
79
|
+
include Request
|
80
|
+
def like()
|
81
|
+
post("/posts/#{self.postId}/likes") if self.postId
|
82
|
+
end
|
83
|
+
end
|
57
84
|
end
|
data/lib/vine_client/request.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Vine
|
2
2
|
module Request
|
3
3
|
|
4
|
-
[:get,:put,:post,:delete].each{|verb|define_method(verb){|*arg| call(verb, arg[0],arg[1])}}
|
4
|
+
[:get,:put,:post,:delete].each{|verb| define_method(verb){|*arg| call(verb, arg[0],arg[1])}}
|
5
5
|
|
6
6
|
def call(http_verb, path, params)
|
7
7
|
result = connection.send(http_verb, path, params){|req| req[:vine_session_id]=@key if @key}
|
@@ -23,7 +23,7 @@ module Vine
|
|
23
23
|
:verify => true
|
24
24
|
},
|
25
25
|
}
|
26
|
-
|
26
|
+
|
27
27
|
Faraday.new(options) do |builder|
|
28
28
|
builder.response :raise_error
|
29
29
|
builder.response :mashify
|
@@ -33,4 +33,4 @@ module Vine
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
data/vine_client.gemspec
CHANGED