Corrected with rubocop cop 'Style/StringLiterals'.

This commit is contained in:
Thorsten Eckel 2015-04-27 15:20:16 +02:00
parent 4a669df039
commit a70b3cfc89
39 changed files with 137 additions and 137 deletions

View file

@ -179,7 +179,7 @@ class IcalTicketsController < ApplicationController
e.dtend = event_data[:dtend] e.dtend = event_data[:dtend]
e.summary = event_data[:summary] e.summary = event_data[:summary]
e.description = event_data[:description] e.description = event_data[:description]
e.ip_class = "PRIVATE" e.ip_class = 'PRIVATE'
end end
end end

View file

@ -45,7 +45,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!(/([^:])(\/+\/)/, '\\1/')
response = UserAgent.request( url ) response = UserAgent.request( url )
#Setting.set('import_mode', true) #Setting.set('import_mode', true)

View file

@ -12,7 +12,7 @@ class LongPollingController < ApplicationController
if !client_id if !client_id
new_connection = true new_connection = true
client_id = client_id_gen client_id = client_id_gen
log 'notice', "new client connection", client_id log 'notice', 'new client connection', client_id
end end
if !params['data'] if !params['data']
params['data'] = {} params['data'] = {}
@ -31,7 +31,7 @@ class LongPollingController < ApplicationController
if params['data']['timestamp'] if params['data']['timestamp']
log 'notice', "request spool data > '#{Time.at( params['data']['timestamp'] ).to_s}'", client_id log 'notice', "request spool data > '#{Time.at( params['data']['timestamp'] ).to_s}'", client_id
else else
log 'notice', "request spool init data", client_id log 'notice', 'request spool init data', client_id
end end
if current_user if current_user
@ -41,7 +41,7 @@ class LongPollingController < ApplicationController
log 'notice', "send spool to (user_id=#{ current_user.id })", client_id log 'notice', "send spool to (user_id=#{ current_user.id })", client_id
Sessions.send( client_id, item[:message] ) Sessions.send( client_id, item[:message] )
else else
log 'notice', "send spool", client_id log 'notice', 'send spool', client_id
Sessions.send( client_id, item[:message] ) Sessions.send( client_id, item[:message] )
end end
} }
@ -49,7 +49,7 @@ class LongPollingController < ApplicationController
# send spool:sent event to client # send spool:sent event to client
sleep 0.2 sleep 0.2
log 'notice', "send spool:sent event", client_id log 'notice', 'send spool:sent event', client_id
Sessions.send( client_id, { :event => 'spool:sent', :data => { :timestamp => Time.now.utc.to_i } } ) Sessions.send( client_id, { :event => 'spool:sent', :data => { :timestamp => Time.now.utc.to_i } } )
end end
@ -86,7 +86,7 @@ class LongPollingController < ApplicationController
Sessions.send( local_client_id, params['data'] ) Sessions.send( local_client_id, params['data'] )
end end
else else
log 'notice', "do not send broadcast to it self", client_id log 'notice', 'do not send broadcast to it self', client_id
end end
} }
end end

View file

@ -51,7 +51,7 @@ class NetworksController < ApplicationController
format.html { redirect_to @network, :notice => 'Network was successfully created.' } format.html { redirect_to @network, :notice => 'Network was successfully created.' }
format.json { render :json => @network, :status => :created } format.json { render :json => @network, :status => :created }
else else
format.html { render :action => "new" } format.html { render :action => 'new' }
format.json { render :json => @network.errors, :status => :unprocessable_entity } format.json { render :json => @network.errors, :status => :unprocessable_entity }
end end
end end
@ -67,7 +67,7 @@ class NetworksController < ApplicationController
format.html { redirect_to @network, :notice => 'Network was successfully updated.' } format.html { redirect_to @network, :notice => 'Network was successfully updated.' }
format.json { render :json => @network, :status => :ok } format.json { render :json => @network, :status => :ok }
else else
format.html { render :action => "edit" } format.html { render :action => 'edit' }
format.json { render :json => @network.errors, :status => :unprocessable_entity } format.json { render :json => @network.errors, :status => :unprocessable_entity }
end end
end end

View file

@ -138,7 +138,7 @@ class SessionsController < ApplicationController
auth = request.env['omniauth.auth'] auth = request.env['omniauth.auth']
if !auth if !auth
logger.info("AUTH IS NULL, SERVICE NOT LINKED TO ACCOUNT") logger.info('AUTH IS NULL, SERVICE NOT LINKED TO ACCOUNT')
# redirect to app # redirect to app
redirect_to '/' redirect_to '/'

View file

@ -352,7 +352,7 @@ class TicketsController < ApplicationController
def stats def stats
if !params[:user_id] && !params[:organization_id] if !params[:user_id] && !params[:organization_id]
raise "Need user_id or organization_id as param" raise 'Need user_id or organization_id as param'
end end
# permissin check # permissin check

View file

@ -344,7 +344,7 @@ returns
} }
return return
else else
raise "Need name, id or login for lookup()" raise 'Need name, id or login for lookup()'
end end
end end
@ -439,7 +439,7 @@ returns
record.save record.save
return record return record
else else
raise "Need name, login or locale for create_or_update()" raise 'Need name, login or locale for create_or_update()'
end end
end end

View file

