ims-lti 2.0.0.beta.11 → 2.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f30f9afef013c59d05a728bbe3dabe7c1d732e7
4
- data.tar.gz: d4fd6ab606ace57581ad64e958fbf36b9dd4cb54
3
+ metadata.gz: 40b8de748fa6f881fb3ba1c3970b1ef79bec9951
4
+ data.tar.gz: e4d254ce59b3a7c473ecaa2f8d36d4a9f61cb33c
5
5
  SHA512:
6
- metadata.gz: 3b761640b405e04c4c67d6350a87129bfc29a81ee1177647b18edb6dc3e431715fbc12ce618747206f223c8f626a29e02e14787371f2b94d8a3d5bf140be2a40
7
- data.tar.gz: c1de59d4c61e50d8dd425ccf1e80c5fc1b899aa2b4c2427c4f5137a8bcf689f8b28d8714a892e747ea0d4073edb1db03911114bda20966b9fd2da1c955d20167
6
+ metadata.gz: 4304bfac89685bf37fb8d175965abc3bd0e7e838de7e1ce74e12383fb9af0231e02ca85337240baf0abeba794874d7bbcbdb4c7abd848a1240f29a62f15a46cd
7
+ data.tar.gz: df72ec7a90e013d9d3a08aa46f1f64b0203c82cbed242b196f5278ad563f42dc2f837696c47eab28875f44f9096d14fc85d65dec61b601ef763c99f3a9539655
@@ -1,10 +1,10 @@
1
1
  module IMS::LTI::Models::Messages
2
- class BasicLTILaunchRequest < IMS::LTI::Models::Messages::Message
2
+ class BasicLTILaunchRequest < Message
3
3
 
4
- required_params :resource_link_id
5
- recommended_params :context_id, :launch_presentation_return_url, :tool_consumer_instance_guid
6
- optional_params :context_type, :role_scope_mentor, :user_image
7
- deprecated_params :context_title, :context_label, :resource_link_title, :resource_link_description,
4
+ add_required_params :resource_link_id
5
+ add_recommended_params :context_id, :launch_presentation_return_url, :tool_consumer_instance_guid
6
+ add_optional_params :context_type, :role_scope_mentor, :user_image
7
+ add_deprecated_params :context_title, :context_label, :resource_link_title, :resource_link_description,
8
8
  :lis_person_name_given, :lis_person_name_family, :lis_person_name_full,
9
9
  :lis_person_contact_email_primary, :user_image, :lis_person_sourcedid,
10
10
  :lis_course_offering_sourcedid, :lis_course_section_sourcedid,
@@ -2,33 +2,53 @@ module IMS::LTI::Models::Messages
2
2
  class Message
3
3
  class << self
4
4
 
5
- def required_params(param, *params)
6
- add_params(param, *params)
5
+ def required_params
6
+ supers_params('@required_params') | (@required_params || [])
7
7
  end
8
8
 
9
- def recommended_params(param, *params)
10
- add_params(param, *params)
9
+ def add_required_params(param, *params)
10
+ add_params('@required_params', param, *params)
11
11
  end
12
12
 
13
- def optional_params(param, *params)
14
- add_params(param, *params)
13
+ def recommended_params
14
+ supers_params('@recommended_params') | (@recommended_params || [])
15
15
  end
16
16
 
17
- def deprecated_params(param, *params)
18
- add_params(param, *params)
17
+ def add_recommended_params(param, *params)
18
+ add_params('@recommended_params', param, *params)
19
+ end
20
+
21
+ def optional_params
22
+ supers_params('@optional_params') | (@optional_params || [])
23
+ end
24
+
25
+ def add_optional_params(param, *params)
26
+ add_params('@optional_params', param, *params)
27
+ end
28
+
29
+ def deprecated_params
30
+ supers_params('@deprecated_params') | (@deprecated_params || [])
31
+ end
32
+
33
+ def add_deprecated_params(param, *params)
34
+ add_params('@deprecated_params', param, *params)
19
35
  end
20
36
 
21
37
  private
22
38
 
23
- def add_params(param, *params)
24
- params.unshift(param)
25
- @parameters ||= superclass.instance_variable_get('@parameters') || []
26
- @parameters += params
39
+ def add_params(instance_variable, param, *params)
40
+ instance_var = self.instance_variable_get(instance_variable) || []
41
+ instance_var |= params.unshift(param)
42
+ self.instance_variable_set(instance_variable, instance_var)
27
43
  attr_accessor(params.shift, *params)
28
44
  end
29
45
 
30
46
  def parameters
31
- @parameters ||= []
47
+ required_params + recommended_params + optional_params + deprecated_params
48
+ end
49
+
50
+ def supers_params(instance_variable)
51
+ superclass == Object ? [] : superclass.instance_variable_get(instance_variable) || []
32
52
  end
33
53
 
34
54
  end
@@ -44,9 +64,9 @@ module IMS::LTI::Models::Messages
44
64
 
