faye_shards 0.1.1 → 0.1.2
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/README.rdoc +4 -4
- data/VERSION +1 -1
- data/faye_shards.gemspec +1 -1
- data/lib/faye_shard/user/faye.rb +7 -1
- data/lib/faye_shards.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -64,12 +64,12 @@ So, in my example for production I have 2 Faye instances listening to ports 4200
|
|
64
64
|
== Usage
|
65
65
|
|
66
66
|
URL for Faye's client-side JS (unless you store it somewhere on diff storage) is returned by this methos:
|
67
|
-
|
67
|
+
current_user.faye_shard.js_url(request.ssl?)
|
68
68
|
|
69
69
|
Module <code>FayeShard::User::Faye</code> which can be included to your User model provides method <tt>faye_channel</tt> which returns unique channel id for user. If you do not want to include module to your model - you need to manage unique channels for users yourself.
|
70
70
|
|
71
71
|
On client side, subscription should look like:
|
72
|
-
client = new Faye.Client(<%= raw
|
72
|
+
client = new Faye.Client(<%= raw current_user.faye_shard.url(request.ssl?).inspect %>);
|
73
73
|
fayeSubscription = client.subscribe(<%= raw current_user.faye_channel.inspect %>, function(data) {});
|
74
74
|
|
75
75
|
or
|
@@ -79,11 +79,11 @@ or
|
|
79
79
|
Pushing data to user's channel also depends on your decision to include module <code>FayeShard::User::Faye</code>. So, 2 options:
|
80
80
|
current_user.push_to_faye(data) # Sends data to channel, returned by current_user.faye_channel
|
81
81
|
or
|
82
|
-
FayeShards.shard(
|
82
|
+
FayeShards.shard(current_user.id).push(my_own_method_for_channel_id, data)
|
83
83
|
|
84
84
|
Extensions can be passed as an additional hash after <tt>data</tt>
|
85
85
|
|
86
|
-
How to push to global channel and more information about gem can be found here:
|
86
|
+
How to push to global channel and more information about gem can be found here: .
|
87
87
|
|
88
88
|
== Roadmap / TODO
|
89
89
|
* UT
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/faye_shards.gemspec
CHANGED
data/lib/faye_shard/user/faye.rb
CHANGED
@@ -19,7 +19,13 @@ module FayeShard
|
|
19
19
|
# * <tt>ext</tt>:: Faye extensions, eg. auth_token
|
20
20
|
#
|
21
21
|
def push_to_faye(data, ext = {})
|
22
|
-
|
22
|
+
faye_shard.push(self.faye_channel, data, ext)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns shard for this user
|
26
|
+
#
|
27
|
+
def faye_shard
|
28
|
+
FayeShards.shard(self.id)
|
23
29
|
end
|
24
30
|
|
25
31
|
end
|
data/lib/faye_shards.rb
CHANGED
@@ -30,7 +30,7 @@ class FayeShards
|
|
30
30
|
# Returns all configured shards
|
31
31
|
#
|
32
32
|
def all_shards
|
33
|
-
@
|
33
|
+
@all_shards ||= config["shards"].map{ |shard_config| FayeShard::Shard.new(shard_config) }
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faye_shards
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Kazeko
|