Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Martin Edenhofer 2015-04-27 15:29:41 +02:00
commit 399a119da9
39 changed files with 137 additions and 137 deletions

View file

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

View file

@ -45,7 +45,7 @@ class ImportOtrsController < ApplicationController
suffixes.each {|suffix|
url = params[:url] + suffix + '?Action=ZammadMigrator'
# strip multible / in url
url.gsub!(/([^:])(\/+\/)/, "\\1/")
url.gsub!(/([^:])(\/+\/)/, '\\1/')
response = UserAgent.request( url )
#Setting.set('import_mode', true)

View file

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

View file

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

View file

@ -138,7 +138,7 @@ class SessionsController < ApplicationController
auth = request.env['omniauth.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 '/'

View file

@ -352,7 +352,7 @@ class TicketsController < ApplicationController
def stats
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
# permissin check

View file

@ -344,7 +344,7 @@ returns
}
return
else
raise "Need name, id or login for lookup()"
raise 'Need name, id or login for lookup()'
end
end
@ -439,7 +439,7 @@ returns
record.save
return record
else
raise "Need name, login or locale for create_or_update()"
raise 'Need name, login or locale for create_or_update()'
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] = 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 => '?')
end
@ -195,7 +195,7 @@ class Channel::EmailParser
data[:body] = mail.body.decoded
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 => '?')
end
@ -576,7 +576,7 @@ module Mail
module Encodings
def Encodings.value_decode(str)
# 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
@ -604,7 +604,7 @@ module Mail
end
end
end
end.join("")
end.join('')
end
end
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,9 +19,9 @@ class Package < ApplicationModel
package = self._parse( data[:string] )
end
build_date = REXML::Element.new("build_date")
build_date = REXML::Element.new('build_date')
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
package.root.insert_after( '//zpm/description', build_date )
@ -33,7 +33,7 @@ class Package < ApplicationModel
element.text = base64
end
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}'"
file = File.new( location, 'wb' )
file.write( package.to_s )
@ -186,9 +186,9 @@ class Package < ApplicationModel
# package meta data
meta = {
:name => package.elements["zpm/name"].text,
:version => package.elements["zpm/version"].text,
:vendor => package.elements["zpm/vendor"].text,
:name => package.elements['zpm/name'].text,
:version => package.elements['zpm/version'].text,
:vendor => package.elements['zpm/vendor'].text,
:state => 'uninstalled',
:created_by_id => 1,
:updated_by_id => 1,
@ -275,8 +275,8 @@ class Package < ApplicationModel
# package meta data
meta = {
:name => package.elements["zpm/name"].text,
:version => package.elements["zpm/version"].text,
:name => package.elements['zpm/name'].text,
:version => package.elements['zpm/version'].text,
}
# down migrations

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -54,7 +54,7 @@ module Zammad
# config.i18n.default_locale = :de
# 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.
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
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
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
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
config.assets.compress = false

View file

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

View file

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

View file

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

View file

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

View file

@ -43,7 +43,7 @@ module Import::OTRS
end
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.success?
@ -52,7 +52,7 @@ module Import::OTRS
end
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.success?
@ -117,10 +117,10 @@ module Import::OTRS
# check if system is in import mode
if !Setting.get('import_mode')
raise "System is not in import mode!"
raise 'System is not in import mode!'
end
response = request("public.pl?Action=Export")
response = request('public.pl?Action=Export')
return if !response
return if !response.success?
@ -181,7 +181,7 @@ module Import::OTRS
# check if system is in import mode
if !Setting.get('import_mode')
raise "System is not in import mode!"
raise 'System is not in import mode!'
end
# create states
@ -203,7 +203,7 @@ module Import::OTRS
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 )
return if !response
return if !response.success?
@ -212,7 +212,7 @@ module Import::OTRS
end
def self.ticket(ticket_ids)
url = "public.pl?Action=Export;Type=Ticket;"
url = 'public.pl?Action=Export;Type=Ticket;'
ticket_ids.each {|ticket_id|
url = url + "TicketID=#{CGI::escape ticket_id};"
}
@ -543,7 +543,7 @@ module Import::OTRS
end
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.success?
@ -600,7 +600,7 @@ module Import::OTRS
}
end
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.success?
@ -644,7 +644,7 @@ module Import::OTRS
}
end
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.success?
@ -688,7 +688,7 @@ module Import::OTRS
}
end
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.success?
result = json(response)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -267,7 +267,7 @@ returns
def self.set_params(request, params, options)
if options[:json]
request.add_field("Content-Type", "application/json")
request.add_field('Content-Type', 'application/json')
if !params.empty?
request.body = params.to_json
end
@ -308,7 +308,7 @@ returns
:code => response.code,
)
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']
return get(url, params, options, count - 1)
when Net::HTTPOK

