github-to-canvas 0.0.58 → 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.
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ require 'byebug'
4
+
2
5
  require 'optparse'
3
6
  require 'github-to-canvas'
7
+
4
8
  options = {}
5
9
  OptionParser.new do |opts|
6
10
  opts.banner = <<-EOBANNER
@@ -29,23 +33,40 @@ OptionParser.new do |opts|
29
33
  Run these commands from inside a local GitHub repository. This gem is built for Flatiron School's internal use.
30
34
  Some default behaviors assume this, like the default Canvas API path.
31
35
 
32
- Example usage:
36
+ Create and Update Canvas Lessons From Inside a Local GitHub Repo Folder:
37
+
38
+ github-to-canvas --create-lesson 154 -> Creates a lesson in course 154, derives the name and type from the local repo
39
+ github-to-canvas --create-lesson 154 --name "Fetch Lab" -> Creates a lesson in course 154 with the provided name, derives the type from the local repo
40
+ github-to-canvas --create-lesson 154 --name "Fetch Lab" --type assignment -> Creates an assignment in course 154 with the provided name
41
+ github-to-canvas --create-lesson 154 --name "Fetch Lab" --branch solution -> Creates a lesson in course 154 with the provided name, uses the repository's solution branch and derives the type from the local repo
42
+ github-to-canvas --align -> Patches existing lessons in Canvas based on the .canvas file
43
+ github-to-canvas --align --fis-links -> Patches existing lessons in Canvas based on the .canvas file, adds additional Flatiron School specific HTML and meta-data
44
+ github-to-canvas --align --remove-header-and-footer -> Patches existing lessons in Canvas based on the .canvas file, removes top lesson header before converting to HTML
45
+
46
+ Get Info on a Canvas Course, Lesson or GitHub Repo:
47
+
48
+ github-to-canvas --query COURSE -> Displays a course's modules and their lessons in course order as YAML
49
+ github-to-canvas --map YAML -> Uses a YAML file created with --query to retrieve repositories that were associated with Canvas lessons using --fis-links. Returns an updated YAML.
50
+ github-to-canvas --read-from-canvas CANVAS_LESSON_URL -> Retrieves a lesson's contents and information from Canvas
51
+ github-to-canvas --read-from-github GITHUB_URL -> Retrieves the provided GitHub markdown file, converted into HTML
52
+
53
+ Create and Update Canvas Lessons Using Remote GitHub Repositories:
33
54
 
34
- github-to-canvas --create-lesson 154 -> Creates a lesson in course 154, derives the name and type from the local repo
35
- github-to-canvas --create-lesson 154 --name "Fetch Lab" -> Creates a lesson in course 154 with the provided name, derives the type from the local repo
36
- github-to-canvas --create-lesson 154 --name "Fetch Lab" --type assignment -> Creates an assignment in course 154 with the provided name
37
- github-to-canvas --create-lesson 154 --name "Fetch Lab" --branch solution -> Creates a lesson in course 154 with the provided name, uses the repository's solution branch and derives the type from the local repo
38
- github-to-canvas --align -> Patches existing lessons in Canvas based on the .canvas file
39
- github-to-canvas --align --fis-links -> Patches existing lessons in Canvas based on the .canvas file, adds additional Flatiron School specific HTML and meta-data
40
- github-to-canvas --align --remove-header-and-footer -> Patches existing lessons in Canvas based on the .canvas file, removes top lesson header before converting to HTML
41
- github-to-canvas --info COURSE -> Displays a course's lesson and assignment names
55
+ github-to-canvas --create-from-github GITHUB_URL --course COURSE_ID --type TYPE -> Creates a lesson in the provided course using the remote GitHub URL. Source must be from a public repo.
56
+ github-to-canvas --align-from-github GITHUB_URL --course COURSE_ID --id LESSON_ID --type TYPE -> Updates a lesson in the provided course using the remote GitHub URL. Source must be from a public repo.
57
+
58
+ Create and Update Canvas Courses From YAML:
59
+
60
+ github-to-canvas --build-course YAML_FILE -> Uses the provided YAML file to create a course, add modules and populate them with lessons using remote GitHub repositories
61
+ github-to-canvas --add-to-course YAML_FILE --course -> Uses a YAML file to a modules and lessons to an existing course.
62
+ github-to-canvas --update-course YAML_FILE -> Uses a YAML file to update lessons using their associated GitHub repositories (ignores module/course structure in YAML file)
42
63
 