@ -142,7 +142,7 @@ class Channel::EmailParser
data[:body] = Encode.conv( mail.html_part.charset.to_s, data[:body] ) data[:body] = Encode.conv( mail.html_part.charset.to_s, data[:body] )
data[:body] = data[:body].html2text.to_s.force_encoding('utf-8') data[:body] = data[:body].html2text.to_s.force_encoding('utf-8')
if !data[:body].force_encoding("UTF-8").valid_encoding? if !data[:body].force_encoding('UTF-8').valid_encoding?
data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?') data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
end end
@ -195,7 +195,7 @@ class Channel::EmailParser
data[:body] = mail.body.decoded data[:body] = mail.body.decoded
data[:body] = Encode.conv( mail.charset, data[:body] ) data[:body] = Encode.conv( mail.charset, data[:body] )
if !data[:body].force_encoding("UTF-8").valid_encoding? if !data[:body].force_encoding('UTF-8').valid_encoding?
data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?') data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
end end
@ -576,7 +576,7 @@ module Mail
module Encodings module Encodings
def Encodings.value_decode(str) def Encodings.value_decode(str)
# Optimization: If there's no encoded-words in the string, just return it # Optimization: If there's no encoded-words in the string, just return it
return str unless str.index("=?") return str unless str.index('=?')
str = str.gsub(/\?=(\s*)=\?/, '?==?') # Remove whitespaces between 'encoded-word's str = str.gsub(/\?=(\s*)=\?/, '?==?') # Remove whitespaces between 'encoded-word's
@ -604,7 +604,7 @@ module Mail
end end
end end
end end
end.join("") end.join('')
end end
end end
end end

View file

@ -42,7 +42,7 @@ class Channel::IMAP < Channel::EmailParser
@imap.select( channel[:options][:folder] ) @imap.select( channel[:options][:folder] )
end end
if check_type == 'check' if check_type == 'check'
puts "check only mode, fetch no emails" puts 'check only mode, fetch no emails'
disconnect disconnect
return return
elsif check_type == 'verify' elsif check_type == 'verify'
@ -68,7 +68,7 @@ class Channel::IMAP < Channel::EmailParser
subject = @imap.fetch(message_id,'ENVELOPE')[0].attr['ENVELOPE'].subject subject = @imap.fetch(message_id,'ENVELOPE')[0].attr['ENVELOPE'].subject
if subject && subject =~ /#{verify_string}/ if subject && subject =~ /#{verify_string}/
puts " - verify email #{verify_string} found" puts " - verify email #{verify_string} found"
@imap.store(message_id, "+FLAGS", [:Deleted]) @imap.store(message_id, '+FLAGS', [:Deleted])
@imap.expunge() @imap.expunge()
disconnect disconnect
return 'verify ok' return 'verify ok'
@ -78,16 +78,16 @@ class Channel::IMAP < Channel::EmailParser
# delete email from server after article was created # delete email from server after article was created
msg = @imap.fetch(message_id,'RFC822')[0].attr['RFC822'] msg = @imap.fetch(message_id,'RFC822')[0].attr['RFC822']
if process(channel, msg) if process(channel, msg)
@imap.store(message_id, "+FLAGS", [:Deleted]) @imap.store(message_id, '+FLAGS', [:Deleted])
end end
end end
end end
@imap.expunge() @imap.expunge()
disconnect disconnect
if count == 0 if count == 0
puts " - no message" puts ' - no message'
end end
puts "done" puts 'done'
end end
def disconnect def disconnect

View file

@ -2,7 +2,7 @@
class Channel::MailStdin < Channel::EmailParser class Channel::MailStdin < Channel::EmailParser
def initialize def initialize
puts "read main from STDIN" puts 'read main from STDIN'
msg = ARGF.read msg = ARGF.read

View file

@ -27,11 +27,11 @@ class Channel::POP3 < Channel::EmailParser
end end
@pop.start( channel[:options][:user], channel[:options][:password] ) @pop.start( channel[:options][:user], channel[:options][:password] )
if check_type == 'check' if check_type == 'check'
puts "check only mode, fetch no emails" puts 'check only mode, fetch no emails'
disconnect disconnect
return return
elsif check_type == 'verify' elsif check_type == 'verify'
puts "verify mode, fetch no emails" puts 'verify mode, fetch no emails'
end end
mails = @pop.mails mails = @pop.mails
@ -66,9 +66,9 @@ class Channel::POP3 < Channel::EmailParser
end end
disconnect disconnect
if count == 0 if count == 0
puts " - no message" puts ' - no message'
end end
puts "done" puts 'done'
end end
def disconnect def disconnect

View file

