dotremap 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 401825fbab15250619f14ea781ceff9f345819b6
4
- data.tar.gz: 5c1630693db09459e9b23d794f509795ad8897f4
3
+ metadata.gz: 6a0be0149bc8f1e2f22a3530011bb12951a162b7
4
+ data.tar.gz: 613a9476f47e93566e72550551c5c380de128450
5
5
  SHA512:
6
- metadata.gz: 567031667b38d096621e099ff818b0dcdad609df05f58b326942aa26bfcf03e83589d57fe380819c8085fa5b91903ceaf961f49e9e58fd09269a50e85f6870d8
7
- data.tar.gz: b5546f823689fd450952619f5f01c68970b9c073ebc26e60f73acc8af8eac4c803b60c0f3cb26a3074cdfe498b89e51e4b72eb80fc5e886f73004fc73179a006
6
+ metadata.gz: 732d4e7c57cb83a53c4af0092d6ed1876b79edb35bbdd723ae21c315a7cd57ab7b6d95feea8ed97966cc2bbfae0feb256eeda686bc9af4589ff0301dbebfeb6e
7
+ data.tar.gz: 0e8b8b641b31f4d6b41a0625a90da035acfc2732a5cbf8ce4b00424e6abab4d4d327cbdcc87ba12150d1c12ca3f1d962a068740f3dbcec44d843918378056862
data/README.md CHANGED
@@ -44,11 +44,8 @@ It will replace KeyRemap4MacBook's private.xml with compiled ~/.remap:
44
44
  </root>
