Windows.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. module RimeDeploy
  2. class WindowsJobGroup < JobGroup
  3. ConfigPath = 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. [
  20. "I have installed Rime. Let's go next.",
  21. -> {}
  22. ],
  23. [
  24. "I'll quit first.After installed Rime by myself then run this program again.",
  25. -> { exit 0 }
  26. ]
  27. ]
  28. ).call
  29. sleep 1
  30. return :next
  31. end
  32. end
  33. class BackupRimeConfigJob < Job
  34. def call
  35. puts intro
  36. system(
  37. "move #{WindowsJobGroup::ConfigPath} #{WindowsJobGroup::ConfigPath}.#{Time.now.to_i}.old"
  38. )
  39. sleep 1
  40. return :next
  41. end
  42. end
  43. class CloneConfigJob < Job
  44. def call
  45. puts intro
  46. system(
  47. "git clone --depth=1 #{Config::RIME_CONFIG_REPO} #{WindowsJobGroup::ConfigPath}"
  48. )
  49. sleep 1
  50. return :next
  51. end
  52. end
  53. class CopyCustomConfigJob < Job
  54. def call
  55. puts intro
  56. system("copy .\\custom\\*.yaml #{WindowsJobGroup::ConfigPath}")
  57. sleep 1
  58. return :next
  59. end
  60. end
  61. class FinishedJob < Job
  62. def call
  63. puts ""
  64. puts "Tips: When finished all jobs. You need to do follow:".yellow
  65. puts "1) Restart system."
  66. puts "2) open Rime input method setting pane and click " +
  67. "DEPLOY".yellow + " button."
  68. puts "Enjoy~"
  69. puts "more info:".yellow
  70. puts "Config path: #{WindowsJobGroup::ConfigPath}"
  71. return :next
  72. end
  73. end
  74. self.before_jobs = [CheckInstallRimeJob]
  75. self.jobs = [BackupRimeConfigJob, CloneConfigJob, CopyCustomConfigJob]
  76. self.after_jobs = [FinishedJob]
  77. end
  78. end