@ -28,7 +28,7 @@ class Channel::TWITTER2
channel[:options][:search].each { |search| channel[:options][:search].each { |search|
puts " - searching for #{search[:item]}" puts " - searching for #{search[:item]}"
tweets = [] tweets = []
@client.search( search[:item], :count => 50, :result_type => "recent" ).collect do |tweet| @client.search( search[:item], :count => 50, :result_type => 'recent' ).collect do |tweet|
tweets.push tweet tweets.push tweet
end end
@article_type = 'twitter status' @article_type = 'twitter status'
@ -38,7 +38,7 @@ class Channel::TWITTER2
# mentions # mentions
if channel[:options][:mentions] if channel[:options][:mentions]
puts " - searching for mentions" puts ' - searching for mentions'
tweets = @client.mentions_timeline tweets = @client.mentions_timeline
@article_type = 'twitter status' @article_type = 'twitter status'
fetch_loop( tweets, channel, channel[:options][:mentions][:group] ) fetch_loop( tweets, channel, channel[:options][:mentions][:group] )
@ -46,7 +46,7 @@ class Channel::TWITTER2
# direct messages # direct messages
if channel[:options][:direct_messages] if channel[:options][:direct_messages]
puts " - searching for direct_messages" puts ' - searching for direct_messages'
tweets = @client.direct_messages tweets = @client.direct_messages
@article_type = 'twitter direct-message' @article_type = 'twitter direct-message'
fetch_loop( tweets, channel, channel[:options][:direct_messages][:group] ) fetch_loop( tweets, channel, channel[:options][:direct_messages][:group] )
@ -112,7 +112,7 @@ class Channel::TWITTER2
begin begin
sender = @client.user(tweet.from_user_id) sender = @client.user(tweet.from_user_id)
rescue Exception => e rescue Exception => e
puts "Exception: twitter: " + e.inspect puts 'Exception: twitter: ' + e.inspect
return return
end end
end end

View file

@ -80,7 +80,7 @@ class Job < ApplicationModel
end end
def self.match_minutes(minutes) def self.match_minutes(minutes)
minutes.gsub!(/(\d)\d/, "\\1") minutes.gsub!(/(\d)\d/, '\\1')
minutes.to_s + '0' minutes.to_s + '0'
end end
end end

View file

@ -19,9 +19,9 @@ class Package < ApplicationModel
package = self._parse( data[:string] ) package = self._parse( data[:string] )
end end
build_date = REXML::Element.new("build_date") build_date = REXML::Element.new('build_date')
build_date.text = Time.now.utc.iso8601 build_date.text = Time.now.utc.iso8601
build_host = REXML::Element.new("build_host") build_host = REXML::Element.new('build_host')
build_host.text = Socket.gethostname build_host.text = Socket.gethostname
package.root.insert_after( '//zpm/description', build_date ) package.root.insert_after( '//zpm/description', build_date )
@ -33,7 +33,7 @@ class Package < ApplicationModel
element.text = base64 element.text = base64
end end
if data[:output] if data[:output]
location = data[:output] + '/' + package.elements["zpm/name"].text + '-' + package.elements["zpm/version"].text + '.zpm' location = data[:output] + '/' + package.elements['zpm/name'].text + '-' + package.elements['zpm/version'].text + '.zpm'
logger.info "NOTICE: writting package to '#{location}'" logger.info "NOTICE: writting package to '#{location}'"
file = File.new( location, 'wb' ) file = File.new( location, 'wb' )
file.write( package.to_s ) file.write( package.to_s )
@ -186,9 +186,9 @@ class Package < ApplicationModel
# package meta data # package meta data
meta = { meta = {
:name => package.elements["zpm/name"].text, :name => package.elements['zpm/name'].text,
:version => package.elements["zpm/version"].text, :version => package.elements['zpm/version'].text,
:vendor => package.elements["zpm/vendor"].text, :vendor => package.elements['zpm/vendor'].text,
:state => 'uninstalled', :state => 'uninstalled',
:created_by_id => 1, :created_by_id => 1,
:updated_by_id => 1, :updated_by_id => 1,
@ -275,8 +275,8 @@ class Package < ApplicationModel
# package meta data # package meta data
meta = { meta = {
:name => package.elements["zpm/name"].text, :name => package.elements['zpm/name'].text,
:version => package.elements["zpm/version"].text, :version => package.elements['zpm/version'].text,
} }
# down migrations # down migrations

View file

@ -114,7 +114,7 @@ class Scheduler < ApplicationModel
if count.zero? if count.zero?
sleep(wait) sleep(wait)
logger.info "*** worker loop" logger.info '*** worker loop'
else else
printf "*** #{count} jobs processed at %.4f j/s, %d failed ...\n" % [count / realtime, result.last] printf "*** #{count} jobs processed at %.4f j/s, %d failed ...\n" % [count / realtime, result.last]
end end

View file

@ -14,7 +14,7 @@ class Store::File < ApplicationModel
# load backend based on config # load backend based on config
adapter_name = Setting.get('storage_provider') || 'DB' adapter_name = Setting.get('storage_provider') || 'DB'
if !adapter_name if !adapter_name
raise "Missing storage_provider setting option" raise 'Missing storage_provider setting option'
end end
adapter = self.load_adapter( "Store::Provider::#{ adapter_name }" ) adapter = self.load_adapter( "Store::Provider::#{ adapter_name }" )
adapter.add( data, sha ) adapter.add( data, sha )

View file

@ -47,7 +47,7 @@ returns
# load backend based on config # load backend based on config
adapter_name = Setting.get('ticket_number') adapter_name = Setting.get('ticket_number')
if !adapter_name if !adapter_name
raise "Missing ticket_number setting option" raise 'Missing ticket_number setting option'
end end
adapter = load_adapter(adapter_name) adapter = load_adapter(adapter_name)
if !adapter if !adapter

View file

@ -9,7 +9,7 @@ module Ticket::Number::Date
config = Setting.get('ticket_number_date') config = Setting.get('ticket_number_date')
t = Time.now t = Time.now
date = t.strftime("%Y-%m-%d") date = t.strftime('%Y-%m-%d')
# read counter # read counter
counter_increment = nil counter_increment = nil
@ -33,7 +33,7 @@ module Ticket::Number::Date
end end
system_id = Setting.get('system_id') || '' system_id = Setting.get('system_id') || ''
number = t.strftime("%Y%m%d") + system_id.to_s + sprintf( "%04d", counter_increment) number = t.strftime('%Y%m%d') + system_id.to_s + sprintf( '%04d', counter_increment)
# calculate a checksum # calculate a checksum
# The algorithm to calculate the checksum is derived from the one # The algorithm to calculate the checksum is derived from the one

View file

@ -88,7 +88,7 @@ returns
# check ignored files # check ignored files
if attachment.filename if attachment.filename
filename_extention = attachment.filename.downcase filename_extention = attachment.filename.downcase
filename_extention.gsub!(/^.*(\..+?)$/, "\\1") filename_extention.gsub!(/^.*(\..+?)$/, '\\1')
if !attachments_ignore.include?( filename_extention.downcase ) if !attachments_ignore.include?( filename_extention.downcase )
data = { data = {
'_name' => attachment.filename, '_name' => attachment.filename,

View file

@ -54,7 +54,7 @@ module Zammad
# config.i18n.default_locale = :de # config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9. # Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8" config.encoding = 'utf-8'
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password] config.filter_parameters += [:password]

View file

@ -14,7 +14,7 @@ Zammad::Application.configure do
# Configure static asset server for tests with Cache-Control for performance # Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600" config.static_cache_control = 'public, max-age=3600'
# Disable assert compression for relyable error code lines # Disable assert compression for relyable error code lines
config.assets.compress = false config.assets.compress = false

View file

@ -9,7 +9,7 @@ Zammad::Application.configure do
# Configure static asset server for tests with Cache-Control for performance # Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600" config.static_cache_control = 'public, max-age=3600'
# Disable assert compression for relyable error code lines # Disable assert compression for relyable error code lines
config.assets.compress = false config.assets.compress = false

View file

@ -4,7 +4,7 @@ class Class
camel_cased_word.gsub(/::/, '_'). camel_cased_word.gsub(/::/, '_').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_"). tr('-', '_').
downcase downcase
end end
def to_app_model def to_app_model

View file

@ -84,10 +84,10 @@ class String
# pre/code handling 1/2 # pre/code handling 1/2
string.gsub!( /<pre>(.+?)<\/pre>/m ) { |placeholder| string.gsub!( /<pre>(.+?)<\/pre>/m ) { |placeholder|
placeholder = placeholder.gsub(/\n/, "###BR###") placeholder = placeholder.gsub(/\n/, '###BR###')
} }
string.gsub!( /<code>(.+?)<\/code>/m ) { |placeholder| string.gsub!( /<code>(.+?)<\/code>/m ) { |placeholder|
placeholder = placeholder.gsub(/\n/, "###BR###") placeholder = placeholder.gsub(/\n/, '###BR###')
} }
# remove all new lines # remove all new lines

View file

@ -1,6 +1,6 @@
module FillDB module FillDB
def self.load( agents, customers, groups, organizations, tickets ) def self.load( agents, customers, groups, organizations, tickets )
puts "load db with:" puts 'load db with:'
puts " agents:#{agents}" puts " agents:#{agents}"
puts " customers:#{customers}" puts " customers:#{customers}"
puts " groups:#{groups}" puts " groups:#{groups}"

View file

@ -11,7 +11,7 @@ class GeoIp::ZammadGeoIp
return cache if cache return cache if cache
# do lookup # do lookup
host = "https://geo.zammad.com" host = 'https://geo.zammad.com'
url = "/lookup?ip=#{CGI::escape address}" url = "/lookup?ip=#{CGI::escape address}"
data = {} data = {}
begin begin

View file

@ -43,7 +43,7 @@ module Import::OTRS
end end
def self.auth(username, password) def self.auth(username, password)
response = post( "public.pl", { :Action => 'Export', :Type => 'Auth', :User => username, :Pw => password } ) response = post( 'public.pl', { :Action => 'Export', :Type => 'Auth', :User => username, :Pw => password } )
return if !response return if !response
return if !response.success? return if !response.success?
@ -52,7 +52,7 @@ module Import::OTRS
end end
def self.session(session_id) def self.session(session_id)
response = post( "public.pl", { :Action => 'Export', :Type => 'SessionCheck', :SessionID => session_id } ) response = post( 'public.pl', { :Action => 'Export', :Type => 'SessionCheck', :SessionID => session_id } )
return if !response return if !response
return if !response.success? return if !response.success?
@ -117,10 +117,10 @@ module Import::OTRS
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise "System is not in import mode!" raise 'System is not in import mode!'
end end
response = request("public.pl?Action=Export") response = request('public.pl?Action=Export')
return if !response return if !response
return if !response.success? return if !response.success?
@ -181,7 +181,7 @@ module Import::OTRS
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise "System is not in import mode!" raise 'System is not in import mode!'
end end
# create states # create states
@ -203,7 +203,7 @@ module Import::OTRS
def self.ticket_diff() def self.ticket_diff()
url = "public.pl?Action=Export;Type=TicketDiff;Limit=30" url = 'public.pl?Action=Export;Type=TicketDiff;Limit=30'
response = request( url ) response = request( url )
return if !response return if !response
return if !response.success? return if !response.success?
@ -212,7 +212,7 @@ module Import::OTRS
end end
def self.ticket(ticket_ids) def self.ticket(ticket_ids)
url = "public.pl?Action=Export;Type=Ticket;" url = 'public.pl?Action=Export;Type=Ticket;'
ticket_ids.each {|ticket_id| ticket_ids.each {|ticket_id|
url = url + "TicketID=#{CGI::escape ticket_id};" url = url + "TicketID=#{CGI::escape ticket_id};"
} }
@ -543,7 +543,7 @@ module Import::OTRS
end end
def self.state def self.state
response = request( "public.pl?Action=Export;Type=State" ) response = request( 'public.pl?Action=Export;Type=State' )
return if !response return if !response
return if !response.success? return if !response.success?
@ -600,7 +600,7 @@ module Import::OTRS
} }
end end
def self.priority def self.priority
response = request( "public.pl?Action=Export;Type=Priority" ) response = request( 'public.pl?Action=Export;Type=Priority' )
return if !response return if !response
return if !response.success? return if !response.success?
@ -644,7 +644,7 @@ module Import::OTRS
} }
end end
def self.ticket_group def self.ticket_group
response = request( "public.pl?Action=Export;Type=Queue" ) response = request( 'public.pl?Action=Export;Type=Queue' )
return if !response return if !response
return if !response.success? return if !response.success?
@ -688,7 +688,7 @@ module Import::OTRS
} }
end end
def self.user def self.user
response = request( "public.pl?Action=Export;Type=User" ) response = request( 'public.pl?Action=Export;Type=User' )
return if !response return if !response
return if !response.success? return if !response.success?
result = json(response) result = json(response)

