installer.rb 940 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env ruby
  2. require "./lib/core"
  3. require "./lib/config"
  4. module OSPatch
  5. def check_os
  6. case RUBY_PLATFORM.downcase
  7. when /darwin/
  8. @osname = "MacOS"
  9. when /linux/
  10. @osname = "LinuxDistro"
  11. when /mswin|win32|mingw|cygwin/
  12. @osname = "win"
  13. not_support_exit
  14. else
  15. not_support_exit
  16. end
  17. end
  18. end
  19. module RimeDeploy
  20. class Installer
  21. include OSPatch
  22. def initialize
  23. @osname = nil
  24. check_os
  25. dispatch
  26. run
  27. end
  28. def not_support_exit
  29. puts "Not support this system. Bye~"
  30. exit 0
  31. end
  32. def dispatch
  33. require "./os/#{@osname}"
  34. end
  35. def run
  36. os_prefix = @osname
  37. code = <<-CODE
  38. class #{os_prefix}JobGroup < JobGroup
  39. end
  40. mod = #{os_prefix}JobGroup.new(#{os_prefix}::BeforeHook, #{os_prefix}::Jobs, #{os_prefix}::FinishedHook)
  41. mod.call
  42. CODE
  43. instance_eval(code)
  44. end
  45. end
  46. end
  47. RimeDeploy::Installer.new