| VERSION | = | '0.1.1' | Sketches version |
Configure Sketches with the given options.
options may contain the following keys:
| :tmpdir: | Directory to store temporary sketches in. Defaults to Dir.tmpdir if unspecified. |
| :background: | Specifies wether to run the editor as a background or a foreground process. |
| :terminal: | The terminal to optionally run the editor within. |
| :editor: | The editor to use to edit sketches. |
| :pause: | The number of seconds to pause in-between checking if any sketches were modified. |
Sketches.config :editor => 'gvim', :pause => 2
Sketches.config :editor => 'vim',
:background => true,
:terminal => lambda { |cmd|
"xterm -fg gray -bg black -e #{cmd.dump}"
}
# File lib/sketches/sketches.rb, line 48 def Sketches.config(options={}) if options[:tmpdir] Config.tmpdir = options[:tmpdir] end if options[:background] Config.background = options[:background] end if options[:terminal] Config.terminal = options[:terminal] end if options[:editor] Config.editor = options[:editor] end if options[:pause] Config.pause = options[:pause] end return nil end
Print out all of the sketches.
# File lib/sketches/sketches.rb, line 145 def Sketches.print Sketches.cache.synchronize { puts Sketches.cache } end
Saves the sketch with the specified id_or_name to the specified path.
Sketches.save 2, 'path/to/example.rb' Sketches.save :foo, 'path/to/foo.rb'
# File lib/sketches/sketches.rb, line 134 def Sketches.save(id_or_name,path) Sketches.cache.synchronize do if (sketch = Sketches.cache[id_or_name]) sketch.save(path) end end end
Edits the sketch with the specified id_or_name. If no sketch exists with the specified id_or_name, one will be created.
Sketches.sketch 2 Sketches.sketch :foo
# File lib/sketches/sketches.rb, line 93 def Sketches.sketch(id_or_name) Sketches.cache.synchronize do sketch = Sketches.cache[id_or_name] sketch ||= Sketches.cache.new_sketch(id_or_name) sketch.synchronize { sketch.edit } end end