Module: Sketches::Config

Defined in:
lib/sketches/config.rb

Constant Summary collapse

TMPDIR =

Directory to store temporary sketches in

Dir.tmpdir
EDITOR =

Default editor to use

ENV['EDITOR']
PAUSE =

Default pause between checking if sketches were modified

3
@@sketches_tmpdir =
TMPDIR
@@sketches_background =
false
@@sketches_eval_after_editor_quit =
false
@@sketches_terminal =
nil
@@sketches_editor =
EDITOR
@@sketches_pause =
PAUSE

Class Method Summary collapse

Class Method Details

.backgroundObject

Returns true if the editor shall be ran as a background or a foreground process, returns false otherwise.

Config.background
# => false


68
69
70
# File 'lib/sketches/config.rb', line 68

def Config.background
  @@sketches_background
end

.background=(mode) ⇒ Object

Sets the background mode to the specified mode.

Config.background = true


77
78
79
# File 'lib/sketches/config.rb', line 77

def Config.background=(mode)
  @@sketches_background = mode
end

.editorObject

Returns the current editor to use for editing sketches.

Config.editor
# => 'pico'


132
133
134
# File 'lib/sketches/config.rb', line 132

def Config.editor
  @@sketches_editor
end

.editor=(new_editor) ⇒ Object

Use the specified new_editor to edit sketches. new_editor may be either a String or a lambda which accepts the path of the sketch and returns the command to run.

Config.editor = 'gvim'

Config.editor = lambda { |path|
  "xterm -fg gray -bg black -e vim #{path} &"
}


147
148
149
# File 'lib/sketches/config.rb', line 147

def Config.editor=(new_editor)
  @@sketches_editor = new_editor
end

.eval_after_editor_quitObject

Returns true if the sketch is eval’d immediatly on editor quit (only if background = false)

Config.eval_after_editor_quit
# => false


88
89
90
# File 'lib/sketches/config.rb', line 88

def Config.eval_after_editor_quit
  @@sketches_eval_after_editor_quit
end

.eval_after_editor_quit=(mode) ⇒ Object

When background is false, can eval immediately after editor quits.

Config.eval_after_editor_quit = true


97
98
99
# File 'lib/sketches/config.rb', line 97

def Config.eval_after_editor_quit=(mode)
  @@sketches_eval_after_editor_quit = mode
end

.pauseObject

Returns the current number of seconds to pause in between checking if any sketches were modified.

Config.pause
# => 3


158
159
160
# File 'lib/sketches/config.rb', line 158

def Config.pause
  @@sketches_pause
end

.pause=(seconds) ⇒ Object

Use the specified number of seconds to pause in between checking if any sketches were modified.

Config.pause = 2


168
169
170
# File 'lib/sketches/config.rb', line 168

def Config.pause=(seconds)
  @@sketches_pause = seconds
end

.terminalObject

Returns the terminal to optionally run the editor within.

Config.terminal
# => "xterm"


107
108
109
# File 'lib/sketches/config.rb', line 107

def Config.terminal
  @@sketches_terminal
end

.terminal=(new_term) ⇒ Object

Sets the terminal to optionally run the editor within to the specified new_term. new_term may either be a String or a Proc.

Config.terminal = 'gnome-terminal'

Config.terminal = lambda { |cmd|
  "xterm -fg gray -bg black -e #{cmd.dump} &"
}


122
123
124
# File 'lib/sketches/config.rb', line 122

def Config.terminal=(new_term)
  @@sketches_terminal = new_term
end

.tmpdirObject

Returns the directory to store temporary sketches in.

Config.tmpdir
# => "/tmp"


49
50
51
# File 'lib/sketches/config.rb', line 49

def Config.tmpdir
  @@sketches_tmpdir
end

.tmpdir=(directory) ⇒ Object

Sets the directory to store temporary sketches in to the specified directory.



57
58
59
# File 'lib/sketches/config.rb', line 57

def Config.tmpdir=(directory)
  @@sketches_tmpdir = File.expand_path(directory)
end