totter 0.3.0 → 0.3.1
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.
- data/lib/totter/client/timelines.rb +13 -7
- data/lib/totter/version.rb +1 -1
- data/test/totter/client/timelines_test.rb +11 -11
- metadata +1 -1
@@ -17,7 +17,7 @@ module Totter
|
|
17
17
|
# @example
|
18
18
|
# Totter.global_timeline(limit: 20, since: '1,15')
|
19
19
|
def global_timeline(options = DEFAULT_TIMELINE_OPTIONS)
|
20
|
-
get('timelines/global', options)
|
20
|
+
format_timeline_result get('timelines/global', options)
|
21
21
|
end
|
22
22
|
|
23
23
|
# Get recent decisions from a hashtag timeline
|
@@ -31,7 +31,7 @@ module Totter
|
|
31
31
|
# @example
|
32
32
|
# Totter.global_timeline(limit: 20, since: '1,15')
|
33
33
|
def hashtag_timeline(hashtag, options = DEFAULT_TIMELINE_OPTIONS)
|
34
|
-
get('timelines/global', options.merge({hashtag: hashtag}))
|
34
|
+
format_timeline_result get('timelines/global', options.merge({hashtag: hashtag}))
|
35
35
|
end
|
36
36
|
|
37
37
|
# Get recent decisions from a sticker timeline
|
@@ -45,7 +45,7 @@ module Totter
|
|
45
45
|
# @example
|
46
46
|
# Totter.global_timeline(limit: 20, since: '1,15')
|
47
47
|
def sticker_timeline(sticker, options = DEFAULT_TIMELINE_OPTIONS)
|
48
|
-
get('timelines/global', options.merge({sticker: sticker}))
|
48
|
+
format_timeline_result get('timelines/global', options.merge({sticker: sticker}))
|
49
49
|
end
|
50
50
|
|
51
51
|
# Search for published items
|
@@ -59,7 +59,7 @@ module Totter
|
|
59
59
|
# @example
|
60
60
|
# Totter.global_timeline(limit: 20, since: '1,15')
|
61
61
|
def search_timeline(query, options = DEFAULT_TIMELINE_OPTIONS)
|
62
|
-
get('timelines/search', options.merge({query: query}))
|
62
|
+
format_timeline_result get('timelines/search', options.merge({query: query}))
|
63
63
|
end
|
64
64
|
|
65
65
|
# Get recent decisions from the flagged-for-review timeline
|
@@ -72,7 +72,7 @@ module Totter
|
|
72
72
|
# @example
|
73
73
|
# Totter.global_timeline(limit: 20, since: '1,15')
|
74
74
|
def flagged_timeline(options = DEFAULT_TIMELINE_OPTIONS)
|
75
|
-
get('timelines/flagged', options)
|
75
|
+
format_timeline_result get('timelines/flagged', options)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Get recent decisions from a given user.
|
@@ -86,7 +86,7 @@ module Totter
|
|
86
86
|
# @example
|
87
87
|
# Totter.user_timeline(4, limit: 20, since: '1,15')
|
88
88
|
def user_timeline(user_id, options = DEFAULT_TIMELINE_OPTIONS)
|
89
|
-
get("users/#{user_id}/timelines/user", options)
|
89
|
+
format_timeline_result get("users/#{user_id}/timelines/user", options)
|
90
90
|
end
|
91
91
|
|
92
92
|
# Get the friends timeline (also known as "feed" or "home") for a given user.
|
@@ -103,7 +103,13 @@ module Totter
|
|
103
103
|
# @example
|
104
104
|
# Totter.friends_timeline(4, limit: 20, since: '1,15')
|
105
105
|
def friends_timeline(user_id, options = DEFAULT_TIMELINE_OPTIONS)
|
106
|
-
get("users/#{user_id}/timelines/friends", options)
|
106
|
+
format_timeline_result get("users/#{user_id}/timelines/friends", options)
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def format_timeline_result(http_result)
|
112
|
+
Hashie::Mash.new(items: http_result.body, pusher_channel: http_result.headers['x-pusher-channel'])
|
107
113
|
end
|
108
114
|
end
|
109
115
|
end
|
data/lib/totter/version.rb
CHANGED
@@ -4,8 +4,8 @@ class TimelinesTest < Totter::TestCase
|
|
4
4
|
def test_global
|
5
5
|
VCR.use_cassette 'timelines/global' do
|
6
6
|
response = Totter.global_timeline(limit: 15)
|
7
|
-
assert_equal 15, response.
|
8
|
-
assert_equal 'timeline-global', response.
|
7
|
+
assert_equal 15, response.items.length
|
8
|
+
assert_equal 'timeline-global', response.pusher_channel
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -13,8 +13,8 @@ class TimelinesTest < Totter::TestCase
|
|
13
13
|
VCR.use_cassette 'timelines/hashtags' do
|
14
14
|
client = local_client
|
15
15
|
response = local_client.hashtag_timeline('test')
|
16
|
-
assert_equal 1, response.
|
17
|
-
assert_equal 'timeline-hashtag-test', response.
|
16
|
+
assert_equal 1, response.items.length
|
17
|
+
assert_equal 'timeline-hashtag-test', response.pusher_channel
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,8 +22,8 @@ class TimelinesTest < Totter::TestCase
|
|
22
22
|
VCR.use_cassette 'timelines/stickers' do
|
23
23
|
client = local_client
|
24
24
|
response = local_client.sticker_timeline('test')
|
25
|
-
assert_equal 1, response.
|
26
|
-
assert_equal 'timeline-sticker-test', response.
|
25
|
+
assert_equal 1, response.items.length
|
26
|
+
assert_equal 'timeline-sticker-test', response.pusher_channel
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ class TimelinesTest < Totter::TestCase
|
|
31
31
|
VCR.use_cassette 'timelines/search' do
|
32
32
|
client = local_client
|
33
33
|
response = local_client.search_timeline('bacon')
|
34
|
-
assert_equal 2, response.
|
34
|
+
assert_equal 2, response.items.length
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,8 +39,8 @@ class TimelinesTest < Totter::TestCase
|
|
39
39
|
VCR.use_cassette 'timelines/flagged' do
|
40
40
|
client = local_client
|
41
41
|
response = local_client.flagged_timeline
|
42
|
-
assert_equal 1, response.
|
43
|
-
assert_equal 'timeline-flagged', response.
|
42
|
+
assert_equal 1, response.items.length
|
43
|
+
assert_equal 'timeline-flagged', response.pusher_channel
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -48,8 +48,8 @@ class TimelinesTest < Totter::TestCase
|
|
48
48
|
VCR.use_cassette 'timelines/user' do
|
49
49
|
client = local_client
|
50
50
|
response = local_client.user_timeline(4)
|
51
|
-
assert_equal 0, response.
|
52
|
-
assert_equal 'timeline-user-4', response.
|
51
|
+
assert_equal 0, response.items.length
|
52
|
+
assert_equal 'timeline-user-4', response.pusher_channel
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|