github-to-canvas 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3d7cf49277d1fb40bb6a956a16865fded3e5a722b115313ab598c8b0ac16338
4
- data.tar.gz: '01129c91256e4391343d2dd4bafc0c87acf57d7f8e0a4f3b040289ab045b6dea'
3
+ metadata.gz: 17f3d65ceff1b6670cb57429c118cd22448bb68ff01d673e6ae43654f87f786e
4
+ data.tar.gz: 85f6f9c85cafb25b76988d4697dcc9bb539ddc7d9c0c34d59290256bce8cb34f
5
5
  SHA512:
6
- metadata.gz: ead1b6073842a1d3c65214ffc3e3cd8bd20048df97a878d8f12dd522655090e02b98f9fb2d45be70a16a044d05aea682bf5c6c71cd31ccd8a6ab9fb215591948
7
- data.tar.gz: cb340a9d7f4910116ede731ad44cb44a02f90bf77dae5e632669d2b54879af2eab38a8ff1ebf4e1fd639ee1c68ac22fdd5ded4d3ae5f57cd283696b4e32b0834
6
+ metadata.gz: 2b4ea1f94dbfb8534de1fe2b2383443c4a0f846becc90b6ea553bf92d0ba366363be2db123157be1e1ce3bea85db1a020309d01cb91d14ca959ebd646ab60e2d
7
+ data.tar.gz: 71d4bc983ce83768a17b85b1cc92111ed7909b2ae27f3755f441da7b0810d846b6cf36b1ff827a09d7aacfd1af81860ec86c46c7e1a174f27dc06e82d63f82f4
@@ -1,5 +1,7 @@
1
- require 'byebug'
2
1
  #!/usr/bin/env ruby
2
+
3
+ require 'byebug'
4
+
3
5
  require 'optparse'
4
6
  require 'github-to-canvas'
5
7
 
@@ -138,10 +140,14 @@ OptionParser.new do |opts|
138
140
  "REQUIRES -f or --file Associates canvas lessons with repositories. Use query to create required YAML file") do |file|
139
141
  options[:map] = file
140
142
  end
141
- opts.on("--csv COURSE",
142
- "Returns a course's lesson struction as CSV") do |course|
143
- options[:csv] = course
143
+ opts.on("--urls-only",
144
+ "Use with --map. Outputs repo URLs instead of YAML") do |urls|
145
+ options[:urls_only] = urls
144
146
  end
147
+ # opts.on("--csv COURSE",
148
+ # "Returns a course's lesson struction as CSV") do |course|
149
+ # options[:csv] = course
150
+ # end
145
151
  opts.on("--read-from-canvas CANVAS_URL",
146
152
  "Retrieves an existing Canvas lesson using the provided URL") do |url|
147
153
  options[:read_from_canvas] = url
@@ -250,7 +256,9 @@ if options[:query]
250
256
  end
251
257
 
252
258
  if options[:map]
253
- GithubToCanvas.new(mode: 'map', file_to_convert: options[:map])
259
+ GithubToCanvas.new(mode: 'map',
260
+ file_to_convert: options[:map],
261
+ urls_only: !!options[:urls_only])
254
262
  abort
255
263
  end
256
264
 
@@ -21,7 +21,7 @@ class GithubToCanvas
21
21
  when 'query'
22
22
  CanvasInterface.get_course_info(options[:course_id], options[:id])
23
23
  when 'map'
24
- CanvasInterface.map_course_info(options[:file_to_convert])
24
+ CanvasInterface.map_course_info(options)
25
25
  when 'csv'
26
26
  CanvasInterface.csv(options[:file_to_convert])
27
27
  when 'canvas_read'
@@ -241,8 +241,8 @@ class CanvasInterface
241
241
  end
242
242
  end
243
243
 
244
- def self.map_course_info(file_to_convert)
245
- course_info = YAML.load(File.read("#{Dir.pwd}/#{file_to_convert}"))
244
+ def self.map_course_info(options)
245
+ course_info = YAML.load(File.read("#{Dir.pwd}/#{options[:file_to_convert]}"))
246
246
  course_info[:modules] = course_info[:modules].map do |mod|
247
247
  mod[:lessons] = mod[:lessons].map do |lesson|
248
248
 
@@ -278,6 +278,7 @@ class CanvasInterface
278
278
  lesson["repository"] = repo
279
279
  else
280
280
  lesson["repository"] = "https://github.com/learn-co-curriculum/" + repo
281
+ puts lesson["repository"] if options[:urls_only]
281
282
  end
282
283
  end
283
284
  sleep(1)
@@ -285,7 +286,7 @@ class CanvasInterface
285
286
  end
286
287
  mod
287
288
  end
288
- puts course_info.to_yaml
289
+ puts course_info.to_yaml if !options[:urls_only]
289
290
  end
290
291
 
291
292
  def self.csv(file_to_convert)
@@ -61,12 +61,13 @@ class GithubInterface
61
61
  rescue
62
62
  begin
63
63
  response = RestClient.get(url_fallback)
64
+ return response.body
64
65
  rescue
65
66
  puts 'Error reading ' + url
66
67
  end
67
68
  end
68
69
 
69
- response.body
70
+
70
71
  end
71
72
 
72
73
  def self.save_to_github(filepath, branch)
@@ -26,7 +26,11 @@ class RepositoryConverter
26
26
  def self.remote_file_conversion(options)
27
27
  markdown = GithubInterface.read_remote(options[:filepath])
28
28
  raw_remote_url = self.set_raw_image_remote_url(options[:filepath])
29
- markdown = self.escape_existing_html(markdown) if options[:contains_html]
29
+ if options[:contains_html]
30
+ puts "Contains HTML"
31
+ puts options[:contains_html]
32
+ markdown = self.escape_existing_html(markdown)
33
+ end
30
34
  markdown = self.fix_local_images(options, markdown, raw_remote_url)
31
35
  html = self.convert_to_html(markdown)
32
36
  # self.fix_local_html_links(options, html, options[:filepath])
@@ -48,7 +52,9 @@ class RepositoryConverter
48
52
  html = self.add_fis_links(options, html)
49
53
  end
50
54
 
51
- html = self.fix_escaped_inline_html_code(html)
55
+ if options[:contains_html]
56
+ html = self.fix_escaped_inline_html_code(html)
57
+ end
52
58
 
53
59
  html
54
60
  end
@@ -1,3 +1,3 @@
1
1
  class GithubToCanvas
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxwellbenton