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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbf4acfef5de0008c9e181c97242511e28985bc57ea09f722b3a41d5af9c0c04
4
- data.tar.gz: fd7557c89ec0e9c52381f90b22c484466276f5d866be2636f7c27e0728b02fe4
3
+ metadata.gz: cfafd60f403921db6037838554ff73e249aba5b3d19946a6a001c73598534ee8
4
+ data.tar.gz: 5ba978a32528ff25e6139d18ddaf60e3b82bbf1b412d357c6562d9bccfbf4939
5
5
  SHA512:
6
- metadata.gz: 8c386ae46339d2474c5056a091095b1ffe85c45f103fd0d6915fcfdcc96f21bf616bac55f42a19671ed429fada551e7942609a51dd7966cc1b79292e6a33415b
7
- data.tar.gz: 110fe2f62222d994347bd82e65ab47ecfa8f116f00fef031e991cdc02bd51a6c263b9c27acb54c5698220742b44bf33c9e31d6ed85dadd176dc2bbecde3eb3e2
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
- "[Int]"
23
- elsif property["items"]["$ref"] == "Array"
24
- "[String]"
25
- elsif property["items"]["$ref"] == "[String]"
26
- "[String]"
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
- "[LMSGraphQL::Types::DateTimeType]"
29
- elsif property["items"]["$ref"]
30
- # HACK on https://canvas.instructure.com/doc/api/submissions.json
31
- # the ref value is set to a full sentence rather than a
32
- # simple type, so we look for that specific value
33
- if property["items"]["$ref"].include?("UserDisplay if anonymous grading is not enabled")
34
- "[LMSGraphQL::Types::Canvas::CanvasUserDisplay]"
35
- else
36
- "[#{canvas_name(property["items"]["$ref"], input_type)}]"
37
- end
38
- else
39
- graphql_primitive(name, property["items"]["type"].downcase, property["items"]["format"])
40
- end
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
- name = type.split('|').first.strip.singularize
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 = no_brackets(type_from_operation(@operation))
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 no_brackets(str)
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 = no_brackets(type_from_operation(@operation))
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 = no_brackets(graphql_type(name, property, true, model))
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("[", "_").gsub("]", "").gsub("*", "star").gsub("<", "_").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)
@@ -1,3 +1,3 @@
1
1
  module LMS
2
- VERSION = "1.16.0".freeze
2
+ VERSION = "1.17.0".freeze
3
3
  end
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.16.0
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-14 00:00:00.000000000 Z
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: []