github-to-canvas 0.1.4 → 0.1.5

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: 17f3d65ceff1b6670cb57429c118cd22448bb68ff01d673e6ae43654f87f786e
4
- data.tar.gz: 85f6f9c85cafb25b76988d4697dcc9bb539ddc7d9c0c34d59290256bce8cb34f
3
+ metadata.gz: b18946099c8b4fd23e1c2230f71fac458f932079fd22ada5297732358fec4d0e
4
+ data.tar.gz: '092e1b7854f2b4c4026f0713599d423d8eac6431ae16e4f9372c1a00ebb9775c'
5
5
  SHA512:
6
- metadata.gz: 2b4ea1f94dbfb8534de1fe2b2383443c4a0f846becc90b6ea553bf92d0ba366363be2db123157be1e1ce3bea85db1a020309d01cb91d14ca959ebd646ab60e2d
7
- data.tar.gz: 71d4bc983ce83768a17b85b1cc92111ed7909b2ae27f3755f441da7b0810d846b6cf36b1ff827a09d7aacfd1af81860ec86c46c7e1a174f27dc06e82d63f82f4
6
+ metadata.gz: d11be9f366fc3a457a671669a57802d6a1a8cc8ff3b0a7e9fa3ee10b4b8b91334cbaa336d39c1e3057c41e787619716d76df3e8523d918393cbb1b6fa9737549
7
+ data.tar.gz: 85d91f81000c82d55cb45e02f31c9aa3b2e241c785cb58366f5fbef99b72c7ce76e7e9d70f101cedb7f54c5082b2061926e0453cd8a162227cdba78f96c54e71
@@ -193,6 +193,7 @@ class CanvasInterface
193
193
  while !!index
194
194
  url = "#{ENV['CANVAS_API_PATH']}/courses/#{course}/modules?page=#{index}&per_page=20"
195
195
  index += 1
196
+
196
197
  response = RestClient.get(url, self.headers)
197
198
  modules = JSON.parse(response.body)
198
199
 
@@ -200,7 +201,7 @@ class CanvasInterface
200
201
  course_info[:modules] = course_info[:modules] + modules
201
202
  else
202
203
  index = nil
203
- end
204
+ end
204
205
  end
205
206
 
206
207
  course_info[:modules] = course_info[:modules].map do |mod|
@@ -213,11 +214,12 @@ class CanvasInterface
213
214
  while !!index
214
215
  url = "#{ENV['CANVAS_API_PATH']}/courses/#{course}/modules/#{mod['id']}/items?page=#{index}&per_page=20"
215
216
  index += 1
216
- response = RestClient.get(url, headers={
217
- "Authorization" => "Bearer #{ENV['CANVAS_API_KEY']}"
218
- })
217
+ response = RestClient.get(url, self.headers)
219
218
  lessons = JSON.parse(response.body)
220
219
  lessons = lessons.map do |lesson|
220
+ if lesson["type"] == "ExternalUrl"
221
+ next
222
+ end
221
223
  lesson = lesson.slice("id","title","name","indent","type","html_url","page_url","url","completion_requirement", "published")
222
224
  lesson["repository"] = ""
223
225
  lesson['id'] = lesson['url'].gsub(/^(.*[\\\/])/,'')
@@ -232,10 +234,11 @@ class CanvasInterface
232
234
  end
233
235
  new_mod
234
236
  end
235
-
237
+
236
238
  puts course_info.to_yaml
237
239
 
238
240
  rescue
241
+ byebug
239
242
  puts "Something went wrong while getting info about course #{course}"
240
243
  abort
241
244
  end
@@ -136,7 +136,7 @@ class RepositoryConverter
136
136
  end
137
137
 
138
138
  def self.adjust_local_markdown_images(readme, raw_remote_url, branch)
139
- readme.gsub!(/\!\[.+\]\(.+\)/) {|image_markdown|
139
+ readme.gsub(/\!\[.+\]\(.+\)/) {|image_markdown|
140
140
  if !image_markdown.match?('amazonaws.com') && !image_markdown.match?('https://') && !image_markdown.match?('http://') && !image_markdown.match?('youtube')
141
141
  image_markdown.gsub!(/\(.+\)/) { |path|
142
142
  path.delete_prefix!("(")
@@ -149,11 +149,12 @@ class RepositoryConverter
149
149
  end
150
150
 
151
151
  def self.adjust_local_html_images(readme, raw_remote_url, branch)
152
- readme.gsub!(/src=(\'|\")[\s\S]*?(\'|\")/) { |image_source|
153
- if !image_source.match?('amazonaws.com') && !image_source.match?('https://') && !image_source.match?('http://') && !image_source.match?('youtube')
154
- image_source.gsub!(/(\'|\")/, "")
155
- image_source.gsub!(/src=/, '')
156
- image_source.strip!
152
+ readme.gsub(/src=(\'|\")[\s\S]*?(\'|\")/) { |image_source|
153
+
154
+ if !image_source.match?('amazonaws.com') && !image_source.match?('https://') && !image_source.match?('http://') && !image_source.match?('youtube') && !image_source.match(/src=(\'|\")(?=<%)/)
155
+ image_source = image_source.gsub(/(\'|\")/, "")
156
+ image_source = image_source.gsub(/src=/, '')
157
+ image_source = image_source.strip
157
158
  'src="' + raw_remote_url + '/' + branch + '/' + image_source + '"'
158
159
  else
159
160
  image_source
@@ -1,3 +1,3 @@
1
1
  class GithubToCanvas
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-to-canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxwellbenton