Corrected with rubocop cop 'Style/RegexpLiteral'.

This commit is contained in:
Thorsten Eckel 2015-05-01 14:12:37 +02:00
parent 7929477838
commit 834ad2d64a
5 changed files with 13 additions and 13 deletions

View file

@ -76,7 +76,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# validate url # validate url
messages = {} messages = {}
if !Setting.get('system_online_service') if !Setting.get('system_online_service')
if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/ if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
messages[:url] = 'A URL looks like http://zammad.example.com' messages[:url] = 'A URL looks like http://zammad.example.com'
end end
end end
@ -107,7 +107,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# split url in http_type and fqdn # split url in http_type and fqdn
settings = {} settings = {}
if !Setting.get('system_online_service') if !Setting.get('system_online_service')
if params[:url] =~ /^(http|https):\/\/(.+?)$/ if params[:url] =~ %r{/^(http|https)://(.+?)$}
Setting.set('http_type', $1) Setting.set('http_type', $1)
settings[:http_type] = $1 settings[:http_type] = $1
Setting.set('fqdn', $2) Setting.set('fqdn', $2)

View file

@ -6,7 +6,7 @@ class ImportOtrsController < ApplicationController
return if setup_done_response return if setup_done_response
# validate # validate
if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/ if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
render json: { render json: {
result: 'invalid', result: 'invalid',
message: 'Invalid!', message: 'Invalid!',
@ -44,7 +44,7 @@ class ImportOtrsController < ApplicationController
suffixes.each {|suffix| suffixes.each {|suffix|
url = params[:url] + suffix + '?Action=ZammadMigrator' url = params[:url] + suffix + '?Action=ZammadMigrator'
# strip multible / in url # strip multible / in url
url.gsub!(/([^:])(\/+\/)/, '\\1/') url.gsub!(%r{([^:])(/+/)}, '\\1/')
response = UserAgent.request( url ) response = UserAgent.request( url )
#Setting.set('import_mode', true) #Setting.set('import_mode', true)

View file

@ -110,7 +110,7 @@ add a avatar
# twitter workaround to get bigger avatar images # twitter workaround to get bigger avatar images
# see also https://dev.twitter.com/overview/general/user-profile-images-and-banners # see also https://dev.twitter.com/overview/general/user-profile-images-and-banners
if data[:url] =~ /\/\/pbs.twimg.com\//i if data[:url] =~ %r{//pbs.twimg.com/}i
data[:url].sub!(/normal\.png$/, 'bigger.png') data[:url].sub!(/normal\.png$/, 'bigger.png')
end end

View file

@ -82,7 +82,7 @@ class Package < ApplicationModel
def self._package_base_dir?(package_base_dir) def self._package_base_dir?(package_base_dir)
package = false package = false
Dir.glob( package_base_dir + '/*.szpm') do |entry| Dir.glob( package_base_dir + '/*.szpm') do |entry|
package = entry.sub( /^.*\/(.+?)\.szpm$/, '\1') package = entry.sub( %r{^.*/(.+?)\.szpm$}, '\1')
end end
if package == false if package == false
raise "Can't link package, '#{package_base_dir}' is no package source directory!" raise "Can't link package, '#{package_base_dir}' is no package source directory!"
@ -133,7 +133,7 @@ class Package < ApplicationModel
entry = entry.sub( '//', '/' ) entry = entry.sub( '//', '/' )
file = entry file = entry
file = file.sub( /#{package_base_dir.to_s}/, '' ) file = file.sub( /#{package_base_dir.to_s}/, '' )
file = file.sub( /^\//, '' ) file = file.sub( %r{^/}, '' )
# ignore files # ignore files
if file =~ /^README/ if file =~ /^README/

View file

@ -83,10 +83,10 @@ class String
string.gsub!( /^\s*/m, '' ) string.gsub!( /^\s*/m, '' )
# pre/code handling 1/2 # pre/code handling 1/2
string.gsub!( /<pre>(.+?)<\/pre>/m ) { |placeholder| string.gsub!( %r{<pre>(.+?)</pre>}m ) { |placeholder|
placeholder = placeholder.gsub(/\n/, '###BR###') placeholder = placeholder.gsub(/\n/, '###BR###')
} }
string.gsub!( /<code>(.+?)<\/code>/m ) { |placeholder| string.gsub!( %r{<code>(.+?)</code>/}m ) { |placeholder|
placeholder = placeholder.gsub(/\n/, '###BR###') placeholder = placeholder.gsub(/\n/, '###BR###')
} }
@ -103,12 +103,12 @@ class String
string.gsub!(/<blockquote(| [^>]*)>/i, '> ') string.gsub!(/<blockquote(| [^>]*)>/i, '> ')
# add hr # add hr
string.gsub!(/<hr(|\/| [^>]*)>/i, "___\n") string.gsub!(%r{<hr(|/| [^>]*)>}i, "___\n")
# add new lines # add new lines
string.gsub!( /\<(br|table)(|\/| [^>]*)\>/i, "\n" ) string.gsub!( %r{\<(br|table)(|/| [^>]*)\>}i, "\n" )
string.gsub!( /\<\/(div|p|pre|blockquote|table|tr)(|\s.+?)\>/i, "\n" ) string.gsub!( %r{\</(div|p|pre|blockquote|table|tr)(|\s.+?)\>}i, "\n" )
string.gsub!( /\<\/td\>/i, ' ' ) string.gsub!( %r{/</td\>}i, ' ' )
# strip all other tags # strip all other tags
string.gsub!( /\<.+?\>/, '' ) string.gsub!( /\<.+?\>/, '' )