module Flammarion::Revelator
Private Class Methods
browser(name, &block)
click to toggle source
# File lib/flammarion/revelator.rb, line 33 def self.browser(name, &block) @@browsers << OpenStruct.new(name: name, method:define_method(name, block)) end
Public Instance Methods
open_a_window(**options)
click to toggle source
# File lib/flammarion/revelator.rb, line 5 def open_a_window(**options) index_path = FlammarionRails::Engine.root.join('public', 'index.html') url = "file://#{index_path}?" + { port: server.port, path: @window_id, boot: FlammarionRails.config.boot_path }.to_query @browser_options = options.merge(url: url) @requested_browser = ENV["FLAMMARION_BROWSER"] || options[:browser] @browser = @@browsers.find do |browser| next if @requested_browser and browser.name.to_s != @requested_browser begin send(browser.name, @browser_options) rescue Exception next end end raise SetupError.new("You must have google-chrome installed and accesible via your path.") unless @browser end
wait_for_a_connection(options)
click to toggle source
# File lib/flammarion/revelator.rb, line 23 def wait_for_a_connection(options) Timeout.timeout(options[:wait] || 20) { sleep 0.5 while @sockets.empty? } rescue Timeout::Error raise SetupError.new("Timed out while waiting for a connecting using #{@browser.name}.") end
Private Instance Methods
which(cmd)
click to toggle source
# File lib/flammarion/revelator.rb, line 68 def which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) end end nil end