lib/sketches/sketch.rb in sketches-0.1.0 vs lib/sketches/sketch.rb in sketches-0.1.1

- old
+ new

@@ -36,10 +36,13 @@ # Optional name of the sketch attr_accessor :name # Last modification time of the sketch attr_reader :mtime + + # command runner + RUNNER = Kernel.method(:system) # # Creates a new sketch object with the specified _id_ and the given # _options_. # @@ -83,11 +86,24 @@ cmd = Config.editor.call(@path) else cmd = "#{Config.editor} #{@path}" end - system(cmd) + if Config.terminal + if Config.terminal.kind_of?(Proc) + cmd = Config.terminal.call(cmd) + else + cmd = "#{Config.terminal} #{cmd}" + end + end + + if Config.background + Thread.new(cmd,&RUNNER) + else + RUNNER.call(cmd) + self.reload! if Config.eval_after_editor_quit + end end # # Returns +true+ if the sketch has become stale and needs reloading, # returns +false+ otherwise. @@ -138,10 +154,10 @@ def to_s(verbose=false) str = "##{@id}" str << ": #{@name}" if @name str << "\n\n" - if File.file?(@path) + if @path && File.file?(@path) File.open(@path) do |file| unless verbose 4.times do if file.eof? str << "\n" unless str[-1..-1] == "\n"