MacOS.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. module RimeDeploy
  2. module MacOS
  3. class InstallRimeJob < Job
  4. def call
  5. puts intro
  6. system(Config::MacOS::InstallCmd)
  7. sleep 1
  8. return :next
  9. end
  10. end
  11. class BackupRimeConfigJob < Job
  12. def call
  13. puts intro
  14. system(
  15. "mv #{Config::MacOS::ConfigPath} #{Config::MacOS::ConfigPath}.#{Time.now.to_i}.old"
  16. )
  17. sleep 1
  18. return :next
  19. end
  20. end
  21. class CloneConfigJob < Job
  22. def call
  23. puts intro
  24. system(
  25. "git clone --depth=1 #{Config::RIME_CONFIG_REPO} #{Config::MacOS::ConfigPath}"
  26. )
  27. sleep 1
  28. return :next
  29. end
  30. end
  31. class CopyCustomConfigJob < Job
  32. def call
  33. puts intro
  34. system("cp ./custom/default.custom.yaml #{Config::MacOS::ConfigPath}/")
  35. system("cp ./custom/squirrel.custom.yaml #{Config::MacOS::ConfigPath}/")
  36. sleep 1
  37. return :next
  38. end
  39. end
  40. class FinishedJob < Job
  41. def call
  42. puts ""
  43. puts "Tips: When finished all jobs. You need to do follow:".yellow
  44. puts "1) Restart system."
  45. puts "2) open Rime input method setting pane and click " +
  46. "DEPLOY".yellow + " button."
  47. puts "Enjoy~ 🍻"
  48. puts "more info:".yellow
  49. puts "Config path: #{Config::MacOS::ConfigPath}/"
  50. return :next
  51. end
  52. end
  53. BeforeHook = []
  54. Jobs = [
  55. InstallRimeJob,
  56. BackupRimeConfigJob,
  57. CloneConfigJob,
  58. CopyCustomConfigJob
  59. ]
  60. FinishedHook = [FinishedJob]
  61. end
  62. end