domoscio_rails 0.2.10 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/domoscio_rails.rb +76 -44
- data/lib/domoscio_rails/adaptative/predictive/objective_knowledge_node.rb +6 -0
- data/lib/domoscio_rails/adaptative/predictive/objective_knowledge_node_student.rb +7 -0
- data/lib/domoscio_rails/adaptative/predictive/objective_student.rb +2 -1
- data/lib/domoscio_rails/authorization_token.rb +4 -12
- data/lib/domoscio_rails/data/learning_session.rb +10 -0
- data/lib/domoscio_rails/http_calls.rb +12 -9
- data/lib/domoscio_rails/metadata/delta_object.rb +6 -0
- data/lib/domoscio_rails/utils/alerts_util.rb +6 -0
- data/lib/domoscio_rails/utils/recommendation_util.rb +6 -0
- data/lib/domoscio_rails/version.rb +1 -1
- metadata +44 -46
- data/lib/domoscio_rails/admin/user.rb +0 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 80036d711a50e0323cbd9f9fa260ebc9c9c6d194060f68b8be05d2ee7eab4206
|
4
|
+
data.tar.gz: 944991129c4a01704a0b24776d605ff926f408b48e17e998b1a525bcf43a469b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae6d858a4ca54802ff2504ee268fcacf8915cc45832fad48ba59c70daf1f49567112f5647b68dded5ab0056cef403cb77e52e9a06f341fc52f9ee45d52babd98
|
7
|
+
data.tar.gz: 01f77a383197e1e91b4b4c196d40098b44fec5a60eb2ec87a06ed34bde89633053000799b2920200d38b3b14266dda6e64cba292b34fdd726d54a4f1feb4109f
|
data/lib/domoscio_rails.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
require 'net/
|
1
|
+
|
2
|
+
require 'net/https'
|
3
3
|
require 'cgi/util'
|
4
4
|
require 'multi_json'
|
5
5
|
|
@@ -18,11 +18,12 @@ require 'domoscio_rails/adaptative/deterministic/rule_output'
|
|
18
18
|
require 'domoscio_rails/adaptative/deterministic/rule_condition'
|
19
19
|
require 'domoscio_rails/adaptative/predictive/objective'
|
20
20
|
require 'domoscio_rails/adaptative/predictive/objective_student'
|
21
|
+
require 'domoscio_rails/adaptative/predictive/objective_knowledge_node'
|
22
|
+
require 'domoscio_rails/adaptative/predictive/objective_knowledge_node_student'
|
21
23
|
require 'domoscio_rails/adaptative/recommendation'
|
22
24
|
require 'domoscio_rails/path/learning_path'
|
23
25
|
require 'domoscio_rails/content/content'
|
24
26
|
require 'domoscio_rails/content/knowledge_node_content'
|
25
|
-
require 'domoscio_rails/admin/user'
|
26
27
|
require 'domoscio_rails/student/student'
|
27
28
|
require 'domoscio_rails/student/student_cluster'
|
28
29
|
require 'domoscio_rails/knowledge/knowledge_graph'
|
@@ -34,17 +35,18 @@ require 'domoscio_rails/metadata/tag_set'
|
|
34
35
|
require 'domoscio_rails/metadata/tag_edge'
|
35
36
|
require 'domoscio_rails/data/knowledge_node_student'
|
36
37
|
require 'domoscio_rails/data/event'
|
38
|
+
require 'domoscio_rails/data/learning_session'
|
37
39
|
require 'domoscio_rails/utils/review_util'
|
38
40
|
require 'domoscio_rails/utils/gameplay_util'
|
39
|
-
|
41
|
+
require 'domoscio_rails/utils/alerts_util'
|
42
|
+
require 'domoscio_rails/utils/recommendation_util'
|
43
|
+
require 'domoscio_rails/metadata/delta_object'
|
40
44
|
|
41
45
|
module DomoscioRails
|
42
46
|
|
43
47
|
class Configuration
|
44
|
-
attr_accessor :preproduction, :root_url,
|
45
|
-
|
46
|
-
:temp_dir, :disabled, :version
|
47
|
-
|
48
|
+
attr_accessor :preproduction, :test, :dev, :root_url, :client_id, :client_passphrase, :temp_dir, :disabled, :version
|
49
|
+
|
48
50
|
def disabled
|
49
51
|
@disabled || false
|
50
52
|
end
|
@@ -52,13 +54,31 @@ module DomoscioRails
|
|
52
54
|
def preproduction
|
53
55
|
@preproduction || false
|
54
56
|
end
|
55
|
-
|
57
|
+
|
58
|
+
def test
|
59
|
+
@test || false
|
60
|
+
end
|
61
|
+
|
62
|
+
def dev
|
63
|
+
@dev || false
|
64
|
+
end
|
65
|
+
|
56
66
|
def version
|
57
67
|
@version || 1
|
58
68
|
end
|
59
69
|
|
60
70
|
def root_url
|
61
|
-
|
71
|
+
if @preproduction == true
|
72
|
+
if @test == true
|
73
|
+
@root_url || "https://staging.adaptive-engine.domoscio.com"
|
74
|
+
elsif @dev == true
|
75
|
+
@root_url || "https://preprod.adaptive-engine.domoscio.com"
|
76
|
+
else
|
77
|
+
@root_url || "https://adaptive-engine.domoscio.com"
|
78
|
+
end
|
79
|
+
else
|
80
|
+
@root_url || "http://localhost:3001"
|
81
|
+
end
|
62
82
|
end
|
63
83
|
end
|
64
84
|
|
@@ -88,42 +108,50 @@ module DomoscioRails
|
|
88
108
|
def self.request(method, url, params={}, filters={}, headers = request_headers, before_request_proc = nil)
|
89
109
|
return false if @disabled
|
90
110
|
uri = api_uri(url)
|
91
|
-
uri.query = URI.encode_www_form(filters) unless filters.empty?
|
92
|
-
|
93
|
-
res =
|
94
|
-
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
95
|
-
req.body = DomoscioRails::JSON.dump(params)
|
96
|
-
before_request_proc.call(req) if before_request_proc
|
97
|
-
http.request req
|
98
|
-
end
|
111
|
+
uri.query = URI.encode_www_form(filters) unless filters.empty?
|
112
|
+
|
113
|
+
res = DomoscioRails.send_request(uri, method, params, headers, before_request_proc)
|
99
114
|
|
100
115
|
# decode json data
|
101
116
|
begin
|
102
117
|
data = DomoscioRails::JSON.load(res.body.nil? ? '' : res.body)
|
118
|
+
unless (res.kind_of? Net::HTTPClientError) || (res.kind_of? Net::HTTPServerError)
|
119
|
+
DomoscioRails::AuthorizationToken::Manager.storage.store({access_token: res['Accesstoken'], refresh_token: res['Refreshtoken']})
|
120
|
+
end
|
103
121
|
rescue MultiJson::LoadError
|
104
122
|
data = {}
|
105
123
|
end
|
106
124
|
|
107
|
-
|
108
|
-
|
109
|
-
#pp res, data
|
110
|
-
#puts
|
125
|
+
if res['Total'] && !filters[:page]
|
126
|
+
pagetotal = (res['Total'].to_i / res['Per-Page'].to_f).ceil
|
111
127
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
# #pp ex, data
|
116
|
-
# raise ex
|
117
|
-
# end
|
128
|
+
for j in 2..pagetotal
|
129
|
+
params = params.merge({page: j})
|
130
|
+
res = DomoscioRails.send_request(uri, method, params, headers, before_request_proc)
|
118
131
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
132
|
+
# decode json data
|
133
|
+
begin
|
134
|
+
data += DomoscioRails::JSON.load(res.body.nil? ? '' : res.body)
|
135
|
+
data.flatten!
|
136
|
+
rescue MultiJson::LoadError
|
137
|
+
data = {}
|
138
|
+
end
|
123
139
|
|
140
|
+
end
|
141
|
+
end
|
124
142
|
data
|
125
143
|
end
|
126
144
|
|
145
|
+
|
146
|
+
def self.send_request(uri, method, params, headers, before_request_proc)
|
147
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| # , use_ssl: uri.scheme == 'https') do |http|
|
148
|
+
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
149
|
+
req.body = DomoscioRails::JSON.dump(params)
|
150
|
+
before_request_proc.call(req) if before_request_proc
|
151
|
+
http.request req
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
127
155
|
private
|
128
156
|
|
129
157
|
def self.user_agent
|
@@ -146,17 +174,21 @@ module DomoscioRails
|
|
146
174
|
|
147
175
|
def self.request_headers
|
148
176
|
auth_token = DomoscioRails::AuthorizationToken::Manager.get_token
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
177
|
+
|
178
|
+
if !auth_token.is_a? String
|
179
|
+
headers = {
|
180
|
+
'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
|
181
|
+
'AccessToken' => "#{auth_token[:access_token]}",
|
182
|
+
'RefreshToken' => "#{auth_token[:refresh_token]}",
|
183
|
+
'Content-Type' => 'application/json'
|
184
|
+
}
|
185
|
+
else
|
186
|
+
headers = {
|
187
|
+
'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
|
188
|
+
'Authorization' => "Token token=#{DomoscioRails.configuration.client_passphrase}",#"#{auth_token['token_type']} #{auth_token['access_token']}",
|
189
|
+
'Content-Type' => 'application/json'
|
190
|
+
}
|
191
|
+
end
|
192
|
+
headers
|
159
193
|
end
|
160
|
-
|
161
|
-
|
162
194
|
end
|
@@ -5,7 +5,7 @@ module DomoscioRails
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def storage
|
8
|
-
@@storage ||=
|
8
|
+
@@storage ||= FileStorage.new
|
9
9
|
end
|
10
10
|
|
11
11
|
def storage= (storage)
|
@@ -13,17 +13,8 @@ module DomoscioRails
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_token
|
16
|
-
|
17
|
-
|
18
|
-
# token = DomoscioRails.request(:post, '/api/oauth/token', {}, {}, {}, Proc.new do |req|
|
19
|
-
# cfg = DomoscioRails.configuration
|
20
|
-
# req.basic_auth cfg.client_id, cfg.client_passphrase
|
21
|
-
# req.body = 'grant_type=client_credentials'
|
22
|
-
# end)
|
23
|
-
# token['timestamp'] = Time.now + token['expires_in'].to_i
|
24
|
-
# storage.store token
|
25
|
-
# end
|
26
|
-
token = DomoscioRails.configuration.client_passphrase
|
16
|
+
token = storage.get
|
17
|
+
token = DomoscioRails.configuration.client_passphrase if token.nil?
|
27
18
|
token
|
28
19
|
end
|
29
20
|
end
|
@@ -72,6 +63,7 @@ module DomoscioRails
|
|
72
63
|
end
|
73
64
|
|
74
65
|
def file_path
|
66
|
+
@temp_dir = DomoscioRails.configuration.temp_dir if @temp_dir != DomoscioRails.configuration.temp_dir
|
75
67
|
File.join(@temp_dir, "DomoscioRails.AuthorizationToken.FileStore.tmp")
|
76
68
|
end
|
77
69
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module DomoscioRails
|
2
2
|
module HTTPCalls
|
3
|
-
|
3
|
+
|
4
4
|
module Create
|
5
5
|
module ClassMethods
|
6
6
|
def create(*id, params)
|
@@ -25,7 +25,7 @@ module DomoscioRails
|
|
25
25
|
base.extend(ClassMethods)
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
module UpdateSelf
|
30
30
|
module ClassMethods
|
31
31
|
def update_self(params = {})
|
@@ -54,7 +54,7 @@ module DomoscioRails
|
|
54
54
|
id_or_filters.is_a?(Hash) ? [nil, id_or_filters] : [id_or_filters, {}]
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
module Destroy
|
59
59
|
module ClassMethods
|
60
60
|
def destroy(id = nil, params = {})
|
@@ -64,21 +64,24 @@ module DomoscioRails
|
|
64
64
|
|
65
65
|
def self.included(base)
|
66
66
|
base.extend(ClassMethods)
|
67
|
-
end
|
67
|
+
end
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
module Util
|
71
71
|
module ClassMethods
|
72
72
|
def util(id = nil, util_name = nil, params = {})
|
73
73
|
DomoscioRails.request(:get, url(id, util_name), params)
|
74
74
|
end
|
75
|
+
def util_post(id = nil, util_name = nil, params = {})
|
76
|
+
DomoscioRails.request(:post, url(id, util_name), params)
|
77
|
+
end
|
75
78
|
end
|
76
79
|
|
77
80
|
def self.included(base)
|
78
81
|
base.extend(ClassMethods)
|
79
|
-
end
|
82
|
+
end
|
80
83
|
end
|
81
|
-
|
82
|
-
|
84
|
+
|
85
|
+
|
83
86
|
end
|
84
|
-
end
|
87
|
+
end
|
metadata
CHANGED
@@ -1,51 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: domoscio_rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.24
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Benoit Praly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
17
20
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
21
24
|
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
24
|
-
|
25
|
-
|
26
|
-
email:
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
description: Ruby client to interact with Domoscio API.
|
28
|
+
email:
|
27
29
|
- benoit.praly@domoscio.com
|
28
30
|
executables: []
|
29
|
-
|
30
31
|
extensions: []
|
31
|
-
|
32
32
|
extra_rdoc_files: []
|
33
|
-
|
34
|
-
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.rdoc
|
36
|
+
- Rakefile
|
37
|
+
- lib/domoscio_rails.rb
|
38
|
+
- lib/domoscio_rails.tbz
|
35
39
|
- lib/domoscio_rails/adaptative/deterministic/path_rule.rb
|
36
40
|
- lib/domoscio_rails/adaptative/deterministic/rule_condition.rb
|
37
41
|
- lib/domoscio_rails/adaptative/deterministic/rule_input.rb
|
38
42
|
- lib/domoscio_rails/adaptative/deterministic/rule_output.rb
|
39
43
|
- lib/domoscio_rails/adaptative/predictive/objective.rb
|
44
|
+
- lib/domoscio_rails/adaptative/predictive/objective_knowledge_node.rb
|
45
|
+
- lib/domoscio_rails/adaptative/predictive/objective_knowledge_node_student.rb
|
40
46
|
- lib/domoscio_rails/adaptative/predictive/objective_student.rb
|
41
47
|
- lib/domoscio_rails/adaptative/recommendation.rb
|
42
48
|
- lib/domoscio_rails/admin/instance.rb
|
43
|
-
- lib/domoscio_rails/admin/user.rb
|
44
49
|
- lib/domoscio_rails/authorization_token.rb
|
45
50
|
- lib/domoscio_rails/content/content.rb
|
46
51
|
- lib/domoscio_rails/content/knowledge_node_content.rb
|
47
52
|
- lib/domoscio_rails/data/event.rb
|
48
53
|
- lib/domoscio_rails/data/knowledge_node_student.rb
|
54
|
+
- lib/domoscio_rails/data/learning_session.rb
|
49
55
|
- lib/domoscio_rails/data/result.rb
|
50
56
|
- lib/domoscio_rails/errors.rb
|
51
57
|
- lib/domoscio_rails/http_calls.rb
|
@@ -53,6 +59,7 @@ files:
|
|
53
59
|
- lib/domoscio_rails/knowledge/knowledge_edge.rb
|
54
60
|
- lib/domoscio_rails/knowledge/knowledge_graph.rb
|
55
61
|
- lib/domoscio_rails/knowledge/knowledge_node.rb
|
62
|
+
- lib/domoscio_rails/metadata/delta_object.rb
|
56
63
|
- lib/domoscio_rails/metadata/tag.rb
|
57
64
|
- lib/domoscio_rails/metadata/tag_edge.rb
|
58
65
|
- lib/domoscio_rails/metadata/tag_set.rb
|
@@ -61,42 +68,33 @@ files:
|
|
61
68
|
- lib/domoscio_rails/resource.rb
|
62
69
|
- lib/domoscio_rails/student/student.rb
|
63
70
|
- lib/domoscio_rails/student/student_cluster.rb
|
71
|
+
- lib/domoscio_rails/utils/alerts_util.rb
|
64
72
|
- lib/domoscio_rails/utils/gameplay_util.rb
|
73
|
+
- lib/domoscio_rails/utils/recommendation_util.rb
|
65
74
|
- lib/domoscio_rails/utils/review_util.rb
|
66
75
|
- lib/domoscio_rails/version.rb
|
67
|
-
- lib/domoscio_rails.rb
|
68
|
-
- lib/domoscio_rails.tbz
|
69
76
|
- lib/tasks/domoscio_rails_tasks.rake
|
70
|
-
- MIT-LICENSE
|
71
|
-
- Rakefile
|
72
|
-
- README.rdoc
|
73
|
-
has_rdoc: true
|
74
77
|
homepage: http://www.domoscio.com
|
75
|
-
licenses:
|
78
|
+
licenses:
|
76
79
|
- MIT
|
80
|
+
metadata: {}
|
77
81
|
post_install_message:
|
78
82
|
rdoc_options: []
|
79
|
-
|
80
|
-
require_paths:
|
83
|
+
require_paths:
|
81
84
|
- lib
|
82
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
requirements:
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
84
87
|
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version:
|
87
|
-
|
88
|
-
|
89
|
-
requirements:
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
90
92
|
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version:
|
93
|
-
version:
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
94
95
|
requirements: []
|
95
|
-
|
96
|
-
rubyforge_project:
|
97
|
-
rubygems_version: 1.3.5
|
96
|
+
rubygems_version: 3.1.2
|
98
97
|
signing_key:
|
99
|
-
specification_version:
|
98
|
+
specification_version: 4
|
100
99
|
summary: Summary of DomoscioRails.
|
101
100
|
test_files: []
|
102
|
-
|