ims-lti 2.0.0.beta.19 → 2.0.0.beta.20
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/lib/ims/lti/models/messages/message.rb +43 -9
- data/lib/ims/lti/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bcf94db095c67ba98ec3812f19f8c8c31a8a86d
|
4
|
+
data.tar.gz: 98f29e780c98723f7ad66c87bb242de83e3f41e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf3b2ec04f3537773b4a3c4c4591a416920b35017fe2485cf2ccafd1641c23a4370a092024203ff0b010e3334a67d06fb7dc04bfacc5b02bb6e3be639ec5eb2a
|
7
|
+
data.tar.gz: 06912f014181ce1d03277864abc6c22440c84ff9f521b64da5a49ce8fb9864352a30223af7186d7d3d6f073bfc9036ccdbd4556d9cd0c3b3b9fa25537f852195
|
@@ -63,15 +63,28 @@ module IMS::LTI::Models::Messages
|
|
63
63
|
:oauth_timestamp, :oauth_token, :oauth_verifier, :oauth_version
|
64
64
|
|
65
65
|
attr_accessor :launch_url, *OAUTH_KEYS
|
66
|
+
attr_reader :unknown_params, :custom_params, :ext_params
|
66
67
|
|
67
68
|
add_required_params :lti_message_type, :lti_version
|
68
69
|
add_recommended_params :user_id, :roles, :launch_presentation_document_target, :launch_presentation_width, :launch_presentation_height
|
69
70
|
add_optional_params :launch_presentation_locale, :launch_presentation_css_url
|
70
71
|
|
72
|
+
def self.generate(params)
|
73
|
+
case params['lti_message_type']
|
74
|
+
when BasicLTILaunchRequest::MESSAGE_TYPE
|
75
|
+
BasicLTILaunchRequest.new(params)
|
76
|
+
when RegistrationRequest::MESSAGE_TYPE
|
77
|
+
RegistrationRequest.new(params)
|
78
|
+
else
|
79
|
+
self.new(params)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
71
83
|
def initialize(attrs = {})
|
72
84
|
|
73
85
|
@custom_params = {}
|
74
86
|
@ext_params = {}
|
87
|
+
@unknown_params = {}
|
75
88
|
|
76
89
|
attrs.each do |k, v|
|
77
90
|
str_key = k.to_s
|
@@ -83,6 +96,7 @@ module IMS::LTI::Models::Messages
|
|
83
96
|
instance_variable_set("@#{k}", v)
|
84
97
|
else
|
85
98
|
warn "Unknown parameter #{k}"
|
99
|
+
@unknown_params[str_key] = v
|
86
100
|
end
|
87
101
|
end
|
88
102
|
end
|
@@ -96,7 +110,7 @@ module IMS::LTI::Models::Messages
|
|
96
110
|
end
|
97
111
|
|
98
112
|
def post_params
|
99
|
-
@custom_params.merge(@ext_params).merge(parameters)
|
113
|
+
unknown_params.merge(@custom_params).merge(@ext_params).merge(parameters)
|
100
114
|
end
|
101
115
|
|
102
116
|
def signed_post_params(secret)
|
@@ -118,6 +132,26 @@ module IMS::LTI::Models::Messages
|
|
118
132
|
header.valid?(signature: signature)
|
119
133
|
end
|
120
134
|
|
135
|
+
def parameters
|
136
|
+
collect_attributes(self.class.send("parameters"))
|
137
|
+
end
|
138
|
+
|
139
|
+
def required_params
|
140
|
+
collect_attributes(self.class.required_params)
|
141
|
+
end
|
142
|
+
|
143
|
+
def recommended_params
|
144
|
+
collect_attributes(self.class.recommended_params)
|
145
|
+
end
|
146
|
+
|
147
|
+
def optional_params
|
148
|
+
collect_attributes(self.class.optional_params)
|
149
|
+
end
|
150
|
+
|
151
|
+
def deprecated_params
|
152
|
+
collect_attributes(self.class.deprecated_params)
|
153
|
+
end
|
154
|
+
|
121
155
|
def method_missing(meth, *args, &block)
|
122
156
|
if match = /^(custom|ext)_([^=$]*)/.match(meth)
|
123
157
|
param_type, key = match.captures
|
@@ -130,14 +164,6 @@ module IMS::LTI::Models::Messages
|
|
130
164
|
|
131
165
|
private
|
132
166
|
|
133
|
-
def parameters
|
134
|
-
self.class.send("parameters").inject({}) do |h, param|
|
135
|
-
value = instance_variable_get("@#{param.to_s}")
|
136
|
-
h[param.to_s] = value unless value.nil?
|
137
|
-
h
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
167
|
def parse_params(params)
|
142
168
|
params.inject([{}, {}]) do |array, (k, v)|
|
143
169
|
attr = k.to_s.sub('oauth_', '').to_sym
|
@@ -150,5 +176,13 @@ module IMS::LTI::Models::Messages
|
|
150
176
|
end
|
151
177
|
end
|
152
178
|
|
179
|
+
def collect_attributes(attributes)
|
180
|
+
attributes.inject({}) do |h, param|
|
181
|
+
value = instance_variable_get("@#{param.to_s}")
|
182
|
+
h[param.to_s] = value unless value.nil?
|
183
|
+
h
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
153
187
|
end
|
154
188
|
end
|
data/lib/ims/lti/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ims-lti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_oauth
|