lib/rhoconnect/utilities.rb in rhoconnect-3.3.6 vs lib/rhoconnect/utilities.rb in rhoconnect-3.4.2
- old
+ new
@@ -1,18 +1,15 @@
require 'json'
+require 'rbconfig'
module Utilities
# Prints the command to be issued and then issues it to system
def cmd(cmd)
puts cmd
system "#{cmd}"
end #cmd
- def redis_home
- ENV['REDIS_HOME'] || File.join($redis_dest,$redis_ver)
- end
-
def mk_bin_dir(bin_dir)
begin
mkdir_p bin_dir unless File.exists?(bin_dir)
rescue
puts "Can't create #{bin_dir}, maybe you need to run command as root?"
@@ -26,11 +23,11 @@
print_resp(resp, resp.is_a?(Net::HTTPSuccess) ? true : false)
end
def print_resp(resp,success=true)
if success
- puts "=> OK"
+ puts "=> OK"
else
puts "=> FAILED"
end
puts "=> " + resp.body if resp and resp.body and resp.body.length > 0
end
@@ -41,63 +38,68 @@
def ask(msg)
print msg
STDIN.gets.chomp
end
-
+
def load_settings(file)
begin
$settings = YAML.load_file(file)
rescue Exception => e
puts "Error opening settings file #{file}: #{e}."
puts e.backtrace.join("\n")
raise e
end
end
-
+
def rhoconnect_socket
'/tmp/rhoconnect.dtach'
end
-
+
def rhoconnect_pid
if windows?
Dir.mkdir 'C:/TMP' unless File.directory? 'C:/TMP'
'C:/TMP/rhoconnect.pid'
else
'/tmp/rhoconnect.pid'
end
end
+ # See http://rbjl.net/35-how-to-properly-check-for-your-ruby-interpreter-version-and-os
def windows?
- RUBY_PLATFORM =~ /(win|w)32$/
+ RbConfig::CONFIG['host_os'] =~ /(win|w)32$/
end
-
+
+ def redis_home
+ ENV['REDIS_HOME'] || File.join($redis_dest,$redis_ver)
+ end
+
def ruby19?
- RUBY_VERSION =~ /1.9/
+ RUBY_VERSION =~ /1.9/
end
def jruby?
defined?(JRUBY_VERSION)
end
-
+
def thin?
begin
require 'thin'
'bundle exec rackup -s thin'
rescue LoadError
nil
end
end
-
+
def mongrel?
begin
require 'mongrel'
'bundle exec rackup -s mongrel'
rescue LoadError
nil
end
end
-
+
def report_missing_server
msg =<<-EOF
Could not find 'thin' or 'mongrel' on your system. Please install one:
gem install thin
or
\ No newline at end of file