45
45
  ```
46
46
 
47
- ### 3. Reload private.xml and update config
48
-
49
- You have to reload private.xml to activate compiled configurations.
50
-
51
- ![](https://raw.githubusercontent.com/k0kubun/dotremap/master/reload.gif)
47
+ dotremap will automatically execute "ReloadXML".
48
+ Then activate your favorite configurations.
52
49
 
53
50
  ## Example
54
51
 
data/bin/dotremap CHANGED
@@ -8,5 +8,4 @@ require "dotremap"
8
8
  DOTREMAP_PATH = File.expand_path("~/.remap")
9
9
 
10
10
  dotremap = Dotremap.new(DOTREMAP_PATH)
11
- dotremap.compile
12
- dotremap.replace_private_xml
11
+ dotremap.apply_configuration
data/example.rb CHANGED
@@ -33,7 +33,7 @@ item "Exchange Control + Space and Command + Space" do
33
33
  end
34
34
 
35
35
  item "CapsLock ON", config_not: "notsave.private_capslock_on" do
36
- remap "Cmd-L", to: ["capslock", "VK_CONFIG_FORCE_OFF_notsave_private_capslock_on"]
36
+ remap "Cmd-L", to: ["capslock", "VK_CONFIG_FORCE_ON_notsave_private_capslock_on"]
37
37
  end
38
38
 
39
39
  item "CapsLock OFF", config_only: "notsave.private_capslock_on" do
@@ -66,7 +66,7 @@ end
66
66
  # Use Cmd_R+B/F as M-b/f, and Cmd_R+S as Cmd+F to avoid conflict with M-f
67
67
  item "[Not Terminal] Command+B/F to Option+Left/Right, Command+S to Command+F", not: "TERMINAL" do
68
68
  remap "Cmd-B", to: "Opt-Left"
69
- remap "Cmd-B", to: "Opt-Left"
69
+ remap "Cmd-F", to: "Opt-Right"
70
70
  remap "Cmd-S", to: "Cmd-F"
71
71
  end
72
72
 
@@ -115,8 +115,8 @@ item "Shift by control" do
115
115
  end
116
116
 
117
117
  item "Exchange single quote and double quote" do
118
- remap "'", to: "Shift-'"
119
118
  remap "Shift-'", to: "'"
119
+ remap "'", to: "Shift-'"
120
120
  end
121
121
 
122
122
  item "[Only Terminal] Command+A to Option+A", only: "TERMINAL" do
@@ -1,3 +1,3 @@
1
1
  class Dotremap
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/dotremap.rb CHANGED
@@ -4,44 +4,37 @@ require "unindent"
4
4
  require "fileutils"
5
5
 
6
6
  class Dotremap
7
+ XML_FILE_NAME = "private.xml"
7
8
  OLD_XML_DIR = File.expand_path("~/Library/Application Support/KeyRemap4MacBook")
8
9
  NEW_XML_DIR = File.expand_path("~/Library/Application Support/Karabiner")
9
- XML_FILE_NAME = "private.xml"
10
+ OLD_APP_PATH = "/Applications/KeyRemap4MacBook.app"
11
+ NEW_APP_PATH = "/Applications/Karabiner.app"
12
+ RELOAD_XML_PATH = "Contents/Applications/Utilities/ReloadXML.app"
10
13
 
11
14
  def initialize(config_path)
12
15
  @config_path = config_path
13
- @root = Root.new
14
16
  end
15
- attr_reader :config_path, :root
16
-
17
- def compile
18
- validate_config_existence
17
+ attr_reader :config_path
19
18
 
20
- config = File.read(config_path)
21
- root.instance_eval(config)
19
+ def apply_configuration
20
+ replace_private_xml
21
+ reload_xml
22
+ puts "Successfully updated Karabiner configuration"
22
23
  end
23
24
 
25
+ private
26
+
24
27
  def replace_private_xml
25
28
  ensure_xml_dir_existence
26
29
  remove_current_xml
27
30
  write_new_xml
28
- puts "Successfully generated private.xml"
29
31
  end
30
32
 
31
- private
33
+ def reload_xml
34
+ app_path = File.exists?(OLD_APP_PATH) ? OLD_APP_PATH : NEW_APP_PATH
35
+ reload_xml_path = File.join(app_path, RELOAD_XML_PATH)
32
36
 
33
- def validate_config_existence
34
- return if File.exists?(config_path)
35
-
36
- File.write(config_path, <<-EOS.unindent)
37
- #!/usr/bin/env ruby
38
-
39
- # # Example
40
- # item "Command+E to Command+W", not: "TERMINAL" do
41
- # identifier "option.not_terminal_opt_e"
42
- # autogen "__KeyToKey__ KeyCode::E, VK_COMMAND, KeyCode::W, ModifierFlag::COMMAND_L"
43
- # end
44
- EOS
37
+ system("open #{reload_xml_path}")
45
38
  end
46
39
 
47
40
  def ensure_xml_dir_existence
@@ -55,7 +48,31 @@ class Dotremap
55
48
  end
56
49
 
57
50
  def write_new_xml
58
- File.write(File.join(OLD_XML_DIR, XML_FILE_NAME), root.to_xml)
59
- File.write(File.join(NEW_XML_DIR, XML_FILE_NAME), root.to_xml)
51
+ File.write(File.join(OLD_XML_DIR, XML_FILE_NAME), new_xml)
52
+ File.write(File.join(NEW_XML_DIR, XML_FILE_NAME), new_xml)
53
+ end
54
+
55
+ def new_xml
56
+ return @new_xml if defined?(@new_xml)
57
+ validate_config_existence
58
+
59
+ root = Root.new
60
+ config = File.read(config_path)
61
+ root.instance_eval(config)
62
+ @new_xml = root.to_xml.gsub(/ *$/, "")
63
+ end
64
+
65
+ def validate_config_existence
66
+ return if File.exists?(config_path)
67
+
68
+ File.write(config_path, <<-EOS.unindent)
69
+ #!/usr/bin/env ruby
70
+
71
+ # # Example
72
+ # item "Command+E to Command+W", not: "TERMINAL" do
73
+ # identifier "option.not_terminal_opt_e"
74
+ # autogen "__KeyToKey__ KeyCode::E, VK_COMMAND, KeyCode::W, ModifierFlag::COMMAND_L"
75
+ # end
76
+ EOS
60
77
  end
61
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotremap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-12 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,7 +78,6 @@ files:
78
78
  - lib/dotremap/remap.rb
79
79
  - lib/dotremap/root.rb
80
80
  - lib/dotremap/version.rb
81
- - reload.gif
82
81
  homepage: https://github.com/k0kubun/dotremap
83
82
  licenses:
84
83
  - MIT
data/reload.gif DELETED
Binary file