Sha256: 55383ac588b36065b04abe4fbd901556e2ab56d765100b0989f19832e1e7d2d3
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
# -*- coding: utf-8 -*- $LOAD_PATH << File.dirname(File.expand_path(__FILE__)) require "socket" require "rack" require "daemons" require "fileutils" require "kconv" require "json" require "facter" # 空きポートを取得 def get_unused_port s = TCPServer.open(0) port = s.addr[1] s.close return port end # 空きポートを取得 port = get_unused_port puts "port=#{port}" # config.ruの編集 buf = File.read("config.ru").toutf8 buf.gsub!(/port [0-9]+/, "port #{port}") File.write("config.ru", buf) # main.jsの編集 buf = File.read("js/main.js").toutf8 buf.gsub!(/localhost:[0-9]+\//, "localhost:#{port}/") File.write("js/main.js", buf) # index.htaの編集 buf = File.read("index.html").toutf8 buf.gsub!(/localhost:[0-9]+\//, "localhost:#{port}/") File.write("index.html", buf) Thread.start { puts "start browser" json_file = File.dirname(File.expand_path(__FILE__)) + "/config/browser.json" json = JSON.parse(File.read json_file) puts json kernel = Facter.value(:kernel) if kernel == "windows" browser = json["chrome_win"] elsif kernel == "Linux" browser = json["chrome_linux"] else browser = json["chrome_win"] end #browser = "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" -app=http://localhost:#{port}" browser += " -app=http://localhost:#{port}" puts browser system browser } Rack::Server.start
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
browser_app_base-0.0.2 | lib/template/start.rb |
browser_app_base-0.0.1 | lib/template/start.rb |