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.
- checksums.yaml +8 -8
- data/.gitignore +37 -0
- data/.idea/caliper-ruby.iml +98 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/Gemfile +12 -1
- data/Gemfile.lock +42 -1
- data/LICENSE +67 -0
- data/NOTICE +15 -0
- data/README.md +13 -5
- data/caliper.gemspec +2 -8
- data/lib/caliper/defaults.rb +4 -4
- data/lib/caliper/entities/annotation/annotation.rb +14 -4
- data/lib/caliper/entities/annotation/bookmark_annotation.rb +14 -4
- data/lib/caliper/entities/annotation/highlight_annotation.rb +14 -3
- data/lib/caliper/entities/annotation/shared_annotation.rb +12 -3
- data/lib/caliper/entities/annotation/tag_annotation.rb +13 -3
- data/lib/caliper/entities/assessment/assessment.rb +27 -0
- data/lib/caliper/entities/assessment/assessment_item.rb +26 -0
- data/lib/caliper/entities/assignable/assignable_digital_resource.rb +47 -0
- data/lib/caliper/entities/assignable/attempt.rb +32 -0
- data/lib/caliper/entities/digital_resource.rb +36 -35
- data/lib/caliper/entities/entity.rb +50 -36
- data/lib/caliper/entities/foaf/agent.rb +1 -1
- data/lib/caliper/entities/jsonable.rb +56 -0
- data/lib/caliper/entities/learning_objective.rb +26 -0
- data/lib/caliper/entities/lis/course_offering.rb +30 -0
- data/lib/caliper/entities/lis/course_section.rb +27 -15
- data/lib/caliper/entities/lis/group.rb +27 -0
- data/lib/caliper/entities/lis/membership.rb +32 -0
- data/lib/caliper/entities/lis/organization.rb +20 -17
- data/lib/caliper/entities/lis/person.rb +23 -10
- data/lib/caliper/entities/lis/roles.rb +77 -0
- data/lib/caliper/entities/lis/status.rb +19 -0
- data/lib/caliper/entities/media/audio_object.rb +21 -0
- data/lib/caliper/entities/media/image_object.rb +21 -0
- data/lib/caliper/entities/media/media_location.rb +23 -0
- data/lib/caliper/entities/media/media_object.rb +38 -0
- data/lib/caliper/entities/media/video_object.rb +21 -0
- data/lib/caliper/entities/reading/epub_volume.rb +15 -7
- data/lib/caliper/entities/reading/frame.rb +7 -15
- data/lib/caliper/entities/response/fillin_blank_response.rb +20 -0
- data/lib/caliper/entities/response/multiple_choice_response.rb +20 -0
- data/lib/caliper/entities/response/multiple_response_response.rb +20 -0
- data/lib/caliper/entities/response/response.rb +23 -0
- data/lib/caliper/entities/response/response_type.rb +13 -0
- data/lib/caliper/entities/response/select_type_response.rb +20 -0
- data/lib/caliper/entities/response/true_false_response.rb +21 -0
- data/lib/caliper/entities/schemadotorg/software_application.rb +8 -8
- data/lib/caliper/entities/session.rb +25 -17
- data/lib/caliper/entities/software_application.rb +16 -7
- data/lib/caliper/entities/web_page.rb +2 -0
- data/lib/caliper/entity_envelope.rb +21 -0
- data/lib/caliper/event/annotation_event.rb +10 -6
- data/lib/caliper/event/assessment_event.rb +19 -0
- data/lib/caliper/event/assessment_item_event.rb +19 -0
- data/lib/caliper/event/assignable_event.rb +19 -0
- data/lib/caliper/event/event.rb +70 -50
- data/lib/caliper/event/jsonable.rb +55 -0
- data/lib/caliper/event/navigation_event.rb +2 -7
- data/lib/caliper/event/outcome_event.rb +1 -1
- data/lib/caliper/event/session_event.rb +13 -14
- data/lib/caliper/event/view_event.rb +6 -7
- data/lib/caliper/event_envelope.rb +22 -0
- data/lib/caliper/jsonable.rb +53 -0
- data/lib/caliper/profiles/annotation_profile.rb +56 -53
- data/lib/caliper/profiles/assessment_profile.rb +48 -0
- data/lib/caliper/profiles/assignable_profile.rb +44 -0
- data/lib/caliper/profiles/media_profile.rb +54 -0
- data/lib/caliper/profiles/profile.rb +38 -38
- data/lib/caliper/profiles/reading_profile.rb +31 -28
- data/lib/caliper/profiles/session_profile.rb +17 -18
- data/lib/caliper/request/event_store_requestor.rb +26 -26
- data/lib/caliper/sensor.rb +46 -35
- data/lib/caliper/version.rb +1 -1
- data/spec/lib/entities/entity.json +9 -0
- data/spec/lib/entities/entity_spec.rb +37 -0
- data/spec/lib/entities/lis/person_spec.rb +37 -0
- data/spec/lib/entities/lis/student.json +11 -0
- data/spec/lib/event/annotation_event_bookmark_spec.rb +159 -0
- data/spec/lib/event/annotation_event_highlight_spec.rb +160 -0
- data/spec/lib/event/annotation_event_shared_spec.rb +172 -0
- data/spec/lib/event/annotation_event_tag_spec.rb +159 -0
- data/spec/lib/event/assessment_event_spec.rb +207 -0
- data/spec/lib/event/assessment_item_completed_event_spec.rb +223 -0
- data/spec/lib/event/assessment_item_started_event_spec.rb +207 -0
- data/spec/lib/event/media_event_spec.rb +157 -0
- data/spec/lib/event/navigated_event_spec.rb +160 -0
- data/spec/lib/event/session_event_login_spec.rb +160 -0
- data/spec/lib/event/session_event_logout_spec.rb +145 -0
- data/spec/lib/event/session_event_timeout_spec.rb +145 -0
- data/spec/lib/event/viewed_event_spec.rb +149 -0
- data/spec/lib/event_helper.rb +145 -0
- data/spec/lib/sensor_spec.rb +30 -0
- data/spec/spec_helper.rb +3 -2
- metadata +84 -61
- data/lib/caliper/client.rb +0 -33
- data/lib/caliper/consumer/base.rb +0 -46
- data/lib/caliper/consumer/queue.rb +0 -40
- data/lib/caliper/consumer/socket.rb +0 -132
- data/lib/caliper/entities/annotation/text_position_selector.rb +0 -14
- data/lib/caliper/entities/schemadotorg/audio_object.rb +0 -15
- data/lib/caliper/entities/schemadotorg/image_object.rb +0 -15
- data/lib/caliper/entities/schemadotorg/media_object.rb +0 -19
- data/lib/caliper/entities/schemadotorg/video_object.rb +0 -15
- data/lib/caliper/event/.shared.rb.swp +0 -0
- data/spec/lib/client_spec.rb +0 -35
- data/spec/lib/consumer/base_spec.rb +0 -28
- data/spec/lib/consumer/queue_spec.rb +0 -16
- data/spec/lib/event/annotation_spec.rb +0 -12
- data/spec/lib/event/bookmarked_spec.rb +0 -17
- data/spec/lib/event/commented_spec.rb +0 -19
- data/spec/lib/event/highlighted_spec.rb +0 -18
- data/spec/lib/event/navigation_spec.rb +0 -15
- data/spec/lib/event/shared_spec.rb +0 -18
- data/spec/lib/event/tagged_spec.rb +0 -17
- data/spec/lib/event/used_spec.rb +0 -15
- data/spec/lib/event/viewed_spec.rb +0 -15
- data/test/caliper/events/session_login_event_test.rb +0 -58
- data/test/caliper/events/session_logout_event_test.rb +0 -55
- data/test/caliper/events/session_timeout_event_test.rb +0 -55
- data/test/caliper/request/http_requestor_test.rb +0 -59
- data/test/caliper/test_event.rb +0 -53
- data/test/caliper/test_utils.rb +0 -198
- data/test/fixtures/caliper_session_login_event.json +0 -71
- data/test/fixtures/caliper_session_logout_event.json +0 -52
- data/test/fixtures/caliper_session_timeout_event.json +0 -52
- data/test/fixtures/event_store_payload.json +0 -85
@@ -1,13 +1,17 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
require_relative '../profiles/annotation_profile'
|
3
|
+
|
1
4
|
module Caliper
|
2
5
|
module Event
|
6
|
+
|
7
|
+
#
|
8
|
+
# Annotation Event per Caliper Annotation Profile
|
9
|
+
#
|
3
10
|
class AnnotationEvent < Event
|
4
|
-
attr_accessor :location
|
5
11
|
|
6
|
-
def initialize
|
7
|
-
@context =
|
8
|
-
|
9
|
-
# only subclasses should be instantiated
|
10
|
-
@action = action
|
12
|
+
def initialize
|
13
|
+
@context = Caliper::Event::EventContext::ANNOTATION
|
14
|
+
@type = Caliper::Event::EventType::ANNOTATION
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
|
3
|
+
module Caliper
|
4
|
+
module Event
|
5
|
+
class AssessmentEvent < Event
|
6
|
+
attr_accessor :context,
|
7
|
+
:type,
|
8
|
+
:action,
|
9
|
+
:object,
|
10
|
+
:target
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
@context = EventContext::ASSESSMENT
|
15
|
+
@type = EventType::ASSESSMENT
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
|
3
|
+
module Caliper
|
4
|
+
module Event
|
5
|
+
class AssessmentItemEvent < Event
|
6
|
+
attr_accessor :context,
|
7
|
+
:type,
|
8
|
+
:action,
|
9
|
+
:object,
|
10
|
+
:target
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
@context = EventContext::ASSESSMENT_ITEM
|
15
|
+
@type = EventType::ASSESSMENT_ITEM
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'event'
|
2
|
+
|
3
|
+
module Caliper
|
4
|
+
module Event
|
5
|
+
class AssignableEvent < Event
|
6
|
+
attr_accessor :context,
|
7
|
+
:type,
|
8
|
+
:action,
|
9
|
+
:object,
|
10
|
+
:target
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
@context = EventContext::ASSIGNABLE
|
15
|
+
@type = EventType::ASSIGNABLE
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/caliper/event/event.rb
CHANGED
@@ -1,68 +1,88 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './jsonable'
|
3
|
+
|
1
4
|
module Caliper
|
2
5
|
module Event
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
module EventContext
|
7
|
+
ANNOTATION = "http://purl.imsglobal.org/ctx/caliper/v1/AnnotationEvent"
|
8
|
+
ASSESSMENT = "http://purl.imsglobal.org/ctx/caliper/v1/AssessmentEvent"
|
9
|
+
ASSESSMENT_ITEM = "http://purl.imsglobal.org/ctx/caliper/v1/AssessmentItemEvent"
|
10
|
+
ASSIGNABLE = "http://purl.imsglobal.org/ctx/caliper/v1/AssignableEvent"
|
11
|
+
EVENT = "http://purl.imsglobal.org/ctx/caliper/v1/Event"
|
12
|
+
MEDIA = "http://purl.imsglobal.org/ctx/caliper/v1/MediaEvent"
|
13
|
+
NAVIGATION = "http://purl.imsglobal.org/ctx/caliper/v1/NavigationEvent"
|
14
|
+
OUTCOME = "http://purl.imsglobal.org/ctx/caliper/v1/OutcomeEvent"
|
15
|
+
SESSION = "http://purl.imsglobal.org/ctx/caliper/v1/SessionEvent"
|
16
|
+
VIEW = "http://purl.imsglobal.org/ctx/caliper/v1/ViewEvent"
|
17
|
+
end
|
18
|
+
module EventType
|
19
|
+
ANNOTATION = "http://purl.imsglobal.org/caliper/v1/AnnotationEvent"
|
20
|
+
ASSESSMENT = "http://purl.imsglobal.org/caliper/v1/AssessmentEvent"
|
21
|
+
ASSESSMENT_ITEM = "http://purl.imsglobal.org/caliper/v1/AssessmentItemEvent"
|
22
|
+
ASSIGNABLE = "http://purl.imsglobal.org/caliper/v1/AssignableEvent"
|
23
|
+
EVENT = "http://purl.imsglobal.org/caliper/v1/Event"
|
24
|
+
MEDIA = "http://purl.imsglobal.org/caliper/v1/MediaEvent"
|
25
|
+
NAVIGATION = "http://purl.imsglobal.org/caliper/v1/NavigationEvent"
|
26
|
+
OUTCOME = "http://purl.imsglobal.org/caliper/v1/OutcomeEvent"
|
27
|
+
SESSION = "http://purl.imsglobal.org/caliper/v1/SessionEvent"
|
28
|
+
VIEW = "http://purl.imsglobal.org/caliper/v1/ViewEvent"
|
29
|
+
end
|
27
30
|
class Event
|
31
|
+
include Caliper::Event::Jsonable
|
32
|
+
|
28
33
|
attr_accessor :context, # String Required - the JSON-LD context for the Event
|
29
34
|
|
30
|
-
|
31
|
-
|
35
|
+
# Required - the type of the Event
|
36
|
+
:type, # String
|
37
|
+
|
38
|
+
# Learning Context
|
39
|
+
:edApp, # SoftwareApplication
|
32
40
|
|
33
|
-
|
34
|
-
|
41
|
+
# LIS Group
|
42
|
+
:group, # Group
|
35
43
|
|
36
|
-
|
37
|
-
|
44
|
+
# Required - Agent (User, System) that performed the action
|
45
|
+
:actor, # Agent
|
38
46
|
|
39
|
-
|
40
|
-
|
47
|
+
# Required - Action performed by Agent From Metric Profile
|
48
|
+
:action, # String
|
41
49
|
|
42
|
-
|
43
|
-
|
50
|
+
# Required - "Activity Context" from Metric Profile
|
51
|
+
:object, # Object
|
44
52
|
|
45
|
-
|
46
|
-
|
53
|
+
# Optional - "target" from Metric Profile
|
54
|
+
:target, # Targetable
|
47
55
|
|
48
|
-
|
49
|
-
|
56
|
+
# Optional - entity "generated" as result of action - from Metric Profile
|
57
|
+
:generated, # Generatable
|
50
58
|
|
51
|
-
|
52
|
-
|
59
|
+
# Required time that the event was started at
|
60
|
+
:startedAtTime, # ISO-8601 date string
|
53
61
|
|
54
|
-
|
55
|
-
|
62
|
+
# An optional time that the event ended at
|
63
|
+
:endedAtTime, # ISO-8601 date string
|
56
64
|
|
57
|
-
|
58
|
-
|
65
|
+
# An xsd:duration (http://books.xmlschemata.org/relaxng/ch19-77073.html)
|
66
|
+
# The format is expected to be PnYnMnDTnHnMnS
|
67
|
+
# Valid values include PT1004199059S, PT130S, PT2M10S, P1DT2S, -P1Y, or P1Y2M3DT5H20M30.123S.
|
68
|
+
# The following values are invalid: 1Y (leading P is missing), P1S (T separator is missing),
|
69
|
+
# 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). */
|
70
|
+
:duration # String
|
59
71
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
72
|
+
def initialize()
|
73
|
+
@context = EventContext::EVENT
|
74
|
+
@type = EventType::EVENT
|
75
|
+
@actor = nil
|
76
|
+
@action = nil
|
77
|
+
@object = nil
|
78
|
+
@target = nil
|
79
|
+
@generated = nil
|
80
|
+
@edApp = nil
|
81
|
+
@group = nil
|
82
|
+
@startedAtTime = Time.now.utc.iso8601(3)
|
83
|
+
@endedAtTime = nil
|
84
|
+
@duration = nil
|
85
|
+
end
|
66
86
|
end
|
67
87
|
end
|
68
88
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# @copyright @copyright ©2013 IMS Global Learning Consortium, Inc. All Rights Reserved.
|
6
|
+
# @license For license information contact, info@imsglobal.org
|
7
|
+
#
|
8
|
+
# Module that supports ser-des for Caliper Event/JSON
|
9
|
+
#
|
10
|
+
module Caliper
|
11
|
+
module Event
|
12
|
+
module Jsonable
|
13
|
+
|
14
|
+
def self.included(base)
|
15
|
+
base.extend ClassMethods
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_json(*a)
|
22
|
+
# puts 'Jsonable: to_json invoked'
|
23
|
+
result = {}
|
24
|
+
result['@context'] = self.context
|
25
|
+
result['@type'] = self.type
|
26
|
+
self.instance_variables.each do |key|
|
27
|
+
# puts "got key = #{key}"
|
28
|
+
next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
29
|
+
value = self.instance_variable_get key
|
30
|
+
# puts "setting #{key}: #{value}"
|
31
|
+
result[key[1..-1]] = value
|
32
|
+
end
|
33
|
+
result.to_json(*a)
|
34
|
+
end
|
35
|
+
|
36
|
+
def from_json json_hash
|
37
|
+
data = json_hash
|
38
|
+
# puts "Jsonable: from_json: json_hash = #{json_hash}"
|
39
|
+
self.context = data['@context']
|
40
|
+
self.type = data['@type']
|
41
|
+
json_hash.each do | key, value |
|
42
|
+
next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
43
|
+
# puts "Jsonable - adding #{key} : #{value}"
|
44
|
+
self.instance_variable_set "@#{key}", value
|
45
|
+
end
|
46
|
+
return self
|
47
|
+
end
|
48
|
+
|
49
|
+
def eql?(other)
|
50
|
+
@context == other.context && @type == other.type && @startedAtTime == other.startedAtTime && @endedAtTime == other.endedAtTime
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -5,18 +5,13 @@ module Caliper
|
|
5
5
|
module Event
|
6
6
|
class NavigationEvent < Event
|
7
7
|
|
8
|
-
attr_accessor :
|
9
|
-
:type,
|
10
|
-
:action,
|
11
|
-
:object,
|
12
|
-
:from_resource, #the resource from which the navigation starts
|
13
|
-
:target
|
8
|
+
attr_accessor :navigatedFrom
|
14
9
|
|
15
10
|
def initialize
|
16
11
|
super
|
17
12
|
@context = EventContext::NAVIGATION
|
18
13
|
@type = EventType::NAVIGATION
|
19
|
-
|
14
|
+
@navigatedFrom = nil
|
20
15
|
end
|
21
16
|
end
|
22
17
|
end
|
@@ -2,20 +2,19 @@ require_relative 'event'
|
|
2
2
|
require_relative '../profiles/session_profile'
|
3
3
|
|
4
4
|
module Caliper
|
5
|
-
|
6
|
-
|
5
|
+
module Event
|
6
|
+
|
7
|
+
class SessionEvent < Event
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@type = Caliper::Event::EventType::SESSION
|
17
|
-
end
|
9
|
+
#
|
10
|
+
# Session Event per the Caliper Session Profile
|
11
|
+
#
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
@context = Caliper::Event::EventContext::SESSION
|
15
|
+
@type = Caliper::Event::EventType::SESSION
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
end
|
19
|
+
end
|
21
20
|
end
|
@@ -1,20 +1,19 @@
|
|
1
1
|
require_relative 'event'
|
2
|
-
require_relative '../profiles/
|
2
|
+
require_relative '../profiles/reading_profile.rb'
|
3
3
|
|
4
4
|
module Caliper
|
5
5
|
module Event
|
6
|
+
|
6
7
|
class ViewEvent < Event
|
7
|
-
attr_accessor :context,
|
8
|
-
:type,
|
9
|
-
:action,
|
10
|
-
:object,
|
11
|
-
:target
|
12
8
|
|
9
|
+
#
|
10
|
+
# Viewed Event per the Caliper Base Profile
|
11
|
+
#
|
13
12
|
def initialize
|
14
13
|
@type = EventType::VIEW
|
15
|
-
@action = ReadingProfileKey::VIEWED
|
16
14
|
@context = EventContext::VIEW
|
17
15
|
end
|
16
|
+
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require_relative "options"
|
3
|
+
require_relative 'jsonable'
|
4
|
+
|
5
|
+
##
|
6
|
+
#
|
7
|
+
# @copyright @copyright ©2013 IMS Global Learning Consortium, Inc. All Rights Reserved.
|
8
|
+
# @license For license information contact, info@imsglobal.org
|
9
|
+
#
|
10
|
+
# Caliper Sensor Event Envelope
|
11
|
+
#
|
12
|
+
#
|
13
|
+
module Caliper
|
14
|
+
|
15
|
+
class EventEnvelope
|
16
|
+
include Caliper::Jsonable
|
17
|
+
|
18
|
+
attr_accessor :apiKey,
|
19
|
+
:sensorId,
|
20
|
+
:event
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# @copyright @copyright ©2013 IMS Global Learning Consortium, Inc. All Rights Reserved.
|
6
|
+
# @license For license information contact, info@imsglobal.org
|
7
|
+
#
|
8
|
+
# Module that supports ser-des for Caliper Envelope
|
9
|
+
#
|
10
|
+
module Caliper
|
11
|
+
module Jsonable
|
12
|
+
|
13
|
+
def self.included(base)
|
14
|
+
base.extend ClassMethods
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_json(*a)
|
21
|
+
# puts 'Jsonable: to_json invoked'
|
22
|
+
result = {}
|
23
|
+
# result['@context'] = self.context
|
24
|
+
# result['@type'] = self.type
|
25
|
+
self.instance_variables.each do |key|
|
26
|
+
# puts "got key = #{key}"
|
27
|
+
next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
28
|
+
value = self.instance_variable_get key
|
29
|
+
# puts "setting #{key}: #{value}"
|
30
|
+
result[key[1..-1]] = value
|
31
|
+
end
|
32
|
+
result.to_json(*a)
|
33
|
+
end
|
34
|
+
|
35
|
+
def from_json json_hash
|
36
|
+
data = json_hash
|
37
|
+
# puts "Jsonable: from_json: json_hash = #{json_hash}"
|
38
|
+
# self.context = data['@context']
|
39
|
+
# self.type = data['@type']
|
40
|
+
json_hash.each do | key, value |
|
41
|
+
next if (key[1..-1] == 'context' || key[1..-1] == 'type')
|
42
|
+
# puts "Jsonable - adding #{key} : #{value}"
|
43
|
+
self.instance_variable_set "@#{key}", value
|
44
|
+
end
|
45
|
+
return self
|
46
|
+
end
|
47
|
+
|
48
|
+
def eql?(other)
|
49
|
+
@sensorId == other.sensorId && @apiKey == other.apiKey
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|