socket.io-emitter 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24c40abfcadda66cf7c2f9952c3c26d5e63126b0
4
- data.tar.gz: 71ba37dc4034554cc6f539baf6433a018ff073d0
3
+ metadata.gz: 20c7ad7c5bf64297f833e433feff914d1ce62c2d
4
+ data.tar.gz: 6c18218cf9ad4ab872eff0612b9b1436496bca1a
5
5
  SHA512:
6
- metadata.gz: 1cafda5d0a0f6ee261fba5c3705605e4d2dd4ac3e17c7c49a0d81b78b037ab81dca08f3ae86de337cf54980e33b00a87e773f4c24b1ff4e308f3067a87493690
7
- data.tar.gz: 097715651f51f215da68c378adfb38b828da192bf38ce6ad2b09a25fde6959648fe9591fb4f46c9f5c82ee5a54fcbaa90189c56b4fb7faf799e48ebe2316eb28
6
+ metadata.gz: 23ac834cd52c6fa0a8f97bd3af6387a98f590028e943c3cd6cfdddcfa241600502e2eca7f489500e760f657602c55cd9f5c215d3517ed299b75d9cf7f420cd0d
7
+ data.tar.gz: d8efc036e436fcc81fbdd2e6e0666a55cacc6d160a6c3c8f3fa7ca167127eca1b95b793fb466ec92840d6591c520c44017d71222ab3f97d1b84250dcfe55b9a1
data/Readme.md CHANGED
@@ -1,7 +1,16 @@
1
1
 
2
2
  # SocketIO::Emitter
3
3
 
4
- TODO: Write a gem description
4
+ A Ruby implementation of [socket.io-emitter](https://github.com/Automattic/socket.io-emitter).
5
+
6
+ ## How to use
7
+
8
+ ```ruby
9
+ require 'socket.io-emitter'
10
+
11
+ emitter = SocketIO::Emitter.new
12
+ emitter.emit('time', DateTime.now.to_s)
13
+ ```
5
14
 
6
15
  ## Installation
7
16
 
@@ -17,17 +26,26 @@ Or install it yourself as:
17
26
 
18
27
  $ gem install socket.io-emitter
19
28
 
20
- ## Usage
29
+ ## API
30
+
31
+ ### Emitter.new([opts])
32
+
33
+ The following options are allowed:
34
+
35
+ - key: the name of the key to pub/sub events on as prefix (`socket.io`)
36
+ - redis: the Instance of [Redis](https://github.com/redis/redis-rb) (`redis://127.0.0.1:6379/0`)
37
+
38
+ ### Emitter#to(room)
39
+
40
+ Specifies a specific room that you want to emit to.
41
+
42
+ ### Emitter#in(room)
21
43
 
22
- TODO: Write usage instructions here
44
+ _Alias of `Emitter#to`._
23
45
 
24
- ## Contributing
46
+ ### Emitter#of(namespace)
25
47
 
26
- 1. Fork it ( https://github.com/[my-github-username]/socket.io-ruby-emitter/fork )
27
- 2. Create your feature branch (`git checkout -b my-new-feature`)
28
- 3. Commit your changes (`git commit -am 'Add some feature'`)
29
- 4. Push to the branch (`git push origin my-new-feature`)
30
- 5. Create a new Pull Request
48
+ Specifies a specific namespace that you want to emit to.
31
49
 
32
50
  ## License
33
51
 
@@ -20,14 +20,14 @@ module SocketIO
20
20
  def method_missing(name)
21
21
  match = /(?<flag>\S+)\?$/.match(name)
22
22
  unless match.nil?
23
- return !!@flags[:flag]
23
+ return !!@flags[match[:flag].to_sym]
24
24
  end
25
25
  @flags[name.to_sym] = true
26
26
  self
27
27
  end
28
28
 
29
29
  def in(room)
30
- @rooms << room unless @rooms.includes?(room)
30
+ @rooms << room unless @rooms.include?(room)
31
31
  self
32
32
  end
33
33
 
@@ -62,7 +62,7 @@ module SocketIO
62
62
  packet[:nsp] = '/'
63
63
  end
64
64
 
65
- packed = MessagePack.pack([packet, [rooms: @rooms, flags: @flags]])
65
+ packed = MessagePack.pack([packet, { rooms: @rooms, flags: @flags }])
66
66
  @redis.publish(@key, packed)
67
67
 
68
68
  @rooms = []
@@ -3,6 +3,6 @@ require 'socket.io/emitter'
3
3
 
4
4
  module SocketIO
5
5
  class Emitter
6
- VERSION = '0.0.0'
6
+ VERSION = '0.0.1'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socket.io-emitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nulltask
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis