class Dotremap
Files which require this file can avoid deep nesting for class declaration
Constants
- VERSION
- XML_DIR
- XML_FILE_NAME
Attributes
config_path[R]
Public Class Methods
new(config_path)
click to toggle source
# File lib/dotremap.rb, line 11 def initialize(config_path) @config_path = config_path Dotremap::InvokeHistory.clear_histroy end
Public Instance Methods
apply_configuration()
click to toggle source
# File lib/dotremap.rb, line 17 def apply_configuration replace_private_xml Karabiner.reload_xml puts "Successfully updated Karabiner configuration" end
Private Instance Methods
new_xml()
click to toggle source
# File lib/dotremap.rb, line 33 def new_xml return @new_xml if defined?(@new_xml) validate_config_existence root = Root.new config = File.read(config_path) root.instance_eval(config) @new_xml = root.to_xml.gsub(/ *$/, "").concat("\n") end
replace_private_xml()
click to toggle source
# File lib/dotremap.rb, line 26 def replace_private_xml FileUtils.mkdir_p(XML_DIR) xml_path = File.join(XML_DIR, XML_FILE_NAME) File.write(xml_path, new_xml) end
validate_config_existence()
click to toggle source
# File lib/dotremap.rb, line 43 def validate_config_existence return if File.exists?(config_path) File.write(config_path, <<-EOS.unindent) #!/usr/bin/env ruby # # Example # item "Command+E to Command+W", not: "TERMINAL" do # identifier "option.not_terminal_opt_e" # autogen "__KeyToKey__ KeyCode::E, VK_COMMAND, KeyCode::W, ModifierFlag::COMMAND_L" # end EOS end