class Victor::CLI::Commands::Render
Public Instance Methods
run()
click to toggle source
# File lib/victor/cli/commands/render.rb, line 23 def run if args['--watch'] watch { generate } else generate end end
Private Instance Methods
file_watcher()
click to toggle source
# File lib/victor/cli/commands/render.rb, line 55 def file_watcher @file_watcher ||= Filewatcher.new(ruby_file, immediate: true) end
generate()
click to toggle source
# File lib/victor/cli/commands/render.rb, line 33 def generate code = File.read ruby_file ruby_source = RubySource.new code, ruby_file ruby_source.evaluate ruby_source.template template if template if svg_file ruby_source.svg.save svg_file say "Saved #{svg_file}" else puts ruby_source.svg.render end end
ruby_file()
click to toggle source
# File lib/victor/cli/commands/render.rb, line 59 def ruby_file args["RUBY_FILE"] end
svg_file()
click to toggle source
# File lib/victor/cli/commands/render.rb, line 63 def svg_file args["SVG_FILE"] end
template()
click to toggle source
# File lib/victor/cli/commands/render.rb, line 67 def template args['--template'] end
watch() { || ... }
click to toggle source
# File lib/victor/cli/commands/render.rb, line 48 def watch say "Watching #{ruby_file} for changes" file_watcher.watch do |file, event| yield unless event == :deleted end end