binnacle_ar 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.asc +49 -0
- data/Rakefile +7 -0
- data/lib/binnacle_ar.rb +6 -0
- data/lib/binnacle_ar/engine.rb +5 -0
- data/lib/binnacle_ar/hooks.rb +51 -0
- data/lib/binnacle_ar/version.rb +3 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b2429eb6a586aeb62ecb6a854d17bc247e0ee85
|
4
|
+
data.tar.gz: 3f7cfdcbe84eaa353582dedfcc0c21ce2a4101cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: adb0d30cf3dae08e782abd020f27efc99059fb9704529d9fa5194cee51d2be7f091bbcbefa84060894906e64421058b9537c0a711d5a4ea4c94dfaaf2cb6188f
|
7
|
+
data.tar.gz: 5831b8d36278f135037fd364881e2d9e0bccd1507fccbe57e67be949ecc1f9135bce92e2db789a5739ef13c9194da37d8d38e216e8f28fadcb98e6626a197dcd
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Brian Sam-Bodden
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.asc
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
== binnacle_ar
|
2
|
+
|
3
|
+
## Active Record CUD (Create-Update-Delete) interceptor for Binnacle
|
4
|
+
|
5
|
+
....
|
6
|
+
__/\\\______________________________________________________________________________/\\\\\\____________________
|
7
|
+
_\/\\\_____________________________________________________________________________\////\\\____________________
|
8
|
+
_\/\\\__________/\\\__________________________________________________________________\/\\\____________________
|
9
|
+
_\/\\\_________\///____/\\/\\\\\\_____/\\/\\\\\\_____/\\\\\\\\\_________/\\\\\\\\_____\/\\\_________/\\\\\\\\__
|
10
|
+
_\/\\\\\\\\\____/\\\__\/\\\////\\\___\/\\\////\\\___\////////\\\______/\\\//////______\/\\\_______/\\\/////\\\_
|
11
|
+
_\/\\\////\\\__\/\\\__\/\\\__\//\\\__\/\\\__\//\\\____/\\\\\\\\\\____/\\\_____________\/\\\______/\\\\\\\\\\\__
|
12
|
+
_\/\\\__\/\\\__\/\\\__\/\\\___\/\\\__\/\\\___\/\\\___/\\\/////\\\___\//\\\____________\/\\\_____\//\\///////___
|
13
|
+
_\/\\\\\\\\\___\/\\\__\/\\\___\/\\\__\/\\\___\/\\\__\//\\\\\\\\/\\___\///\\\\\\\\___/\\\\\\\\\___\//\\\\\\\\\\_
|
14
|
+
_\/////////____\///___\///____\///___\///____\///____\////////\//______\////////___\/////////_____\//////////__
|
15
|
+
....
|
16
|
+
|
17
|
+
Overview
|
18
|
+
========
|
19
|
+
Adds ActiveRecord callbacks for create, update and delete that will signal Binnacle
|
20
|
+
with the state of the object (to_json)
|
21
|
+
|
22
|
+
Setup
|
23
|
+
=====
|
24
|
+
Add the binnacle_ar gem to your Gemfile:
|
25
|
+
|
26
|
+
```
|
27
|
+
gem 'binnacle_ar'
|
28
|
+
```
|
29
|
+
|
30
|
+
Configure Binnacle Ruby driver by providing the values for endpoint, target context and
|
31
|
+
a valid publisher's api key and secret:
|
32
|
+
|
33
|
+
```
|
34
|
+
BINNACLE_ENDPOINT=localhost
|
35
|
+
BINNACLE_AR_CTX=26e5z3cybiv5tqj12zy6
|
36
|
+
BINNACLE_API_KEY=nmp9wnfoj1t10spzi57r
|
37
|
+
BINNACLE_API_SECRET=xsh3lanzk4oaqxcvho7d
|
38
|
+
```
|
39
|
+
|
40
|
+
Usage
|
41
|
+
=====
|
42
|
+
Use the `binnacle_signal` class method on an ActiveRecord model to decide on
|
43
|
+
which actions to signal Binnacle:
|
44
|
+
|
45
|
+
```
|
46
|
+
class Comment < ActiveRecord::Base
|
47
|
+
binnacle_signal :on => [:create, :update, :destroy]
|
48
|
+
end
|
49
|
+
```
|
data/Rakefile
ADDED
data/lib/binnacle_ar.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module BinnacleAr
|
2
|
+
module Hooks
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def binnacle_signal(options = {})
|
7
|
+
options[:on] ||= [:create, :update, :destroy]
|
8
|
+
|
9
|
+
options_on = Array(options[:on])
|
10
|
+
|
11
|
+
after_create :record_create if options_on.include?(:create)
|
12
|
+
after_update :record_update if options_on.include?(:update)
|
13
|
+
after_destroy :record_destroy if options_on.include?(:destroy)
|
14
|
+
|
15
|
+
after_initialize do
|
16
|
+
@binnacle_client = Binnacle::Client.new(ENV['BINNACLE_API_KEY'], ENV['BINNACLE_API_SECRET'])
|
17
|
+
end
|
18
|
+
|
19
|
+
include BinnacleAr::Hooks::InstanceMethods
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module InstanceMethods
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def record_create
|
28
|
+
signal 'create'
|
29
|
+
end
|
30
|
+
|
31
|
+
def record_update
|
32
|
+
signal 'update'
|
33
|
+
end
|
34
|
+
|
35
|
+
def record_destroy
|
36
|
+
signal 'destroy'
|
37
|
+
end
|
38
|
+
|
39
|
+
def signal(method)
|
40
|
+
@binnacle_client.signal_asynch(ENV['BINNACLE_AR_CHANNEL'], "#{method}_#{self.class.to_s.underscore}",
|
41
|
+
nil,
|
42
|
+
nil,
|
43
|
+
'INFO',
|
44
|
+
[],
|
45
|
+
self.to_json)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
ActiveRecord::Base.send :include, BinnacleAr::Hooks
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: binnacle_ar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Sam-Bodden
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: binnacle
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.4.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.4.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sqlite3
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.3.10
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.3'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.3.10
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: jquery-rails
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '4.0'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 4.0.5
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4.0'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 4.0.5
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: coffee-rails
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '4.1'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.1.0
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.1'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 4.1.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: dotenv-rails
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.0'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.0.2
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.0.2
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: turbolinks
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '2.5'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '2.5'
|
127
|
+
description: |-
|
128
|
+
Adds ActiveRecord callbacks for create, update and delete that will signal Binnacle
|
129
|
+
with the state of the object (to_json)
|
130
|
+
email:
|
131
|
+
- brian@binnacle.io
|
132
|
+
executables: []
|
133
|
+
extensions: []
|
134
|
+
extra_rdoc_files: []
|
135
|
+
files:
|
136
|
+
- MIT-LICENSE
|
137
|
+
- README.asc
|
138
|
+
- Rakefile
|
139
|
+
- lib/binnacle_ar.rb
|
140
|
+
- lib/binnacle_ar/engine.rb
|
141
|
+
- lib/binnacle_ar/hooks.rb
|
142
|
+
- lib/binnacle_ar/version.rb
|
143
|
+
homepage: https://github.com/binnacle-io/binnacle_ar
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.6.11
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: ActiveRecord callbacks to signal Binnacle
|
167
|
+
test_files: []
|