github-to-canvas 0.0.42 → 0.0.43

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: 2c38080e6c0827bce0491f53aaada600e08d92ebf0b7a2d61c6d363a460e42ef
4
- data.tar.gz: b1099325700aadcc9bb0e12115ac5a3c67992ce62ab62277a0aaebd638736319
3
+ metadata.gz: 6e37325db45799844237ba747240be9e85d677e9dc1289836c01205e51cd9f4f
4
+ data.tar.gz: cad741664204320b94a578ab4e617afd8c4b0e8e209c8ead9e8b91493d97b693
5
5
  SHA512:
6
- metadata.gz: ec29a4070f46afe5a7dd580ab24688d9f19dba943d2f93e4850278516eccd583cf41e9793228b77e488aa8ef491d6015634116648339c6f2f0a6fb8f1cb1b8ec
7
- data.tar.gz: 325b22cf79ef204466723ab79d638ce3c1790bdaf9a8e3485184200b6947d73b4d543fba55e8580591b794216483428faf997d3033a8b2ce128463bd495cd595
6
+ metadata.gz: 45753e9af5e7da01e1daccb8b89fe76d3edd6bda219cc47c6662d03e047e7ce323b0d2270fbc04120a2f7b57224f9eea31f3bade71a3a5d2fbddf4278f73dac2
7
+ data.tar.gz: 95c4ce9a722bd3ce2e8e4f9ec9ea933fbf92ad627f29719c02ce8fc7b547616baed012b26059d91b6e6d3df8d60b52b74f7b8587a7589237c80c740cda1f177f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # GitHub to Canvas Gem Test
1
+ # GitHub to Canvas Gem
2
2
 
3
3
  ## Introduction
4
4
 
@@ -1,8 +1,12 @@
1
1
  require 'yaml'
2
2
  class CanvasDotfile
3
3
 
4
+ def self.exists?
5
+ File.file?(".canvas")
6
+ end
7
+
4
8
  def self.update_or_create(filepath, response, course, type)
5
- if File.file?(".canvas")
9
+ if self.exists?
6
10
  if type == "assignment" || type == "discussion"
7
11
  canvas_data = self.update_assignment_data(response, course, type)
8
12
  else
@@ -22,11 +26,6 @@ class CanvasDotfile
22
26
  File.write("#{filepath}/.canvas", canvas_data.to_yaml)
23
27
  end
24
28
 
25
- def self.commit_canvas_dotfile(filepath)
26
- GithubInterface.git_add(filepath, '.canvas')
27
- GithubInterface.git_commit(filepath, 'AUTO: add .canvas file after migration')
28
- end
29
-
30
29
  def self.read_canvas_data
31
30
  if File.file?(".canvas")
32
31
  YAML.load(File.read(".canvas"))
@@ -114,7 +114,7 @@ class CanvasInterface
114
114
  })
115
115
  rescue
116
116
  puts "Something went wrong while pushing lesson #{id} to course #{course_id}"
117
- # abort
117
+ nil
118
118
  end
119
119
  end
120
120
 
@@ -18,15 +18,21 @@ class CreateCanvasLesson
18
18
  new_html = RepositoryConverter.add_fis_links(filepath, new_html)
19
19
  end
20
20
  response = CanvasInterface.submit_to_canvas(course, type, name, new_html)
21
+
22
+ puts 'Creating .canvas file'
23
+ CanvasDotfile.update_or_create(filepath, response, course, type)
24
+
25
+ puts "Canvas lesson created. Lesson available at #{response['html_url']}."
26
+
27
+ # If --save option is used, the .canvas file gets committed and pushed to the remote repo
21
28
  if save_to_github
22
- puts 'Creating .canvas file'
23
- CanvasDotfile.update_or_create(filepath, response, course, type)
29
+ puts 'Adding .canvas file'
30
+ GithubInterface.git_add(filepath, '.canvas')
24
31
  puts 'Commiting .canvas file'
25
- CanvasDotfile.commit_canvas_dotfile(filepath)
32
+ GithubInterface.git_commit(filepath, 'AUTO: add .canvas file after migration')
26
33
  puts 'Pushing .canvas file'
27
34
  GithubInterface.git_push(filepath, branch)
28
35
  end
29
- puts "Canvas lesson created. Lesson available at #{response['html_url']}."
30
36
  end
31
37
 
32
38
  end
@@ -12,25 +12,46 @@ class UpdateCanvasLesson
12
12
  end
13
13
 
14
14
  def update_canvas_lesson(course, markdown, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id)
15
+ # Pulls any updates that exist on GitHub
15
16
  GithubInterface.get_updated_repo(filepath, branch)
17
+
18
+ # Converts markdown to HTML
19
+ # Default is README.md. --file <FILENAME> can be used to override default.
16
20
  new_html = RepositoryConverter.convert(filepath, markdown, branch, remove_header_and_footer)
21
+
22
+ # adds Flatiron School specific header and footer
17
23
  if fis_links
18
- new_html = RepositoryConverter.add_fis_links(filepath, new_html) # adds Flatiron School specific header and footer
24
+ new_html = RepositoryConverter.add_fis_links(filepath, new_html)
19
25
  end
26
+
27
+ # Read the local .canvas file if --id <ID> is not used. Otherwise, use provided ID (--course <COURSE> also required)
20
28
  if !id
21
- # If no assignment or page ID is provided, tries to get info from a .canvas file
22
29
  canvas_data = CanvasDotfile.read_canvas_data
23
- canvas_data[:lessons].each { |lesson|
30
+ canvas_data[:lessons] = canvas_data[:lessons].map { |lesson|
24
31
  response = CanvasInterface.update_existing_lesson(lesson[:course_id], lesson[:id], lesson[:type], name, new_html, only_update_content)
25
- # puts "Canvas lesson created. Lesson available at #{response['html_url']}."
26
32
  }
27
33
  else
28
- # If an ID is provided, uses the ID instead of the .canvas file
34
+ # If an ID (and course) are provided, they are used instead of the .canvas file
35
+ # Gets the current lesson's type (page or assignment)
29
36
  info = CanvasInterface.get_lesson_info(course, id)
30
- CanvasInterface.update_existing_lesson(course, id, info[1], name, new_html, only_update_content)
37
+
38
+ # Implements update on Canvas
39
+ response = JSON.parse(CanvasInterface.update_existing_lesson(course, id, info[1], name, new_html, only_update_content))
40
+
41
+ # Updates or creates a local .canvas file
42
+ CanvasDotfile.update_or_create(filepath, response, course, info[1])
31
43
  end
44
+ # If --save option is used, the .canvas file gets committed and pushed to the remote repo
45
+ if save_to_github
46
+ puts 'Adding .canvas file'
47
+ GithubInterface.git_add(filepath, '.canvas')
48
+ puts 'Commiting .canvas file'
49
+ GithubInterface.git_commit(filepath, 'AUTO: add .canvas file after migration')
50
+ puts 'Pushing .canvas file'
51
+ GithubInterface.git_push(filepath, branch)
52
+ end
53
+
32
54
  end
33
-
34
55
 
35
56
 
36
57
  end
@@ -1,3 +1,3 @@
1
1
  class GithubToCanvas
2
- VERSION = "0.0.42"
2
+ VERSION = "0.0.43"
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.0.42
4
+ version: 0.0.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxwellbenton