Index: lib/plugins/open_id_authentication/lib/open_id_authentication.rb
===================================================================
--- lib/plugins/open_id_authentication/lib/open_id_authentication.rb (revision 17364)
+++ lib/plugins/open_id_authentication/lib/open_id_authentication.rb (working copy)
@@ -87,7 +87,7 @@
# dodge XRIs -- TODO: validate, don't just skip.
unless ['=', '@', '+', '$', '!', '('].include?(identifier.at(0))
# does it begin with http? if not, add it.
- identifier = "http://#{identifier}" unless identifier =~ /^http/i
+ identifier = "http://#{identifier}" unless /^http/i.match?(identifier)
# strip any fragments
identifier.gsub!(/\#(.*)$/, '')
Index: lib/redmine/codeset_util.rb
===================================================================
--- lib/redmine/codeset_util.rb (revision 17364)
+++ lib/redmine/codeset_util.rb (working copy)
@@ -39,7 +39,7 @@
return str if str.nil?
str.force_encoding('ASCII-8BIT')
return str if str.empty?
- return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
+ return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match?(str) # for us-ascii
str.force_encoding('UTF-8')
encodings = Setting.repositories_encodings.split(',').collect(&:strip)
encodings.each do |encoding|
Index: lib/redmine/configuration.rb
===================================================================
--- lib/redmine/configuration.rb (revision 17364)
+++ lib/redmine/configuration.rb (working copy)
@@ -114,7 +114,7 @@
# Checks the validness of regular expressions set for repository paths at startup
def check_regular_expressions
@config.each do |name, value|
- if value.present? && name =~ /^scm_.+_path_regexp$/
+ if value.present? && /^scm_.+_path_regexp$/.match?(name)
begin
Regexp.new value.to_s.strip
rescue => e
Index: lib/redmine/core_ext/active_record.rb
===================================================================
--- lib/redmine/core_ext/active_record.rb (revision 17364)
+++ lib/redmine/core_ext/active_record.rb (working copy)
@@ -19,7 +19,7 @@
def validate_each(record, attribute, value)
before_type_cast = record.attributes_before_type_cast[attribute.to_s]
if before_type_cast.is_a?(String) && before_type_cast.present?
- unless before_type_cast =~ /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/ && value
+ unless /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/.match?(before_type_cast) && value
record.errors.add attribute, :not_a_date
end
end
Index: lib/redmine/export/pdf.rb
===================================================================
--- lib/redmine/export/pdf.rb (revision 17364)
+++ lib/redmine/export/pdf.rb (working copy)
@@ -141,7 +141,7 @@
def self.attach(attachments, filename, encoding)
filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
atta = nil
- if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
+ if /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i.match?(filename_utf8)
atta = Attachment.latest_attach(attachments, filename_utf8)
end
if atta && atta.readable? && atta.visible?
Index: lib/redmine/field_format.rb
===================================================================
--- lib/redmine/field_format.rb (revision 17364)
+++ lib/redmine/field_format.rb (working copy)
@@ -249,7 +249,7 @@
[text, url]
end
links = texts_and_urls.sort_by(&:first).map do |text, url|
- css_class = (url =~ /^https?:\/\//) ? 'external' : nil
+ css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil
view.link_to_if uri_with_safe_scheme?(url), text, url, :class => css_class
end
links.join(', ').html_safe
@@ -358,7 +358,7 @@
def validate_single_value(custom_field, value, customized=nil)
errs = super
value = value.to_s
- unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
+ unless custom_field.regexp.blank? or Regexp.new(custom_field.regexp).match?(value)
errs << ::I18n.t('activerecord.errors.messages.invalid')
end
if custom_field.min_length && value.length < custom_field.min_length
@@ -440,12 +440,12 @@
url = url_from_pattern(custom_field, value, customized)
else
url = value.to_s
- unless url =~ %r{\A[a-z]+://}i
+ unless %r{\A[a-z]+://}i.match?(url)
# no protocol found, use http by default
url = "http://" + url
end
end
- css_class = (url =~ /^https?:\/\//) ? 'external' : nil
+ css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil
view.link_to value.to_s.truncate(40), url, :class => css_class
else
value.to_s
@@ -490,7 +490,7 @@
def validate_single_value(custom_field, value, customized=nil)
errs = super
- errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s =~ /^[+-]?\d+$/
+ errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless /^[+-]?\d+$/.match?(value.to_s)
errs
end
@@ -534,7 +534,7 @@
end
def validate_single_value(custom_field, value, customized=nil)
- if value =~ /^\d{4}-\d{2}-\d{2}$/ && (value.to_date rescue false)
+ if /^\d{4}-\d{2}-\d{2}$/.match?(value) && (value.to_date rescue false)
[]
else
[::I18n.t('activerecord.errors.messages.not_a_date')]
Index: lib/redmine/platform.rb
===================================================================
--- lib/redmine/platform.rb (revision 17364)
+++ lib/redmine/platform.rb (working copy)
@@ -19,8 +19,8 @@
module Platform
class << self
def mswin?
- (RUBY_PLATFORM =~ /(:?mswin|mingw)/) ||
- (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i)
+ (/(:?mswin|mingw)/.match?(RUBY_PLATFORM)) ||
+ (RUBY_PLATFORM == 'java' && /windows/i.match?(ENV['OS'] || ENV['os']))
end
end
end
Index: lib/redmine/scm/adapters/abstract_adapter.rb
===================================================================
--- lib/redmine/scm/adapters/abstract_adapter.rb (revision 17364)
+++ lib/redmine/scm/adapters/abstract_adapter.rb (working copy)
@@ -183,7 +183,7 @@
def target(path, sq=true)
path ||= ''
- base = path.match(/^\//) ? root_url : url
+ base = /^\//.match?(path) ? root_url : url
str = "#{base}/#{path}".gsub(/[?<>\*]/, '')
if sq
str = shell_quote(str)
Index: lib/redmine/scm/adapters/cvs_adapter.rb
===================================================================
--- lib/redmine/scm/adapters/cvs_adapter.rb (revision 17364)
+++ lib/redmine/scm/adapters/cvs_adapter.rb (working copy)
@@ -168,7 +168,7 @@
file_state = nil
branch_map = nil
io.each_line() do |line|
- if state != "revision" && /^#{ENDLOG}/ =~ line
+ if state != "revision" && /^#{ENDLOG}/.match?(line)
commit_log = String.new
revision = nil
state = "entry_start"
@@ -181,9 +181,9 @@
logger.debug("Path #{entry_path} <=> Name #{entry_name}")
elsif /^head: (.+)$/ =~ line
entry_headRev = $1 #unless entry.nil?
- elsif /^symbolic names:/ =~ line
+ elsif /^symbolic names:/.match?(line)
state = "symbolic" #unless entry.nil?
- elsif /^#{STARTLOG}/ =~ line
+ elsif /^#{STARTLOG}/.match?(line)
commit_log = String.new
state = "revision"
end
Index: lib/redmine/scm/adapters/filesystem_adapter.rb
===================================================================
--- lib/redmine/scm/adapters/filesystem_adapter.rb (revision 17364)
+++ lib/redmine/scm/adapters/filesystem_adapter.rb (working copy)
@@ -107,7 +107,7 @@
# Here we do not shell-out, so we do not want quotes.
def target(path=nil)
# Prevent the use of ..
- if path and !path.match(/(^|\/)\.\.(\/|$)/)
+ if path and !/(^|\/)\.\.(\/|$)/.match?(path)
return "#{self.url}#{without_leading_slash(path)}"
end
return self.url
Index: lib/redmine/scm/adapters/mercurial_adapter.rb
===================================================================
--- lib/redmine/scm/adapters/mercurial_adapter.rb (revision 17364)
+++ lib/redmine/scm/adapters/mercurial_adapter.rb (working copy)
@@ -296,10 +296,10 @@
# Runs 'hg' command with the given args
def hg(*args, &block)
# as of hg 4.4.1, early parsing of bool options is not terminated at '--'
- if args.any? { |s| s =~ HG_EARLY_BOOL_ARG }
+ if args.any? { |s| HG_EARLY_BOOL_ARG.match?(s) }
raise HgCommandArgumentError, "malicious command argument detected"
end
- if args.take_while { |s| s != '--' }.any? { |s| s =~ HG_EARLY_LIST_ARG }
+ if args.take_while { |s| s != '--' }.any? { |s| HG_EARLY_LIST_ARG.match?(s) }
raise HgCommandArgumentError, "malicious command argument detected"
end
Index: lib/redmine/scm/adapters/subversion_adapter.rb
===================================================================
--- lib/redmine/scm/adapters/subversion_adapter.rb (revision 17364)
+++ lib/redmine/scm/adapters/subversion_adapter.rb (working copy)
@@ -265,7 +265,7 @@
end
def target(path = '')
- base = path.match(/^\//) ? root_url : url
+ base = /^\//.match?(path) ? root_url : url
uri = "#{base}/#{path}"
uri = URI.escape(URI.escape(uri), '[]')
shell_quote(uri.gsub(/[?<>\*]/, ''))
Index: lib/redmine/sort_criteria.rb
===================================================================
--- lib/redmine/sort_criteria.rb (revision 17364)
+++ lib/redmine/sort_criteria.rb (working copy)
@@ -94,7 +94,7 @@
# Appends ASC/DESC to the sort criterion unless it has a fixed order
def append_order(criterion, order)
- if criterion =~ / (asc|desc)$/i
+ if / (asc|desc)$/i.match?(criterion)
criterion
else
"#{criterion} #{order.to_s.upcase}"
Index: lib/redmine/unified_diff.rb
===================================================================
--- lib/redmine/unified_diff.rb (revision 17364)
+++ lib/redmine/unified_diff.rb (working copy)
@@ -76,7 +76,7 @@
@parsing = true
end
else
- if line =~ %r{^[^\+\-\s@\\]}
+ if %r{^[^\+\-\s@\\]}.match?(line)
@parsing = false
return false
elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
@@ -112,9 +112,9 @@
def file_name=(arg)
both_git_diff = false
if file_name.nil?
- @git_diff = true if arg =~ %r{^(a/|/dev/null)}
+ @git_diff = true if %r{^(a/|/dev/null)}.match?(arg)
else
- both_git_diff = (@git_diff && arg =~ %r{^(b/|/dev/null)})
+ both_git_diff = (@git_diff && %r{^(b/|/dev/null)}.match?(arg))
end
if both_git_diff
if file_name && arg == "/dev/null"
@@ -166,7 +166,7 @@
true
else
write_offsets
- if line[0, 1] =~ /\s/
+ if /\s/.match?(line[0, 1])
diff = Diff.new
diff.line_right = line[1..-1]
diff.nb_line_right = @line_num_r
Index: lib/redmine/wiki_formatting/macros.rb
===================================================================
--- lib/redmine/wiki_formatting/macros.rb (revision 17364)
+++ lib/redmine/wiki_formatting/macros.rb (working copy)
@@ -141,7 +141,7 @@
# If a block of text is given, the closing tag }} must be at the start of a new line.
def macro(name, options={}, &block)
options.assert_valid_keys(:desc, :parse_args)
- unless name.to_s.match(/\A\w+\z/)
+ unless /\A\w+\z/.match?(name.to_s)
raise "Invalid macro name: #{name} (only 0-9, A-Z, a-z and _ characters are accepted)"
end
unless block_given?
@@ -238,7 +238,7 @@
filename = args.first
raise 'Filename required' unless filename.present?
size = options[:size]
- raise 'Invalid size parameter' unless size.nil? || size.match(/^\d+$/)
+ raise 'Invalid size parameter' unless size.nil? || /^\d+$/.match?(size)
size = size.to_i
size = 200 unless size > 0
if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
Index: lib/redmine/wiki_formatting.rb
===================================================================
--- lib/redmine/wiki_formatting.rb (revision 17364)
+++ lib/redmine/wiki_formatting.rb (working copy)
@@ -133,7 +133,7 @@
def auto_link!(text)
text.gsub!(AUTO_LINK_RE) do
all, leading, proto, url, post = $&, $1, $2, $3, $6
- if leading =~ /=]?/
+ if /=]?/.match?(leading)
# don't replace URLs that are already linked
# and URLs prefixed with ! !> !< != (textile images)
all
@@ -155,7 +155,7 @@
def auto_mailto!(text)
text.gsub!(/((?]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
+ if /]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/.match?(text)
mail
else
%(#{ERB::Util.html_escape mail}).html_safe