Class: Xray::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/xray/config.rb

Constant Summary collapse

CONFIG_FILE =
".xrayconfig"

Instance Method Summary collapse

Instance Method Details

#config_fileObject



34
35
36
37
38
39
40
# File 'lib/xray/config.rb', line 34

def config_file
  if File.exist?("#{Dir.pwd}/#{CONFIG_FILE}")
    "#{Dir.pwd}/#{CONFIG_FILE}"
  else
    "#{Dir.home}/#{CONFIG_FILE}"
  end
end

#default_editorObject



10
11
12
13
14
15
# File 'lib/xray/config.rb', line 10

def default_editor
  ENV['GEM_EDITOR'] ||
    ENV['VISUAL'] ||
    ENV['EDITOR'] ||
    '/usr/local/bin/subl'
end

#editorObject



17
18
19
# File 'lib/xray/config.rb', line 17

def editor
  load_config[:editor]
end

#editor=(new_editor) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/xray/config.rb', line 21

def editor=(new_editor)
  if new_editor && new_editor != editor
    write_config(editor: new_editor)
    true
  else
    false
  end
end

#to_yamlObject



30
31
32
# File 'lib/xray/config.rb', line 30

def to_yaml
  {editor: editor}.to_yaml
end