43
64
  EOBANNER
44
65
 
45
66
  opts.on("-cCOURSE", "--create-lesson COURSE",
46
67
  "Creates a new canvas lesson, converting the local repository's README.md to HTML. Adds .canvas file to remote repository") do |course|
47
68
  options[:create_lesson] = true
48
- options[:course] = course
69
+ options[:course_id] = course
49
70
  end
50
71
  opts.on("-bBRANCH", "--branch BRANCH",
51
72
  "Sets the repository branch used for lesson creation") do |branch|
@@ -57,12 +78,15 @@ OptionParser.new do |opts|
57
78
  end
58
79
  opts.on("-tTYPE", "--type TYPE",
59
80
  "Sets the type Canvas lesson to be created (page or assignment). If no type, type decided based on repository structure") do |type|
60
- if type == 'page' || type == 'assignment' || type == 'discussion'
61
- options[:type] = type
62
- else
63
- puts "Invalid type. Defaulting to page"
64
- options[:type] = "page"
65
- end
81
+ # byebug
82
+ options[:type] = type.downcase
83
+ abort if type == 'quiz' || type == 'discussion'
84
+ # if type == 'page' || type == 'assignment' || type == 'discussion' || type == 'quiz' || type == 'Page' || type == 'Assignment' || type == 'Discussion' || type == 'Quiz'
85
+
86
+ # else
87
+ # puts "Invalid type. Defaulting to page"
88
+ # options[:type] = "page"
89
+ # end
66
90
  end
67
91
  opts.on("-fFILE", "--file FILE",
68
92
  "Looks for and uses a markdown file in the currentt folder as source for conversion. Default file is README.md. Skips writing .canvas to repository") do |file|
@@ -84,6 +108,10 @@ OptionParser.new do |opts|
84
108
  "Adds additional Flatiron School HTML after markdown conversion") do |f|
85
109
  options[:fis] = true
86
110
  end
111
+ opts.on("--aaq",
112
+ "Adds AAQ flag to HTML header appended with --fis-links") do |aaq|
113
+ options[:aaq] = aaq
114
+ end
87
115
  opts.on("--forkable",
88
116
  "Used with --fis-links, adds fork button to HTML header injected into Canvas lesson") do |remote|
89
117
  options[:forkable] = true
@@ -93,8 +121,8 @@ OptionParser.new do |opts|
93
121
  options[:remove_header_and_footer] = true
94
122
  end
95
123
  opts.on("--course COURSE",
96
- "For align functionality only - updates the HTML content of a lesson using the provided course ID. Use with --id.") do |course|
97
- options[:course] = course
124
+ "For align functionality only - updates the HTML content of a lesson using the provided course ID. Use with --id.") do |course_id|
125
+ options[:course_id] = course_id
98
126
  end
99
127
  opts.on("--id ID",
100
128
  "For align functionality only - updates the HTML content of a lesson using the provided assignment or page ID. Use with --course.") do |id|
@@ -108,28 +136,178 @@ OptionParser.new do |opts|
108
136
  "Displays a course's lessons and assignments") do |course|
109
137
  options[:query] = course
110
138
  end
