Class: LessonsIndexer::Indexer
- Includes:
- Addons::FileManager, Addons::GitManager
- Defined in:
- lib/lessons_indexer/indexer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #add_headings(course) ⇒ Object
- #build_index(course) ⇒ Object
- #do_work! ⇒ Object
- #generate_files(course) ⇒ Object
- #generate_pdfs(course) ⇒ Object
- #get_course_dir ⇒ Object
-
#initialize(options) ⇒ Indexer
constructor
A new instance of Indexer.
Constructor Details
#initialize(options) ⇒ Indexer
Returns a new instance of Indexer.
8 9 10 |
# File 'lib/lessons_indexer/indexer.rb', line 8 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/lessons_indexer/indexer.rb', line 6 def @options end |
Instance Method Details
#add_headings(course) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/lessons_indexer/indexer.rb', line 35 def add_headings(course) course.load_lessons! course.load_headings! (pou('heading.starting'), pou('heading.done', title: course.title)) do course.generate_headings { |heading_line, lesson_file| prepend!(heading_line, lesson_file) } end end |
#build_index(course) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/lessons_indexer/indexer.rb', line 28 def build_index(course) course.load_lessons! (pou('index.starting'), pou('index.done', title: course.title)) do write! course.generate_index, .output end end |
#do_work! ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/lessons_indexer/indexer.rb', line 12 def do_work! course = Course.new(get_course_dir, .headings_dir) generate_files(course) if .lessons.length > 0 build_index(course) unless .skip_index add_headings(course) if .headings generate_pdfs(course) if .pdf git_push! if .git end |
#generate_files(course) ⇒ Object
22 23 24 25 26 |
# File 'lib/lessons_indexer/indexer.rb', line 22 def generate_files(course) (pou('lessons.starting'), pou('lessons.done', title: course.title)) do course.generate_files(.lessons) end end |
#generate_pdfs(course) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/lessons_indexer/indexer.rb', line 43 def generate_pdfs(course) course.load_lessons! (pou('pdf.starting'), pou('pdf.done', title: course.title)) do course.generate_pdfs end end |
#get_course_dir ⇒ Object
50 51 52 53 54 |
# File 'lib/lessons_indexer/indexer.rb', line 50 def get_course_dir dir = Dir.entries('.').detect {|el| el =~ /_handouts\z/i} exit_msg(pou('errors.files_not_found')) if dir.nil? dir end |