ims_caliper 0.1.1 → 0.1.2

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.
Files changed (131) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +37 -0
  3. data/.idea/caliper-ruby.iml +98 -0
  4. data/.idea/encodings.xml +5 -0
  5. data/.idea/misc.xml +5 -0
  6. data/.idea/modules.xml +9 -0
  7. data/.idea/scopes/scope_settings.xml +5 -0
  8. data/.idea/vcs.xml +7 -0
  9. data/Gemfile +12 -1
  10. data/Gemfile.lock +42 -1
  11. data/LICENSE +67 -0
  12. data/NOTICE +15 -0
  13. data/README.md +13 -5
  14. data/caliper.gemspec +2 -8
  15. data/lib/caliper/defaults.rb +4 -4
  16. data/lib/caliper/entities/annotation/annotation.rb +14 -4
  17. data/lib/caliper/entities/annotation/bookmark_annotation.rb +14 -4
  18. data/lib/caliper/entities/annotation/highlight_annotation.rb +14 -3
  19. data/lib/caliper/entities/annotation/shared_annotation.rb +12 -3
  20. data/lib/caliper/entities/annotation/tag_annotation.rb +13 -3
  21. data/lib/caliper/entities/assessment/assessment.rb +27 -0
  22. data/lib/caliper/entities/assessment/assessment_item.rb +26 -0
  23. data/lib/caliper/entities/assignable/assignable_digital_resource.rb +47 -0
  24. data/lib/caliper/entities/assignable/attempt.rb +32 -0
  25. data/lib/caliper/entities/digital_resource.rb +36 -35
  26. data/lib/caliper/entities/entity.rb +50 -36
  27. data/lib/caliper/entities/foaf/agent.rb +1 -1
  28. data/lib/caliper/entities/jsonable.rb +56 -0
  29. data/lib/caliper/entities/learning_objective.rb +26 -0
  30. data/lib/caliper/entities/lis/course_offering.rb +30 -0
  31. data/lib/caliper/entities/lis/course_section.rb +27 -15
  32. data/lib/caliper/entities/lis/group.rb +27 -0
  33. data/lib/caliper/entities/lis/membership.rb +32 -0
  34. data/lib/caliper/entities/lis/organization.rb +20 -17
  35. data/lib/caliper/entities/lis/person.rb +23 -10
  36. data/lib/caliper/entities/lis/roles.rb +77 -0
  37. data/lib/caliper/entities/lis/status.rb +19 -0
  38. data/lib/caliper/entities/media/audio_object.rb +21 -0
  39. data/lib/caliper/entities/media/image_object.rb +21 -0
  40. data/lib/caliper/entities/media/media_location.rb +23 -0
  41. data/lib/caliper/entities/media/media_object.rb +38 -0
  42. data/lib/caliper/entities/media/video_object.rb +21 -0
  43. data/lib/caliper/entities/reading/epub_volume.rb +15 -7
  44. data/lib/caliper/entities/reading/frame.rb +7 -15
  45. data/lib/caliper/entities/response/fillin_blank_response.rb +20 -0
  46. data/lib/caliper/entities/response/multiple_choice_response.rb +20 -0
  47. data/lib/caliper/entities/response/multiple_response_response.rb +20 -0
  48. data/lib/caliper/entities/response/response.rb +23 -0
  49. data/lib/caliper/entities/response/response_type.rb +13 -0
  50. data/lib/caliper/entities/response/select_type_response.rb +20 -0
  51. data/lib/caliper/entities/response/true_false_response.rb +21 -0
  52. data/lib/caliper/entities/schemadotorg/software_application.rb +8 -8
  53. data/lib/caliper/entities/session.rb +25 -17
  54. data/lib/caliper/entities/software_application.rb +16 -7
  55. data/lib/caliper/entities/web_page.rb +2 -0
  56. data/lib/caliper/entity_envelope.rb +21 -0
  57. data/lib/caliper/event/annotation_event.rb +10 -6
  58. data/lib/caliper/event/assessment_event.rb +19 -0
  59. data/lib/caliper/event/assessment_item_event.rb +19 -0
  60. data/lib/caliper/event/assignable_event.rb +19 -0
  61. data/lib/caliper/event/event.rb +70 -50
  62. data/lib/caliper/event/jsonable.rb +55 -0
  63. data/lib/caliper/event/navigation_event.rb +2 -7
  64. data/lib/caliper/event/outcome_event.rb +1 -1
  65. data/lib/caliper/event/session_event.rb +13 -14
  66. data/lib/caliper/event/view_event.rb +6 -7
  67. data/lib/caliper/event_envelope.rb +22 -0
  68. data/lib/caliper/jsonable.rb +53 -0
  69. data/lib/caliper/profiles/annotation_profile.rb +56 -53
  70. data/lib/caliper/profiles/assessment_profile.rb +48 -0
  71. data/lib/caliper/profiles/assignable_profile.rb +44 -0
  72. data/lib/caliper/profiles/media_profile.rb +54 -0
  73. data/lib/caliper/profiles/profile.rb +38 -38
  74. data/lib/caliper/profiles/reading_profile.rb +31 -28
  75. data/lib/caliper/profiles/session_profile.rb +17 -18
  76. data/lib/caliper/request/event_store_requestor.rb +26 -26
  77. data/lib/caliper/sensor.rb +46 -35
  78. data/lib/caliper/version.rb +1 -1
  79. data/spec/lib/entities/entity.json +9 -0
  80. data/spec/lib/entities/entity_spec.rb +37 -0
  81. data/spec/lib/entities/lis/person_spec.rb +37 -0
  82. data/spec/lib/entities/lis/student.json +11 -0
  83. data/spec/lib/event/annotation_event_bookmark_spec.rb +159 -0
  84. data/spec/lib/event/annotation_event_highlight_spec.rb +160 -0
  85. data/spec/lib/event/annotation_event_shared_spec.rb +172 -0
  86. data/spec/lib/event/annotation_event_tag_spec.rb +159 -0
  87. data/spec/lib/event/assessment_event_spec.rb +207 -0
  88. data/spec/lib/event/assessment_item_completed_event_spec.rb +223 -0
  89. data/spec/lib/event/assessment_item_started_event_spec.rb +207 -0
  90. data/spec/lib/event/media_event_spec.rb +157 -0
  91. data/spec/lib/event/navigated_event_spec.rb +160 -0
  92. data/spec/lib/event/session_event_login_spec.rb +160 -0
  93. data/spec/lib/event/session_event_logout_spec.rb +145 -0
  94. data/spec/lib/event/session_event_timeout_spec.rb +145 -0
  95. data/spec/lib/event/viewed_event_spec.rb +149 -0
  96. data/spec/lib/event_helper.rb +145 -0
  97. data/spec/lib/sensor_spec.rb +30 -0
  98. data/spec/spec_helper.rb +3 -2
  99. metadata +84 -61
  100. data/lib/caliper/client.rb +0 -33
  101. data/lib/caliper/consumer/base.rb +0 -46
  102. data/lib/caliper/consumer/queue.rb +0 -40
  103. data/lib/caliper/consumer/socket.rb +0 -132
  104. data/lib/caliper/entities/annotation/text_position_selector.rb +0 -14
  105. data/lib/caliper/entities/schemadotorg/audio_object.rb +0 -15
  106. data/lib/caliper/entities/schemadotorg/image_object.rb +0 -15
  107. data/lib/caliper/entities/schemadotorg/media_object.rb +0 -19
  108. data/lib/caliper/entities/schemadotorg/video_object.rb +0 -15
  109. data/lib/caliper/event/.shared.rb.swp +0 -0
  110. data/spec/lib/client_spec.rb +0 -35
  111. data/spec/lib/consumer/base_spec.rb +0 -28
  112. data/spec/lib/consumer/queue_spec.rb +0 -16
  113. data/spec/lib/event/annotation_spec.rb +0 -12
  114. data/spec/lib/event/bookmarked_spec.rb +0 -17
  115. data/spec/lib/event/commented_spec.rb +0 -19
  116. data/spec/lib/event/highlighted_spec.rb +0 -18
  117. data/spec/lib/event/navigation_spec.rb +0 -15
  118. data/spec/lib/event/shared_spec.rb +0 -18
  119. data/spec/lib/event/tagged_spec.rb +0 -17
  120. data/spec/lib/event/used_spec.rb +0 -15
  121. data/spec/lib/event/viewed_spec.rb +0 -15
  122. data/test/caliper/events/session_login_event_test.rb +0 -58
  123. data/test/caliper/events/session_logout_event_test.rb +0 -55
  124. data/test/caliper/events/session_timeout_event_test.rb +0 -55
  125. data/test/caliper/request/http_requestor_test.rb +0 -59
  126. data/test/caliper/test_event.rb +0 -53
  127. data/test/caliper/test_utils.rb +0 -198
  128. data/test/fixtures/caliper_session_login_event.json +0 -71
  129. data/test/fixtures/caliper_session_logout_event.json +0 -52
  130. data/test/fixtures/caliper_session_timeout_event.json +0 -52
  131. data/test/fixtures/event_store_payload.json +0 -85