111
- opts.on("--remote",
112
- "Retrieves a Canvas lesson. Requires --course and --id") do |remote|
113
- options[:remote] = true
139
+ opts.on("--map YAML_FILE",
140
+ "REQUIRES -f or --file Associates canvas lessons with repositories. Use query to create required YAML file") do |file|
141
+ options[:map] = file
142
+ end
143
+ opts.on("--urls-only",
144
+ "Use with --map. Outputs repo URLs instead of YAML") do |urls|
145
+ options[:urls_only] = urls
146
+ end
147
+ # opts.on("--csv COURSE",
148
+ # "Returns a course's lesson struction as CSV") do |course|
149
+ # options[:csv] = course
150
+ # end
151
+ opts.on("--read-from-canvas CANVAS_URL",
152
+ "Retrieves an existing Canvas lesson using the provided URL") do |url|
153
+ options[:read_from_canvas] = url
154
+ end
155
+ opts.on("--read-from-github GITHUB_URL",
156
+ "Converts an existing GitHub Readme to HTML using the provided URL. URL must be for a GitHub markdown file") do |url|
157
+ options[:read_from_github] = url
158
+ end
159
+ opts.on("--create-from-github GITHUB_URL",
160
+ "Creates a new Canvas lesson from a remote GitHub Readme. --course and --type options required") do |url|
161
+ options[:create_from_github] = url
162
+ end
163
+ # opts.on("--create-quiz-from-github GITHUB_URL",
164
+ # "Creates a new Canvas quiz from a remote GitHub YAML file. --course option required") do |url|
165
+ # options[:quiz_from_github] = url
166
+ # end
167
+ opts.on("--align-from-github GITHUB_URL",
168
+ "Aligns an existing Canvas lesson using a remote GitHub Readme. --course, --id, and --type options required") do |url|
169
+ options[:align_from_github] = url
170
+ end
171
+ opts.on("--build-course YAML_FILE",
172
+ "Creates Canvas course using provided YAML file") do |file|
173
+ options[:build_course] = file
174
+ end
175
+ opts.on("--add-to-course YAML_FILE",
176
+ "Creates Canvas course using provided YAML file") do |file|
177
+ options[:add_to_course] = file
178
+ end
179
+ opts.on("--update-course-lessons YAML_FILE",
180
+ "Updates all lessons in a course using remote repos in provided YAML file") do |file|
181
+ options[:update_course_lessons] = file
182
+ end
183
+ opts.on("--clone-from-yaml YAML_FILE",
184
+ "Iterates over provided course YAML file and clones repos locally") do |file|
185
+ options[:clone_from_yaml] = file
186
+ end
187
+ opts.on("--contains-html",
188
+ "Escapes all HTML included in source markdown by replacing '<' and '>' with HTML charset values") do |html|
189
+ options[:contains_html] = html
114
190
  end
115
-
116
191
 
117
192
  end.parse!
118
193
 
119
194
  if options[:version]
120
- GithubToCanvas.new(mode: 'version', course: nil)
195
+ GithubToCanvas.new(mode: 'version', course_id: nil)
196
+ abort
197
+ end
198
+
199
+ if options[:read_from_canvas]
200
+ GithubToCanvas.new(mode: 'canvas_read',
201
+ filepath: options[:read_from_canvas])
202
+ abort
203
+ end
204
+
205
+ if options[:read_from_github]
206
+ GithubToCanvas.new(mode: 'github_read',
207
+ filepath: options[:read_from_github],
208
+ remove_header_and_footer: !!options[:remove_header_and_footer],
209
+ forkable: !!options[:forkable],
210
+ fis_links: !!options[:fis],
211
+ aaq: !!options[:aaq],
212
+ contains_html: options[:contains_html])
213
+ abort
214
+ end
215
+
216
+ if options[:create_from_github]
217
+ if options[:course_id] && options[:type]
218
+ GithubToCanvas.new(mode: 'github_create',
219
+ filepath: options[:create_from_github],
220
+ course_id: options[:course_id],
221
+ type: options[:type],
222
+ name: options[:name],
223
+ remove_header_and_footer: !!options[:remove_header_and_footer],
224
+ forkable: !!options[:forkable],
225
+ fis_links: !!options[:fis],
226
+ aaq: !!options[:aaq],
227
+ contains_html: options[:contains_html])
228
+ else
229
+ puts 'Canvas course ID and lesson type required. Example: github-to-canvas --create-from-github URL --course ID --type TYPE'
230
+ end
231
+ abort
232
+ end
233
+
234
+ if options[:align_from_github]
235
+ if options[:course_id] && options[:type] && options[:id]
236
+ GithubToCanvas.new(mode: 'github_align',
237
+ filepath: options[:align_from_github],
238
+ course_id: options[:course_id],
239
+ type: options[:type],
240
+ id: options[:id],
241
+ name: options[:name],
242
+ remove_header_and_footer: !!options[:remove_header_and_footer],
243
+ forkable: !!options[:forkable],
244
+ fis_links: !!options[:fis],
245
+ aaq: !!options[:aaq],
246
+ contains_html: options[:contains_html])
247
+ else
248
+ puts 'Canvas course ID, lesson ID, and type required. Example: github-to-canvas --create-from-github URL --course COURSE_ID --id LESSON_ID --type TYPE'
249
+ end
250
+ abort
121
251
  end
122
252
 
123
253
  if options[:query]
124
- GithubToCanvas.new(mode: 'query', course: options[:query], id: options[:id])
254
+ GithubToCanvas.new(mode: 'query', course_id: options[:query], id: options[:id])
255
+ abort
256
+ end
257
+
258
+ if options[:map]
259
+ GithubToCanvas.new(mode: 'map',
260
+ file_to_convert: options[:map],
261
+ urls_only: !!options[:urls_only])
262
+ abort
263
+ end
264
+
265
+ if options[:csv]
266
+ GithubToCanvas.new(mode: 'csv', file_to_convert: options[:csv])
267
+ abort
268
+ end
269
+
270
+ if options[:build_course]
271
+ GithubToCanvas.new(mode: 'build_course',
272
+ file_to_convert: options[:build_course],
273
+ fis_links: !!options[:fis],
274
+ remove_header_and_footer: !!options[:remove_header_and_footer],
275
+ aaq: !!options[:aaq],
276
+ forkable: !!options[:forkable])
277
+ abort
125
278
  end
126
279
 
127
- if options[:remote]
128
- if !options[:course] || !options[:id]
129
- puts "Both --course and --id required when using --remote"
130
- abort
280
+ if options[:add_to_course]
281
+ if options[:course_id]
282
+ GithubToCanvas.new(mode: 'add_to_course',
283
+ course_id: options[:course_id],
284
+ file_to_convert: options[:add_to_course],
285
+ fis_links: !!options[:fis],
286
+ remove_header_and_footer: !!options[:remove_header_and_footer],
287
+ forkable: !!options[:forkable],
288
+ aaq: !!options[:aaq],
289
+ contains_html: options[:contains_html])
290
+ else
291
+ puts '--course required'
131
292
  end
132
- GithubToCanvas.new(mode: 'remote', course: options[:course], id: options[:id])
293
+ abort
294
+ end
295
+
296
+ if options[:update_course_lessons]
297
+ GithubToCanvas.new(mode: 'update_course_lessons',
298
+ file_to_convert: options[:update_course_lessons],
299
+ fis_links: !!options[:fis],
300
+ remove_header_and_footer: !!options[:remove_header_and_footer],
301
+ forkable: !!options[:forkable],
302
+ aaq: !!options[:aaq],
303
+ contains_html: options[:contains_html])
304
+ abort
305
+ end
306
+
307
+ if options[:clone_from_yaml]
308
+ GithubToCanvas.new(mode: 'clone_course',
309
+ file_to_convert: options[:clone_from_yaml])
310
+ abort
133
311
  end
134
312
 
135
313
  if !options[:type]
@@ -174,7 +352,7 @@ end
174
352
 
175
353
  if options[:create_lesson]
176
354
  GithubToCanvas.new(mode: "create",
177
- course: options[:course],
355
+ course_id: options[:course_id],
178
356
  filepath: Dir.pwd,
179
357
  file_to_convert: options[:file_to_convert],
180
358
  branch: options[:branch],
@@ -184,12 +362,14 @@ if options[:create_lesson]
184
362
  fis_links: !!options[:fis],
185
363
  remove_header_and_footer: !!options[:remove_header_and_footer],
186
364
  only_update_content: !!options[:only_content],
187
- forkable: !!options[:forkable])
365
+ forkable: !!options[:forkable],
366
+ aaq: !!options[:aaq],
367
+ contains_html: options[:contains_html])
188
368
  end
189
369
 
190
370
  if options[:align]
191
371
  GithubToCanvas.new(mode: "align",
192
- course: options[:course],
372
+ course_id: options[:course_id],
193
373
  id: options[:id],
194
374
  filepath: Dir.pwd,
195
375
  file_to_convert: options[:file_to_convert],
@@ -200,5 +380,7 @@ if options[:align]
200
380
  fis_links: !!options[:fis],
201
381
  remove_header_and_footer: !!options[:remove_header_and_footer],
202
382
  only_update_content: !!options[:only_content],
203
- forkable: !!options[:forkable])
383
+ forkable: !!options[:forkable],
384
+ aaq: !!options[:aaq],
385
+ contains_html: options[:contains_html])
204
386
  end
@@ -1,56 +1,160 @@
1
+ require 'byebug'
1
2
  require_relative './github-to-canvas/create_canvas_lesson'
2
3
  require_relative './github-to-canvas/update_canvas_lesson'
4
+ require_relative './github-to-canvas/canvas_dotfile'
5
+ require_relative './github-to-canvas/repository_interface'
3
6
  require_relative './github-to-canvas/repository_converter'
4
7
  require_relative './github-to-canvas/github_interface'
