Class: Hexlet::TeacherCLI
Constant Summary
Constants inherited
from BaseCLI
BaseCLI::CONFIG_DIR, BaseCLI::CREDENTIALS_FILE
Instance Method Summary
collapse
Methods inherited from BaseCLI
#login
Instance Method Details
#init(lesson_name) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/hexlet/teacher_cli.rb', line 4
def init(lesson_name)
folder = "#{lesson_name}_lesson"
FileUtils.mkdir(folder)
template_folder = File.join(File.dirname(__FILE__), "templates", "lesson", ".")
FileUtils.cp_r(template_folder, folder)
puts (t "lesson_folder_created", folder: folder)
true
end
|
#submit(path) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/hexlet/teacher_cli.rb', line 15
def submit(path)
expanded_path = File.expand_path(path)
lesson_folder = File.split(expanded_path)[1]
parts = lesson_folder.split("_")
if parts.last != "lesson"
puts (t "wrong_lesson_folder")
return false
end
slug = parts[0, parts.size - 1].join("_")
filepath = generate_lesson_tarball(expanded_path)
client = build_client
result = client.submit slug, filepath
if result
puts (t :created)
true
else
puts (t :error)
false
end
end
|