class ChidConfig
Attributes
chid_config_path[R]
chid_path[R]
home_path[R]
Public Class Methods
new(home_base_path: "~/")
click to toggle source
# File lib/chid/chid_config.rb, line 5 def initialize(home_base_path: "~/") @chid_path = Dir.pwd @home_path = File.expand_path(home_base_path) @chid_config_path = File.join(home_path, '.chid.config') end
on_linux() { || ... }
click to toggle source
# File lib/chid/chid_config.rb, line 16 def self.on_linux if platform =~ /Linux/ yield end end
on_osx() { || ... }
click to toggle source
# File lib/chid/chid_config.rb, line 22 def self.on_osx if platform =~ /Darwin/ yield end end
platform()
click to toggle source
# File lib/chid/chid_config.rb, line 28 def self.platform %x{echo $(uname -s)}.strip end
username()
click to toggle source
# File lib/chid/chid_config.rb, line 11 def self.username on_linux { return %x[echo $USER].strip } on_osx { return %x[echo $(logname)].strip } end
Public Instance Methods
all_tmux_templates()
click to toggle source
# File lib/chid/chid_config.rb, line 37 def all_tmux_templates data = YAML.load_file chid_config_path data[:chid][:tmux_templates] end
all_workstations()
click to toggle source
# File lib/chid/chid_config.rb, line 32 def all_workstations data = YAML.load_file chid_config_path data[:chid][:workstations] end
create_workstation(name, apps = [])
click to toggle source
# File lib/chid/chid_config.rb, line 54 def create_workstation(name, apps = []) data = YAML.load_file chid_config_path data[:chid][:workstations][:"#{name}"] = apps File.open(chid_config_path, 'w') do |file| YAML.dump(data, file) end end
destroy_workstations(workstations = [])
click to toggle source
# File lib/chid/chid_config.rb, line 42 def destroy_workstations(workstations = []) data = YAML.load_file chid_config_path workstations.each do |w| data[:chid][:workstations].delete_if { |key, value| key == w } end File.open(chid_config_path, 'w') do |file| YAML.dump(data, file) end end