nark 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29c7165758015c9bbdedec21b261060b85a310a9
4
- data.tar.gz: 1d3532ed320f88b395a1c0657c2c6f1ca0ba5fd0
3
+ metadata.gz: 8184a8ba4c90d62012e5628c1c91077f4685b5b4
4
+ data.tar.gz: d2bb1770658dd080b076051b761680ca34848bd4
5
5
  SHA512:
6
- metadata.gz: 04fe5b59371d7c7bcc5b487c645a745f66f88969254cac051026acbc2c628fb5cbe945c98055e48bdbe020163f4bd2391dbe79d4e1fec412d65792de3262f91f
7
- data.tar.gz: 186067bca857a98f6526c96bf35ac44d210ad010822cc37e8efeabf2bffde3113fbac9039ddb16d5f922c392e9b11882fa8a4839512444007196434886f0a200
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
@@ -1,3 +1,3 @@
1
1
  module Nark
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/spec/nark_spec.rb CHANGED
@@ -3,11 +3,7 @@ require 'nark'
3
3
  class TestSignup
4
4
  include Nark
5
5
 
6
- def self.collection_name
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, user_name: 'everydayhero',
28
- keen: { timestamp: time }
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
- end
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.1
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-06-26 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler