domoscio_rails 0.2.8 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03c45140be6fcfd0873cefd29cc711d7d31e5769
4
- data.tar.gz: 73a9af6e7f09e1f790cc29d8d7ddb7d9d144114d
3
+ metadata.gz: add91f521b4696d8f1b28a6bf6dcc1dd72503176
4
+ data.tar.gz: e574faa0b6825861ce4003d727c89132b954df62
5
5
  SHA512:
6
- metadata.gz: e73a369d6598c0a51ec4255d013167c8cdcb8bf6791c34083b27a7d2cdcffd99844b0a075a363581f5303f9596141948514b52ef56a0bc3f968dabb609c7aba3
7
- data.tar.gz: 680d0647684a775ef733b610cecd9f87538d9a1c3e55447d02a71d44bb6ab7f685d21b0bb598e2d3eaeed99751d79fd196586a320b349a3ef25525960ae01940
6
+ metadata.gz: 5448dbccc4872fdc44a40e41bc38de1320c8e4877950191047104d6e3058f6416ebf4b10e86e63bb40df4845568267f49c1310b73e1d38522aa1653ab6fd163b
7
+ data.tar.gz: 344c000e34b3f35778e387fd850a5e927a31366518a877d19fa27dabf484663d51bd418ec0912ed0760c430154a66d8fa35f89d29cd093c8fb67c53daf1c19f5
@@ -1,5 +1,5 @@
1
-
2
- require 'net/http'
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
- @root_url || (@preproduction == true ? ( @version > 1 ? "http://api.domoscio.com" : "http://stats-engine-api.domoscio.com" ) : "http://localhost:3001/")
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 = Net::HTTP.start(uri.host, uri.port) do |http| # , use_ssl: uri.scheme == 'https') do |http|
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
- headers = {
148
- 'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
149
- 'Authorization' => "Token token=#{DomoscioRails.configuration.client_passphrase}",#"#{auth_token['token_type']} #{auth_token['access_token']}",
150
- 'Content-Type' => 'application/json'
151
- }
152
- # begin
153
- # headers.update('x_mangopay_client_user_agent' => DomoscioRails::JSON.dump(user_agent))
154
- # rescue => e
155
- # headers.update('x_mangopay_client_raw_user_agent' => user_agent.inspect, error: "#{e} (#{e.class})")
156
- # end
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
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # An objective knowledge node.
3
+ class ObjectiveKnowledgeNode < Resource
4
+ include DomoscioRails::HTTPCalls::Fetch
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # An objective knowledge node student.
3
+ class ObjectiveKnowledgeNodeStudent < Resource
4
+ include DomoscioRails::HTTPCalls::Fetch
5
+ end
6
+ end
@@ -5,7 +5,7 @@ module DomoscioRails
5
5
 
6
6
  class << self
7
7
  def storage
8
- @@storage ||= StaticStorage.new
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
- # token = storage.get
17
- # if token.nil? || token['timestamp'].nil? || token['timestamp'] <= Time.now
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)
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A delta object.
3
+ class DeltaObject < Resource
4
+ include DomoscioRails::HTTPCalls::Fetch
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A student cluster.
3
+ class StudentCluster < Resource
4
+ include DomoscioRails::HTTPCalls::Fetch
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A company.
3
+ class AlertsUtil < Resource
4
+ include DomoscioRails::HTTPCalls::Util
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A company.
3
+ class GameplayUtil < Resource
4
+ include DomoscioRails::HTTPCalls::Util
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A company.
3
+ class RecommendationUtil < Resource
4
+ include DomoscioRails::HTTPCalls::Util
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module DomoscioRails
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.16.9"
3
3
  end
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.8
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: 2017-01-04 00:00:00.000000000 Z
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: Description of DomoscioRails.
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.5.1
96
+ rubygems_version: 2.6.14
91
97
  signing_key:
92
98
  specification_version: 4
93
99
  summary: Summary of DomoscioRails.
@@ -1,10 +0,0 @@
1
- module DomoscioRails
2
- # A user of the API.
3
- class User < Resource
4
-
5
- include DomoscioRails::HTTPCalls::Create
6
- include DomoscioRails::HTTPCalls::Fetch
7
- include DomoscioRails::HTTPCalls::Update
8
-
9
- end
10
- end