octocore 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -4
- data/README.md +10 -2
- data/lib/octocore.rb +1 -0
- data/lib/octocore/callbacks.rb +1 -1
- data/lib/octocore/helpers/api_consumer_helper.rb +0 -1
- data/lib/octocore/helpers/kong_helper.rb +17 -9
- data/lib/octocore/message_parser.rb +16 -1
- data/lib/octocore/models.rb +1 -0
- data/lib/octocore/models/enterprise/adapter_details.rb +18 -0
- data/lib/octocore/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9217fe8265f87093f929941062a52bd05862d089
|
4
|
+
data.tar.gz: 7ec1def0cdb3e175845776e940cf03db0cbb0e08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331f7b6fa6efe0fb5aeb185ade0e4eb58e3d8d476a1cc3cec524316beadda8ce8633371346a5df6f1e32e8d5027d39bc7ddde05baa9a43d27c4334fe3415b106
|
7
|
+
data.tar.gz: 4b2d77e6d28d57fbebc335ade50d0b371a7c6386a784d7864565bab7430efdd3d4fb29f411198649b30780d3efce60c253d3cefa459f331a80af8867e4777d37
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
octocore (0.0.
|
4
|
+
octocore (0.0.5)
|
5
5
|
cequel (~> 1.9, >= 1.9.0)
|
6
6
|
descriptive_statistics (~> 2.5.1, >= 2.5.0)
|
7
7
|
elasticsearch (~> 1.0.17, >= 1.0.17)
|
@@ -118,6 +118,3 @@ DEPENDENCIES
|
|
118
118
|
parallel_tests (~> 2.5.0, >= 2.5.0)
|
119
119
|
rake
|
120
120
|
rspec
|
121
|
-
|
122
|
-
BUNDLED WITH
|
123
|
-
1.11.2
|
data/README.md
CHANGED
@@ -4,7 +4,15 @@ This is the Octomatic Enterprise Core gem. It provides most of the ORM stuff. Cl
|
|
4
4
|
|
5
5
|
## Installting
|
6
6
|
|
7
|
-
|
7
|
+
```bash
|
8
|
+
gem install octocore
|
9
|
+
```
|
10
|
+
|
11
|
+
In case you are using bundler, you need to add something like this to your Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'octocore', :git => 'git@github.com:octoai/gem-octocore.git'
|
15
|
+
```
|
8
16
|
|
9
17
|
|
10
18
|
|
@@ -56,6 +64,6 @@ Octo.connect_with_config_file config_dir
|
|
56
64
|
|
57
65
|
It ships with a utility called `fakestream`. It will automatically stream random data. To use just open your console and type
|
58
66
|
|
59
|
-
```
|
67
|
+
```bash
|
60
68
|
$ fakestream /path/to/config/dir
|
61
69
|
```
|
data/lib/octocore.rb
CHANGED
data/lib/octocore/callbacks.rb
CHANGED
@@ -11,7 +11,7 @@ module Octo
|
|
11
11
|
included do
|
12
12
|
|
13
13
|
define_hooks :after_app_init, :after_app_login, :after_app_logout,
|
14
|
-
:after_page_view, :after_productpage_view
|
14
|
+
:after_page_view, :after_productpage_view, :after_connect
|
15
15
|
|
16
16
|
# Define the after_app_init hook
|
17
17
|
after_app_init do |args|
|
@@ -8,14 +8,17 @@ module Octo
|
|
8
8
|
module Helpers
|
9
9
|
module KongHelper
|
10
10
|
|
11
|
+
# The default URL for kong to connect to
|
12
|
+
KONG_URL = 'http://127.0.0.1:8001'
|
13
|
+
|
11
14
|
# Fetch Kong URL
|
12
15
|
# @return [String] Kong URL
|
13
16
|
def kong_url
|
14
17
|
kong_config = Octo.get_config :kong
|
15
|
-
if kong_config.
|
16
|
-
kong_config
|
17
|
-
|
18
|
-
|
18
|
+
if kong_config.class == String
|
19
|
+
kong_config
|
20
|
+
elsif kong_config.class == Hash
|
21
|
+
kong_config.fetch :url, KONG_URL
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -26,13 +29,12 @@ module Octo
|
|
26
29
|
# @return [Hash] Response
|
27
30
|
def process_kong_request (url, method, payload)
|
28
31
|
begin
|
29
|
-
|
30
32
|
url = kong_url + url
|
31
33
|
header = {
|
32
34
|
'Accept' => 'application/json, text/plain, */*',
|
33
35
|
'Content-Type' => 'application/json'
|
34
36
|
}
|
35
|
-
uri = URI.parse(url)
|
37
|
+
uri = URI.parse(URI.encode(url.strip))
|
36
38
|
http = Net::HTTP.new(uri.host,uri.port)
|
37
39
|
|
38
40
|
case method
|
@@ -50,10 +52,16 @@ module Octo
|
|
50
52
|
# Default Case
|
51
53
|
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
puts "HTTP #{ method } to #{ uri.host}:#{ uri.port }. Body: #{ payload.to_json }"
|
56
|
+
body = "#{ payload.to_json }"
|
57
|
+
res = http.request(req, body)
|
58
|
+
if res.body
|
59
|
+
JSON.parse(res.body) # Returned Data
|
60
|
+
else
|
61
|
+
{}
|
62
|
+
end
|
56
63
|
rescue Exception => e
|
64
|
+
puts "Exception: " + e.message.to_s + "\n" + e.backtrace_locations.join("\n") + "}"
|
57
65
|
{ message: e.to_s }.to_json
|
58
66
|
end
|
59
67
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'json'
|
2
|
-
require 'set'
|
3
2
|
|
4
3
|
module Octo
|
5
4
|
# Message abstraction module
|
@@ -93,6 +92,22 @@ module Octo
|
|
93
92
|
def to_h
|
94
93
|
parse(@message)
|
95
94
|
end
|
95
|
+
|
96
|
+
# To get enterprise id
|
97
|
+
# @return [String] Enterprise Id
|
98
|
+
def eid
|
99
|
+
msg = to_json
|
100
|
+
enterprise = msg['enterprise']
|
101
|
+
raise StandardError, 'Parse Error' if enterprise.nil?
|
102
|
+
|
103
|
+
eid = if enterprise.has_key?'custom_id'
|
104
|
+
enterprise['custom_id']
|
105
|
+
elsif enterprise.has_key?'customId'
|
106
|
+
enterprise['customId']
|
107
|
+
end
|
108
|
+
|
109
|
+
eid
|
110
|
+
end
|
96
111
|
|
97
112
|
end
|
98
113
|
end
|
data/lib/octocore/models.rb
CHANGED
@@ -217,6 +217,7 @@ end
|
|
217
217
|
|
218
218
|
|
219
219
|
require 'octocore/models/enterprise'
|
220
|
+
require 'octocore/models/enterprise/adapter_details'
|
220
221
|
require 'octocore/models/enterprise/api_event'
|
221
222
|
require 'octocore/models/enterprise/api_hit'
|
222
223
|
require 'octocore/models/enterprise/api_track'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'cequel'
|
2
|
+
require 'octocore/record'
|
3
|
+
|
4
|
+
module Octo
|
5
|
+
# Store adapter details of Enterprise
|
6
|
+
class AdapterDetails
|
7
|
+
include Cequel::Record
|
8
|
+
include Octo::Record
|
9
|
+
|
10
|
+
belongs_to :enterprise, class_name: 'Octo::Enterprise'
|
11
|
+
|
12
|
+
key :adapter_id, :int
|
13
|
+
key :enable, :boolean
|
14
|
+
|
15
|
+
column :settings, :text
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/octocore/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octocore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pranav Prakash
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cequel
|
@@ -377,6 +377,7 @@ files:
|
|
377
377
|
- lib/octocore/models.rb
|
378
378
|
- lib/octocore/models/contactus.rb
|
379
379
|
- lib/octocore/models/enterprise.rb
|
380
|
+
- lib/octocore/models/enterprise/adapter_details.rb
|
380
381
|
- lib/octocore/models/enterprise/api_event.rb
|
381
382
|
- lib/octocore/models/enterprise/api_hit.rb
|
382
383
|
- lib/octocore/models/enterprise/api_track.rb
|