lib/flammarion/revelator.rb in flammarion-0.1.14 vs lib/flammarion/revelator.rb in flammarion-0.2.0
- old
+ new
@@ -18,15 +18,11 @@
# @todo This all needs a lot of clean up
module Revelator
CHROME_PATH = ENV["FLAMMARION_REVELATOR_PATH"] || 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
def open_a_window(options = {})
- if RbConfig::CONFIG["host_os"] =~ /cygwin|mswin|mingw/
- development_mode = ENV["FLAMMARION_DEVELOPMENT"] == "true"
- else
- development_mode = system("lsof -i:#{4567}", out: '/dev/null') and File.exist?("#{File.dirname(__FILE__)}/../html/source/index.html.slim")
- end
+ development_mode = Flammarion.development_mode?
host_path = File.absolute_path(File.join(File.dirname(File.absolute_path(__FILE__)), "/../html/build/index.html"))
host_path = `cygpath -w '#{host_path}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
host = "file://#{host_path}"
host = "http://localhost:4567/" if development_mode
@@ -114,7 +110,21 @@
return exe if File.executable?(exe) && !File.directory?(exe)
end
end
return nil
end
+ end
+
+ private
+ def self.development_mode?
+ if RbConfig::CONFIG["host_os"] =~ /cygwin|mswin|mingw/
+ development_mode = ENV["FLAMMARION_DEVELOPMENT"] == "true"
+ else
+ development_mode = system("lsof -i:#{4567}", out: '/dev/null') and File.exist?("#{File.dirname(__FILE__)}/../html/source/index.html.slim")
+ end
+ end
+
+ def self.development_mode=(turnOn)
+ raise StandardError.new("Can't turn on development mode on unix system. (Just start the middleman server, and flammarion will detect it automatically.") unless RbConfig::CONFIG["host_os"] =~ /cygwin|mswin|mingw/
+ ENV["FLAMMARION_DEVELOPMENT"] = "true"
end
end