Class: KiskoSuits::Application
- Inherits:
-
Object
- Object
- KiskoSuits::Application
- Defined in:
- lib/kisko-suits/application.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Application
constructor
A new instance of Application.
- #parse_options(argv) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Application
Returns a new instance of Application.
3 4 5 |
# File 'lib/kisko-suits/application.rb', line 3 def initialize(argv) @params, @files = (argv) end |
Instance Method Details
#parse_options(argv) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/kisko-suits/application.rb', line 27 def (argv) params = {} parser = OptionParser.new parser.on("-w") { params[:watch] = true } files = parser.parse(argv) [params, files] end |
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kisko-suits/application.rb', line 7 def run if @files.empty? || @files.size > 1 || !@files.first.include?(".suits") abort "Usage: 'kisko-suits my-presentation.md.suits'\n\nOr start watching file with: 'kisko-suits -w my-presentation.md.suits'" else if @params[:watch] on_update = ->(filename) { compiler = KiskoSuits::Compiler.new(@files.first) compiler.render puts "Processed files and compiled '#{compiler.output_filename}'" compiler.included_filenames } KiskoSuits::Watcher.new(@files.first, on_update).start else compiler = KiskoSuits::Compiler.new(@files.first) compiler.render puts "Processed files and compiled '#{compiler.output_filename}'" end end end |