domoscio_rails 0.2.8 → 0.2.16.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/domoscio_rails.rb +78 -28
- data/lib/domoscio_rails/adaptative/predictive/objective_knowledge_node.rb +6 -0
- data/lib/domoscio_rails/adaptative/predictive/objective_knowledge_node_student.rb +6 -0
- data/lib/domoscio_rails/authorization_token.rb +3 -12
- data/lib/domoscio_rails/http_calls.rb +3 -0
- data/lib/domoscio_rails/metadata/delta_object.rb +6 -0
- data/lib/domoscio_rails/student/student_cluster.rb +6 -0
- data/lib/domoscio_rails/utils/alerts_util.rb +6 -0
- data/lib/domoscio_rails/utils/gameplay_util.rb +6 -0
- data/lib/domoscio_rails/utils/recommendation_util.rb +6 -0
- data/lib/domoscio_rails/version.rb +1 -1
- metadata +11 -5
- data/lib/domoscio_rails/admin/user.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add91f521b4696d8f1b28a6bf6dcc1dd72503176
|
4
|
+
data.tar.gz: e574faa0b6825861ce4003d727c89132b954df62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5448dbccc4872fdc44a40e41bc38de1320c8e4877950191047104d6e3058f6416ebf4b10e86e63bb40df4845568267f49c1310b73e1d38522aa1653ab6fd163b
|
7
|
+
data.tar.gz: 344c000e34b3f35778e387fd850a5e927a31366518a877d19fa27dabf484663d51bd418ec0912ed0760c430154a66d8fa35f89d29cd093c8fb67c53daf1c19f5
|
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,12 +18,14 @@ 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'
|
28
|
+
require 'domoscio_rails/student/student_cluster'
|
27
29
|
require 'domoscio_rails/knowledge/knowledge_graph'
|
28
30
|
require 'domoscio_rails/knowledge/knowledge_edge'
|
29
31
|
require 'domoscio_rails/knowledge/knowledge_node'
|
@@ -34,15 +36,18 @@ require 'domoscio_rails/metadata/tag_edge'
|
|
34
36
|
require 'domoscio_rails/data/knowledge_node_student'
|
35
37
|
require 'domoscio_rails/data/event'
|
36
38
|
require 'domoscio_rails/utils/review_util'
|
37
|
-
|
39
|
+
require 'domoscio_rails/utils/gameplay_util'
|
40
|
+
require 'domoscio_rails/utils/alerts_util'
|
41
|
+
require 'domoscio_rails/utils/recommendation_util'
|
42
|
+
require 'domoscio_rails/metadata/delta_object'
|
38
43
|
|
39
44
|
module DomoscioRails
|
40
45
|
|
41
46
|
class Configuration
|
42
|
-
attr_accessor :preproduction, :root_url,
|
47
|
+
attr_accessor :preproduction, :test, :root_url,
|
43
48
|
:client_id, :client_passphrase,
|
44
49
|
:temp_dir, :disabled, :version
|
45
|
-
|
50
|
+
|
46
51
|
def disabled
|
47
52
|
@disabled || false
|
48
53
|
end
|
@@ -50,13 +55,25 @@ module DomoscioRails
|
|
50
55
|
def preproduction
|
51
56
|
@preproduction || false
|
52
57
|
end
|
53
|
-
|
58
|
+
|
59
|
+
def test
|
60
|
+
@test || false
|
61
|
+
end
|
62
|
+
|
54
63
|
def version
|
55
64
|
@version || 1
|
56
65
|
end
|
57
66
|
|
58
67
|
def root_url
|
59
|
-
|
68
|
+
if @preproduction == true
|
69
|
+
if @test == true
|
70
|
+
@root_url || "https://domoscio-adaptive-engine-staging.azurewebsites.net"
|
71
|
+
else
|
72
|
+
@root_url || "https://domoscio-adaptive-engine.azurewebsites.net"
|
73
|
+
end
|
74
|
+
else
|
75
|
+
@root_url || "http://localhost:3001"
|
76
|
+
end
|
60
77
|
end
|
61
78
|
end
|
62
79
|
|
@@ -86,22 +103,38 @@ module DomoscioRails
|
|
86
103
|
def self.request(method, url, params={}, filters={}, headers = request_headers, before_request_proc = nil)
|
87
104
|
return false if @disabled
|
88
105
|
uri = api_uri(url)
|
89
|
-
uri.query = URI.encode_www_form(filters) unless filters.empty?
|
90
|
-
|
91
|
-
res =
|
92
|
-
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
93
|
-
req.body = DomoscioRails::JSON.dump(params)
|
94
|
-
before_request_proc.call(req) if before_request_proc
|
95
|
-
http.request req
|
96
|
-
end
|
106
|
+
uri.query = URI.encode_www_form(filters) unless filters.empty?
|
107
|
+
|
108
|
+
res = DomoscioRails.send_request(uri, method, params, headers, before_request_proc)
|
97
109
|
|
98
110
|
# decode json data
|
99
111
|
begin
|
100
112
|
data = DomoscioRails::JSON.load(res.body.nil? ? '' : res.body)
|
113
|
+
unless (res.kind_of? Net::HTTPClientError) || (res.kind_of? Net::HTTPServerError)
|
114
|
+
DomoscioRails::AuthorizationToken::Manager.storage.store({access_token: res['Accesstoken'], refresh_token: res['Refreshtoken']})
|
115
|
+
end
|
101
116
|
rescue MultiJson::LoadError
|
102
117
|
data = {}
|
103
118
|
end
|
104
119
|
|
120
|
+
if res['Total'] && !filters[:page]
|
121
|
+
pagetotal = (res['Total'].to_i / res['Per-Page'].to_f).ceil
|
122
|
+
|
123
|
+
for j in 2..pagetotal
|
124
|
+
params = params.merge({page: j})
|
125
|
+
res = DomoscioRails.send_request(uri, method, params, headers, before_request_proc)
|
126
|
+
|
127
|
+
# decode json data
|
128
|
+
begin
|
129
|
+
data += DomoscioRails::JSON.load(res.body.nil? ? '' : res.body)
|
130
|
+
data.flatten!
|
131
|
+
rescue MultiJson::LoadError
|
132
|
+
data = {}
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
105
138
|
############### TEMP!!!! #######################################################
|
106
139
|
#pp method, uri.request_uri, params #, filters, headers
|
107
140
|
#pp res, data
|
@@ -122,6 +155,16 @@ module DomoscioRails
|
|
122
155
|
data
|
123
156
|
end
|
124
157
|
|
158
|
+
|
159
|
+
def self.send_request(uri, method, params, headers, before_request_proc)
|
160
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| # , use_ssl: uri.scheme == 'https') do |http|
|
161
|
+
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
162
|
+
req.body = DomoscioRails::JSON.dump(params)
|
163
|
+
before_request_proc.call(req) if before_request_proc
|
164
|
+
http.request req
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
125
168
|
private
|
126
169
|
|
127
170
|
def self.user_agent
|
@@ -144,17 +187,24 @@ module DomoscioRails
|
|
144
187
|
|
145
188
|
def self.request_headers
|
146
189
|
auth_token = DomoscioRails::AuthorizationToken::Manager.get_token
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
190
|
+
|
191
|
+
if !auth_token.is_a? String
|
192
|
+
headers = {
|
193
|
+
'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
|
194
|
+
'AccessToken' => "#{auth_token[:access_token]}",
|
195
|
+
'RefreshToken' => "#{auth_token[:refresh_token]}",
|
196
|
+
'Content-Type' => 'application/json'
|
197
|
+
}
|
198
|
+
else
|
199
|
+
headers = {
|
200
|
+
'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
|
201
|
+
'Authorization' => "Token token=#{DomoscioRails.configuration.client_passphrase}",#"#{auth_token['token_type']} #{auth_token['access_token']}",
|
202
|
+
'Content-Type' => 'application/json'
|
203
|
+
}
|
204
|
+
end
|
205
|
+
headers
|
206
|
+
|
157
207
|
end
|
158
|
-
|
159
|
-
|
208
|
+
|
209
|
+
|
160
210
|
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 +72,9 @@ module DomoscioRails
|
|
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)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: domoscio_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.16.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoit Praly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
|
-
description:
|
27
|
+
description: Ruby client to interact with Domoscio API.
|
28
28
|
email:
|
29
29
|
- benoit.praly@domoscio.com
|
30
30
|
executables: []
|
@@ -41,10 +41,11 @@ files:
|
|
41
41
|
- lib/domoscio_rails/adaptative/deterministic/rule_input.rb
|
42
42
|
- lib/domoscio_rails/adaptative/deterministic/rule_output.rb
|
43
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
|
44
46
|
- lib/domoscio_rails/adaptative/predictive/objective_student.rb
|
45
47
|
- lib/domoscio_rails/adaptative/recommendation.rb
|
46
48
|
- lib/domoscio_rails/admin/instance.rb
|
47
|
-
- lib/domoscio_rails/admin/user.rb
|
48
49
|
- lib/domoscio_rails/authorization_token.rb
|
49
50
|
- lib/domoscio_rails/content/content.rb
|
50
51
|
- lib/domoscio_rails/content/knowledge_node_content.rb
|
@@ -57,6 +58,7 @@ files:
|
|
57
58
|
- lib/domoscio_rails/knowledge/knowledge_edge.rb
|
58
59
|
- lib/domoscio_rails/knowledge/knowledge_graph.rb
|
59
60
|
- lib/domoscio_rails/knowledge/knowledge_node.rb
|
61
|
+
- lib/domoscio_rails/metadata/delta_object.rb
|
60
62
|
- lib/domoscio_rails/metadata/tag.rb
|
61
63
|
- lib/domoscio_rails/metadata/tag_edge.rb
|
62
64
|
- lib/domoscio_rails/metadata/tag_set.rb
|
@@ -64,6 +66,10 @@ files:
|
|
64
66
|
- lib/domoscio_rails/path/learning_path.rb
|
65
67
|
- lib/domoscio_rails/resource.rb
|
66
68
|
- lib/domoscio_rails/student/student.rb
|
69
|
+
- lib/domoscio_rails/student/student_cluster.rb
|
70
|
+
- lib/domoscio_rails/utils/alerts_util.rb
|
71
|
+
- lib/domoscio_rails/utils/gameplay_util.rb
|
72
|
+
- lib/domoscio_rails/utils/recommendation_util.rb
|
67
73
|
- lib/domoscio_rails/utils/review_util.rb
|
68
74
|
- lib/domoscio_rails/version.rb
|
69
75
|
- lib/tasks/domoscio_rails_tasks.rake
|
@@ -87,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
93
|
version: '0'
|
88
94
|
requirements: []
|
89
95
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.6.14
|
91
97
|
signing_key:
|
92
98
|
specification_version: 4
|
93
99
|
summary: Summary of DomoscioRails.
|