ims_caliper 0.9.3.15 → 1.0.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 +4 -4
- data/README.md +10 -5
- data/lib/caliper/{profiles/annotation_profile.rb → actions/annotation_actions.rb} +3 -41
- data/lib/caliper/{profiles/assessment_profile.rb → actions/assessment_actions.rb} +3 -19
- data/lib/caliper/actions/assessment_item_actions.rb +31 -0
- data/lib/caliper/{profiles/assignable_profile.rb → actions/assignable_actions.rb} +3 -28
- data/lib/caliper/{profiles/media_profile.rb → actions/media_actions.rb} +4 -29
- data/lib/caliper/{event/view_event.rb → actions/navigation_actions.rb} +5 -11
- data/lib/caliper/{validators/event_validator_context.rb → actions/outcome_actions.rb} +7 -15
- data/lib/caliper/{event/navigation_event.rb → actions/reading_actions.rb} +6 -14
- data/lib/caliper/actions/session_actions.rb +30 -0
- data/lib/caliper/context/context.rb +31 -0
- data/lib/caliper/entities/agent/organization.rb +4 -3
- data/lib/caliper/entities/agent/person.rb +4 -3
- data/lib/caliper/entities/agent/software_application.rb +4 -3
- data/lib/caliper/entities/annotation/annotation.rb +4 -12
- data/lib/caliper/entities/annotation/annotation_type.rb +32 -0
- data/lib/caliper/entities/annotation/bookmark_annotation.rb +3 -1
- data/lib/caliper/entities/annotation/highlight_annotation.rb +4 -4
- data/lib/caliper/entities/annotation/shared_annotation.rb +3 -1
- data/lib/caliper/entities/annotation/tag_annotation.rb +3 -1
- data/lib/caliper/entities/assessment/assessment.rb +1 -1
- data/lib/caliper/entities/assessment/assessment_item.rb +2 -0
- data/lib/caliper/entities/assignable/assignable_digital_resource.rb +3 -13
- data/lib/caliper/{event/session_event.rb → entities/assignable/assignable_digital_resource_type.rb} +7 -11
- data/lib/caliper/entities/assignable/attempt.rb +8 -9
- data/lib/caliper/entities/digital_resource.rb +5 -22
- data/lib/caliper/entities/digital_resource_type.rb +33 -0
- data/lib/caliper/entities/entity.rb +7 -37
- data/lib/caliper/entities/{learning_context.rb → entity_base.rb} +19 -15
- data/lib/caliper/entities/entity_type.rb +39 -0
- data/lib/caliper/entities/foaf/agent.rb +0 -2
- data/lib/caliper/entities/jsonable.rb +14 -3
- data/lib/caliper/entities/learning_objective.rb +4 -3
- data/lib/caliper/entities/lis/course_offering.rb +9 -6
- data/lib/caliper/entities/lis/course_section.rb +3 -1
- data/lib/caliper/entities/lis/group.rb +5 -3
- data/lib/caliper/entities/lis/membership.rb +5 -7
- data/lib/caliper/entities/media/audio_object.rb +2 -1
- data/lib/caliper/entities/media/image_object.rb +2 -1
- data/lib/caliper/entities/media/media_location.rb +2 -1
- data/lib/caliper/entities/media/media_object.rb +2 -9
- data/lib/caliper/entities/media/media_object_type.rb +31 -0
- data/lib/caliper/entities/media/video_object.rb +2 -1
- data/lib/caliper/entities/outcome/result.rb +23 -16
- data/lib/caliper/entities/reading/epub_chapter.rb +2 -1
- data/lib/caliper/entities/reading/epub_part.rb +2 -1
- data/lib/caliper/entities/reading/epub_sub_chapter.rb +2 -1
- data/lib/caliper/entities/reading/epub_volume.rb +2 -1
- data/lib/caliper/entities/reading/frame.rb +4 -3
- data/lib/caliper/entities/reading/web_page.rb +3 -2
- data/lib/caliper/entities/response/fillin_blank_response.rb +3 -3
- data/lib/caliper/entities/response/multiple_choice_response.rb +3 -3
- data/lib/caliper/entities/response/multiple_response_response.rb +3 -3
- data/lib/caliper/entities/response/response.rb +8 -10
- data/lib/caliper/entities/response/response_type.rb +5 -5
- data/lib/caliper/entities/response/select_type_response.rb +3 -3
- data/lib/caliper/entities/response/true_false_response.rb +2 -3
- data/lib/caliper/entities/session/session.rb +8 -7
- data/lib/caliper/{event → events}/annotation_event.rb +11 -3
- data/lib/caliper/{event → events}/assessment_event.rb +11 -8
- data/lib/caliper/{event → events}/assessment_item_event.rb +11 -8
- data/lib/caliper/{event → events}/assignable_event.rb +11 -8
- data/lib/caliper/{profiles/profile.rb → events/event.rb} +15 -15
- data/lib/caliper/events/event_context.rb +24 -0
- data/lib/caliper/events/event_type.rb +33 -0
- data/lib/caliper/{event → events}/jsonable.rb +2 -2
- data/lib/caliper/{event → events}/media_event.rb +11 -8
- data/lib/caliper/events/navigation_event.rb +47 -0
- data/lib/caliper/events/outcome_event.rb +44 -0
- data/lib/caliper/{event/outcome_event.rb → events/reading_event.rb} +13 -10
- data/lib/caliper/events/session_event.rb +42 -0
- data/lib/caliper/events/view_event.rb +44 -0
- data/lib/caliper/request/envelope.rb +4 -15
- data/lib/caliper/request/event_store_requestor.rb +1 -1
- data/lib/caliper/request/{envelope_jsonable.rb → jsonable.rb} +9 -11
- data/lib/caliper/sensor.rb +1 -1
- data/lib/caliper/version.rb +1 -1
- data/lib/caliper.rb +1 -1
- data/spec/lib/entities/agent/{student.json → person.json} +4 -3
- data/spec/lib/entities/agent/person_spec.rb +5 -6
- data/spec/lib/entities/assessment/assessment.json +23 -0
- data/spec/lib/entities/assessment/assessment_spec.rb +54 -0
- data/spec/lib/event_helper.rb +33 -41
- data/spec/lib/{event/annotation_event_bookmark_spec.rb → events/annotation_bookmarked_event_spec.rb} +36 -46
- data/spec/lib/{event/annotation_event_highlight_spec.rb → events/annotation_highlighted_event_spec.rb} +36 -46
- data/spec/lib/{event/annotation_event_shared_spec.rb → events/annotation_shared_event_spec.rb} +42 -52
- data/spec/lib/{event/annotation_event_tag_spec.rb → events/annotation_tagged_event_spec.rb} +36 -46
- data/spec/lib/{event → events}/assessment_item_completed_event_spec.rb +41 -65
- data/spec/lib/{event → events}/assessment_item_started_event_spec.rb +38 -56
- data/spec/lib/{event/assessment_event_spec.rb → events/assessment_started_event_spec.rb} +36 -51
- data/spec/lib/{event/assignable_event_spec.rb → events/assignable_activated_event_spec.rb} +37 -52
- data/spec/lib/{event/media_event_spec.rb → events/media_paused_video_event_spec.rb} +33 -43
- data/spec/lib/{event/navigated_event_spec.rb → events/navigation_navigated_to_event_spec.rb} +36 -45
- data/spec/lib/events/outcome_graded_event_spec.rb +163 -0
- data/spec/lib/{event/session_event_login_spec.rb → events/session_logged_in_event_spec.rb} +38 -46
- data/spec/lib/{event/session_event_logout_spec.rb → events/session_logged_out-event_spec.rb} +28 -37
- data/spec/lib/{event/session_event_timeout_spec.rb → events/session_timed_out_event_spec.rb} +24 -34
- data/spec/lib/{event/viewed_event_spec.rb → events/view_viewed_event_spec.rb} +33 -41
- data/spec/lib/request/{http_requestor_spec.rb → http_requestor_single_event_spec.rb} +46 -47
- data/spec/lib/request/http_requestor_single_minimal_event_spec.rb +84 -0
- data/spec/lib/sensor_spec.rb +1 -1
- metadata +77 -70
- data/lib/caliper/event/event.rb +0 -114
- data/lib/caliper/profiles/assessment_item_profile.rb +0 -48
- data/lib/caliper/profiles/reading_profile.rb +0 -56
- data/lib/caliper/profiles/session_profile.rb +0 -46
- data/lib/caliper/validators/error_message.rb +0 -63
- data/lib/caliper/validators/event_validator.rb +0 -57
- data/lib/caliper/validators/property_type_check.rb +0 -33
- data/lib/caliper/validators/session_login_event_validator.rb +0 -121
- data/lib/caliper/validators/session_logout_event_validator.rb +0 -120
- data/lib/caliper/validators/time_check.rb +0 -50
- data/spec/lib/entities/entity.json +0 -9
- data/spec/lib/entities/entity_spec.rb +0 -52
@@ -0,0 +1,24 @@
|
|
1
|
+
##
|
2
|
+
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
+
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
+
# under one or more contributor license agreements. See the NOTICE
|
5
|
+
# file distributed with this work for additional information.
|
6
|
+
#
|
7
|
+
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
+
# Software Foundation, version 3 of the License.
|
10
|
+
#
|
11
|
+
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
+
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
|
18
|
+
module Caliper
|
19
|
+
module Events
|
20
|
+
module EventContext
|
21
|
+
attr_accessor :target, :generated, :edApp, :group, :membership, :federatedSession
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
##
|
2
|
+
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
+
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
+
# under one or more contributor license agreements. See the NOTICE
|
5
|
+
# file distributed with this work for additional information.
|
6
|
+
#
|
7
|
+
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
+
# Software Foundation, version 3 of the License.
|
10
|
+
#
|
11
|
+
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
+
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
|
18
|
+
module Caliper
|
19
|
+
module Events
|
20
|
+
module EventType
|
21
|
+
ANNOTATION = "http://purl.imsglobal.org/caliper/v1/AnnotationEvent"
|
22
|
+
ASSESSMENT = "http://purl.imsglobal.org/caliper/v1/AssessmentEvent"
|
23
|
+
ASSESSMENT_ITEM = "http://purl.imsglobal.org/caliper/v1/AssessmentItemEvent"
|
24
|
+
ASSIGNABLE = "http://purl.imsglobal.org/caliper/v1/AssignableEvent"
|
25
|
+
EVENT = "http://purl.imsglobal.org/caliper/v1/Event"
|
26
|
+
MEDIA = "http://purl.imsglobal.org/caliper/v1/MediaEvent"
|
27
|
+
NAVIGATION = "http://purl.imsglobal.org/caliper/v1/NavigationEvent"
|
28
|
+
OUTCOME = "http://purl.imsglobal.org/caliper/v1/OutcomeEvent"
|
29
|
+
SESSION = "http://purl.imsglobal.org/caliper/v1/SessionEvent"
|
30
|
+
VIEW = "http://purl.imsglobal.org/caliper/v1/ViewEvent"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -21,7 +21,7 @@ require 'json'
|
|
21
21
|
# Module that supports ser-des for Caliper Event/JSON
|
22
22
|
#
|
23
23
|
module Caliper
|
24
|
-
module
|
24
|
+
module Events
|
25
25
|
module Jsonable
|
26
26
|
|
27
27
|
def self.included(base)
|
@@ -60,7 +60,7 @@ module Caliper
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def eql?(other)
|
63
|
-
@context == other.context && @type == other.type && @
|
63
|
+
@context == other.context && @type == other.type && @eventTime == other.eventTime
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -16,23 +16,26 @@
|
|
16
16
|
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
17
|
|
18
18
|
require_relative './event'
|
19
|
+
require_relative './event_context'
|
20
|
+
require_relative './event_type'
|
19
21
|
|
20
22
|
#
|
21
23
|
# Media Event.
|
22
24
|
#
|
23
25
|
module Caliper
|
24
|
-
module
|
26
|
+
module Events
|
25
27
|
class MediaEvent < Event
|
26
|
-
|
27
|
-
:type,
|
28
|
-
:action,
|
29
|
-
:object,
|
30
|
-
:target
|
28
|
+
include Caliper::Events::EventContext
|
31
29
|
|
32
30
|
def initialize
|
33
31
|
super
|
34
|
-
@
|
35
|
-
|
32
|
+
@type = Caliper::Events::EventType::MEDIA
|
33
|
+
@target = nil
|
34
|
+
@generated = nil
|
35
|
+
@edApp = nil
|
36
|
+
@group = nil
|
37
|
+
@membership = nil
|
38
|
+
@federatedSession = nil
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
##
|
2
|
+
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
+
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
+
# under one or more contributor license agreements. See the NOTICE
|
5
|
+
# file distributed with this work for additional information.
|
6
|
+
#
|
7
|
+
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
+
# Software Foundation, version 3 of the License.
|
10
|
+
#
|
11
|
+
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
+
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
|
18
|
+
require_relative '../actions/navigation_actions.rb'
|
19
|
+
require_relative './event'
|
20
|
+
require_relative './event_context'
|
21
|
+
require_relative './event_type'
|
22
|
+
|
23
|
+
#
|
24
|
+
# Navigation Event.
|
25
|
+
#
|
26
|
+
module Caliper
|
27
|
+
module Events
|
28
|
+
class NavigationEvent < Event
|
29
|
+
include Caliper::Events::EventContext
|
30
|
+
|
31
|
+
attr_accessor :navigatedFrom
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
super
|
35
|
+
@type = Caliper::Events::EventType::NAVIGATION
|
36
|
+
@action = Caliper::Actions::NavigationActions::NAVIGATED_TO
|
37
|
+
@navigatedFrom = nil
|
38
|
+
@target = nil
|
39
|
+
@generated = nil
|
40
|
+
@edApp = nil
|
41
|
+
@group = nil
|
42
|
+
@membership = nil
|
43
|
+
@federatedSession = nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
##
|
2
|
+
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
+
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
+
# under one or more contributor license agreements. See the NOTICE
|
5
|
+
# file distributed with this work for additional information.
|
6
|
+
#
|
7
|
+
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
+
# Software Foundation, version 3 of the License.
|
10
|
+
#
|
11
|
+
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
+
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
|
18
|
+
require_relative '../actions/outcome_actions.rb'
|
19
|
+
require_relative './event'
|
20
|
+
require_relative './event_context'
|
21
|
+
require_relative './event_type'
|
22
|
+
|
23
|
+
#
|
24
|
+
# Outcome Event.
|
25
|
+
#
|
26
|
+
module Caliper
|
27
|
+
module Events
|
28
|
+
class OutcomeEvent < Event
|
29
|
+
include Caliper::Events::EventContext
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
super
|
33
|
+
@type = Caliper::Events::EventType::OUTCOME
|
34
|
+
@action = Caliper::Actions::OutcomeActions::GRADED
|
35
|
+
@target = nil
|
36
|
+
@generated = nil
|
37
|
+
@edApp = nil
|
38
|
+
@group = nil
|
39
|
+
@membership = nil
|
40
|
+
@federatedSession = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -16,23 +16,26 @@
|
|
16
16
|
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
17
|
|
18
18
|
require_relative './event'
|
19
|
+
require_relative './event_context'
|
20
|
+
require_relative './event_type'
|
19
21
|
|
20
22
|
#
|
21
23
|
# Outcome Event.
|
22
24
|
#
|
23
25
|
module Caliper
|
24
|
-
module
|
25
|
-
class
|
26
|
-
|
27
|
-
:type,
|
28
|
-
:action,
|
29
|
-
:object,
|
30
|
-
:generated
|
26
|
+
module Events
|
27
|
+
class ReadingEvent < Event
|
28
|
+
include Caliper::Events::EventContext
|
31
29
|
|
32
30
|
def initialize
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
super
|
32
|
+
@type = Caliper::Events::EventType::READING
|
33
|
+
@target = nil
|
34
|
+
@generated = nil
|
35
|
+
@edApp = nil
|
36
|
+
@group = nil
|
37
|
+
@membership = nil
|
38
|
+
@federatedSession = nil
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
##
|
2
|
+
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
+
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
+
# under one or more contributor license agreements. See the NOTICE
|
5
|
+
# file distributed with this work for additional information.
|
6
|
+
#
|
7
|
+
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
+
# Software Foundation, version 3 of the License.
|
10
|
+
#
|
11
|
+
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
+
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
|
18
|
+
require_relative './event'
|
19
|
+
require_relative './event_context'
|
20
|
+
require_relative './event_type'
|
21
|
+
|
22
|
+
#
|
23
|
+
# Session Event per the Caliper Session Profile.
|
24
|
+
#
|
25
|
+
module Caliper
|
26
|
+
module Events
|
27
|
+
class SessionEvent < Event
|
28
|
+
include Caliper::Events::EventContext
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
super
|
32
|
+
@type = Caliper::Events::EventType::SESSION
|
33
|
+
@target = nil
|
34
|
+
@generated = nil
|
35
|
+
@edApp = nil
|
36
|
+
@group = nil
|
37
|
+
@membership = nil
|
38
|
+
@federatedSession = nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
##
|
2
|
+
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
+
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
+
# under one or more contributor license agreements. See the NOTICE
|
5
|
+
# file distributed with this work for additional information.
|
6
|
+
#
|
7
|
+
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
+
# Software Foundation, version 3 of the License.
|
10
|
+
#
|
11
|
+
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
+
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
|
18
|
+
require_relative '../actions/reading_actions.rb'
|
19
|
+
require_relative './event'
|
20
|
+
require_relative './event_context'
|
21
|
+
require_relative './event_type'
|
22
|
+
|
23
|
+
#
|
24
|
+
# View Event per the Caliper Base Profile.
|
25
|
+
#
|
26
|
+
module Caliper
|
27
|
+
module Events
|
28
|
+
class ViewEvent < Event
|
29
|
+
include Caliper::Events::EventContext
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
super
|
33
|
+
@type = Caliper::Events::EventType::VIEW
|
34
|
+
@action = Caliper::Actions::ReadingActions::VIEWED
|
35
|
+
@target = nil
|
36
|
+
@generated = nil
|
37
|
+
@edApp = nil
|
38
|
+
@group = nil
|
39
|
+
@membership = nil
|
40
|
+
@federatedSession = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -15,31 +15,20 @@
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License along
|
16
16
|
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
17
|
|
18
|
-
|
18
|
+
require 'json'
|
19
|
+
require_relative './jsonable'
|
19
20
|
|
20
21
|
#
|
21
22
|
# Event store envelope. Contains event info.
|
22
23
|
#
|
23
24
|
module Caliper
|
24
25
|
module Request
|
25
|
-
module Context
|
26
|
-
CONTEXT = "http://purl.imsglobal.org/caliper/ctx/v1/Envelope"
|
27
|
-
end
|
28
|
-
|
29
|
-
# module Type
|
30
|
-
# TYPE = "http://purl.imsglobal.org/caliper/v1/Envelope"
|
31
|
-
# end
|
32
|
-
|
33
26
|
class Envelope
|
34
|
-
include Caliper::Request::
|
27
|
+
include Caliper::Request::Jsonable
|
35
28
|
|
36
|
-
attr_accessor :
|
37
|
-
:sensor,
|
38
|
-
:sendTime,
|
39
|
-
:data
|
29
|
+
attr_accessor :sensor, :sendTime, :data
|
40
30
|
|
41
31
|
def initialize
|
42
|
-
@context = Context::CONTEXT
|
43
32
|
@sensor = ''
|
44
33
|
@sendTime = Time.now.utc.iso8601(3)
|
45
34
|
@data = []
|
@@ -18,11 +18,11 @@
|
|
18
18
|
require 'json'
|
19
19
|
|
20
20
|
#
|
21
|
-
# Module that supports ser-des for Caliper
|
21
|
+
# Module that supports ser-des for Caliper Event/JSON
|
22
22
|
#
|
23
23
|
module Caliper
|
24
24
|
module Request
|
25
|
-
module
|
25
|
+
module Jsonable
|
26
26
|
|
27
27
|
def self.included(base)
|
28
28
|
base.extend ClassMethods
|
@@ -34,12 +34,11 @@ module Caliper
|
|
34
34
|
def to_json(*a)
|
35
35
|
# puts 'Jsonable: to_json invoked'
|
36
36
|
result = {}
|
37
|
-
result['@context'] = self.context
|
38
|
-
#
|
37
|
+
#result['@context'] = self.context
|
38
|
+
#result['@type'] = self.type
|
39
39
|
self.instance_variables.each do |key|
|
40
40
|
# puts "got key = #{key}"
|
41
|
-
next if (key[1..-1] == 'context')
|
42
|
-
# next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
41
|
+
next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
43
42
|
value = self.instance_variable_get key
|
44
43
|
# puts "setting #{key}: #{value}"
|
45
44
|
result[key[1..-1]] = value
|
@@ -50,11 +49,10 @@ module Caliper
|
|
50
49
|
def from_json json_hash
|
51
50
|
data = json_hash
|
52
51
|
# puts "Jsonable: from_json: json_hash = #{json_hash}"
|
53
|
-
self.context = data['@context']
|
54
|
-
#
|
52
|
+
#self.context = data['@context']
|
53
|
+
#self.type = data['@type']
|
55
54
|
json_hash.each do | key, value |
|
56
|
-
next if (key[1..-1] == 'context')
|
57
|
-
# next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
55
|
+
next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
58
56
|
# puts "Jsonable - adding #{key} : #{value}"
|
59
57
|
self.instance_variable_set "@#{key}", value
|
60
58
|
end
|
@@ -62,7 +60,7 @@ module Caliper
|
|
62
60
|
end
|
63
61
|
|
64
62
|
def eql?(other)
|
65
|
-
@
|
63
|
+
@sensor == other.sensor && @sendTime == other.sendTime && @data == other.data
|
66
64
|
end
|
67
65
|
end
|
68
66
|
end
|
data/lib/caliper/sensor.rb
CHANGED
@@ -39,7 +39,7 @@ module Caliper
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def send(event)
|
42
|
-
raise ArgumentError, "Expecting Caliper::Event but got #{event.class.to_s}" unless event.is_a?(Caliper::
|
42
|
+
raise ArgumentError, "Expecting Caliper::Event but got #{event.class.to_s}" unless event.is_a?(Caliper::Events::Event)
|
43
43
|
|
44
44
|
HttpRequestor.new(@options).send(self, event)
|
45
45
|
end
|