Quellcode durchsuchen

feat: use mac os config

Mark24 vor 2 Jahren
Ursprung
Commit
e30d02fb96
3 geänderte Dateien mit 25 neuen und 7 gelöschten Zeilen
  1. 1 0
      installer.rb
  2. 12 0
      lib/config.rb
  3. 12 7
      os/mac.rb

+ 1 - 0
installer.rb

@@ -1,6 +1,7 @@
 #!/usr/bin/env ruby
 
 require "./lib/core"
+require "./lib/config"
 module RimeDeploy
   class Installer
     def initialize

+ 12 - 0
lib/config.rb

@@ -0,0 +1,12 @@
+module RimeDeploy
+  module OSConfig
+    module Mac
+      InstallCmd = "brew install --cask squirrel"
+      ConfigPath = "~/Library/Rime"
+    end
+
+    module Linux
+      ConfigPath = "~/Library/Rime"
+    end
+  end
+end

+ 12 - 7
os/mac.rb

@@ -3,7 +3,7 @@ module RimeDeploy
     class InstallRimeJob < Job
       def call
         puts intro
-        system("brew install --cask squirrel")
+        system(OSConfig::Mac::InstallCmd)
         sleep 1
         return :next
       end
@@ -12,7 +12,9 @@ module RimeDeploy
     class BackupRimeConfigJob < Job
       def call
         puts "Job: BackupRimeConfigJob".blue
-        system("mv ~/Library/Rime ~/Library/Rime.#{Time.now.to_i}.old")
+        system(
+          "mv #{OSConfig::Mac::ConfigPath} #{OSConfig::Mac::ConfigPath}.#{Time.now.to_i}.old"
+        )
         sleep 1
         return :next
       end
@@ -21,7 +23,9 @@ module RimeDeploy
     class CloneConfigJob < Job
       def call
         puts intro
-        system("git clone https://github.com/iDvel/rime-ice.git ~/Library/Rime")
+        system(
+          "git clone https://github.com/iDvel/rime-ice.git #{OSConfig::Mac::ConfigPath}"
+        )
         sleep 1
         return :next
       end
@@ -30,8 +34,8 @@ module RimeDeploy
     class CopyCustomConfigJob < Job
       def call
         puts intro
-        system("cp ./custom/default.custom.yaml ~/Library/Rime/")
-        system("cp ./custom/squirrel.custom.yaml ~/Library/Rime/")
+        system("cp ./custom/default.custom.yaml #{OSConfig::Mac::ConfigPath}/")
+        system("cp ./custom/squirrel.custom.yaml #{OSConfig::Mac::ConfigPath}/")
         sleep 1
         return :next
       end
@@ -42,10 +46,11 @@ module RimeDeploy
         puts ""
         puts "Tips: When finished all jobs. You need to do follow:".yellow
         puts "1) Restart system."
-        puts "2) open Rime input method setting pane and click " + "DEPLOY".yellow + " button."
+        puts "2) open Rime input method setting pane and click " +
+               "DEPLOY".yellow + " button."
         puts "Enjoy~ 🍻"
         puts "more info:".yellow
-        puts "Config path: ~/Library/Rime/"
+        puts "Config path: #{OSConfig::Mac::ConfigPath}/"
         return :next
       end
     end