ims_caliper 0.1.1
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 +15 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +16 -0
- data/README.md +16 -0
- data/caliper.gemspec +26 -0
- data/config/locales/en.yml +86 -0
- data/lib/caliper/client.rb +33 -0
- data/lib/caliper/consumer/base.rb +46 -0
- data/lib/caliper/consumer/queue.rb +40 -0
- data/lib/caliper/consumer/socket.rb +132 -0
- data/lib/caliper/defaults.rb +8 -0
- data/lib/caliper/entities/annotation/annotation.rb +29 -0
- data/lib/caliper/entities/annotation/bookmark_annotation.rb +17 -0
- data/lib/caliper/entities/annotation/highlight_annotation.rb +18 -0
- data/lib/caliper/entities/annotation/shared_annotation.rb +18 -0
- data/lib/caliper/entities/annotation/tag_annotation.rb +17 -0
- data/lib/caliper/entities/annotation/text_position_selector.rb +14 -0
- data/lib/caliper/entities/digital_resource.rb +52 -0
- data/lib/caliper/entities/entity.rb +44 -0
- data/lib/caliper/entities/foaf/agent.rb +12 -0
- data/lib/caliper/entities/generatable.rb +9 -0
- data/lib/caliper/entities/learning_context.rb +21 -0
- data/lib/caliper/entities/lis/course_section.rb +18 -0
- data/lib/caliper/entities/lis/organization.rb +22 -0
- data/lib/caliper/entities/lis/person.rb +12 -0
- data/lib/caliper/entities/outcome/result.rb +23 -0
- data/lib/caliper/entities/reading/epub_chapter.rb +20 -0
- data/lib/caliper/entities/reading/epub_part.rb +20 -0
- data/lib/caliper/entities/reading/epub_sub_chapter.rb +20 -0
- data/lib/caliper/entities/reading/epub_volume.rb +20 -0
- data/lib/caliper/entities/reading/frame.rb +32 -0
- data/lib/caliper/entities/schemadotorg/audio_object.rb +15 -0
- data/lib/caliper/entities/schemadotorg/creative_work.rb +12 -0
- data/lib/caliper/entities/schemadotorg/image_object.rb +15 -0
- data/lib/caliper/entities/schemadotorg/media_object.rb +19 -0
- data/lib/caliper/entities/schemadotorg/software_application.rb +11 -0
- data/lib/caliper/entities/schemadotorg/thing.rb +9 -0
- data/lib/caliper/entities/schemadotorg/video_object.rb +15 -0
- data/lib/caliper/entities/schemadotorg/web_page.rb +11 -0
- data/lib/caliper/entities/session.rb +26 -0
- data/lib/caliper/entities/software_application.rb +19 -0
- data/lib/caliper/entities/targetable.rb +12 -0
- data/lib/caliper/entities/web_page.rb +13 -0
- data/lib/caliper/event/.shared.rb.swp +0 -0
- data/lib/caliper/event/annotation_event.rb +14 -0
- data/lib/caliper/event/event.rb +68 -0
- data/lib/caliper/event/media_event.rb +19 -0
- data/lib/caliper/event/navigation_event.rb +23 -0
- data/lib/caliper/event/outcome_event.rb +20 -0
- data/lib/caliper/event/session_event.rb +21 -0
- data/lib/caliper/event/view_event.rb +20 -0
- data/lib/caliper/options.rb +18 -0
- data/lib/caliper/profiles/annotation_profile.rb +61 -0
- data/lib/caliper/profiles/profile.rb +46 -0
- data/lib/caliper/profiles/reading_profile.rb +36 -0
- data/lib/caliper/profiles/session_profile.rb +29 -0
- data/lib/caliper/request/event_store_envelope.rb +9 -0
- data/lib/caliper/request/event_store_requestor.rb +41 -0
- data/lib/caliper/request/http_requestor.rb +42 -0
- data/lib/caliper/sensor.rb +37 -0
- data/lib/caliper/stats/atomic_wrapper.rb +86 -0
- data/lib/caliper/stats/statistic.rb +104 -0
- data/lib/caliper/stats/statistics.rb +45 -0
- data/lib/caliper/stats/statistics_map.rb +39 -0
- data/lib/caliper/validators/error_message.rb +43 -0
- data/lib/caliper/validators/event_validator.rb +37 -0
- data/lib/caliper/validators/event_validator_context.rb +16 -0
- data/lib/caliper/validators/property_type_check.rb +14 -0
- data/lib/caliper/validators/session_login_event_validator.rb +103 -0
- data/lib/caliper/validators/session_logout_event_validator.rb +102 -0
- data/lib/caliper/validators/time_check.rb +30 -0
- data/lib/caliper/version.rb +4 -0
- data/lib/caliper.rb +17 -0
- data/spec/lib/client_spec.rb +35 -0
- data/spec/lib/consumer/base_spec.rb +28 -0
- data/spec/lib/consumer/queue_spec.rb +16 -0
- data/spec/lib/event/annotation_spec.rb +12 -0
- data/spec/lib/event/bookmarked_spec.rb +17 -0
- data/spec/lib/event/commented_spec.rb +19 -0
- data/spec/lib/event/highlighted_spec.rb +18 -0
- data/spec/lib/event/navigation_spec.rb +15 -0
- data/spec/lib/event/shared_spec.rb +18 -0
- data/spec/lib/event/tagged_spec.rb +17 -0
- data/spec/lib/event/used_spec.rb +15 -0
- data/spec/lib/event/viewed_spec.rb +15 -0
- data/spec/spec_helper.rb +26 -0
- data/test/caliper/events/session_login_event_test.rb +58 -0
- data/test/caliper/events/session_logout_event_test.rb +55 -0
- data/test/caliper/events/session_timeout_event_test.rb +55 -0
- data/test/caliper/request/http_requestor_test.rb +59 -0
- data/test/caliper/test_event.rb +53 -0
- data/test/caliper/test_utils.rb +198 -0
- data/test/fixtures/caliper_session_login_event.json +71 -0
- data/test/fixtures/caliper_session_logout_event.json +52 -0
- data/test/fixtures/caliper_session_timeout_event.json +52 -0
- data/test/fixtures/event_store_payload.json +85 -0
- metadata +165 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
require "json"
|
2
|
+
require_relative 'entity'
|
3
|
+
require_relative 'software_application'
|
4
|
+
require_relative 'lis/organization'
|
5
|
+
require_relative 'foaf/agent'
|
6
|
+
|
7
|
+
module Caliper
|
8
|
+
module Entities
|
9
|
+
class LearningContext < Entity
|
10
|
+
attr_accessor :ed_app, # SoftwareApplication educational app
|
11
|
+
:lis_organization, # Organization the LIS organization
|
12
|
+
:agent # Agent the agent, since the Agent module is empty for now, use Entity type
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
@ed_app = SoftwareApplication.new
|
16
|
+
@lis_organization = Caliper::Entities::LIS::Organization.new
|
17
|
+
@agent = Caliper::Entities::Entity.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative './organization'
|
2
|
+
|
3
|
+
module Caliper
|
4
|
+
module Entities
|
5
|
+
module LIS
|
6
|
+
class CourseSection < Caliper::Entities::LIS::Organization
|
7
|
+
attr_accessor :type,
|
8
|
+
:semester,
|
9
|
+
:course_number,
|
10
|
+
:label
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
@type = OrganizationType::LIS_COURSE_SECTION
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../../entities/foaf/agent'
|
2
|
+
require_relative '../../entities/entity'
|
3
|
+
|
4
|
+
module Caliper
|
5
|
+
module Entities
|
6
|
+
module LIS
|
7
|
+
module OrganizationType
|
8
|
+
LIS_COURSE_SECTION = "http://purl.imsglobal.org/caliper/v1/lis/CourseSection"
|
9
|
+
end
|
10
|
+
class Organization < Entity
|
11
|
+
include Caliper::Entities::FOAF::Agent
|
12
|
+
attr_accessor :type, # String
|
13
|
+
:parent_org # Organization
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
@type = EntityType::LIS_ORGANIZATION
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../entity'
|
2
|
+
require_relative '../generatable'
|
3
|
+
module Caliper
|
4
|
+
module Entities
|
5
|
+
class Result < Entity
|
6
|
+
include Generatable
|
7
|
+
|
8
|
+
attr_accessor :type, # String
|
9
|
+
:normal_score,
|
10
|
+
:penalty_score,
|
11
|
+
:extra_credit_score,
|
12
|
+
:total_score,
|
13
|
+
:curved_total_score,
|
14
|
+
:curve_factor,
|
15
|
+
:comment,
|
16
|
+
:scored_by
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative "../digital_resource"
|
2
|
+
|
3
|
+
# Public: Representation of an EPUB 3 Chapter.
|
4
|
+
#
|
5
|
+
# A major structural division of a piece of writing
|
6
|
+
# http://www.idpf.org/epub/vocab/structure/#chapter
|
7
|
+
|
8
|
+
module Caliper
|
9
|
+
module Entities
|
10
|
+
module Reading
|
11
|
+
class EpubChapter < DigitalResource
|
12
|
+
def initialize()
|
13
|
+
super
|
14
|
+
@id = id
|
15
|
+
@type = DigitalResourceType::EPUB_CHAPTER
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Public: Representation of an EPUB 3 Part
|
2
|
+
# A major structural division of a piece of writing, typically
|
3
|
+
# encapsulating a set of related chapters.
|
4
|
+
# http://www.idpf.org/epub/vocab/structure/#part
|
5
|
+
|
6
|
+
require_relative "../digital_resource"
|
7
|
+
|
8
|
+
module Caliper
|
9
|
+
module Entities
|
10
|
+
module Reading
|
11
|
+
class EpubPart < ::Caliper::Entity::DigitalResource
|
12
|
+
def initialize()
|
13
|
+
super
|
14
|
+
@id = ""
|
15
|
+
@type = DigitalResourceType::EPUB_PART
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Public: Representation of an EPUB 3 subchapter
|
2
|
+
# A major sub-division of a chapter
|
3
|
+
# http://www.idpf.org/epub/vocab/structure/#subchapter
|
4
|
+
|
5
|
+
require_relative "../digital_resource"
|
6
|
+
|
7
|
+
module Caliper
|
8
|
+
module Entities
|
9
|
+
module Reading
|
10
|
+
class EpubSubChapter < Caliper::Entities::DigitalResource
|
11
|
+
def initialize()
|
12
|
+
super
|
13
|
+
@id = ""
|
14
|
+
@type = DigitalResourceType::EPUB_SUB_CHAPTER
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Public: Representation of an EPUB 3 Volume
|
2
|
+
# A component of a collection
|
3
|
+
# http://www.idpf.org/epub/vocab/structure/#volume
|
4
|
+
|
5
|
+
require_relative '../digital_resource'
|
6
|
+
require_relative '../entity'
|
7
|
+
|
8
|
+
module Caliper
|
9
|
+
module Entities
|
10
|
+
module Reading
|
11
|
+
class EpubVolume < Caliper::Entities::DigitalResource
|
12
|
+
def initialize()
|
13
|
+
super
|
14
|
+
@id = ""
|
15
|
+
@type = DigitalResourceType::EPUB_VOLUME
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../digital_resource'
|
2
|
+
require_relative '../targetable'
|
3
|
+
|
4
|
+
module Caliper
|
5
|
+
module Entities
|
6
|
+
module Reading
|
7
|
+
class Frame < DigitalResource
|
8
|
+
include Targetable
|
9
|
+
|
10
|
+
attr_accessor :id,
|
11
|
+
:type,
|
12
|
+
:name,
|
13
|
+
:description,
|
14
|
+
:object_type,
|
15
|
+
:aligned_learning_objective,
|
16
|
+
:keywords,
|
17
|
+
:is_part_of,
|
18
|
+
:properties,
|
19
|
+
:date_created,
|
20
|
+
:date_modified,
|
21
|
+
:date_published,
|
22
|
+
:index
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
super
|
26
|
+
@type = DigitalResourceType::FRAME
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require_relative 'entity'
|
3
|
+
require_relative 'generatable'
|
4
|
+
require_relative 'targetable'
|
5
|
+
|
6
|
+
|
7
|
+
module Caliper
|
8
|
+
module Entities
|
9
|
+
class Session < Entity
|
10
|
+
include Generatable
|
11
|
+
include Targetable
|
12
|
+
|
13
|
+
attr_accessor :type, # String
|
14
|
+
:actor, # Agent
|
15
|
+
:started_at_time,
|
16
|
+
:ended_at_time,
|
17
|
+
:duration # String
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
super
|
21
|
+
@type = EntityType::SESSION
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "json"
|
2
|
+
require_relative '../entities/entity'
|
3
|
+
require_relative '../entities/foaf/agent'
|
4
|
+
require_relative '../entities/schemadotorg/software_application'
|
5
|
+
|
6
|
+
module Caliper
|
7
|
+
module Entities
|
8
|
+
class SoftwareApplication < Entity
|
9
|
+
include Caliper::Entities::FOAF::Agent
|
10
|
+
include Caliper::Entities::SchemaDotOrg::SoftwareApplication
|
11
|
+
|
12
|
+
attr_accessor :type
|
13
|
+
|
14
|
+
def initialize()
|
15
|
+
@type=EntityType::SOFTWARE_APPLICATION
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
# The targetable interface marks an object type that provides coordinates to a target destination
|
3
|
+
# required by certain actions. The interface allows Caliper to catch errors at compile time for
|
4
|
+
# instances of the marked class rather than at runtime if a marker annotation was defined instead.
|
5
|
+
|
6
|
+
module Caliper
|
7
|
+
module Entities
|
8
|
+
module Targetable
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "../entities/digital_resource"
|
2
|
+
require_relative "../entities/schemadotorg/web_page"
|
3
|
+
module Caliper
|
4
|
+
module Entities
|
5
|
+
class WebPage < DigitalResource
|
6
|
+
include Caliper::Entities::SchemaDotOrg::WebPage
|
7
|
+
def initialize()
|
8
|
+
super
|
9
|
+
@type = Caliper::Entities::DigitalResourceType::WEB_PAGE
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Caliper
|
2
|
+
module Event
|
3
|
+
class AnnotationEvent < Event
|
4
|
+
attr_accessor :location
|
5
|
+
|
6
|
+
def initialize(action)
|
7
|
+
@context = "http://purl.imsglobal.org/ctx/caliper/v1/AnnotationEvent"
|
8
|
+
@type = "http://purl.imsglobal.org/caliper/v1/AnnotationEvent"
|
9
|
+
# only subclasses should be instantiated
|
10
|
+
@action = action
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Caliper
|
2
|
+
module Event
|
3
|
+
module EventContext
|
4
|
+
ANNOTATION = "http://purl.imsglobal.org/ctx/caliper/v1/AnnotationEvent"
|
5
|
+
ASSESSMENT = "http://purl.imsglobal.org/ctx/caliper/v1/AssessmentEvent"
|
6
|
+
ASSESSMENT_ITEM = "http://purl.imsglobal.org/ctx/caliper/v1/AssessmentItemEvent"
|
7
|
+
ASSIGNABLE = "http://purl.imsglobal.org/ctx/caliper/v1/AssignableEvent"
|
8
|
+
EVENT = "http://purl.imsglobal.org/ctx/caliper/v1/Event"
|
9
|
+
MEDIA = "http://purl.imsglobal.org/ctx/caliper/v1/MediaEvent"
|
10
|
+
NAVIGATION = "http://purl.imsglobal.org/ctx/caliper/v1/NavigationEvent"
|
11
|
+
OUTCOME = "http://purl.imsglobal.org/ctx/caliper/v1/OutcomeEvent"
|
12
|
+
SESSION = "http://purl.imsglobal.org/ctx/caliper/v1/SessionEvent"
|
13
|
+
VIEW = "http://purl.imsglobal.org/ctx/caliper/v1/ViewEvent"
|
14
|
+
end
|
15
|
+
module EventType
|
16
|
+
ANNOTATION = "http://purl.imsglobal.org/caliper/v1/AnnotationEvent"
|
17
|
+
ASSESSMENT = "http://purl.imsglobal.org/caliper/v1/AssessmentEvent"
|
18
|
+
ASSESSMENT_ITEM = "http://purl.imsglobal.org/caliper/v1/AssessmentItemEvent"
|
19
|
+
ASSIGNABLE = "http://purl.imsglobal.org/caliper/v1/AssignableEvent"
|
20
|
+
EVENT = "http://purl.imsglobal.org/caliper/v1/Event"
|
21
|
+
MEDIA = "http://purl.imsglobal.org/caliper/v1/MediaEvent"
|
22
|
+
NAVIGATION = "http://purl.imsglobal.org/caliper/v1/NavigationEvent"
|
23
|
+
OUTCOME = "http://purl.imsglobal.org/caliper/v1/OutcomeEvent"
|
24
|
+
SESSION = "http://purl.imsglobal.org/caliper/v1/SessionEvent"
|
25
|
+
VIEW = "http://purl.imsglobal.org/caliper/v1/ViewEvent"
|
26
|
+
end
|
27
|
+
class Event
|
28
|
+
attr_accessor :context, # String Required - the JSON-LD context for the Event
|
29
|
+
|
30
|
+
# Required - the type of the Event
|
31
|
+
:type, # String
|
32
|
+
|
33
|
+
# Learning Context
|
34
|
+
:ed_app, # SoftwareApplication
|
35
|
+
|
36
|
+
# LIS organization
|
37
|
+
:lis_organization, # Organization
|
38
|
+
|
39
|
+
# Required - Agent (User, System) that performed the action
|
40
|
+
:actor, # Agent
|
41
|
+
|
42
|
+
# Required - Action performed by Agent From Metric Profile
|
43
|
+
:action, # String
|
44
|
+
|
45
|
+
# Required - "Activity Context" from Metric Profile
|
46
|
+
:object, # Object
|
47
|
+
|
48
|
+
# Optional - "target" from Metric Profile
|
49
|
+
:target, # Targetable
|
50
|
+
|
51
|
+
# Optional - entity "generated" as result of action - from Metric Profile
|
52
|
+
:generated, # Generatable
|
53
|
+
|
54
|
+
# Required time in milliseconds that the event was started at
|
55
|
+
:started_at_time, # long
|
56
|
+
|
57
|
+
# An optional time in milliseconds that the event ended at
|
58
|
+
:ended_at_time, # long
|
59
|
+
|
60
|
+
# An xsd:duration (http://books.xmlschemata.org/relaxng/ch19-77073.html)
|
61
|
+
# The format is expected to be PnYnMnDTnHnMnS
|
62
|
+
# Valid values include PT1004199059S, PT130S, PT2M10S, P1DT2S, -P1Y, or P1Y2M3DT5H20M30.123S.
|
63
|
+
# The following values are invalid: 1Y (leading P is missing), P1S (T separator is missing),
|
64
|
+
# P-1Y (all parts must be positive), P1M2Y (parts order is significant and Y must precede M) * or P1Y-1M (all parts must be positive). */
|
65
|
+
:duration # String
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
|
3
|
+
module Caliper
|
4
|
+
module Event
|
5
|
+
class MediaEvent < Event
|
6
|
+
attr_accessor :context,
|
7
|
+
:type,
|
8
|
+
:action,
|
9
|
+
:object,
|
10
|
+
:target
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
@context = EventContext::MEDIA
|
15
|
+
@type = EventType::MEDIA
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
require_relative '../profiles/profile'
|
3
|
+
|
4
|
+
module Caliper
|
5
|
+
module Event
|
6
|
+
class NavigationEvent < Event
|
7
|
+
|
8
|
+
attr_accessor :context,
|
9
|
+
:type,
|
10
|
+
:action,
|
11
|
+
:object,
|
12
|
+
:from_resource, #the resource from which the navigation starts
|
13
|
+
:target
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
@context = EventContext::NAVIGATION
|
18
|
+
@type = EventType::NAVIGATION
|
19
|
+
@action = Caliper::Profiles::ProfileActions::NAVIGATED_TO
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
require_relative '../profiles/profile_actions'
|
3
|
+
|
4
|
+
module Caliper
|
5
|
+
module Event
|
6
|
+
class OutcomeEvent < Event
|
7
|
+
attr_accessor :context,
|
8
|
+
:type,
|
9
|
+
:action,
|
10
|
+
:object,
|
11
|
+
:generated
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
@context = EventContext::OUTCOME
|
16
|
+
@type = EventType::OUTCOME
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
require_relative '../profiles/session_profile'
|
3
|
+
|
4
|
+
module Caliper
|
5
|
+
module Event
|
6
|
+
class SessionEvent < Event
|
7
|
+
|
8
|
+
# Utilize builder to construct SessionEvent. Validate Session object copy rather than the
|
9
|
+
# Session builder. This approach protects the class against parameter changes from another
|
10
|
+
# thread during the "window of vulnerability" between the time the parameters are checked
|
11
|
+
# until when they are copied. Validate properties of builder copy and if conformance violations
|
12
|
+
# are found throw an IllegalStateException (Bloch, Effective Java, 2nd ed., items 2, 39, 60, 63).
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
@context = Caliper::Event::EventContext::SESSION
|
16
|
+
@type = Caliper::Event::EventType::SESSION
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
require_relative '../profiles/reading_profile_key'
|
3
|
+
|
4
|
+
module Caliper
|
5
|
+
module Event
|
6
|
+
class ViewEvent < Event
|
7
|
+
attr_accessor :context,
|
8
|
+
:type,
|
9
|
+
:action,
|
10
|
+
:object,
|
11
|
+
:target
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@type = EventType::VIEW
|
15
|
+
@action = ReadingProfileKey::VIEWED
|
16
|
+
@context = EventContext::VIEW
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Caliper
|
2
|
+
class Options
|
3
|
+
attr_accessor :api_key
|
4
|
+
attr_accessor :host
|
5
|
+
attr_accessor :time_out
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
@host = Defaults.HOST
|
10
|
+
@time_out = Defaults.CONNECTION_TIMEOUT
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(host, time_out)
|
14
|
+
@host = host
|
15
|
+
@time_out = time_out
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|