Class: ET::Lesson
- Inherits:
-
Object
- Object
- ET::Lesson
- Defined in:
- lib/et/lesson.rb
Instance Attribute Summary collapse
-
#cwd ⇒ Object
readonly
Returns the value of attribute cwd.
Instance Method Summary collapse
- #archive! ⇒ Object
- #dir ⇒ Object
- #exists? ⇒ Boolean
- #ignored_files ⇒ Object
-
#initialize(cwd) ⇒ Lesson
constructor
A new instance of Lesson.
- #slug ⇒ Object
Constructor Details
#initialize(cwd) ⇒ Lesson
Returns a new instance of Lesson.
8 9 10 |
# File 'lib/et/lesson.rb', line 8 def initialize(cwd) @cwd = cwd end |
Instance Attribute Details
#cwd ⇒ Object (readonly)
Returns the value of attribute cwd.
6 7 8 |
# File 'lib/et/lesson.rb', line 6 def cwd @cwd end |
Instance Method Details
#archive! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/et/lesson.rb', line 12 def archive! if exists? filepath = random_archive_path cmd = "tar zcf #{filepath} -C #{dir}" ignored_files.each do |file| cmd += " --exclude='#{file}'" end cmd += " ." if system(cmd) filepath else nil end else nil end end |
#dir ⇒ Object
34 35 36 |
# File 'lib/et/lesson.rb', line 34 def dir @dir ||= find_lesson_dir(cwd) end |
#exists? ⇒ Boolean
42 43 44 |
# File 'lib/et/lesson.rb', line 42 def exists? !dir.nil? end |
#ignored_files ⇒ Object
46 47 48 |
# File 'lib/et/lesson.rb', line 46 def ignored_files (config["ignore"] || []) + [".lesson.yml"] end |
#slug ⇒ Object
38 39 40 |
# File 'lib/et/lesson.rb', line 38 def slug File.basename(dir) end |