View file

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

View file

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

View file

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

View file

@ -26,30 +26,30 @@ require 'daemons'
tls_options = {}
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
end
opts.on("-v", "--verbose", "enable debug messages") do |d|
opts.on('-v', '--verbose', 'enable debug messages') do |d|
@options[:v] = d
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
end
opts.on("-b", "--bind [OPT]", "bind address") do |b|
opts.on('-b', '--bind [OPT]', 'bind address') do |b|
@options[:b] = b
end
opts.on("-s", "--secure", "enable secure connections") do |s|
opts.on('-s', '--secure', 'enable secure connections') do |s|
@options[:s] = s
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
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
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
end
end.parse!
@ -66,7 +66,7 @@ if ARGV[0] == 'stop'
# read pid
pid =File.open( @options[:i].to_s ).read
pid.gsub!(/\r|\n/, "")
pid.gsub!(/\r|\n/, '')
# kill
Process.kill( 9, pid.to_i )
@ -77,7 +77,7 @@ if ARGV[0] == 'start' && @options[:d]
Daemons.daemonize
# 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.puts(Process.pid.to_s)
$daemon_pid.close
@ -142,7 +142,7 @@ EventMachine.run {
if data['timestamp']
log 'notice', "request spool data > '#{Time.at(data['timestamp']).to_s}'", client_id
else
log 'notice', "request spool with init data", client_id
log 'notice', 'request spool with init data', client_id
end
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
@clients[client_id][:websocket].send( "[#{ msg }]" )
else
log 'notice', "send spool", client_id
log 'notice', 'send spool', client_id
@clients[client_id][:websocket].send( "[#{ msg }]" )
end
}
@ -164,7 +164,7 @@ EventMachine.run {
end
# 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 + '}}]' )
end
@ -222,7 +222,7 @@ EventMachine.run {
end
end
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
@ -264,7 +264,7 @@ EventMachine.run {
EventMachine.add_periodic_timer(0.4) {
next if @clients.size == 0
log 'debug', "checking for data to send..."
log 'debug', 'checking for data to send...'
@clients.each { |client_id, client|
next if client[:disconnect]
log 'debug', 'checking for data...', client_id
@ -272,7 +272,7 @@ EventMachine.run {
queue = Sessions.queue( client_id )
if queue && queue[0]
# 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 )
end
rescue => e
@ -291,14 +291,14 @@ EventMachine.run {
}
def check_unused_connections
log 'notice', "check unused idle connections..."
log 'notice', 'check unused idle connections...'
idle_time_in_sec = 4 * 60
# close unused web socket sessions
@clients.each { |client_id, client|
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
client[:disconnect] = true
@ -315,7 +315,7 @@ EventMachine.run {
# close unused ajax long polling sessions
clients = Sessions.destory_idle_sessions(idle_time_in_sec)
clients.each { |client_id|
log 'notice', "closing idle long polling connection", client_id
log 'notice', 'closing idle long polling connection', client_id
}
end