installer.rb 937 B

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