View file

@ -29,7 +29,7 @@ module Import::OTRS2
end end
result = json(response) result = json(response)
if !result if !result
raise "Invalid response" raise 'Invalid response'
end end
if data_only if data_only
result['Result'] result['Result']
@ -292,12 +292,12 @@ module Import::OTRS2
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise "System is not in import mode!" raise 'System is not in import mode!'
end end
result = request_json({}) result = request_json({})
if !result['Success'] if !result['Success']
"API key not valid!" 'API key not valid!'
end end
# set settings # set settings
@ -350,7 +350,7 @@ module Import::OTRS2
count += steps count += steps
records = load('CustomerUser', steps, count-steps) records = load('CustomerUser', steps, count-steps)
if !records || !records[0] if !records || !records[0]
log "all customers imported." log 'all customers imported.'
run = false run = false
next next
end end
@ -408,7 +408,7 @@ module Import::OTRS2
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise "System is not in import mode!" raise 'System is not in import mode!'
end end
# create states # create states
@ -450,14 +450,14 @@ module Import::OTRS2
locks = { :User => {} } locks = { :User => {} }
while run while run
count += steps count += steps
log "loading... diff ..." log 'loading... diff ...'
offset = count-steps offset = count-steps
if offset != 0 if offset != 0
offset = count - steps + 1 offset = count - steps + 1
end end
records = load( 'Ticket', steps, count-steps, 1 ) records = load( 'Ticket', steps, count-steps, 1 )
if !records || !records[0] if !records || !records[0]
log "... no more work." log '... no more work.'
run = false run = false
next next
end end

