pupilfirst_xapi 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 99a6dddb084209a85ef5d3f6ad55cf489fb50cf21b0a1f1c1e01a392079a13e9
4
- data.tar.gz: bff106abc8d633185bda3b156203ad901ae0beff5fdb544051014a462405fd67
3
+ metadata.gz: 6435e3040cef3863e99115b8a474bf193c05484c7c9048701425827b27353188
4
+ data.tar.gz: 412e2b47cc25daa790d214d111d8a7bf4645050dd2294c110859129b695bbee1
5
5
  SHA512:
6
- metadata.gz: b41c20f2967044b42d4d3f11c5307a5970e680f8313d200a91e98e948f0e7ae8053793c976d091372d78eb3a9ede6da505d0253265cd588c51707d355fe26ad5
7
- data.tar.gz: 8a526960635e5065792c221140153834f5eb3f01ab5ef66b221369b034e18510f094e972637702052a2a7a7bfe506fe1762838cf39d3f98a558b7878abf1d2f0
6
+ metadata.gz: 2c44119ab5421640425e20e55629d7281e68d284f72c9ccceaa5ee66c1e50f35776aad758a8f5a7f39d5b72215ba5f00185ad64385f23617cecc70d0aea66476
7
+ data.tar.gz: 776ae2649f8d242ad26a32b798373186df902855079a75668d50a3e9c6af25536abfc9e827e2ca5af0a4e429fbfb5309edcb7ac5910bbce624da641350b6d950
@@ -2,6 +2,7 @@ require "action_controller/railtie"
2
2
  require "active_job/railtie"
3
3
  require "growthtribe_xapi"
4
4
  require "pupilfirst_xapi/version"
5
+ require "pupilfirst_xapi/lrs"
5
6
  require "pupilfirst_xapi/outbox"
6
7
  require "pupilfirst_xapi/actors"
7
8
  require "pupilfirst_xapi/objects"
@@ -11,6 +12,7 @@ require "pupilfirst_xapi/statements"
11
12
  module PupilfirstXapi
12
13
  mattr_accessor :uri_for
13
14
  mattr_accessor :repository
15
+ mattr_accessor :lrs
14
16
 
15
17
  Statements.subscribe do |event_type|
16
18
  ActiveSupport::Notifications.subscribe("#{event_type}.pupilfirst") do |_name, _start, finish, _id, payload|
@@ -0,0 +1,24 @@
1
+ require 'xapi'
2
+
3
+ module PupilfirstXapi
4
+ class Lrs
5
+ def initialize(
6
+ end_point: ENV['LRS_ENDPOINT'],
7
+ key: ENV['LRS_KEY'],
8
+ secret: ENV['LRS_SECRET']
9
+ )
10
+ @lrs = end_point && key && secret &&
11
+ Xapi.create_remote_lrs(
12
+ end_point: end_point,
13
+ user_name: key,
14
+ password: secret
15
+ )
16
+ end
17
+
18
+ def call(statement)
19
+ return unless statement && @lrs
20
+
21
+ Xapi.post_statement(remote_lrs: @lrs, statement: statement)
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,4 @@
1
1
  require "active_job"
2
- require 'xapi'
3
2
 
4
3
  module PupilfirstXapi
5
4
  class Outbox
@@ -14,19 +13,11 @@ module PupilfirstXapi
14
13
 
15
14
  def outbox
16
15
  Outbox.new(
17
- lrs: remote_lrs,
16
+ lrs: PupilfirstXapi.lrs || PupilfirstXapi::Lrs.new,
18
17
  repository: PupilfirstXapi.repository,
19
18
  uri_for: PupilfirstXapi.uri_for
20
19
  )
21
20
  end
22
-
23
- def remote_lrs
24
- Xapi.create_remote_lrs(
25
- end_point: ENV['LRS_ENDPOINT'],
26
- user_name: ENV['LRS_KEY'],
27
- password: ENV['LRS_SECRET']
28
- )
29
- end
30
21
  end
31
22
 
32
23
  class << self
@@ -42,8 +33,7 @@ module PupilfirstXapi
42
33
  end
43
34
 
44
35
  def call(**payload)
45
- statement = statement_for(**payload)
46
- Xapi.post_statement(remote_lrs: @lrs, statement: statement) if statement
36
+ @lrs.call(statement_for(**payload))
47
37
  end
48
38
 
49
39
  private
@@ -1,3 +1,3 @@
1
1
  module PupilfirstXapi
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -50,7 +50,9 @@ class FakeLrs
50
50
  end
51
51
  attr_reader :statements
52
52
 
53
- def save_statement(statement)
53
+ def call(statement)
54
+ return unless statement
55
+
54
56
  @statements << statement
55
57
  end
56
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pupilfirst_xapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GrowthTribe
@@ -98,6 +98,7 @@ files:
98
98
  - Rakefile
99
99
  - lib/pupilfirst_xapi.rb
100
100
  - lib/pupilfirst_xapi/actors.rb
101
+ - lib/pupilfirst_xapi/lrs.rb
101
102
  - lib/pupilfirst_xapi/objects.rb
102
103
  - lib/pupilfirst_xapi/objects/builder.rb
103
104
  - lib/pupilfirst_xapi/objects/course.rb