adn 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/adn/api/token.rb +1 -1
- data/lib/adn/post.rb +4 -4
- data/lib/adn/user.rb +16 -12
- data/lib/adn/version.rb +1 -1
- data/lib/adn.rb +0 -4
- data/spec/adn/user_spec.rb +11 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/adn/api/token.rb
CHANGED
data/lib/adn/post.rb
CHANGED
@@ -8,7 +8,7 @@ module ADN
|
|
8
8
|
|
9
9
|
def self.send_post(params)
|
10
10
|
result = ADN::API::Post.create(params)
|
11
|
-
Post.new(result["data"])
|
11
|
+
Post.new(result["data"])
|
12
12
|
end
|
13
13
|
|
14
14
|
def initialize(raw_post)
|
@@ -42,17 +42,17 @@ module ADN
|
|
42
42
|
|
43
43
|
def reply_to_post
|
44
44
|
result = ADN::API::Post.by_id(reply_to)
|
45
|
-
ADN.create_instance(result["data"], Post)
|
45
|
+
ADN.create_instance(result["data"], Post)
|
46
46
|
end
|
47
47
|
|
48
48
|
def replies(params = nil)
|
49
49
|
result = ADN::API::Post.replies(id, params)
|
50
|
-
ADN.create_collection(result["data"], Post)
|
50
|
+
ADN.create_collection(result["data"], Post)
|
51
51
|
end
|
52
52
|
|
53
53
|
def delete
|
54
54
|
result = ADN::API::Post.delete(id)
|
55
|
-
ADN.create_instance(result["data"], Post)
|
55
|
+
ADN.create_instance(result["data"], Post)
|
56
56
|
end
|
57
57
|
|
58
58
|
def set_values(values)
|
data/lib/adn/user.rb
CHANGED
@@ -9,12 +9,16 @@ module ADN
|
|
9
9
|
:locale, :name, :timezone, :type, :username,
|
10
10
|
:you_follow, :you_muted
|
11
11
|
|
12
|
+
def self.me
|
13
|
+
new ADN::API::Token.current['user']
|
14
|
+
end
|
15
|
+
|
12
16
|
def initialize(user)
|
13
17
|
if user.respond_to?(:each_pair)
|
14
18
|
set_values(user)
|
15
|
-
self.user_id = id
|
19
|
+
self.user_id = id.to_s
|
16
20
|
else
|
17
|
-
self.user_id = user
|
21
|
+
self.user_id = user.to_s
|
18
22
|
user_details = details
|
19
23
|
if details.has_key? "data"
|
20
24
|
set_values(user_details["data"])
|
@@ -43,23 +47,23 @@ module ADN
|
|
43
47
|
def follow(user)
|
44
48
|
user_id = get_user(user)
|
45
49
|
result = ADN.post("/stream/0/users/#{user_id}/follow")
|
46
|
-
ADN.create_instance(result["data"], User)
|
50
|
+
ADN.create_instance(result["data"], User)
|
47
51
|
end
|
48
52
|
|
49
53
|
def unfollow(user)
|
50
54
|
user_id = get_user(user)
|
51
55
|
result = ADN.delete("/stream/0/users/#{user_id}/follow")
|
52
|
-
ADN.create_instance(result["data"], User)
|
56
|
+
ADN.create_instance(result["data"], User)
|
53
57
|
end
|
54
58
|
|
55
59
|
def followers
|
56
60
|
result = ADN::API::User.followers(user_id)
|
57
|
-
ADN.create_collection(result["data"], User)
|
61
|
+
ADN.create_collection(result["data"], User)
|
58
62
|
end
|
59
63
|
|
60
64
|
def following
|
61
65
|
result = ADN::API::User.following(user_id)
|
62
|
-
ADN.create_collection(result["data"], User)
|
66
|
+
ADN.create_collection(result["data"], User)
|
63
67
|
end
|
64
68
|
|
65
69
|
# Mute
|
@@ -67,35 +71,35 @@ module ADN
|
|
67
71
|
def mute(user)
|
68
72
|
user_id = get_user(user)
|
69
73
|
result = ADN.post("#{ADN::API_ENDPOINT_USERS}/#{user_id}/mute")
|
70
|
-
ADN.create_instance(result["data"], User)
|
74
|
+
ADN.create_instance(result["data"], User)
|
71
75
|
end
|
72
76
|
|
73
77
|
def unmute(user)
|
74
78
|
user_id = get_user(user)
|
75
79
|
result = ADN.delete("#{ADN::API_ENDPOINT_USERS}/#{user_id}/mute")
|
76
|
-
ADN.create_instance(result["data"], User)
|
80
|
+
ADN.create_instance(result["data"], User)
|
77
81
|
end
|
78
82
|
|
79
83
|
def mute_list
|
80
84
|
result = ADN.get("#{ADN::API_ENDPOINT_USERS}/me/muted")
|
81
|
-
ADN.create_collection(result["data"], User)
|
85
|
+
ADN.create_collection(result["data"], User)
|
82
86
|
end
|
83
87
|
|
84
88
|
# Posts
|
85
89
|
|
86
90
|
def posts(params = nil)
|
87
91
|
result = ADN::API::Post.by_user(user_id, params)
|
88
|
-
ADN.create_collection(result["data"], Post)
|
92
|
+
ADN.create_collection(result["data"], Post)
|
89
93
|
end
|
90
94
|
|
91
95
|
def stream(params = nil)
|
92
96
|
result = ADN::API::Post.stream(params)
|
93
|
-
ADN.create_collection(result["data"], Post)
|
97
|
+
ADN.create_collection(result["data"], Post)
|
94
98
|
end
|
95
99
|
|
96
100
|
def mentions(params = nil)
|
97
101
|
result = ADN::API::Post.mentioning_user(user_id, params)
|
98
|
-
ADN.create_collection(result["data"], Post)
|
102
|
+
ADN.create_collection(result["data"], Post)
|
99
103
|
end
|
100
104
|
|
101
105
|
def set_values(values)
|
data/lib/adn/version.rb
CHANGED
data/lib/adn.rb
CHANGED
data/spec/adn/user_spec.rb
CHANGED
@@ -9,6 +9,16 @@ describe ADN::User do
|
|
9
9
|
let(:user) { subject.new(user_data) }
|
10
10
|
let(:user_data) { fixture('user.json') }
|
11
11
|
|
12
|
+
describe "me" do
|
13
|
+
it "retrieves the user based on the current token" do
|
14
|
+
ADN::API::Token.stub(:current, { "user" => user_data }) do
|
15
|
+
u = subject.me
|
16
|
+
u.user_id.must_equal "4821"
|
17
|
+
u.username.must_equal "peterhellberg"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
describe "initialize" do
|
13
23
|
it "populates the accessors based on the raw user data passed in" do
|
14
24
|
u = subject.new(user_data)
|
@@ -18,7 +28,7 @@ describe ADN::User do
|
|
18
28
|
# TODO: Remove this behavior, wrong level of abstraction
|
19
29
|
it "populates the accessors based on the user id passed in" do
|
20
30
|
ADN::API::User.stub(:retrieve, { "data" => user_data }) do
|
21
|
-
u = subject.new(
|
31
|
+
u = subject.new(4821)
|
22
32
|
u.name.must_equal "Peter Hellberg"
|
23
33
|
u.user_id.must_equal "4821"
|
24
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: A simple and easy to use library to interact with App.net's API
|
17
17
|
email:
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
segments:
|
77
77
|
- 0
|
78
|
-
hash:
|
78
|
+
hash: -2288184448617261034
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
81
|
rubygems_version: 1.8.24
|