Module: Guard::Jstd::Configuration
- Defined in:
- lib/guard/jstd/configuration.rb
Constant Summary collapse
- METHODS =
[:java_path, :browser_paths, :server_port, :jstd_config_path, :start_server, :capture_browser]
Class Method Summary collapse
- .browser_paths ⇒ Object
- .capture_browser ⇒ Object
- .default_server_port ⇒ Object
- .jar_home ⇒ Object
- .jar_path ⇒ Object
- .java_path ⇒ Object
- .jstd_config_path ⇒ Object
- .reset! ⇒ Object
- .server_port ⇒ Object
- .start_server ⇒ Object
Class Method Details
.browser_paths ⇒ Object
21 22 23 |
# File 'lib/guard/jstd/configuration.rb', line 21 def browser_paths @browser_paths ||= "\`which open\`" end |
.capture_browser ⇒ Object
37 38 39 |
# File 'lib/guard/jstd/configuration.rb', line 37 def capture_browser @capture_browser == nil ? false : @capture_browser end |
.default_server_port ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/guard/jstd/configuration.rb', line 41 def default_server_port begin conf = File.read(jstd_config_path) conf.match(/server:.*:(\d+)$/)[1] rescue '4224' end end |
.jar_home ⇒ Object
63 64 65 66 67 |
# File 'lib/guard/jstd/configuration.rb', line 63 def jar_home return @jar_home if @jar_home echo = `echo $JSTESTDRIVER_HOME` @jar_home = echo == "" ? '~/bin' : echo.gsub!("\n", "") end |
.jar_path ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/guard/jstd/configuration.rb', line 50 def jar_path path = File.join(jar_home, 'jstest*.jar') files = Dir.glob(File.(path), File::FNM_CASEFOLD) if files.empty? alert = "\e[31mGuard::Jstd could not find your JsTestDriver.jar file. " alert << "Please specify it in the configuration.\e[0m" UI.info(alert, :reset => true) exit else files.first end end |
.java_path ⇒ Object
17 18 19 |
# File 'lib/guard/jstd/configuration.rb', line 17 def java_path @java_path ||= jar_path end |
.jstd_config_path ⇒ Object
25 26 27 |
# File 'lib/guard/jstd/configuration.rb', line 25 def jstd_config_path @jstd_config_path ||= 'jsTestDriver.conf' end |
.reset! ⇒ Object
12 13 14 15 |
# File 'lib/guard/jstd/configuration.rb', line 12 def reset! METHODS.each { |method| instance_variable_set("@#{method.to_s}", nil) } @jar_home = nil end |
.server_port ⇒ Object
29 30 31 |
# File 'lib/guard/jstd/configuration.rb', line 29 def server_port @server_port ||= default_server_port end |
.start_server ⇒ Object
33 34 35 |
# File 'lib/guard/jstd/configuration.rb', line 33 def start_server @start_server == nil ? true : @start_server end |