stream-ruby 0.8.2 → 1.0.0
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 +8 -8
- data/README.md +12 -5
- data/lib/stream/client.rb +9 -4
- data/lib/stream/feed.rb +5 -2
- data/lib/stream/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OThkZjY2OWMwNDJkNzQ1YzlhYjBjNGFkYzc0ZGI0MWQwZDk4Y2U3YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjlhMDk3NmUyODE3OTM5YjFmYTQ3YTYwYThiNGRmMzAzODFhNDNkNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTUzY2NhNmUyNTc0YmRjNTVkZWI1YjlkNDc3ZTEzYjM1ZTIzNDIzYjVmMWNh
|
10
|
+
OWU5YTliZThjZGVmZjQzZmExNmY0ODdmZjc3YTAxYTI2NTVjYTM4M2RmNmM4
|
11
|
+
YzRlMTQxOTMzM2FiYWRhYjVlOGIyYjZkNTZkODRiZTI1NjU4MTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDdlMGM1MmI5ZmJlZTlhMjc1M2EzYzU5NTFlNzEyNWU5MTJiMDU3MjE5ZjUx
|
14
|
+
NmI0NDBlOGI2NDdlMjA3MTlkYmFjZTY3Y2VjMjgxMDY4M2U2MjU3ZWVkOGVh
|
15
|
+
ZjlkNTUwNDUyMmQ1NzYyYWUwNjhlMTJjODhlMWQ5YTFjNDJlNGU=
|
data/README.md
CHANGED
@@ -29,6 +29,13 @@ result = user_feed_1.get(:limit=>5, :id_lt=>'e561de8f-00f1-11e4-b400-0cc47a024be
|
|
29
29
|
# Create a new activity
|
30
30
|
activity_data = {:actor => 1, :verb => 'tweet', :object => 1, :foreign_id => 'tweet:1'}
|
31
31
|
activity_response = user_feed_1.add_activity(activity_data)
|
32
|
+
# Create a bit more complex activity
|
33
|
+
activity_data = {:actor => 1, :verb => 'tweet', :object => 1, :foreign_id => 'tweet:1',
|
34
|
+
:course => {:name => 'Golden Gate park', :distance => 10},
|
35
|
+
:participants => ['Thierry', 'Tommaso'],
|
36
|
+
:started_at => DateTime.now()
|
37
|
+
};
|
38
|
+
activity_response = user_feed_1.add_activity(activity_data)
|
32
39
|
|
33
40
|
# Remove an activity by its id
|
34
41
|
user_feed_1.remove('e561de8f-00f1-11e4-b400-0cc47a024be0')
|
@@ -68,19 +75,19 @@ token = user_feed_1.token
|
|
68
75
|
# user1 = client.feed('user:1', '{{ token }}');
|
69
76
|
|
70
77
|
# Retrieve first 10 followers of a feed
|
71
|
-
user_feed_1.followers(
|
78
|
+
user_feed_1.followers(0, 10);
|
72
79
|
|
73
80
|
# Retrieve followers from 10 to 20
|
74
|
-
user_feed_1.followers(
|
81
|
+
user_feed_1.followers(10, 10);
|
75
82
|
|
76
83
|
# Retrieve 10 feeds followed by user_feed_1
|
77
|
-
user_feed_1.following(
|
84
|
+
user_feed_1.following(10);
|
78
85
|
|
79
86
|
# Retrieve 10 feeds followed by user_feed_1 starting from the 11th
|
80
|
-
user_feed_1.following(
|
87
|
+
user_feed_1.following(10, 10);
|
81
88
|
|
82
89
|
# Check if user_feed_1 follows specific feeds
|
83
|
-
user_feed_1.following(
|
90
|
+
user_feed_1.following(0, 2, filter=['user:42', 'user:43']);
|
84
91
|
|
85
92
|
```
|
86
93
|
|
data/lib/stream/client.rb
CHANGED
@@ -2,21 +2,26 @@ require 'stream/signer'
|
|
2
2
|
require 'stream/feed'
|
3
3
|
|
4
4
|
module Stream
|
5
|
+
STREAM_URL_RE = /https\:\/\/(?<key>\w+)\:(?<secret>\w+).*site=(?<site>\d+)/i
|
6
|
+
|
5
7
|
class Client
|
6
8
|
attr_reader :api_key
|
7
9
|
attr_reader :api_secret
|
8
10
|
attr_reader :site
|
9
11
|
|
10
12
|
def initialize(api_key='', api_secret='', site=0)
|
11
|
-
# Support the Heroku STREAM_URL environment variable
|
12
13
|
|
13
|
-
if ENV['STREAM_URL']
|
14
|
-
matches =
|
14
|
+
if ENV['STREAM_URL'] =~ Stream::STREAM_URL_RE and api_key == ''
|
15
|
+
matches = Stream::STREAM_URL_RE.match(ENV['STREAM_URL'])
|
15
16
|
api_key = matches['key']
|
16
17
|
api_secret = matches['secret']
|
17
18
|
site = matches['site']
|
18
19
|
end
|
19
|
-
|
20
|
+
|
21
|
+
if api_key == ''
|
22
|
+
raise ArgumentError, 'empty api_key parameter and missing or invalid STREAM_URL env variable'
|
23
|
+
end
|
24
|
+
|
20
25
|
@api_key = api_key
|
21
26
|
@api_secret = api_secret
|
22
27
|
@site = site
|
data/lib/stream/feed.rb
CHANGED
@@ -58,6 +58,9 @@ module Stream
|
|
58
58
|
|
59
59
|
def get(params = {})
|
60
60
|
uri = "/feed/#{@feed_url}/"
|
61
|
+
if params[:mark_read]
|
62
|
+
params[:mark_read] = params[:mark_read].join(",")
|
63
|
+
end
|
61
64
|
self.make_request(:get, uri, params)
|
62
65
|
end
|
63
66
|
|
@@ -111,7 +114,7 @@ module Stream
|
|
111
114
|
self.make_request(:post, uri, nil, follow_data)
|
112
115
|
end
|
113
116
|
|
114
|
-
def followers(
|
117
|
+
def followers(offset=0, limit=25)
|
115
118
|
uri = "/feed/#{@feed_url}/followers/"
|
116
119
|
params = {
|
117
120
|
'offset' => offset,
|
@@ -120,7 +123,7 @@ module Stream
|
|
120
123
|
self.make_request(:get, uri, params)
|
121
124
|
end
|
122
125
|
|
123
|
-
def following(
|
126
|
+
def following(offset=0, limit=25, filter=[])
|
124
127
|
uri = "/feed/#{@feed_url}/follows/"
|
125
128
|
params = {
|
126
129
|
'limit' => limit,
|
data/lib/stream/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stream-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommaso Barbugli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|