5
8
  require_relative './github-to-canvas/canvas_interface'
6
- require_relative './github-to-canvas/canvas_dotfile'
9
+ require_relative './github-to-canvas/course_creation_interface'
10
+
7
11
  require_relative './github-to-canvas/version'
8
12
 
13
+ require 'yaml'
14
+
9
15
  class GithubToCanvas
10
16
 
11
- def initialize(mode:,
12
- course:nil,
13
- id:nil,
14
- filepath:Dir.pwd,
15
- file_to_convert:'README.md',
16
- branch:'master',
17
- name:File.basename(Dir.getwd),
18
- type:"page",
19
- save_to_github:false,
20
- fis_links:false,
21
- remove_header_and_footer:false,
22
- only_update_content: false,
23
- forkable: false)
24
-
25
- if mode == 'version'
17
+ def initialize(options)
18
+ case options[:mode]
19
+ when 'version'
26
20
  puts VERSION
27
- end
28
-
29
- if mode == 'query'
30
- CanvasInterface.get_course_info(course, id)
31
- end
32
-
33
- if mode == 'remote'
34
- lesson_data = CanvasInterface.get_lesson_info(course, id)
35
- if !lesson_data[1]
36
- puts "No lesson with id #{id} was found in course #{course}."
37
- else
38
- pp lesson_data[0]
39
- puts "\nLesson Type: #{lesson_data[1]}"
40
- end
21
+ when 'query'
22
+ CanvasInterface.get_course_info(options[:course_id], options[:id])
23
+ when 'map'
24
+ CanvasInterface.map_course_info(options)
25
+ when 'csv'
26
+ CanvasInterface.csv(options[:file_to_convert])
27
+ when 'canvas_read'
28
+ puts CanvasInterface.read_lesson(options[:filepath])
29
+ when 'github_read'
30
+ html = RepositoryConverter.remote_file_conversion(options)
31
+ puts RepositoryConverter.adjust_converted_html(options, html)
32
+ when 'create' # used with a local repo
33
+ html = RepositoryConverter.local_file_conversion(options)
34
+ name = RepositoryInterface.get_name(options[:filepath], html)
35
+ html = RepositoryConverter.adjust_converted_html(options, html)
36
+ response = CanvasInterface.create_lesson(options, name, html)
37
+ RepositoryInterface.local_repo_post_submission(options, response)
38
+ puts "Canvas lesson created. Lesson available at #{response['html_url']}"
39
+ when 'align' # used with a local repo
40
+ html = RepositoryConverter.local_file_conversion(options)
41
+ name = options[:name] ? options[:name] : RepositoryInterface.get_name(options[:filepath], html)
42
+ html = RepositoryConverter.adjust_converted_html(options, html)
43
+ CanvasInterface.update_all_related_lessons(options, name, html)
41
44
 
45
+ when 'github_create'
46
+ html = RepositoryConverter.remote_file_conversion(options)
47
+ name = options[:name] ? options[:name] : RepositoryInterface.get_name(options[:filepath], html)
48
+ html = RepositoryConverter.adjust_converted_html(options, html)
42
49
 
43
- end
50
+ response = CanvasInterface.create_lesson(options, name, html)
51
+
52
+ puts "Canvas lesson created. Lesson available at #{response['html_url']}"
53
+ when 'github_align'
54
+ html = RepositoryConverter.remote_file_conversion(options)
55
+ name = options[:name] ? options[:name] : RepositoryInterface.get_name(options[:filepath], html)
56
+ html = RepositoryConverter.adjust_converted_html(options, html)
57
+ response = CanvasInterface.update_existing_lesson(options, name, html)
58
+ puts "Canvas lesson updated. Lesson available at #{response['html_url']}"
59
+ when 'build_course'
60
+ course_yaml = YAML.load(File.read(options[:file_to_convert]))
61
+ # Create Course
62
+ created_course_info = CanvasInterface.create_course(course_yaml)
63
+ puts "Course created - #{created_course_info["id"]}"
44
64
 