45
65
  attr_accessor :launch_url, *OAUTH_KEYS
46
66
 
47
- required_params :lti_message_type, :lti_version
48
- recommended_params :user_id, :roles, :launch_presentation_document_target, :launch_presentation_width, :launch_presentation_height
49
- optional_params :launch_presentation_local, :launch_presentation_css_url
67
+ add_required_params :lti_message_type, :lti_version
68
+ add_recommended_params :user_id, :roles, :launch_presentation_document_target, :launch_presentation_width, :launch_presentation_height
69
+ add_optional_params :launch_presentation_local, :launch_presentation_css_url
50
70
 
51
71
  def initialize(attrs = {})
52
72
 
@@ -68,11 +88,11 @@ module IMS::LTI::Models::Messages
68
88
  end
69
89
 
70
90
  def add_custom_params(params)
71
- params.each { |k,v| k.to_s.start_with?('custom_') ? @custom_params[k.to_s] = v : @custom_params["custom_#{k.to_s}"] = v }
91
+ params.each { |k, v| k.to_s.start_with?('custom_') ? @custom_params[k.to_s] = v : @custom_params["custom_#{k.to_s}"] = v }
72
92
  end
73
93
 
74
94
  def get_custom_params
75
- @custom_params.inject({}) { |hash, (k,v)| hash[k.gsub(/\Acustom_/, '')] = v ; hash }
95
+ @custom_params.inject({}) { |hash, (k, v)| hash[k.gsub(/\Acustom_/, '')] = v; hash }
76
96
  end
77
97
 
78
98
  def post_params
@@ -111,8 +131,7 @@ module IMS::LTI::Models::Messages
111
131
  private
112
132
 
113
133
  def parameters
114
-
115
- self.class.instance_variable_get("@parameters").inject({}) do |h, param|
134
+ self.class.send("parameters").inject({}) do |h, param|
116
135
  value = instance_variable_get("@#{param.to_s}")
117
136
  h[param.to_s] = value unless value.nil?
118
137
  h
@@ -1,12 +1,12 @@
1
1
  module IMS::LTI::Models::Messages
2
2
  class RegistrationRequest < Message
3
3
 
4
- required_params :reg_key, :reg_password, :tc_profile_url, :launch_presentation_return_url
4
+ add_required_params :reg_key, :reg_password, :tc_profile_url, :launch_presentation_return_url
5
5
 
6
6
  MESSAGE_TYPE = 'ToolProxyRegistrationRequest'
7
7
 
8
- def initialize(attributes = {})
9
- super(attributes)
8
+ def initialize(attrs = {})
9
+ super(attrs)
10
10
  self.lti_message_type = MESSAGE_TYPE
11
11
  end
12
12
 
@@ -0,0 +1,10 @@
1
+ class ServiceDefinition
2
+ attr_reader :name, :formats, :paramater_variables
3
+
4
+ def initialize(name, formats, parameter_variables = [])
5
+ @name = name
6
+ @formats = formats
7
+ @parameter_variables = parameter_variables
8
+ end
9
+
10
+ end
@@ -0,0 +1,30 @@
1
+ class ServiceLookup
2
+
3
+ TOOL_SETTING_SERVICE = ServiceDefinition.new(
4
+ 'ToolSettingsContainer Service',
5
+ %w(application/vnd.ims.lti.v2.toolsettings+json application/vnd.ims.lti.v2.toolsettings.simple+json),
6
+ %w(LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url)
7
+ )
8
+
9
+ TOOL_CONSUMER_PROFILE_SERVICE = ServiceDefinition.new(
10
+ 'ToolConsumerProfile Service',
11
+ %w(application/vnd.ims.lti.v2.toolconsumerprofile+json),
12
+ []
13
+ )
14
+
15
+ TOOL_PROXY_SERVICE = ServiceDefinition.new(
16
+ 'ToolProxy Service',
17
+ %w(application/vnd.ims.lti.v2.toolproxy+json),
18
+ []
19
+ )
20
+
21
+ def self.services
22
+ [TOOL_SETTING_SERVICE, TOOL_CONSUMER_PROFILE_SERVICE, TOOL_PROXY_SERVICE]
23
+ end
24
+
25
+ def self.lookup(format)
26
+ services.select { |service| service.formats.include? format }
27
+ end
28
+
29
+
30
+ end
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.11
4
+ version: 2.0.0.beta.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-15 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simple_oauth
@@ -139,6 +139,8 @@ files:
139
139
  - lib/ims/lti/models/tool_setting_container.rb
140
140
  - lib/ims/lti/models/vendor.rb
141
141
  - lib/ims/lti/services.rb
142
+ - lib/ims/lti/services/service_definition.rb
143
+ - lib/ims/lti/services/service_lookup.rb
142
144
  - lib/ims/lti/services/tool_proxy_registration_service.rb
143
145
  - lib/ims/lti/version.rb
144
146
  homepage: http://github.com/instructure/ims-lti