mac.rb 1.5 KB

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