@@ -1,14 +0,0 @@
1
-
2
- # An Selector which describes a range of text based on its start and end positions
3
- # Defined by: http://www.w3.org/ns/oa#d4e667
4
-
5
- module Caliper
6
- module Entities
7
- module Annotation
8
- class TextPositionSelector
9
- attr_accessor :start,
10
- :end
11
- end
12
- end
13
- end
14
- end
@@ -1,15 +0,0 @@
1
- require_relative 'media_object'
2
-
3
- # https://schema.org/AudioObject
4
- #
5
- # An audio object embedded in a web page.
6
-
7
- module Caliper
8
- module Entities
9
- module SchemaDotOrg
10
- module AudioObject
11
- include MediaObject
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require_relative 'media_object'
2
-
3
- # https://schema.org/ImageObject
4
- #
5
- # An image object embedded in a web page.
6
-
7
- module Caliper
8
- module Entities
9
- module SchemaDotOrg
10
- module ImageObject
11
- include MediaObject
12
- end
13
- end
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- require_relative 'creative_work'
2
-
3
- # An image, video, or audio object embedded in a web page. Note that a
4
- # creative work may have many media objects associated with it on the
5
- # same web page. For example, a page about a single song (MusicRecording)
6
- # may have a music video (VideoObject), and a high and low bandwidth audio
7
- # stream (2 AudioObject's).
8
- #
9
- # From https://schema.org/MediaObject
10
-
11
- module Caliper
12
- module Entities
13
- module SchemaDotOrg
14
- module MediaObject
15
- include CreativeWork
16
- end
17
- end
18
- end
19
- end
@@ -1,15 +0,0 @@
1
- require_relative 'media_object'
2
-
3
- # https://schema.org/VideoObject
4
- #
5
- # A video object embedded in a web page..
6
-
7
- module Caliper
8
- module Entities
9
- module SchemaDotOrg
10
- module VideoObject
11
- include MediaObject
12
- end
13
- end
14
- end
15
- end
Binary file
@@ -1,35 +0,0 @@
1
- require "spec_helper.rb"
2
-
3
- module Caliper
4
- describe Client do
5
- it "should throw error if provided consumer is invalid" do
6
- expect(lambda{ Client.new("some API key", :consumer => "ThisClassTotally::DoesntExist") }).to raise_error(NameError)
7
- expect(lambda{ Client.new("some API key", :consumer => Object) }).to raise_error(ArgumentError)
8
- end
9
-
10
- it "should throw error if provided an invalid event" do
11
- expect(lambda{ Client.new("some API key").measure(Object.new) }).to raise_error(ArgumentError)
12
- end
13
-
14
- it "should call the appropriate method on the consumer" do
15
- consumer = Consumer::Base.new("some API key")
16
- client = Client.new("some API key", :consumer => consumer)
17
- consumer.expects(:measure)
18
- consumer.expects(:describe)
19
-
20
- client.measure(Event::Base.new)
21
- client.describe(Entity::Base.new)
22
- end
23
-
24
- it "should default to current if timestamps are not provided" do
25
- consumer = Consumer::Base.new("some API key")
26
- client = Client.new("some API key", :consumer => consumer)
27
- t = Time.now
28
- Time.stubs(:now).returns(t)
29
- consumer.expects(:measure).with(anything, anything, anything, t)
30
- #todo same for describe
31
- client.measure(Event::Base.new)
32
- end
33
-
34
- end
35
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- module Caliper
4
- module Consumer
5
- describe Base do
6
- it "should validate options hash" do
7
- b = Base.new("Some API key")
8
- expect(b.validate_options({:debug= => true, :ssl => false, :on_error => lambda { "blah blah" }, :some_other_key => "This will be ignored"})).not_to include(:some_other_key)
9
- end
10
-
11
- it "should enable debug and ssl" do
12
- b = Base.new("Some API key", :debug => true, :ssl => true)
13
- expect(b.with_debug?).to be_truthy
14
- expect(b.with_ssl?).to be_truthy
15
- end
16
-
17
- context "#on_error" do
18
- it "should call custom error handler" do
19
- Object.stubs(:non_existent_method).returns(true)
20
- p = proc { |e| Object.non_existent_method }
21
- Object.expects(:non_existent_method).once
22
- b = Base.new("Some API key", :on_error => p)
23
- b.on_error("Some error")
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,16 +0,0 @@
1
- require "spec_helper.rb"
2
-
3
- module Caliper
4
- module Consumer
5
- describe Queue do
6
- it "should store max_queue_size and batch_size" do
7
- max = 1000
8
- batch = 100
9
- c = Queue.new("some API key", :max_queue_size => max, :batch_size => batch)
10
- expect(c.max_queue_size).to equal(max)
11
- expect(c.batch_size).to equal(batch)
12
- end
13
- end
14
- end
15
- end
16
-
@@ -1,12 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Annotation do
7
- it "should raise error if instantiated directly" do
8
- expect(lambda{ Annotation.new("action") }).to raise_error NotImplementedError
9
- end
10
- end
11
- end
12
- end
@@ -1,17 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Bookmarked do
7
- it "should be a BookmarkedEvent" do
8
- expect(Bookmarked.new("action").type).to eq "BookmarkedEvent"
9
- end
10
-
11
- it "should have a 'marked' or 'unmarked' action, as appropriate" do
12
- expect(Bookmarked.mark.action).to eq "marked"
13
- expect(Bookmarked.unmark.action).to eq "unmarked"
14
- end
15
- end
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Commented do
7
- it "should be a CommentedEvent" do
8
- expect(Commented.new("action").type).to eq "CommentedEvent"
9
- end
10
-
11
- it "should have 'commented', 'comment-updated', or 'uncommented' actions, as appropriate" do
12
- expect(Commented.add_comment.action).to eq "commented"
13
- expect(Commented.remove_comment.action).to eq "uncommented"
14
- expect(Commented.update_comment.action).to eq "comment-updated"
15
- end
16
- end
17
- end
18
- end
19
-
@@ -1,18 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Highlighted do
7
- it "should be a HighlightedEvent" do
8
- expect(Highlighted.new("action").type).to eq "HighlightedEvent"
9
- end
10
-
11
- it "should have a 'highlighted' or 'unhighlighted' action, as appropriate" do
12
- expect(Highlighted.highlight.action).to eq "highlighted"
13
- expect(Highlighted.unhighlight.action).to eq "unhighlighted"
14
- end
15
- end
16
- end
17
- end
18
-
@@ -1,15 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Navigation do
7
- it "should be a NavigationEvent" do
8
- e = Navigation.new
9
- expect(e.type).to eq "NavigationEvent"
10
- expect(e.action).to eq "navigatedTo"
11
- end
12
- end
13
- end
14
- end
15
-
@@ -1,18 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Shared do
7
- it "should be a SharedEvent" do
8
- expect(Shared.new("action").type).to eq "SharedEvent"
9
- end
10
-
11
- it "should have a 'shared' or 'unshared' action, as appropriate" do
12
- expect(Shared.share.action).to eq "shared"
13
- expect(Shared.unshare.action).to eq "unshared"
14
- end
15
- end
16
- end
17
- end
18
-
@@ -1,17 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Tagged do
7
- it "should be a TaggedEvent" do
8
- expect(Tagged.new("action").type).to eq "TaggedEvent"
9
- end
10
-
11
- it "should have a 'tagged' or 'untagged' action, as appropriate" do
12
- expect(Tagged.tag.action).to eq "tagged"
13
- expect(Tagged.untag.action).to eq "untagged"
14
- end
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Used do
7
- it "should be a UsedEvent" do
8
- e = Used.new
9
- expect(e.type).to eq "UsedEvent"
10
- expect(e.action).to eq "used"
11
- end
12
- end
13
- end
14
- end
15
-
@@ -1,15 +0,0 @@
1
- require "spec_helper.rb"
2
- require "caliper"
3
-
4
- module Caliper
5
- module Event
6
- describe Viewed do
7
- it "should be a ViewedEvent" do
8
- e = Viewed.new
9
- expect(e.type).to eq "ViewedEvent"
10
- expect(e.action).to eq "viewed"
11
- end
12
- end
13
- end
14
- end
15
-
@@ -1,58 +0,0 @@
1
-
2
- require '../../../lib/caliper/entities/learning_context'
3
- require '../../../lib/caliper/entities/software_application'
4
- require '../../../lib/caliper/entities/reading/epub_sub_chapter'
5
- require '../../../lib/caliper/entities/session'
6
- require '../../../lib/caliper/event/event'
7
-
8
- require_relative "../../../lib/caliper/request/http_requestor"
9
- require_relative "../../../lib/caliper/profiles/session_profile"
10
- require_relative "../../../lib/caliper/profiles/reading_profile"
11
- require_relative "../test_utils"
12
-
13
- require 'i18n'
14
- require 'json'
15
-
16
- class SessionLoginEventTest < Test::Unit::TestCase
17
- include I18n::Tests
18
- include TestUtils
19
-
20
- attr_accessor :learning_context, # LearningContext
21
- :ed_app, # SoftwareApplication
22
- :key, # String
23
- :target, # EpubSubChapter
24
- :generated, # Session
25
- :event # Event
26
-
27
- def setup
28
-
29
- p File.expand_path("../../", Dir.pwd) + '/config/locales/en.yml'
30
- I18n.load_path = [[File.expand_path("../../..", Dir.pwd) + '/config/locales/en.yml']]
31
- I18n.locale = :en
32
- # I18n.t("actions.annotation.attached")
33
-
34
- # Build the Learning Context
35
- @learning_context = TestUtils.build_readium_learning_context
36
-
37
- # Action
38
- @ed_app = learning_context.ed_app
39
-
40
- @key = Caliper::Profiles::SessionActions::LOGGED_IN
41
-
42
- # build target
43
- @target = TestUtils.build_epub_sub_chap_431
44
-
45
- # build generated
46
- @generated = TestUtils.build_session_start
47
-
48
- # build event
49
- @event = TestUtils.build_epub_login_event(@learning_context, @ed_app, @key, @target, @generated)
50
-
51
- end
52
-
53
- def test_caliper_event_serializes_to_json
54
- json_payload_fixture = JSON.parse(File.read(File.expand_path("../../", Dir.pwd) + "/fixtures/caliper_session_login_event.json")).to_json
55
- assert_equal("Test if loggedIn event is serialized to JSON with expected values",
56
- json_payload_fixture, @event.to_json)
57
- end
58
- end
@@ -1,55 +0,0 @@
1
-
2
- require '../../../lib/caliper/entities/learning_context'
3
- require '../../../lib/caliper/entities/software_application'
4
- require '../../../lib/caliper/entities/reading/epub_sub_chapter'
5
- require '../../../lib/caliper/entities/session'
6
- require '../../../lib/caliper/event/event'
7
-
8
- require_relative "../../../lib/caliper/request/http_requestor"
9
- require_relative "../../../lib/caliper/profiles/session_profile"
10
- require_relative "../../../lib/caliper/profiles/reading_profile"
11
- require_relative "../test_utils"
12
-
13
- require 'i18n'
14
- require 'json'
15
-
16
- class SessionLogoutEventTest < Test::Unit::TestCase
17
- include I18n::Tests
18
- include TestUtils
19
-
20
- attr_accessor :learning_context, # LearningContext
21
- :ed_app, # SoftwareApplication
22
- :key, # String
23
- :target, # EpubSubChapter
24
- :event # Event
25
-
26
- def setup
27
-
28
- p File.expand_path("../../", Dir.pwd) + '/config/locales/en.yml'
29
- I18n.load_path = [[File.expand_path("../../..", Dir.pwd) + '/config/locales/en.yml']]
30
- I18n.locale = :en
31
- # I18n.t("actions.annotation.attached")
32
-
33
- # Build the Learning Context
34
- @learning_context = TestUtils.build_readium_learning_context
35
-
36
- # Action
37
- @ed_app = learning_context.ed_app
38
-
39
- # Action
40
- @key = Caliper::Profiles::SessionActions::LOGGED_OUT
41
-
42
- # build target
43
- @target = TestUtils.build_session_end
44
-
45
- # build event
46
- @event = TestUtils.build_epub_logout_event(@learning_context, @ed_app, @key, @target)
47
-
48
- end
49
-
50
- def test_caliper_event_serializes_to_json
51
- json_payload_fixture = JSON.parse(File.read(File.expand_path("../../", Dir.pwd) + "/fixtures/caliper_session_logout_event.json")).to_json
52
- assert_equal("Test if loggedIn event is serialized to JSON with expected values",
53
- json_payload_fixture, @event.to_json)
54
- end
55
- end