45
- if mode == 'create'
46
- puts "github-to-canvas will now create a Canvas lesson based on the current repo"
47
- CreateCanvasLesson.new(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, forkable)
48
- end
65
+ course_yaml[:modules].each { |module_info|
66
+ # Create each module
67
+ created_module_info = CanvasInterface.create_module(created_course_info["id"], module_info)
68
+ puts "Module created - #{created_module_info['name']}"
69
+ module_info[:lessons].each { |lesson|
70
+ # Create each lesson
71
+ options[:type] = lesson["type"].downcase
72
+ options[:course_id] = created_course_info["id"]
73
+ options[:filepath] = lesson["repository"]
74
+
75
+ html = RepositoryConverter.remote_file_conversion(options)
76
+ # Add each lesson to it's module
77
+ html = RepositoryConverter.adjust_converted_html(options, html)
78
+ created_lesson_info = CanvasInterface.create_lesson(options, lesson["title"], html)
79
+ lesson = lesson.merge(created_lesson_info)
80
+
81
+ lesson["page_url"] = lesson["url"] if !lesson["page_url"]
82
+
83
+ response = CanvasInterface.add_to_module(created_course_info["id"], created_module_info, lesson)
84
+
85
+ puts "Lesson added to #{created_module_info['name']} - #{lesson['title']}"
86
+ sleep(1)
87
+ }
88
+ }
89
+ when 'add_to_course'
90
+ course_yaml = YAML.load(File.read(options[:file_to_convert]))
49
91
 
50
- if mode == 'align'
51
- puts "github-to-canvas will now align any existing Canvas lessons based on the current repo. NOTE: .canvas file must be present"
52
- UpdateCanvasLesson.new(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id, forkable)
92
+ course_yaml[:modules].each { |module_info|
93
+ # Create each module
94
+ created_module_info = CanvasInterface.create_module(options[:course_id], module_info)
95
+ puts "Module created - #{created_module_info['name']}"
96
+ module_info[:lessons].each { |lesson|
97
+ # Create each lesson
98
+
99
+ options[:type] = lesson["type"].downcase
100
+ options[:filepath] = lesson["repository"]
101
+ html = RepositoryConverter.remote_file_conversion(options)
102
+ # Add each lesson to it's module
103
+ html = RepositoryConverter.adjust_converted_html(options, html)
104
+ created_lesson_info = CanvasInterface.create_lesson(options, lesson["title"], html)
105
+ lesson = lesson.merge(created_lesson_info)
106
+ response = CanvasInterface.add_to_module(options[:course_id], created_module_info, lesson)
107
+
108
+ puts "Lesson added to #{created_module_info['name']} - #{lesson['title']}"
109
+ sleep(1)
110
+ }
111
+ }
112
+ when 'update_course_lessons'
113
+ course_yaml = YAML.load(File.read(options[:file_to_convert]))
114
+ options[:course_id] = course_yaml[:id]
115
+ course_yaml[:modules].each { |module_info|
116
+ puts "Updating #{module_info[:name]}"
117
+ module_info[:lessons].each { |lesson|
118
+ if lesson["repository"] == ""
119
+ puts "No repository found for #{lesson['title']}"
120
+ next
121
+ end
122
+ options[:id] = lesson['id']
123
+ options[:type] = lesson["type"].downcase
124
+ options[:filepath] = lesson["repository"]
125
+ options[:branch] = 'master'
126
+ html = RepositoryConverter.remote_file_conversion(options)
127
+
128
+ html = RepositoryConverter.adjust_converted_html(options, html)
129
+ created_lesson_info = CanvasInterface.update_existing_lesson(options, lesson["title"], html)
130
+ lesson = lesson.merge(created_lesson_info)
131
+
132
+
133
+ puts "Lesson updated - #{lesson['title']}"
134
+ sleep(1)
135
+ }
136
+ }
137
+ when 'clone_course'
138
+ course_yaml = YAML.load(File.read(options[:file_to_convert]))
139
+ new_dir = "#{course_yaml[:name].downcase.gsub(' ','-')}"
140
+ cmd = "mkdir #{new_dir}"
141
+ `#{cmd}`
142
+ course_yaml[:modules].each { |module_info|
143
+ puts "Cloning #{module_info[:name]}"
144
+ module_info[:lessons].each { |lesson|
145
+ if lesson["repository"] == ""
146
+ puts "No repository found for #{lesson['title']}"
147
+ next
148
+ else
149
+ cmd = "git clone #{lesson['repository']}"
150
+ puts cmd
151
+ GithubInterface.cd_into_and(new_dir, cmd)
152
+ end
153
+ }
154
+ }
155
+ else
156
+ puts VERSION
53
157
  end
54
158
  end
55
-
159
+
56
160
  end