Module: MarkdownRecord::RenderingHelpers
- Defined in:
- lib/markdown_record/rendering/rendering.rb
Instance Method Summary collapse
- #generate_render_strategy_options(options) ⇒ Object
- #record_and_save(lines, text, color = nil) ⇒ Object
- #report_line_color(saved) ⇒ Object
- #report_rendered_files(lines, file_saver) ⇒ Object
- #report_start(lines, strategy_options, formats) ⇒ Object
- #validate ⇒ Object
Instance Method Details
#generate_render_strategy_options(options) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/markdown_record/rendering/rendering.rb', line 3 def () = if [:strat].present? ::MarkdownRecord.config.([:strat].to_sym) else ::MarkdownRecord.config. end .merge!(:save => [:save]) [:render_content_fragment_json] = [:frag] || ::MarkdownRecord.config.render_content_fragment_json end |
#record_and_save(lines, text, color = nil) ⇒ Object
44 45 46 47 |
# File 'lib/markdown_record/rendering/rendering.rb', line 44 def record_and_save(lines, text, color = nil) lines << text say text, color end |
#report_line_color(saved) ⇒ Object
40 41 42 |
# File 'lib/markdown_record/rendering/rendering.rb', line 40 def report_line_color(saved) color = saved ? :green : :yellow end |
#report_rendered_files(lines, file_saver) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/markdown_record/rendering/rendering.rb', line 16 def report_rendered_files(lines, file_saver) file_count = (file_saver.saved_files[:json].count + file_saver.saved_files[:html].count) record_and_save lines, "---------------------------------------------------------------" file_saver.saved_files[:json].each do |file_name| record_and_save lines, "rendered: #{file_name}", report_line_color([:save]) end file_saver.saved_files[:html].each do |file_name| record_and_save lines, "rendered: #{file_name}", report_line_color([:save]) end record_and_save lines, "---------------------------------------------------------------" record_and_save lines, "#{file_count} files rendered." record_and_save lines, "#{options[:save] ? file_count : 0} files saved." ::MarkdownRecord.config.rendered_content_root.join("rendered.txt").open('wb') do |file| file << lines.join("\n") end end |
#report_start(lines, strategy_options, formats) ⇒ Object
35 36 37 38 |
# File 'lib/markdown_record/rendering/rendering.rb', line 35 def report_start(lines, , formats) record_and_save lines, "---------------------------------------------------------------" record_and_save lines, "rendering #{formats} content with options #{strategy_options} ..." end |
#validate ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/markdown_record/rendering/rendering.rb', line 49 def validate MarkdownRecord::Validator.new.validate true rescue MarkdownRecord::Errors::Base => e say e., :red false end |