ingram_micro_engine 0.0.2 → 0.0.3
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/app/controllers/ingram_micro_engine/webhook_controller.rb +12 -1
- data/lib/ingram_micro_engine.rb +37 -1
- data/lib/ingram_micro_engine/version.rb +1 -1
- metadata +1 -2
- data/README.rdoc +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41711d66e1567d3170b9744518d928fdebaf085c
|
4
|
+
data.tar.gz: 5e74a9d1009ea66cabca8741a3f5938c20997bf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba8111b1d53ab1735e70bffe77f34f7485461afab8342138461157e34e546797710f82ff0ae9ae5361a77fd6d343f134f1ae9db47df2b9e1ed0a91a86645d52b
|
7
|
+
data.tar.gz: 29cf9a9961088a0ef576f92f78c854b05700d91f47f551a59c5fc6f3cbfa509663505f53e7eb93daa185f97b73711220356349345e313a20c072156377e19a55
|
@@ -3,13 +3,24 @@ module IngramMicroEngine
|
|
3
3
|
before_action :log_request
|
4
4
|
|
5
5
|
def event
|
6
|
+
IngramMicroEngine.instrument(transaction_name, request_body)
|
7
|
+
|
6
8
|
render status: 200, xml: success_response
|
7
9
|
end
|
8
10
|
|
9
11
|
private
|
10
12
|
|
13
|
+
def transaction_name
|
14
|
+
parsed = Nokogiri::XML.parse(request_body)
|
15
|
+
parsed.xpath("message/message-header/transaction-name").text
|
16
|
+
end
|
17
|
+
|
18
|
+
def request_body
|
19
|
+
@request_body ||= request.body.read
|
20
|
+
end
|
21
|
+
|
11
22
|
def log_request
|
12
|
-
IngramMicroEngine.log(
|
23
|
+
IngramMicroEngine.log(request_body)
|
13
24
|
end
|
14
25
|
|
15
26
|
def imm_response(opts={})
|
data/lib/ingram_micro_engine.rb
CHANGED
@@ -3,7 +3,7 @@ require "ingram_micro_engine/engine"
|
|
3
3
|
|
4
4
|
module IngramMicroEngine
|
5
5
|
class << self
|
6
|
-
attr_accessor :configuration
|
6
|
+
attr_accessor :configuration, :backend, :namespace, :adapter
|
7
7
|
|
8
8
|
def configuration
|
9
9
|
IngramMicro.configuration
|
@@ -14,6 +14,42 @@ module IngramMicroEngine
|
|
14
14
|
configuration.logger.info "[IngramMicroEngine] #{message}"
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
def instrument(transaction_name, xml)
|
19
|
+
backend.instrument namespace.call(transaction_name), xml
|
20
|
+
end
|
21
|
+
|
22
|
+
def subscribe(transaction_name, callable = Proc.new)
|
23
|
+
backend.subscribe namespace.to_regexp(transaction_name), adapter.call(callable)
|
24
|
+
end
|
25
|
+
|
26
|
+
def all(callable=Proc.new)
|
27
|
+
subscribe nil, callable
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Namespace < Struct.new(:value, :delimiter)
|
32
|
+
def call(name = nil)
|
33
|
+
"#{value}#{delimiter}#{name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_regexp(name = nil)
|
37
|
+
%r{^#{Regexp.escape call(name)}}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class NotificationAdapter < Struct.new(:subscriber)
|
42
|
+
def self.call(callable)
|
43
|
+
new(callable)
|
44
|
+
end
|
45
|
+
|
46
|
+
def call(*args)
|
47
|
+
payload = args.last
|
48
|
+
subscriber.call(payload)
|
49
|
+
end
|
17
50
|
end
|
18
51
|
|
52
|
+
self.adapter = NotificationAdapter
|
53
|
+
self.namespace = Namespace.new("ingram_micro", ".")
|
54
|
+
self.backend = ActiveSupport::Notifications
|
19
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ingram_micro_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Le
|
@@ -90,7 +90,6 @@ extensions: []
|
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
92
|
- MIT-LICENSE
|
93
|
-
- README.rdoc
|
94
93
|
- Rakefile
|
95
94
|
- app/assets/javascripts/ingram_micro_engine/application.js
|
96
95
|
- app/assets/stylesheets/ingram_micro_engine/application.css
|
data/README.rdoc
DELETED