View file

@ -174,7 +174,7 @@ return search result
:order => 'desc' :order => 'desc'
} }
}, },
"_score" '_score'
] ]
data['query'] = query_extention || {} data['query'] = query_extention || {}

View file

@ -2,9 +2,9 @@ class Sessions::Client
def initialize( client_id ) def initialize( client_id )
@client_id = client_id @client_id = client_id
self.log 'notify', "---client start ws connection---" self.log 'notify', '---client start ws connection---'
self.fetch self.fetch
self.log 'notify', "---client exiting ws connection---" self.log 'notify', '---client exiting ws connection---'
end end
def fetch def fetch
@ -56,7 +56,7 @@ class Sessions::Client
pool.push pool.push
} }
self.log 'notice', "---/client-" self.log 'notice', '---/client-'
# start faster in the beginnig # start faster in the beginnig
if loop_count < 20 if loop_count < 20

View file

@ -31,7 +31,7 @@ module StaticAssets
if list && list[0] if list && list[0]
return Store.find( list[0] ) return Store.find( list[0] )
end end
raise "No such raw logo!" raise 'No such raw logo!'
end end
# store image in right size # store image in right size

View file

@ -5,7 +5,7 @@ namespace :searchindex do
task :drop, [:opts] => :environment do |t, args| task :drop, [:opts] => :environment do |t, args|
# drop indexes # drop indexes
puts "drop indexes..." puts 'drop indexes...'
SearchIndexBackend.index( SearchIndexBackend.index(
:action => 'delete', :action => 'delete',
) )
@ -15,7 +15,7 @@ namespace :searchindex do
task :create, [:opts] => :environment do |t, args| task :create, [:opts] => :environment do |t, args|
# create indexes # create indexes
puts "create indexes..." puts 'create indexes...'
SearchIndexBackend.index( SearchIndexBackend.index(
:action => 'create', :action => 'create',
:data => { :data => {
@ -41,7 +41,7 @@ namespace :searchindex do
task :reload, [:opts] => :environment do |t, args| task :reload, [:opts] => :environment do |t, args|
puts "reload data..." puts 'reload data...'
User.search_index_reload User.search_index_reload
Organization.search_index_reload Organization.search_index_reload
Ticket.search_index_reload Ticket.search_index_reload
@ -50,9 +50,9 @@ namespace :searchindex do
task :rebuild, [:opts] => :environment do |t, args| task :rebuild, [:opts] => :environment do |t, args|
Rake::Task["searchindex:drop"].execute Rake::Task['searchindex:drop'].execute
Rake::Task["searchindex:create"].execute Rake::Task['searchindex:create'].execute
Rake::Task["searchindex:reload"].execute Rake::Task['searchindex:reload'].execute
end end
end end

View file

@ -2,7 +2,7 @@ $LOAD_PATH << './lib'
require 'rubygems' require 'rubygems'
namespace :test do namespace :test do
desc "Start browser tests" desc 'Start browser tests'
task :browser, [:opts] => :environment do |t, args| task :browser, [:opts] => :environment do |t, args|
start = Time.now() start = Time.now()
@ -11,10 +11,10 @@ namespace :test do
end end
Dir.glob('test/browser/*_test.rb').sort.each { |r| Dir.glob('test/browser/*_test.rb').sort.each { |r|
sh "#{args.opts} ruby -Itest #{r}" do |ok, res| sh "#{args.opts} ruby -Itest #{r}" do |ok, res|
raise "Failed test. " + res.inspect if !ok raise 'Failed test. ' + res.inspect if !ok
end end
} }
puts "All browser tests, elapsed: " + (Time.now() - start).to_s + " seconds" puts 'All browser tests, elapsed: ' + (Time.now() - start).to_s + ' seconds'
end end
end end

View file

@ -49,7 +49,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
} }
if !config_ok if !config_ok
raise "sla config is invalid! " + config.inspect raise 'sla config is invalid! ' + config.inspect
end end
# shift working hours / if needed # shift working hours / if needed

View file

@ -267,7 +267,7 @@ returns
def self.set_params(request, params, options) def self.set_params(request, params, options)
if options[:json] if options[:json]
request.add_field("Content-Type", "application/json") request.add_field('Content-Type', 'application/json')
if !params.empty? if !params.empty?
request.body = params.to_json request.body = params.to_json
end end
@ -308,7 +308,7 @@ returns
:code => response.code, :code => response.code,
) )
when Net::HTTPRedirection when Net::HTTPRedirection
raise "Too many redirections for the original URL, halting." if count <= 0 raise 'Too many redirections for the original URL, halting.' if count <= 0
url = response['location'] url = response['location']
return get(url, params, options, count - 1) return get(url, params, options, count - 1)
when Net::HTTPOK when Net::HTTPOK

