domoscio_rails 0.2.14 → 0.2.16.9
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/lib/domoscio_rails.rb +75 -29
- data/lib/domoscio_rails/adaptative/predictive/objective_knowledge_node.rb +4 -4
- data/lib/domoscio_rails/adaptative/predictive/objective_knowledge_node_student.rb +4 -4
- 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/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 +7 -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,13 +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_student'
|
22
21
|
require 'domoscio_rails/adaptative/predictive/objective_knowledge_node'
|
22
|
+
require 'domoscio_rails/adaptative/predictive/objective_knowledge_node_student'
|
23
23
|
require 'domoscio_rails/adaptative/recommendation'
|
24
24
|
require 'domoscio_rails/path/learning_path'
|
25
25
|
require 'domoscio_rails/content/content'
|
26
26
|
require 'domoscio_rails/content/knowledge_node_content'
|
27
|
-
require 'domoscio_rails/admin/user'
|
28
27
|
require 'domoscio_rails/student/student'
|
29
28
|
require 'domoscio_rails/student/student_cluster'
|
30
29
|
require 'domoscio_rails/knowledge/knowledge_graph'
|
@@ -38,15 +37,17 @@ require 'domoscio_rails/data/knowledge_node_student'
|
|
38
37
|
require 'domoscio_rails/data/event'
|
39
38
|
require 'domoscio_rails/utils/review_util'
|
40
39
|
require 'domoscio_rails/utils/gameplay_util'
|
41
|
-
|
40
|
+
require 'domoscio_rails/utils/alerts_util'
|
41
|
+
require 'domoscio_rails/utils/recommendation_util'
|
42
|
+
require 'domoscio_rails/metadata/delta_object'
|
42
43
|
|
43
44
|
module DomoscioRails
|
44
45
|
|
45
46
|
class Configuration
|
46
|
-
attr_accessor :preproduction, :root_url,
|
47
|
+
attr_accessor :preproduction, :test, :root_url,
|
47
48
|
:client_id, :client_passphrase,
|
48
49
|
:temp_dir, :disabled, :version
|
49
|
-
|
50
|
+
|
50
51
|
def disabled
|
51
52
|
@disabled || false
|
52
53
|
end
|
@@ -54,13 +55,25 @@ module DomoscioRails
|
|
54
55
|
def preproduction
|
55
56
|
@preproduction || false
|
56
57
|
end
|
57
|
-
|
58
|
+
|
59
|
+
def test
|
60
|
+
@test || false
|
61
|
+
end
|
62
|
+
|
58
63
|
def version
|
59
64
|
@version || 1
|
60
65
|
end
|
61
66
|
|
62
67
|
def root_url
|
63
|
-
|
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
|
64
77
|
end
|
65
78
|
end
|
66
79
|
|
@@ -90,22 +103,38 @@ module DomoscioRails
|
|
90
103
|
def self.request(method, url, params={}, filters={}, headers = request_headers, before_request_proc = nil)
|
91
104
|
return false if @disabled
|
92
105
|
uri = api_uri(url)
|
93
|
-
uri.query = URI.encode_www_form(filters) unless filters.empty?
|
94
|
-
|
95
|
-
res =
|
96
|
-
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
97
|
-
req.body = DomoscioRails::JSON.dump(params)
|
98
|
-
before_request_proc.call(req) if before_request_proc
|
99
|
-
http.request req
|
100
|
-
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)
|
101
109
|
|
102
110
|
# decode json data
|
103
111
|
begin
|
104
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
|
105
116
|
rescue MultiJson::LoadError
|
106
117
|
data = {}
|
107
118
|
end
|
108
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
|
+
|
109
138
|
############### TEMP!!!! #######################################################
|
110
139
|
#pp method, uri.request_uri, params #, filters, headers
|
111
140
|
#pp res, data
|
@@ -126,6 +155,16 @@ module DomoscioRails
|
|
126
155
|
data
|
127
156
|
end
|
128
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
|
+
|
129
168
|
private
|
130
169
|
|
131
170
|
def self.user_agent
|
@@ -148,17 +187,24 @@ module DomoscioRails
|
|
148
187
|
|
149
188
|
def self.request_headers
|
150
189
|
auth_token = DomoscioRails::AuthorizationToken::Manager.get_token
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
+
|
161
207
|
end
|
162
|
-
|
163
|
-
|
208
|
+
|
209
|
+
|
164
210
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module DomoscioRails
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
# An objective knowledge node.
|
3
|
+
class ObjectiveKnowledgeNode < Resource
|
4
|
+
include DomoscioRails::HTTPCalls::Fetch
|
5
|
+
end
|
5
6
|
end
|
6
|
-
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module DomoscioRails
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
# An objective knowledge node student.
|
3
|
+
class ObjectiveKnowledgeNodeStudent < Resource
|
4
|
+
include DomoscioRails::HTTPCalls::Fetch
|
5
|
+
end
|
5
6
|
end
|
6
|
-
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: []
|
@@ -46,7 +46,6 @@ files:
|
|
46
46
|
- lib/domoscio_rails/adaptative/predictive/objective_student.rb
|
47
47
|
- lib/domoscio_rails/adaptative/recommendation.rb
|
48
48
|
- lib/domoscio_rails/admin/instance.rb
|
49
|
-
- lib/domoscio_rails/admin/user.rb
|
50
49
|
- lib/domoscio_rails/authorization_token.rb
|
51
50
|
- lib/domoscio_rails/content/content.rb
|
52
51
|
- lib/domoscio_rails/content/knowledge_node_content.rb
|
@@ -59,6 +58,7 @@ files:
|
|
59
58
|
- lib/domoscio_rails/knowledge/knowledge_edge.rb
|
60
59
|
- lib/domoscio_rails/knowledge/knowledge_graph.rb
|
61
60
|
- lib/domoscio_rails/knowledge/knowledge_node.rb
|
61
|
+
- lib/domoscio_rails/metadata/delta_object.rb
|
62
62
|
- lib/domoscio_rails/metadata/tag.rb
|
63
63
|
- lib/domoscio_rails/metadata/tag_edge.rb
|
64
64
|
- lib/domoscio_rails/metadata/tag_set.rb
|
@@ -67,7 +67,9 @@ files:
|
|
67
67
|
- lib/domoscio_rails/resource.rb
|
68
68
|
- lib/domoscio_rails/student/student.rb
|
69
69
|
- lib/domoscio_rails/student/student_cluster.rb
|
70
|
+
- lib/domoscio_rails/utils/alerts_util.rb
|
70
71
|
- lib/domoscio_rails/utils/gameplay_util.rb
|
72
|
+
- lib/domoscio_rails/utils/recommendation_util.rb
|
71
73
|
- lib/domoscio_rails/utils/review_util.rb
|
72
74
|
- lib/domoscio_rails/version.rb
|
73
75
|
- lib/tasks/domoscio_rails_tasks.rake
|
@@ -91,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
93
|
version: '0'
|
92
94
|
requirements: []
|
93
95
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.6.
|
96
|
+
rubygems_version: 2.6.14
|
95
97
|
signing_key:
|
96
98
|
specification_version: 4
|
97
99
|
summary: Summary of DomoscioRails.
|