lms-api 1.16.0 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas_api/rb_graphql_helpers.rb +47 -27
- data/lib/lms/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfafd60f403921db6037838554ff73e249aba5b3d19946a6a001c73598534ee8
|
4
|
+
data.tar.gz: 5ba978a32528ff25e6139d18ddaf60e3b82bbf1b412d357c6562d9bccfbf4939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71254525d790ceceb28697bed2871c0b1994586c536e523d4a75f27e3a38bb1a9e61a0d7b099eb2c042ef900238bfd296c8bcae53cb98311c9c6d92ecfb01501
|
7
|
+
data.tar.gz: bc99de213a91082613dab0c2cfe82e1eec4c40813271146e7e341aded7bf51a02e07eced2982c8ff4870eb283448d9639820073208e3fee5650e071d78609d9c
|
@@ -8,7 +8,6 @@ module CanvasApi
|
|
8
8
|
enum_class_name(model, name)
|
9
9
|
else
|
10
10
|
type = property["type"].downcase
|
11
|
-
|
12
11
|
case type
|
13
12
|
when "{success: true}"
|
14
13
|
"String"
|
@@ -19,25 +18,27 @@ module CanvasApi
|
|
19
18
|
when "array"
|
20
19
|
begin
|
21
20
|
type = if property["items"]["$ref"] == "[Integer]"
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
"[Int]"
|
22
|
+
elsif property["items"]["$ref"] == "Array"
|
23
|
+
"[String]"
|
24
|
+
elsif property["items"]["$ref"] == "[String]"
|
25
|
+
"[String]"
|
27
26
|
elsif property["items"]["$ref"] == "DateTime" || property["items"]["$ref"] == "Date"
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
27
|
+
"[LMSGraphQL::Types::DateTimeType]"
|
28
|
+
elsif property["items"]["$ref"]
|
29
|
+
# HACK on https://canvas.instructure.com/doc/api/submissions.json
|
30
|
+
# the ref value is set to a full sentence rather than a
|
31
|
+
# simple type, so we look for that specific value
|
32
|
+
if property["items"]["$ref"].include?("UserDisplay if anonymous grading is not enabled")
|
33
|
+
"[LMSGraphQL::Types::Canvas::CanvasUserDisplay]"
|
34
|
+
elsif property["items"]["$ref"].include?("Url String The url to the result that was created")
|
35
|
+
"String"
|
36
|
+
else
|
37
|
+
"[#{canvas_name(property["items"]["$ref"], input_type)}]"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
graphql_primitive(name, property["items"]["type"].downcase, property["items"]["format"])
|
41
|
+
end
|
41
42
|
rescue
|
42
43
|
puts "Unable to discover list type for '#{name}' ('#{property}'). Defaulting to String"
|
43
44
|
type = "String"
|
@@ -50,6 +51,12 @@ module CanvasApi
|
|
50
51
|
if property["type"] == "TermsOfService"
|
51
52
|
# HACK There's no TermsOfService object so we return a string
|
52
53
|
"String"
|
54
|
+
elsif property["type"] == "list of content items"
|
55
|
+
# HACK There's no list of content items object so we return an array of string
|
56
|
+
"[String]"
|
57
|
+
elsif property["type"].include?('{ "unread_count": "integer" }')
|
58
|
+
# HACK TODO this should probably be a different type.
|
59
|
+
"Int"
|
53
60
|
elsif return_type
|
54
61
|
canvas_name(property["type"], input_type)
|
55
62
|
else
|
@@ -61,7 +68,8 @@ module CanvasApi
|
|
61
68
|
end
|
62
69
|
|
63
70
|
def canvas_name(type, input_type = false)
|
64
|
-
|
71
|
+
# Remove chars and fix spelling errors
|
72
|
+
name = type.split('|').first.strip.gsub(" ", "_").singularize.gsub("MediaTrackk", "MediaTrack")
|
65
73
|
"LMSGraphQL::Types::Canvas::Canvas#{name}#{input_type ? 'Input' : ''}"
|
66
74
|
end
|
67
75
|
|
@@ -127,6 +135,9 @@ module CanvasApi
|
|
127
135
|
description << "#{safe_rb(property['description'])}." if property["description"].present?
|
128
136
|
description << "Example: #{safe_rb(property['example'])}".gsub("..", "").gsub("\n", " ") if property["example"].present?
|
129
137
|
|
138
|
+
# clean up name
|
139
|
+
name = nested_arg(name)
|
140
|
+
|
130
141
|
if type = graphql_type(name, property, false, model, input_type)
|
131
142
|
if argument
|
132
143
|
<<-CODE
|
@@ -148,7 +159,7 @@ module CanvasApi
|
|
148
159
|
end
|
149
160
|
|
150
161
|
def name_from_operation(operation)
|
151
|
-
type =
|
162
|
+
type = no_brackets_period(type_from_operation(@operation))
|
152
163
|
if !is_basic_type(type)
|
153
164
|
make_file_name(type)
|
154
165
|
else
|
@@ -160,16 +171,16 @@ module CanvasApi
|
|
160
171
|
["Int", "String", "Boolean", "LMSGraphQL::Types::DateTimeType", "Float", "ID"].include?(type)
|
161
172
|
end
|
162
173
|
|
163
|
-
def
|
164
|
-
str.gsub("[", "").gsub("]", "")
|
174
|
+
def no_brackets_period(str)
|
175
|
+
str.gsub("[", "").gsub("]", "").gsub(".", "")
|
165
176
|
end
|
166
177
|
|
167
178
|
def make_file_name(str)
|
168
|
-
str.underscore.split("/").last.split("|").first.gsub("canvas_", "").strip.singularize
|
179
|
+
str.underscore.split("/").last.split("|").first.gsub("canvas_", "").gsub(" ", "_").strip.singularize
|
169
180
|
end
|
170
181
|
|
171
182
|
def require_from_operation(operation)
|
172
|
-
type =
|
183
|
+
type = no_brackets_period(type_from_operation(@operation))
|
173
184
|
if !is_basic_type(type)
|
174
185
|
"require_relative \"../../types/canvas/#{make_file_name(type)}\""
|
175
186
|
end
|
@@ -178,7 +189,7 @@ module CanvasApi
|
|
178
189
|
def require_from_properties(model)
|
179
190
|
return unless model["properties"]
|
180
191
|
requires = model["properties"].map do |name, property|
|
181
|
-
type =
|
192
|
+
type = no_brackets_period(graphql_type(name, property, true, model))
|
182
193
|
if !is_basic_type(type) && !property["allowableValues"]
|
183
194
|
"require_relative \"#{make_file_name(type)}\""
|
184
195
|
end
|
@@ -201,7 +212,16 @@ module CanvasApi
|
|
201
212
|
# TODO/HACK we are replacing values from the string here to get things to work for now.
|
202
213
|
# However, removing these symbols means that the methods that use the arguments
|
203
214
|
# generated herein will have bugs and be unusable.
|
204
|
-
str.gsub("[", "_").
|
215
|
+
str.gsub("[", "_").
|
216
|
+
gsub("]", "").
|
217
|
+
gsub("*", "star").
|
218
|
+
gsub("<", "_").
|
219
|
+
gsub(">", "_").
|
220
|
+
gsub("`", "").
|
221
|
+
gsub("https://canvas.instructure.com/lti/", "").
|
222
|
+
gsub("https://www.instructure.com/", "").
|
223
|
+
gsub("https://purl.imsglobal.org/spec/lti/claim/", "").
|
224
|
+
gsub(".", "")
|
205
225
|
end
|
206
226
|
|
207
227
|
def params_as_string(parameters, paramTypes)
|
data/lib/lms/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lms-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atomic Jolt
|
8
8
|
- Jamis Buck
|
9
9
|
- Justin Ball
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-07-
|
13
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -153,7 +153,7 @@ homepage: https://github.com/atomicjolt/lms_api
|
|
153
153
|
licenses:
|
154
154
|
- MIT
|
155
155
|
metadata: {}
|
156
|
-
post_install_message:
|
156
|
+
post_install_message:
|
157
157
|
rdoc_options: []
|
158
158
|
require_paths:
|
159
159
|
- lib
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
171
|
rubygems_version: 3.1.4
|
172
|
-
signing_key:
|
172
|
+
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Wrapper for the Instructure Canvas API
|
175
175
|
test_files: []
|