informant-rails 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/informant-rails/client.rb +12 -6
- data/lib/informant-rails/config.rb +4 -3
- data/lib/informant-rails/model.rb +4 -0
- data/lib/informant-rails/railtie.rb +1 -3
- data/lib/informant-rails/request.rb +9 -0
- data/lib/informant-rails/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e591798b1be7affc8eaba1cb7ffd4d78e618cdef
|
4
|
+
data.tar.gz: 324e9e8515be049953be4c571e76dbdc3256a8fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 321479096bc623127a210a3155c7e66fe6c4579326fda0ade882593f1eaccd74b50d71210a43cbc7434dfdcb86a594c813412b74631c1e407bc15a339a113db7
|
7
|
+
data.tar.gz: a8dce9703be9e0cc7249f43d3372fb7fcdd00c7f67b2b21e66e5cfd9402cefe8d01265876b417b90317dc2d5a3fe99c4dde398c66eb5a439dd32e80f7d96ff3d
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'typhoeus'
|
2
2
|
|
3
3
|
module InformantRails
|
4
4
|
class Client
|
@@ -16,12 +16,14 @@ module InformantRails
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.inform(model)
|
19
|
-
request.process_model(model) if request && model
|
19
|
+
request.process_model(model) if request && include_model?(model)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.process
|
23
23
|
if Config.api_token.present? && request && request.models.any?
|
24
|
-
|
24
|
+
Typhoeus::Request.new(
|
25
|
+
api_url, method: :post, params: { payload: request.as_json }
|
26
|
+
).run
|
25
27
|
end
|
26
28
|
remove_request
|
27
29
|
end
|
@@ -32,6 +34,10 @@ module InformantRails
|
|
32
34
|
|
33
35
|
private
|
34
36
|
|
37
|
+
def self.include_model?(model)
|
38
|
+
!InformantRails::Config.exclude_models.include?(model.class.to_s)
|
39
|
+
end
|
40
|
+
|
35
41
|
def self.new_request
|
36
42
|
@requests[request_id] = Request.new
|
37
43
|
end
|
@@ -45,11 +51,11 @@ module InformantRails
|
|
45
51
|
end
|
46
52
|
|
47
53
|
def self.api_url
|
48
|
-
@api_url ||=
|
49
|
-
'http://
|
54
|
+
@api_url ||= [
|
55
|
+
'http://api.informantapp.com/api/v1',
|
50
56
|
InformantRails::Config.api_token,
|
51
57
|
InformantRails::Config.server_environment
|
52
|
-
].join('/')
|
58
|
+
].join('/')
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module InformantRails::Config
|
2
2
|
extend self
|
3
3
|
|
4
|
-
attr_accessor :api_token, :server_environment
|
4
|
+
attr_accessor :api_token, :server_environment, :exclude_models
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
self.api_token = ENV['INFORMANT_API_KEY']
|
7
|
+
self.server_environment = Rails.env
|
8
|
+
self.exclude_models = []
|
8
9
|
|
9
10
|
def configure; yield self end
|
10
11
|
end
|
@@ -16,10 +16,8 @@ module InformantRails
|
|
16
16
|
|
17
17
|
initializer 'informant ActiveRecord binding' do
|
18
18
|
class ::ActiveRecord::Base
|
19
|
-
|
20
|
-
result = super(*args)
|
19
|
+
set_callback(:validate, :after) do
|
21
20
|
InformantRails::Client.inform(self)
|
22
|
-
result
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: informant-rails
|
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
|
- Paul Elliott
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: typhoeus
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
description: The Informant tells you what's irritating your users.
|
29
43
|
email:
|
30
44
|
executables: []
|