nark 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nark.rb +14 -0
- data/lib/nark/version.rb +1 -1
- data/spec/nark_spec.rb +11 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8184a8ba4c90d62012e5628c1c91077f4685b5b4
|
4
|
+
data.tar.gz: d2bb1770658dd080b076051b761680ca34848bd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 292b64c6560dd1fa577ee31f78eaf18bab59580c280ed7ab8faf6deeace68da271aead0959c800a93b58f06a8c12f7cd1698c2768005f050824646f25ceed48c
|
7
|
+
data.tar.gz: 5de2832902fd924443b992a0a804a1232a6ead169a35fadfbd6c9fbc32c886a256bd07c8ea7539c06f7bae88978cb9fc304a1f66b631e82bf428a04eca3af9ea
|
data/lib/nark.rb
CHANGED
@@ -2,9 +2,23 @@ require 'nark/version'
|
|
2
2
|
require 'keen'
|
3
3
|
|
4
4
|
module Nark
|
5
|
+
def self.included(klass)
|
6
|
+
klass.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :serializable_hash
|
10
|
+
|
5
11
|
def emit(timestamp: nil)
|
6
12
|
hash = serializable_hash
|
7
13
|
hash.merge! keen: { timestamp: timestamp } if timestamp
|
8
14
|
Keen.publish self.class.collection_name, serializable_hash
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
def collection_name(value = nil)
|
20
|
+
@collection_name = value if value
|
21
|
+
@collection_name
|
22
|
+
end
|
9
23
|
end
|
10
24
|
end
|
data/lib/nark/version.rb
CHANGED
data/spec/nark_spec.rb
CHANGED
@@ -3,11 +3,7 @@ require 'nark'
|
|
3
3
|
class TestSignup
|
4
4
|
include Nark
|
5
5
|
|
6
|
-
|
7
|
-
:test_signups
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_reader :serializable_hash
|
6
|
+
collection_name :test_signups
|
11
7
|
|
12
8
|
def initialize(attributes)
|
13
9
|
@serializable_hash = attributes
|
@@ -24,8 +20,15 @@ describe TestSignup do
|
|
24
20
|
it 'should emit event to keen with specific timestamp' do
|
25
21
|
time = Time.now
|
26
22
|
expect(Keen).to \
|
27
|
-
receive(:publish).with :test_signups,
|
28
|
-
|
23
|
+
receive(:publish).with :test_signups,
|
24
|
+
user_name: 'everydayhero',
|
25
|
+
keen: { timestamp: time }
|
29
26
|
TestSignup.new(user_name: 'everydayhero').emit timestamp: time
|
30
27
|
end
|
31
|
-
|
28
|
+
|
29
|
+
it 'should emit returning self' do
|
30
|
+
allow(Keen).to receive :publish
|
31
|
+
signup = TestSignup.new({})
|
32
|
+
expect(signup.emit).to eq(signup)
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nark
|
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 Ryall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|