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.
@@ -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
@@ -1,4 +1,4 @@
1
1
  module Totter
2
2
  # Verion of the Totter gem
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
@@ -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.body.length
8
- assert_equal 'timeline-global', response.headers['x-pusher-channel']
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.body.length
17
- assert_equal 'timeline-hashtag-test', response.headers['x-pusher-channel']
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.body.length
26
- assert_equal 'timeline-sticker-test', response.headers['x-pusher-channel']
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.body.length
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.body.length
43
- assert_equal 'timeline-flagged', response.headers['x-pusher-channel']
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.body.length
52
- assert_equal 'timeline-user-4', response.headers['x-pusher-channel']
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: