Windows.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. module RimeDeploy
  2. class WindowsJobGroup < JobGroup
  3. Store.config_path = ENV["APPDATA"] + '\\Rime'
  4. def clear_screen
  5. system("cls")
  6. end
  7. class CheckInstallRimeJob < Job
  8. def call
  9. puts "==== Rime auto deploy ====".green
  10. puts "Before Check Rime Installed Staus".yellow
  11. tips = <<-TIP
  12. Windows system doesn't have it's own package manager, so make sure you had installed Rime before.
  13. You can download Rime from: https://rime.im/download/
  14. TIP
  15. puts tips
  16. puts ""
  17. ChooseSession.new(
  18. [
  19. ["I have installed Rime. Let's go next.", -> {}],
  20. [
  21. "I'll quit first.After installed Rime by myself then run this program again.",
  22. -> { exit 0 }
  23. ]
  24. ]
  25. ).call
  26. sleep 1
  27. return :next
  28. end
  29. end
  30. class BackupRimeConfigJob < Job
  31. def call
  32. puts intro
  33. system(
  34. "move #{Store.config_path} #{Store.config_path}.#{Time.now.to_i}.old"
  35. )
  36. sleep 1
  37. return :next
  38. end
  39. end
  40. class CloneConfigJob < Job
  41. def call
  42. puts intro
  43. system(
  44. "git clone #{Config::RIME_CONFIG_REPO} #{Store.config_path}"
  45. )
  46. sleep 1
  47. return :next
  48. end
  49. end
  50. class CopyCustomConfigJob < Job
  51. def call
  52. puts intro
  53. system("copy .\\custom\\*.yaml #{Store.config_path}")
  54. sleep 1
  55. system("copy .\\custom\\custom_phrase.txt #{Store.config_path}")
  56. sleep 1
  57. return :next
  58. end
  59. end
  60. class FinishedJob < Job
  61. def call
  62. puts ""
  63. puts "Tips: When finished all jobs. You need to do follow:".yellow
  64. puts "1) Restart system."
  65. puts "2) open Rime input method setting pane and click " +
  66. "DEPLOY".yellow + " button."
  67. puts "Enjoy~"
  68. puts "more info:".yellow
  69. puts "Config path: #{Store.config_path}"
  70. return :next
  71. end
  72. end
  73. self.before_jobs = [CheckInstallRimeJob]
  74. self.jobs = [BackupRimeConfigJob, CloneConfigJob, CopyCustomConfigJob]
  75. self.after_jobs = [FinishedJob]
  76. self.upgrade_jobs = [
  77. Upgrade::UpgradeRimeAutoDeployJob,
  78. Upgrade::UpgradeRimeConfigJob
  79. ]
  80. end
  81. end