notifilter 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +22 -0
- data/README.md +22 -0
- data/lib/notifilter/version.rb +1 -1
- data/lib/notifilter.rb +9 -10
- data/script/send_test_data.rb +1 -1
- data/spec/notifilter_spec.rb +2 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9181b7933bce88c7fd655a44f5922b516f69fea7
|
4
|
+
data.tar.gz: 595ec219a635b7f0866075ab09a43758924ffb73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb6473b27555340febc11a57ad21e8fc501164f5746c81ecbeeddaf2a50e5a888aec53e0e4f568b9e7567a531a9a6f64f482bc39192eab95d8a4d3ae00eb4906
|
7
|
+
data.tar.gz: 5169506a9f65dab11cf6220d9d0ddbf9120d2ca6f9b9386f5670ebf453c854b3aba4242f276f6e0594a0de16772d0a68849b70434fbd80e25c15eb0c397447df
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
specs:
|
3
|
+
diff-lcs (1.2.5)
|
4
|
+
rspec (3.3.0)
|
5
|
+
rspec-core (~> 3.3.0)
|
6
|
+
rspec-expectations (~> 3.3.0)
|
7
|
+
rspec-mocks (~> 3.3.0)
|
8
|
+
rspec-core (3.3.2)
|
9
|
+
rspec-support (~> 3.3.0)
|
10
|
+
rspec-expectations (3.3.1)
|
11
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
12
|
+
rspec-support (~> 3.3.0)
|
13
|
+
rspec-mocks (3.3.2)
|
14
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
15
|
+
rspec-support (~> 3.3.0)
|
16
|
+
rspec-support (3.3.0)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
rspec
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Notifilter Gem
|
2
|
+
|
3
|
+
[](https://travis-ci.org/bittersweet/notifilter-rb)
|
4
|
+
|
5
|
+
This is a early, early version of a gem that sends events to
|
6
|
+
[Notifilter](https://github.com/bittersweet/notifilter). It is currently UDP
|
7
|
+
based, so fire and forget.
|
8
|
+
|
9
|
+
A TCP version will be forthcoming once everything has ran in production for a
|
10
|
+
while.
|
11
|
+
|
12
|
+
### Ecosystem
|
13
|
+
|
14
|
+
[Server](https://github.com/bittersweet/notifilter)
|
15
|
+
|
16
|
+
### How to use
|
17
|
+
|
18
|
+
```
|
19
|
+
$notifilter = Notifilter.new("application_name", "127.0.0.1", "8000")
|
20
|
+
$notifilter.notify("event_identifier", { product_id: 1 })
|
21
|
+
```
|
22
|
+
|
data/lib/notifilter/version.rb
CHANGED
data/lib/notifilter.rb
CHANGED
@@ -2,23 +2,22 @@ require 'socket'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
class Notifilter
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
ENV["NOTIFILTER_PORT"] || 8000
|
5
|
+
def initialize(application, host = nil, port = nil)
|
6
|
+
@application = application
|
7
|
+
@host = host || "127.0.0.1"
|
8
|
+
@port = port || "8000"
|
10
9
|
end
|
11
10
|
|
12
|
-
def
|
11
|
+
def notify(identifier, data)
|
13
12
|
message = {
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
application: @application,
|
14
|
+
identifier: identifier,
|
15
|
+
data: data
|
17
16
|
}.to_json
|
18
17
|
|
19
18
|
begin
|
20
19
|
socket = UDPSocket.new
|
21
|
-
socket.send(message, 0, host, port)
|
20
|
+
socket.send(message, 0, @host, @port)
|
22
21
|
rescue Exception => e
|
23
22
|
puts "Exception in Notifilter: #{e.message}"
|
24
23
|
ensure
|
data/script/send_test_data.rb
CHANGED
data/spec/notifilter_spec.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
require "./lib/notifilter"
|
2
|
-
require "byebug"
|
3
2
|
|
4
3
|
describe Notifilter do
|
5
4
|
around do |spec|
|
6
5
|
@server = UDPSocket.new
|
7
6
|
@server.bind("127.0.0.1", "8001")
|
8
|
-
ENV["NOTIFILTER_PORT"] = "8001"
|
9
7
|
spec.run
|
10
8
|
@server.close
|
11
9
|
end
|
12
10
|
|
13
11
|
it "sends correct message" do
|
14
12
|
data = { "id" => 1, "name" => "John Doe", "active" => false }
|
15
|
-
Notifilter.
|
13
|
+
notifilter = Notifilter.new("test_app", "127.0.0.1", "8001")
|
14
|
+
notifilter.notify("user.created", data)
|
16
15
|
|
17
16
|
received = @server.recv(1000)
|
18
17
|
result = { "application" => "test_app", "identifier" => "user.created", "data" => data }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifilter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Mulder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -59,6 +59,10 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".travis.yml"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- README.md
|
62
66
|
- Rakefile
|
63
67
|
- lib/notifilter.rb
|
64
68
|
- lib/notifilter/version.rb
|