khepri_connector 0.0.1 → 0.1.0
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/.gitignore +1 -0
- data/README.md +36 -0
- data/lib/khepri_connector/version.rb +1 -1
- data/lib/khepri_connector.rb +26 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e12d6dcc9eb1d67139972b291be99e0034359b
|
4
|
+
data.tar.gz: 7991b6594e50a85735866e1648f183c99ad7cf47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43bf008be687271a7ae0f4c305da0e03fa45721cdc18a0db51519b1fc697088e123dae88d2b347ef74f269de2000006bb5a14349cfea60877a789b5eaff0cd43
|
7
|
+
data.tar.gz: 97322687c0f4605ec1650e25f38b90fb91dabcbdcb56d34fe6b846e3b0a06d81ee115c1dfcae6152f9a7fcee9daf4ae5e2916f18a1b3df7f4bd80279aff17c06
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,42 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
```ruby
|
22
|
+
#!/usr/bin/ruby
|
23
|
+
|
24
|
+
# require ruby libs included in ruby - not install needed
|
25
|
+
require 'net/http'
|
26
|
+
require 'json'
|
27
|
+
#
|
28
|
+
# require the khepri connector gem
|
29
|
+
# You need to install it with :
|
30
|
+
# $ gem install khepri_connector
|
31
|
+
#
|
32
|
+
require 'khepri_connector'
|
33
|
+
|
34
|
+
# setting you're khepri parameters
|
35
|
+
#
|
36
|
+
# Initialize the client with your API-Key. You can find it on your Khepri account.
|
37
|
+
# you can create your instance with your khepri account
|
38
|
+
#
|
39
|
+
khepri_url ='http://sb.khepri.tech'
|
40
|
+
api_key = 'MY_APi_KEY'
|
41
|
+
instance_id = 1
|
42
|
+
|
43
|
+
# create your Khepri object
|
44
|
+
kh = Khepri.new(khepri_url, api_key, instance_id)
|
45
|
+
|
46
|
+
# Simple ask
|
47
|
+
answer = kh.ask
|
48
|
+
# ask method return a JSON object like {"status":"success","solution":"a_solution"}
|
49
|
+
# you can access to the solution if you want
|
50
|
+
puts answer["solution"]
|
51
|
+
|
52
|
+
# Simple success
|
53
|
+
kh.success(answer)
|
54
|
+
```
|
55
|
+
|
56
|
+
|
21
57
|
see exemples on http://khepri.tech/
|
22
58
|
|
23
59
|
## License
|
data/lib/khepri_connector.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "khepri_connector/version"
|
2
2
|
|
3
|
+
# The Main Khepri connector class
|
3
4
|
class Khepri
|
4
5
|
|
5
6
|
def initialize(khepri_url, api_key, instance_id)
|
@@ -7,7 +8,13 @@ class Khepri
|
|
7
8
|
end
|
8
9
|
|
9
10
|
#
|
10
|
-
# prepare and launch ask task
|
11
|
+
# prepare and launch ask task on Khepri
|
12
|
+
#
|
13
|
+
# @param excludes [Array] array of solutions you want to exludes
|
14
|
+
# @param forced [Array] array of solutions you want to force
|
15
|
+
# @param dimensions [Hash] hash of dimensions you want to use
|
16
|
+
#
|
17
|
+
# @return [JSON] the Khepri answer
|
11
18
|
#
|
12
19
|
def ask(exludes = nil, forced = nil, dimensions = {})
|
13
20
|
params_to_add = {}
|
@@ -30,7 +37,11 @@ class Khepri
|
|
30
37
|
end
|
31
38
|
|
32
39
|
#
|
33
|
-
# prepare and launch success task
|
40
|
+
# prepare and launch success task on Khepri
|
41
|
+
#
|
42
|
+
# @param answer [JSON] the JSON answer of your ask
|
43
|
+
#
|
44
|
+
# @return [JSON] the Khepri answer
|
34
45
|
#
|
35
46
|
def success(answer)
|
36
47
|
if answer["status"] == 'success'
|
@@ -42,7 +53,11 @@ class Khepri
|
|
42
53
|
end
|
43
54
|
|
44
55
|
#
|
45
|
-
# prepare and launch dimensions task
|
56
|
+
# prepare and launch dimensions task on Khepri
|
57
|
+
#
|
58
|
+
# @param answer [JSON] the JSON answer of your ask
|
59
|
+
#
|
60
|
+
# @return [JSON] the Khepri answer
|
46
61
|
#
|
47
62
|
def dimensions(answer)
|
48
63
|
puts answer
|
@@ -56,7 +71,9 @@ class Khepri
|
|
56
71
|
end
|
57
72
|
|
58
73
|
#
|
59
|
-
# prepare and launch
|
74
|
+
# prepare and launch success task on Khepri
|
75
|
+
#
|
76
|
+
# @return [JSON] the Khepri answer
|
60
77
|
#
|
61
78
|
def reset
|
62
79
|
launch 'reset'
|
@@ -66,6 +83,11 @@ class Khepri
|
|
66
83
|
#
|
67
84
|
# launch task on khepri and get the result
|
68
85
|
#
|
86
|
+
# @param api [String] the task to call on khepri
|
87
|
+
# @param params_to_add [Hash] hash of parameters to ad on khepri's call
|
88
|
+
#
|
89
|
+
# @return [JSON] the khepri answer to the request
|
90
|
+
#
|
69
91
|
def launch(api, params_to_add = {})
|
70
92
|
|
71
93
|
url = @khepri_url + '/api/' + api + '.json'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: khepri_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khepri Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|