Rakefile 934 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. # -*- frozen_string_literal: true -*-
  3. require "rbconfig"
  4. module Rep1y
  5. Port = 8080
  6. Dir = "public"
  7. end
  8. task :default => :start
  9. desc "Start rep1y"
  10. task :start => [:open, :serve]
  11. desc "Copy reply"
  12. task :copy do
  13. system(*%W[cp -R ./index.html ./scripts ./style #{ENV.fetch("REP1Y_DIR", Rep1y::Dir)}])
  14. end
  15. # private (unlisted, yet available)
  16. task :serve do
  17. sh(*%W[ruby -run -e httpd . -p #{ENV.fetch("REP1Y_PORT", Rep1y::Port)}])
  18. end
  19. # private (unlisted, yet available)
  20. task :open do
  21. rep1y = "http://localhost:#{ENV.fetch("REP1Y_PORT", Rep1y::Port)}"
  22. # Firefox CLI won't work on macOS https://bugzilla.mozilla.org/show_bug.cgi?id=393645#c10
  23. open_rep1y =
  24. if RbConfig::CONFIG["host_os"].match? "darwin"
  25. ff = FileList["/Applications/Firefox*.app/Contents/MacOS/firefox"].first
  26. %W[open -a #{ff} #{rep1y}]
  27. else
  28. %W[firefox -new-tab #{rep1y}]
  29. end
  30. system(*open_rep1y)
  31. end