khepri_connector 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e58487898d8a307775ff7f8b1b1701c346658371
4
+ data.tar.gz: 0b8c86155913f898c09c55b4ce679d852af20f06
5
+ SHA512:
6
+ metadata.gz: c36f3342bf5d26e1d9330f09ed13a230a19271e8852b7e5bad90a34cf433c6cea6f71bab79d8412a4b247b178754c20682d96c2b539c25cdb33e4559f5e7d36f
7
+ data.tar.gz: 5654ea3b89c8cc845cf4231148884213d9b8afaf481be6ee6f141e1b140ac534280a83b09b83e94b1d6959fed64e13b1b89b7bb5cab7c29b78584db779f01763
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in khepri_connector.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 franck.laprevotte
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # KhepriConnector
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'khepri_connector'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install khepri_connector
18
+
19
+ ## Usage
20
+
21
+ see exemples on http://khepri.tech/
22
+
23
+ ## License
24
+
25
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
26
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "khepri_connector"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'khepri_connector/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "khepri_connector"
8
+ spec.version = KhepriConnector::VERSION
9
+ spec.authors = ["Khepri Dev Team"]
10
+ spec.email = ["khepri_dev@wister.fr"]
11
+
12
+ spec.summary = %q{connector to use Khepri :: THE ULTIMATE A/B TESTING AND OPTIMIZATION TOOL.}
13
+ spec.homepage = "http://khepri.tech"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.12"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,3 @@
1
+ module KhepriConnector
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,91 @@
1
+ require "khepri_connector/version"
2
+
3
+ class Khepri
4
+
5
+ def initialize(khepri_url, api_key, instance_id)
6
+ @khepri_url, @api_key, @instance_id = khepri_url, api_key, instance_id
7
+ end
8
+
9
+ #
10
+ # prepare and launch ask task
11
+ #
12
+ def ask(exludes = nil, forced = nil, dimensions = {})
13
+ params_to_add = {}
14
+ if !exludes.nil?
15
+ params_to_add[:exclude] = exludes.join(',')
16
+ end
17
+
18
+ if !forced.nil?
19
+ params_to_add[:forced_solutions] = forced.join(',')
20
+ end
21
+
22
+ if !dimensions.empty?
23
+ dimensions.each do |key, value|
24
+ params_to_add[key] = value
25
+ end
26
+ end
27
+
28
+ launch('ask', params_to_add)
29
+
30
+ end
31
+
32
+ #
33
+ # prepare and launch success task
34
+ #
35
+ def success(answer)
36
+ if answer["status"] == 'success'
37
+ params_to_add = { :solution => answer["solution"]}
38
+ launch('success', params_to_add)
39
+
40
+ end
41
+
42
+ end
43
+
44
+ #
45
+ # prepare and launch dimensions task
46
+ #
47
+ def dimensions(answer)
48
+ puts answer
49
+ if answer["status"] == 'success' && answer.has_key?('dimensions')
50
+ params_to_add = { :dimensions => answer["dimensions"]}
51
+ launch('dimensions', params_to_add)
52
+
53
+ end
54
+
55
+
56
+ end
57
+
58
+ #
59
+ # prepare and launch reset task
60
+ #
61
+ def reset
62
+ launch 'reset'
63
+
64
+ end
65
+
66
+ #
67
+ # launch task on khepri and get the result
68
+ #
69
+ def launch(api, params_to_add = {})
70
+
71
+ url = @khepri_url + '/api/' + api + '.json'
72
+ uri = URI(url)
73
+ params = { :instance => @instance_id, :api_key => @api_key}
74
+ if !params_to_add.empty?
75
+ params.merge!(params_to_add)
76
+ end
77
+ uri.query = URI.encode_www_form(params)
78
+ puts "launching :: " + uri.to_s
79
+
80
+ # real call
81
+ res = Net::HTTP.get_response(uri)
82
+ if res.is_a?(Net::HTTPSuccess) || !res.body.empty?
83
+ puts "khepri answer :: " + res.body
84
+ JSON.parse(res.body)
85
+ else
86
+ false
87
+ end
88
+
89
+ end
90
+
91
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: khepri_connector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Khepri Dev Team
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - khepri_dev@wister.fr
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - khepri_connector.gemspec
56
+ - lib/khepri_connector.rb
57
+ - lib/khepri_connector/version.rb
58
+ homepage: http://khepri.tech
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.5.1
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: 'connector to use Khepri :: THE ULTIMATE A/B TESTING AND OPTIMIZATION TOOL.'
82
+ test_files: []