installer.rb 914 B

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