rack-lti 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/lti/config.rb +14 -1
- data/lib/rack/lti/middleware.rb +2 -1
- data/lib/rack/lti/version.rb +1 -1
- data/rack-lti.gemspec +2 -2
- data/test/config_test.rb +24 -4
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d0b37117873d888fb6eb0d4a27aec831870bdeb
|
4
|
+
data.tar.gz: 8bc012c07da2b921027f8e6b05d955771ef3148d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dee340fa9cd17d2c16726b9b9b04142fc55ec91766e45da43d4df1af5dd24abb63b1df174fe4a4dbcf631b2e8ada86feb2fb0229ddf88434e2232b5dc779be0b
|
7
|
+
data.tar.gz: e7cbb4c050a9d7a2a0bdd2a6f6cd6fef605fc1601caf91f5480d551a73ecd4f8a104e6d90877145457893cb6759e1b1e5c9d744d38a24412bf10f1e20c7de096
|
data/lib/rack/lti/config.rb
CHANGED
@@ -35,7 +35,9 @@ module Rack::LTI
|
|
35
35
|
self[:consumer_key].nil? && self[:consumer_secret].nil?
|
36
36
|
end
|
37
37
|
|
38
|
-
def to_xml(options = {})
|
38
|
+
def to_xml(request, options = {})
|
39
|
+
options = options.merge(get_extensions(request))
|
40
|
+
|
39
41
|
# Stringify keys for IMS::LTI
|
40
42
|
config = self.merge(options).inject({}) do |h, v|
|
41
43
|
h[v[0].to_s] = v[1]
|
@@ -54,5 +56,16 @@ module Rack::LTI
|
|
54
56
|
super
|
55
57
|
end
|
56
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def get_extensions(request)
|
63
|
+
return {} unless self.key? :extensions
|
64
|
+
extensions = self[:extensions].inject({}) do |h, (k, v)|
|
65
|
+
h[k] = v.respond_to?(:call) ? v.call(request) : v
|
66
|
+
h
|
67
|
+
end
|
68
|
+
{ extensions: extensions }
|
69
|
+
end
|
57
70
|
end
|
58
71
|
end
|
data/lib/rack/lti/middleware.rb
CHANGED
@@ -32,7 +32,8 @@ module Rack::LTI
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def config_action(request, env)
|
35
|
-
|
35
|
+
launch_url = request.url.sub(@config.config_path, @config.launch_path)
|
36
|
+
response = [@config.to_xml(request, launch_url: launch_url)]
|
36
37
|
[200, { 'Content-Type' => 'application/xml', 'Content-Length' => response[0].length.to_s }, response]
|
37
38
|
end
|
38
39
|
|
data/lib/rack/lti/version.rb
CHANGED
data/rack-lti.gemspec
CHANGED
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.require_paths = ['lib']
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
28
|
-
spec.add_development_dependency 'minitest', '~> 5.0
|
28
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
29
29
|
spec.add_development_dependency 'rake'
|
30
30
|
|
31
|
-
spec.add_dependency 'ims-lti', '~> 1.1
|
31
|
+
spec.add_dependency 'ims-lti', '~> 1.1'
|
32
32
|
spec.add_dependency 'rack'
|
33
33
|
end
|
data/test/config_test.rb
CHANGED
@@ -74,7 +74,7 @@ class ConfigTest < Minitest::Test
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_to_xml_returns_an_xml_lti_config
|
77
|
-
body = REXML::Document.new(@config.to_xml(launch_url: 'http://example.com/launch'))
|
77
|
+
body = REXML::Document.new(@config.to_xml(nil, launch_url: 'http://example.com/launch'))
|
78
78
|
|
79
79
|
assert_equal @config.title,
|
80
80
|
REXML::XPath.match(body, '//blti:title').first.text
|
@@ -84,7 +84,7 @@ class ConfigTest < Minitest::Test
|
|
84
84
|
REXML::XPath.match(body, '//blti:launch_url').first.text
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
87
|
+
def test_to_xml_includes_hardcoded_extensions
|
88
88
|
@config[:extensions] = {
|
89
89
|
'canvas.instructure.com' => {
|
90
90
|
'course_navigation' => {
|
@@ -95,7 +95,7 @@ class ConfigTest < Minitest::Test
|
|
95
95
|
}
|
96
96
|
}
|
97
97
|
|
98
|
-
body = REXML::Document.new(@config.to_xml(launch_url: 'http://example.com/launch'))
|
98
|
+
body = REXML::Document.new(@config.to_xml(nil, launch_url: 'http://example.com/launch'))
|
99
99
|
assert_equal 'anonymous',
|
100
100
|
REXML::XPath.match(body, '//lticm:property[@name="privacy_level"]').first.text
|
101
101
|
assert_equal 'Tool title',
|
@@ -104,9 +104,29 @@ class ConfigTest < Minitest::Test
|
|
104
104
|
REXML::XPath.match(body, '//lticm:property[@name="url"]').first.text
|
105
105
|
end
|
106
106
|
|
107
|
+
def test_to_xml_includes_extensions_with_lambdas
|
108
|
+
rack_request_stub = Struct.new(:base_url).new('rack-url.com')
|
109
|
+
@config[:extensions] = {
|
110
|
+
'canvas.instructure.com' => ->(req) do
|
111
|
+
{
|
112
|
+
'editor_button' => {
|
113
|
+
'size' => '16x16',
|
114
|
+
'icon_url' => "#{req.base_url}/public/icon.png"
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
}
|
119
|
+
|
120
|
+
body = REXML::Document.new(@config.to_xml(rack_request_stub, launch_url: 'http://example.com/launch'))
|
121
|
+
assert_equal '16x16',
|
122
|
+
REXML::XPath.match(body, '//lticm:property[@name="size"]').first.text
|
123
|
+
assert_equal 'rack-url.com/public/icon.png',
|
124
|
+
REXML::XPath.match(body, '//lticm:property[@name="icon_url"]').first.text
|
125
|
+
end
|
126
|
+
|
107
127
|
def test_to_xml_includes_custom_params
|
108
128
|
@config[:custom_params] = { ck1: 'one', ck2: 'two' }
|
109
|
-
body = REXML::Document.new(@config.to_xml(launch_url: 'http://example.com/launch'))
|
129
|
+
body = REXML::Document.new(@config.to_xml(nil, launch_url: 'http://example.com/launch'))
|
110
130
|
assert_equal 'one', REXML::XPath.match(body, '//blti:custom/lticm:property[@name="ck1"]').first.text
|
111
131
|
assert_equal 'two', REXML::XPath.match(body, '//blti:custom/lticm:property[@name="ck2"]').first.text
|
112
132
|
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-lti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Pendleton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 5.0
|
33
|
+
version: '5.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 5.0
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ims-lti
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.1
|
61
|
+
version: '1.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.1
|
68
|
+
version: '1.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rack
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: |2
|
@@ -92,8 +92,8 @@ executables: []
|
|
92
92
|
extensions: []
|
93
93
|
extra_rdoc_files: []
|
94
94
|
files:
|
95
|
-
- .gitignore
|
96
|
-
- .travis.yml
|
95
|
+
- ".gitignore"
|
96
|
+
- ".travis.yml"
|
97
97
|
- Gemfile
|
98
98
|
- LICENSE.txt
|
99
99
|
- README.md
|
@@ -117,17 +117,17 @@ require_paths:
|
|
117
117
|
- lib
|
118
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- -
|
125
|
+
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.4.5
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Middleware for handling LTI launches inside your Rack app.
|