MacOS.rb 1.6 KB

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