View file

@ -20,13 +20,13 @@
***************************************************************************/ ***************************************************************************/
=end =end
PVERSION = "Version 2.9, 10/24/2008" PVERSION = 'Version 2.9, 10/24/2008'
module RBeautify module RBeautify
# user-customizable values # user-customizable values
RBeautify::TabStr = " " RBeautify::TabStr = ' '
RBeautify::TabSize = 2 RBeautify::TabSize = 2
# indent regexp tests # indent regexp tests
@ -71,7 +71,7 @@ module RBeautify
] ]
def RBeautify.rb_make_tab(tab) def RBeautify.rb_make_tab(tab)
return (tab < 0)?"":TabStr * TabSize * tab return (tab < 0)?'':TabStr * TabSize * tab
end end
def RBeautify.rb_add_line(line,tab) def RBeautify.rb_add_line(line,tab)
@ -80,13 +80,13 @@ module RBeautify
return line return line
end end
def RBeautify.beautify_string(source, path = "") def RBeautify.beautify_string(source, path = '')
comment_block = false comment_block = false
in_here_doc = false in_here_doc = false
here_doc_term = "" here_doc_term = ''
program_end = false program_end = false
multiLine_array = [] multiLine_array = []
multiLine_str = "" multiLine_str = ''
tab = 0 tab = 0
output = [] output = []
source.each do |line| source.each do |line|
@ -99,14 +99,14 @@ module RBeautify
# combine continuing lines # combine continuing lines
if(!(line =~ /^\s*#/) && line =~ /[^\\]\\\s*$/) if(!(line =~ /^\s*#/) && line =~ /[^\\]\\\s*$/)
multiLine_array.push line multiLine_array.push line
multiLine_str += line.sub(/^(.*)\\\s*$/,"\\1") multiLine_str += line.sub(/^(.*)\\\s*$/,'\\1')
next next
end end
# add final line # add final line
if(multiLine_str.length > 0) if(multiLine_str.length > 0)
multiLine_array.push line multiLine_array.push line
multiLine_str += line.sub(/^(.*)\\\s*$/,"\\1") multiLine_str += line.sub(/^(.*)\\\s*$/,'\\1')
end end
tline = ((multiLine_str.length > 0)?multiLine_str:line).strip tline = ((multiLine_str.length > 0)?multiLine_str:line).strip
@ -117,7 +117,7 @@ module RBeautify
in_here_doc = false if tline =~ %r{\s*#{here_doc_term}\s*} in_here_doc = false if tline =~ %r{\s*#{here_doc_term}\s*}
else # not in here_doc else # not in here_doc
if tline =~ %r{=\s*<<} if tline =~ %r{=\s*<<}
here_doc_term = tline.sub(%r{.*=\s*<<-?\s*([_|\w]+).*},"\\1") here_doc_term = tline.sub(%r{.*=\s*<<-?\s*([_|\w]+).*},'\\1')
in_here_doc = here_doc_term.size > 0 in_here_doc = here_doc_term.size > 0
end end
end end
@ -131,24 +131,24 @@ module RBeautify
if(!comment_line) if(!comment_line)
# throw out sequences that will # throw out sequences that will
# only sow confusion # only sow confusion
while tline.gsub!(/\{[^\{]*?\}/,"") while tline.gsub!(/\{[^\{]*?\}/,'')
end end
while tline.gsub!(/\[[^\[]*?\]/,"") while tline.gsub!(/\[[^\[]*?\]/,'')
end end
while tline.gsub!(/'.*?'/,"") while tline.gsub!(/'.*?'/,'')
end end
while tline.gsub!(/".*?"/,"") while tline.gsub!(/".*?"/,'')
end end
while tline.gsub!(/\`.*?\`/,"") while tline.gsub!(/\`.*?\`/,'')
end end
while tline.gsub!(/\([^\(]*?\)/,"") while tline.gsub!(/\([^\(]*?\)/,'')
end end
while tline.gsub!(/\/.*?\//,"") while tline.gsub!(/\/.*?\//,'')
end end
while tline.gsub!(/%r(.).*?\1/,"") while tline.gsub!(/%r(.).*?\1/,'')
end end
# delete end-of-line comments # delete end-of-line comments
tline.sub!(/#[^\"]+$/,"") tline.sub!(/#[^\"]+$/,'')
# convert quotes # convert quotes
tline.gsub!(/\\\"/,"'") tline.gsub!(/\\\"/,"'")
OutdentExp.each do |re| OutdentExp.each do |re|
@ -163,7 +163,7 @@ module RBeautify
output << rb_add_line(ml,tab) output << rb_add_line(ml,tab)
end end
multiLine_array.clear multiLine_array.clear
multiLine_str = "" multiLine_str = ''
else else
output << rb_add_line(line,tab) output << rb_add_line(line,tab)
end end
@ -189,7 +189,7 @@ module RBeautify
error = false error = false
if(path == '-') # stdin source if(path == '-') # stdin source
source = STDIN.read source = STDIN.read
dest,error = beautify_string(source,"stdin") dest,error = beautify_string(source,'stdin')
print dest print dest
else # named file source else # named file source
source = File.read(path) source = File.read(path)
@ -198,7 +198,7 @@ module RBeautify
# make a backup copy # make a backup copy
#File.open(path + "~","w") { |f| f.write(source) } #File.open(path + "~","w") { |f| f.write(source) }
# overwrite the original # overwrite the original
File.open(path,"w") { |f| f.write(dest) } File.open(path,'w') { |f| f.write(dest) }
end end
end end
return error return error

View file

@ -28,9 +28,9 @@ runner_count = 2
Dir.chdir dir Dir.chdir dir
RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development' RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development'
$stdout.reopen( dir + "/log/" + name + "_out.log", "w") $stdout.reopen( dir + '/log/' + name + '_out.log', 'w')
$stderr.reopen( dir + "/log/" + name + "_err.log", "w") $stderr.reopen( dir + '/log/' + name + '_err.log', 'w')
require File.join(dir, "config", "environment") require File.join(dir, 'config', 'environment')
require 'scheduler' require 'scheduler'
Scheduler.run(count, runner_count) Scheduler.run(count, runner_count)
@ -48,9 +48,9 @@ Daemons.run_proc(name, daemon_options) do
Dir.chdir dir Dir.chdir dir
RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development' RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development'
$stdout.reopen( dir + "/log/" + name + "_out.log", "w") $stdout.reopen( dir + '/log/' + name + '_out.log', 'w')
$stderr.reopen( dir + "/log/" + name + "_err.log", "w") $stderr.reopen( dir + '/log/' + name + '_err.log', 'w')
require File.join(dir, "config", "environment") require File.join(dir, 'config', 'environment')
require 'scheduler' require 'scheduler'
Scheduler.worker Scheduler.worker

View file

@ -70,7 +70,7 @@ end
folder = ['app/assets/javascripts/app','app/controllers/', 'app/models/', 'app/helpers/', 'app/mailers/' ] folder = ['app/assets/javascripts/app','app/controllers/', 'app/models/', 'app/helpers/', 'app/mailers/' ]
folder.each do |folder| folder.each do |folder|
puts 'Working on folder' + folder.to_s puts 'Working on folder' + folder.to_s
rbfiles = File.join("../#{folder}**", "*.{rb,coffee}") rbfiles = File.join("../#{folder}**", '*.{rb,coffee}')
d = Dir.glob(rbfiles) d = Dir.glob(rbfiles)
d.each {|fileName| d.each {|fileName|

View file

@ -26,30 +26,30 @@ require 'daemons'
tls_options = {} tls_options = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "Usage: websocket-server.rb start|stop [options]" opts.banner = 'Usage: websocket-server.rb start|stop [options]'
opts.on("-d", "--daemon", "start as daemon") do |d| opts.on('-d', '--daemon', 'start as daemon') do |d|
@options[:d] = d @options[:d] = d
end end
opts.on("-v", "--verbose", "enable debug messages") do |d| opts.on('-v', '--verbose', 'enable debug messages') do |d|
@options[:v] = d @options[:v] = d
end end
opts.on("-p", "--port [OPT]", "port of websocket server") do |p| opts.on('-p', '--port [OPT]', 'port of websocket server') do |p|
@options[:p] = p @options[:p] = p
end end
opts.on("-b", "--bind [OPT]", "bind address") do |b| opts.on('-b', '--bind [OPT]', 'bind address') do |b|
@options[:b] = b @options[:b] = b
end end
opts.on("-s", "--secure", "enable secure connections") do |s| opts.on('-s', '--secure', 'enable secure connections') do |s|
@options[:s] = s @options[:s] = s
end end
opts.on("-i", "--pid [OPT]", "pid, default is tmp/pids/websocket.pid") do |i| opts.on('-i', '--pid [OPT]', 'pid, default is tmp/pids/websocket.pid') do |i|
@options[:i] = i @options[:i] = i
end end
opts.on("-k", "--private-key [OPT]", "/path/to/server.key for secure connections") do |k| opts.on('-k', '--private-key [OPT]', '/path/to/server.key for secure connections') do |k|
tls_options[:private_key_file] = k tls_options[:private_key_file] = k
end end
opts.on("-c", "--certificate [OPT]", "/path/to/server.crt for secure connections") do |c| opts.on('-c', '--certificate [OPT]', '/path/to/server.crt for secure connections') do |c|
tls_options[:cert_chain_file] = c tls_options[:cert_chain_file] = c
end end
end.parse! end.parse!
@ -66,7 +66,7 @@ if ARGV[0] == 'stop'
# read pid # read pid
pid =File.open( @options[:i].to_s ).read pid =File.open( @options[:i].to_s ).read
pid.gsub!(/\r|\n/, "") pid.gsub!(/\r|\n/, '')
# kill # kill
Process.kill( 9, pid.to_i ) Process.kill( 9, pid.to_i )
@ -77,7 +77,7 @@ if ARGV[0] == 'start' && @options[:d]
Daemons.daemonize Daemons.daemonize
# create pid file # create pid file
$daemon_pid = File.new( @options[:i].to_s,"w" ) $daemon_pid = File.new( @options[:i].to_s,'w' )
$daemon_pid.sync = true $daemon_pid.sync = true
$daemon_pid.puts(Process.pid.to_s) $daemon_pid.puts(Process.pid.to_s)
$daemon_pid.close $daemon_pid.close
@ -142,7 +142,7 @@ EventMachine.run {
if data['timestamp'] if data['timestamp']
log 'notice', "request spool data > '#{Time.at(data['timestamp']).to_s}'", client_id log 'notice', "request spool data > '#{Time.at(data['timestamp']).to_s}'", client_id
else else
log 'notice', "request spool with init data", client_id log 'notice', 'request spool with init data', client_id
end end
if @clients[client_id] && @clients[client_id][:session] && @clients[client_id][:session]['id'] if @clients[client_id] && @clients[client_id][:session] && @clients[client_id][:session]['id']
@ -155,7 +155,7 @@ EventMachine.run {
log 'notice', "send spool to (user_id=#{ @clients[client_id][:session]['id'] })", client_id log 'notice', "send spool to (user_id=#{ @clients[client_id][:session]['id'] })", client_id
@clients[client_id][:websocket].send( "[#{ msg }]" ) @clients[client_id][:websocket].send( "[#{ msg }]" )
else else
log 'notice', "send spool", client_id log 'notice', 'send spool', client_id
@clients[client_id][:websocket].send( "[#{ msg }]" ) @clients[client_id][:websocket].send( "[#{ msg }]" )
end end
} }
@ -164,7 +164,7 @@ EventMachine.run {
end end
# send spool:sent event to client # send spool:sent event to client
log 'notice', "send spool:sent event", client_id log 'notice', 'send spool:sent event', client_id
@clients[client_id][:websocket].send( '[{"event":"spool:sent","data":{"timestamp":' + Time.now.utc.to_i.to_s + '}}]' ) @clients[client_id][:websocket].send( '[{"event":"spool:sent","data":{"timestamp":' + Time.now.utc.to_i.to_s + '}}]' )
end end
@ -222,7 +222,7 @@ EventMachine.run {
end end
end end
else else
log 'notice', "do not send broadcast to it self", client_id log 'notice', 'do not send broadcast to it self', client_id
end end
} }
end end
@ -264,7 +264,7 @@ EventMachine.run {
EventMachine.add_periodic_timer(0.4) { EventMachine.add_periodic_timer(0.4) {
next if @clients.size == 0 next if @clients.size == 0
log 'debug', "checking for data to send..." log 'debug', 'checking for data to send...'
@clients.each { |client_id, client| @clients.each { |client_id, client|
next if client[:disconnect] next if client[:disconnect]
log 'debug', 'checking for data...', client_id log 'debug', 'checking for data...', client_id
@ -272,7 +272,7 @@ EventMachine.run {
queue = Sessions.queue( client_id ) queue = Sessions.queue( client_id )
if queue && queue[0] if queue && queue[0]
# log "send " + queue.inspect, client_id # log "send " + queue.inspect, client_id
log 'notice', "send data to client", client_id log 'notice', 'send data to client', client_id
client[:websocket].send( queue.to_json ) client[:websocket].send( queue.to_json )
end end
rescue => e rescue => e
@ -291,14 +291,14 @@ EventMachine.run {
} }
def check_unused_connections def check_unused_connections
log 'notice', "check unused idle connections..." log 'notice', 'check unused idle connections...'
idle_time_in_sec = 4 * 60 idle_time_in_sec = 4 * 60
# close unused web socket sessions # close unused web socket sessions
@clients.each { |client_id, client| @clients.each { |client_id, client|
if ( client[:last_ping] + idle_time_in_sec ) < Time.now if ( client[:last_ping] + idle_time_in_sec ) < Time.now
log 'notice', "closing idle websocket connection", client_id log 'notice', 'closing idle websocket connection', client_id
# remember to not use this connection anymore # remember to not use this connection anymore
client[:disconnect] = true client[:disconnect] = true
@ -315,7 +315,7 @@ EventMachine.run {
# close unused ajax long polling sessions # close unused ajax long polling sessions
clients = Sessions.destory_idle_sessions(idle_time_in_sec) clients = Sessions.destory_idle_sessions(idle_time_in_sec)
clients.each { |client_id| clients.each { |client_id|
log 'notice', "closing idle long polling connection", client_id log 'notice', 'closing idle long polling connection', client_id
} }
end end