##// END OF EJS Templates
Fixes platform determination under JRuby (#1804)....
Jean-Philippe Lang -
r1752:116091a1d2ea
parent child
Show More
@@ -0,0 +1,26
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 module Redmine
19 module Platform
20 class << self
21 def mswin?
22 (RUBY_PLATFORM =~ /(:?mswin|mingw)/) || (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i)
23 end
24 end
25 end
26 end
@@ -138,7 +138,7 module Redmine
138 138 end
139 139
140 140 def shell_quote(str)
141 if RUBY_PLATFORM =~ /mswin/
141 if Redmine::Platform.mswin?
142 142 '"' + str.gsub(/"/, '\\"') + '"'
143 143 else
144 144 "'" + str.gsub(/'/, "'\"'\"'") + "'"
@@ -186,7 +186,7 module Redmine
186 186
187 187 # Hides username/password in a given command
188 188 def self.hide_credential(cmd)
189 q = (RUBY_PLATFORM =~ /mswin/ ? '"' : "'")
189 q = (Redmine::Platform.mswin? ? '"' : "'")
190 190 cmd.to_s.gsub(/(\-\-(password|username))\s+(#{q}[^#{q}]+#{q}|[^#{q}]\S+)/, '\\1 xxxx')
191 191 end
192 192
@@ -25,7 +25,7 class RepositoriesCvsControllerTest < Test::Unit::TestCase
25 25
26 26 # No '..' in the repository path
27 27 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
28 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
28 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
29 29 # CVS module
30 30 MODULE_NAME = 'test'
31 31
@@ -26,7 +26,7 class RepositoriesGitControllerTest < Test::Unit::TestCase
26 26
27 27 # No '..' in the repository path
28 28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
29 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30 30
31 31 def setup
32 32 @controller = RepositoriesController.new
@@ -22,7 +22,7 class RepositoryCvsTest < Test::Unit::TestCase
22 22
23 23 # No '..' in the repository path
24 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
25 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26 26 # CVS module
27 27 MODULE_NAME = 'test'
28 28
@@ -22,7 +22,7 class RepositoryGitTest < Test::Unit::TestCase
22 22
23 23 # No '..' in the repository path
24 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
25 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26 26
27 27 def setup
28 28 @project = Project.find(1)
General Comments 0
You need to be logged in to leave comments. Login now