Browse Source

Corrected with rubocop cop 'Style/HashSyntax'.

Thorsten Eckel 10 years ago
parent
commit
ce58d465c0

+ 0 - 7
.rubocop.yml

@@ -167,13 +167,6 @@ Style/SymbolProc:
   Description: 'Use symbols as procs instead of blocks when possible.'
   Enabled: false
 
-Style/HashSyntax:
-  Description: >-
-                 Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
-                 { :a => 1, :b => 2 }.
-  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-literals'
-  Enabled: false
-
 Style/RedundantBegin:
   Description: "Don't use begin blocks when they are not needed."
   StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#begin-implicit'

+ 3 - 3
Gemfile

@@ -74,10 +74,10 @@ group :development, :test do
     gem 'selenium-webdriver'
 
     # livereload on template changes (html, js, css)
-    gem 'guard', '>= 2.2.2', :require => false
-    gem 'guard-livereload',  :require => false
+    gem 'guard', '>= 2.2.2', require: false
+    gem 'guard-livereload',  require: false
     gem 'rack-livereload'
-    gem 'rb-fsevent',        :require => false
+    gem 'rb-fsevent',        require: false
 
     # code QA
     gem 'rubocop'

+ 1 - 1
Guardfile

@@ -1,7 +1,7 @@
 # A sample Guardfile
 # More info at https://github.com/guard/guard#readme
 
-guard 'livereload', :port => '35738' do
+guard 'livereload', port: '35738' do
   watch(%r{app/views/.+\.(erb|haml|slim)$})
   watch(%r{app/helpers/.+\.rb})
   watch(%r{public/.+\.(css|js|html)})

+ 1 - 1
app/controllers/activity_stream_controller.rb

@@ -8,7 +8,7 @@ class ActivityStreamController < ApplicationController
     activity_stream = current_user.activity_stream( params[:limit], true )
 
     # return result
-    render :json => activity_stream
+    render json: activity_stream
   end
 
 end

+ 30 - 30
app/controllers/application_controller.rb

@@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base
       headers['Access-Control-Allow-Headers']     = 'Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Accept-Language'
       headers['Access-Control-Max-Age']           = '1728000'
       headers['Access-Control-Allow-Credentials'] = 'true'
-      render :text => '', :content_type => 'text/plain'
+      render text: '', content_type: 'text/plain'
       return false
     end
   end
@@ -123,20 +123,20 @@ class ApplicationController < ActionController::Base
         # set basic auth user to current user
         current_user_set(userdata)
         return {
-          :auth => true
+          auth: true
         }
       end
 
       # return auth not ok
       return {
-        :auth    => false,
-        :message => message,
+        auth: false,
+        message: message,
       }
     end
 
     # check logon session
     if params['logon_session']
-      logon_session = ActiveRecord::SessionStore::Session.where( :session_id => params['logon_session'] ).first
+      logon_session = ActiveRecord::SessionStore::Session.where( session_id: params['logon_session'] ).first
       if logon_session
         userdata = User.find( logon_session.data[:user_id] )
       end
@@ -146,7 +146,7 @@ class ApplicationController < ActionController::Base
       # set logon session user to current user
       current_user_set(userdata)
       return {
-        :auth => true
+        auth: true
       }
     end
 
@@ -166,13 +166,13 @@ class ApplicationController < ActionController::Base
       puts 'no valid session, user_id'
       message = 'no valid session, user_id'
       return {
-        :auth    => false,
-        :message => message,
+        auth: false,
+        message: message,
       }
     end
 
     return {
-      :auth => true
+      auth: true
     }
   end
 
@@ -182,10 +182,10 @@ class ApplicationController < ActionController::Base
     # return auth not ok
     if result[:auth] == false
       render(
-        :json   => {
-          :error => result[:message],
+        json: {
+          error: result[:message],
         },
-        :status => :unauthorized
+        status: :unauthorized
       )
       return false
     end
@@ -197,8 +197,8 @@ class ApplicationController < ActionController::Base
   def authentication_check_action_token(action)
 
     user = Token.check(
-      :action => action,
-      :name   => params[:action_token],
+      action: action,
+      name: params[:action_token],
     )
 
     if !user
@@ -219,7 +219,7 @@ class ApplicationController < ActionController::Base
   end
 
   def ticket_permission(ticket)
-    return true if ticket.permission( :current_user => current_user )
+    return true if ticket.permission( current_user: current_user )
     response_access_deny
     false
   end
@@ -236,14 +236,14 @@ class ApplicationController < ActionController::Base
 
   def valid_session_with_user
     return true if current_user
-    render :json => { :message => 'No session user!' }, :status => :unprocessable_entity
+    render json: { message: 'No session user!' }, status: :unprocessable_entity
     false
   end
 
   def response_access_deny
     render(
-      :json => {},
-      :status => :unauthorized
+      json: {},
+      status: :unauthorized
     )
     false
   end
@@ -252,7 +252,7 @@ class ApplicationController < ActionController::Base
 
     # config
     config = {}
-    Setting.select('name').where( :frontend => true ).each { |setting|
+    Setting.select('name').where( frontend: true ).each { |setting|
       config[setting.name] = Setting.get(setting.name)
     }
 
@@ -296,11 +296,11 @@ class ApplicationController < ActionController::Base
       puts e.message.inspect
       logger.error e.message
       logger.error e.backtrace.inspect
-      render :json => { :error => e.message }, :status => :unprocessable_entity
+      render json: { error: e.message }, status: :unprocessable_entity
     end
   end
   def model_create_render_item (generic_object)
-    render :json => generic_object.attributes_with_associations, :status => :created
+    render json: generic_object.attributes_with_associations, status: :created
   end
 
   def model_update_render (object, params)
@@ -319,11 +319,11 @@ class ApplicationController < ActionController::Base
     rescue Exception => e
       logger.error e.message
       logger.error e.backtrace.inspect
-      render :json => { :error => e.message }, :status => :unprocessable_entity
+      render json: { error: e.message }, status: :unprocessable_entity
     end
   end
   def model_update_render_item (generic_object)
-    render :json => generic_object.attributes_with_associations, :status => :ok
+    render json: generic_object.attributes_with_associations, status: :ok
   end
 
   def model_destory_render (object, params)
@@ -334,11 +334,11 @@ class ApplicationController < ActionController::Base
     rescue Exception => e
       logger.error e.message
       logger.error e.backtrace.inspect
-      render :json => { :error => e.message }, :status => :unprocessable_entity
+      render json: { error: e.message }, status: :unprocessable_entity
     end
   end
   def model_destory_render_item ()
-    render :json => {}, :status => :ok
+    render json: {}, status: :ok
   end
 
   def model_show_render (object, params)
@@ -346,7 +346,7 @@ class ApplicationController < ActionController::Base
 
       if params[:full]
         generic_object_full = object.full( params[:id] )
-        render :json => generic_object_full, :status => :ok
+        render json: generic_object_full, status: :ok
         return
       end
 
@@ -355,11 +355,11 @@ class ApplicationController < ActionController::Base
     rescue Exception => e
       logger.error e.message
       logger.error e.backtrace.inspect
-      render :json => { :error => e.message }, :status => :unprocessable_entity
+      render json: { error: e.message }, status: :unprocessable_entity
     end
   end
   def model_show_render_item (generic_object)
-    render :json => generic_object.attributes_with_associations, :status => :ok
+    render json: generic_object.attributes_with_associations, status: :ok
   end
 
   def model_index_render (object, params)
@@ -369,11 +369,11 @@ class ApplicationController < ActionController::Base
     rescue Exception => e
       logger.error e.message
       logger.error e.backtrace.inspect
-      render :json => { :error => e.message }, :status => :unprocessable_entity
+      render json: { error: e.message }, status: :unprocessable_entity
     end
   end
   def model_index_render_result (generic_objects)
-    render :json => generic_objects, :status => :ok
+    render json: generic_objects, status: :ok
   end
 
 end

+ 319 - 319
app/controllers/getting_started_controller.rb

@@ -44,12 +44,12 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
       # set system init to done
       Setting.set( 'system_init_done', true )
 
-      render :json => {
-        :auto_wizard           => true,
-        :setup_done            => setup_done,
-        :import_mode           => Setting.get('import_mode'),
-        :import_backend        => Setting.get('import_backend'),
-        :system_online_service => Setting.get('system_online_service'),
+      render json: {
+        auto_wizard: true,
+        setup_done: setup_done,
+        import_mode: Setting.get('import_mode'),
+        import_backend: Setting.get('import_backend'),
+        system_online_service: Setting.get('system_online_service'),
       }
       return
     end
@@ -60,11 +60,11 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     end
 
     # return result
-    render :json => {
-      :setup_done            => setup_done,
-      :import_mode           => Setting.get('import_mode'),
-      :import_backend        => Setting.get('import_backend'),
-      :system_online_service => Setting.get('system_online_service'),
+    render json: {
+      setup_done: setup_done,
+      import_mode: Setting.get('import_mode'),
+      import_backend: Setting.get('import_backend'),
+      system_online_service: Setting.get('system_online_service'),
     }
   end
 
@@ -97,9 +97,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     end
 
     if !messages.empty?
-      render :json => {
-        :result   => 'invalid',
-        :messages => messages,
+      render json: {
+        result: 'invalid',
+        messages: messages,
       }
       return
     end
@@ -143,9 +143,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
       Setting.set(key, value)
     }
 
-    render :json => {
-      :result   => 'ok',
-      :settings => settings,
+    render json: {
+      result: 'ok',
+      settings: settings,
     }
   end
 
@@ -163,10 +163,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     end
 
     if !user || !domain
-      render :json => {
-        :result   => 'invalid',
-        :messages => {
-          :email => 'Invalid email.'
+      render json: {
+        result: 'invalid',
+        messages: {
+          email: 'Invalid email.'
         },
       }
       return
@@ -174,49 +174,49 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
 
     # check domain based attributes
     providerMap = {
-      :google => {
-        :domain => 'gmail.com|googlemail.com|gmail.de',
-        :inbound => {
-          :adapter => 'imap',
-          :options => {
-            :host     => 'imap.gmail.com',
-            :port     => '993',
-            :ssl      => true,
-            :user     => params[:email],
-            :password => params[:password],
+      google: {
+        domain: 'gmail.com|googlemail.com|gmail.de',
+        inbound: {
+          adapter: 'imap',
+          options: {
+            host: 'imap.gmail.com',
+            port: '993',
+            ssl: true,
+            user: params[:email],
+            password: params[:password],
           },
         },
-        :outbound => {
-          :adapter => 'smtp',
-          :options => {
-            :host      => 'smtp.gmail.com',
-            :port      => '25',
-            :start_tls => true,
-            :user      => params[:email],
-            :password  => params[:password],
+        outbound: {
+          adapter: 'smtp',
+          options: {
+            host: 'smtp.gmail.com',
+            port: '25',
+            start_tls: true,
+            user: params[:email],
+            password: params[:password],
           }
         },
       },
-      :microsoft => {
-        :domain => 'outlook.com|hotmail.com',
-        :inbound => {
-          :adapter => 'imap',
-          :options => {
-            :host     => 'imap-mail.outlook.com',
-            :port     => '993',
-            :ssl      => true,
-            :user     => params[:email],
-            :password => params[:password],
+      microsoft: {
+        domain: 'outlook.com|hotmail.com',
+        inbound: {
+          adapter: 'imap',
+          options: {
+            host: 'imap-mail.outlook.com',
+            port: '993',
+            ssl: true,
+            user: params[:email],
+            password: params[:password],
           },
         },
-        :outbound => {
-          :adapter => 'smtp',
-          :options => {
-            :host      => 'smtp-mail.outlook.com',
-            :port      => 25,
-            :start_tls => true,
-            :user      => params[:email],
-            :password  => params[:password],
+        outbound: {
+          adapter: 'smtp',
+          options: {
+            host: 'smtp-mail.outlook.com',
+            port: 25,
+            start_tls: true,
+            user: params[:email],
+            password: params[:password],
           }
         },
       },
@@ -238,20 +238,20 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
           # probe inbound
           result = email_probe_inbound( settings[:inbound] )
           if result[:result] != 'ok'
-            render :json => result
+            render json: result
             return
           end
 
           # probe outbound
           result = email_probe_outbound( settings[:outbound], params[:email] )
           if result[:result] != 'ok'
-            render :json => result
+            render json: result
             return
           end
 
-          render :json => {
-            :result  => 'ok',
-            :setting => settings,
+          render json: {
+            result: 'ok',
+            setting: settings,
           }
           return
         end
@@ -263,23 +263,23 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
       inboundMx = [
         {
-          :adapter => 'imap',
-          :options => {
-            :host     => mail_exchangers[0][0],
-            :port     => 993,
-            :ssl      => true,
-            :user     => user,
-            :password => params[:password],
+          adapter: 'imap',
+          options: {
+            host: mail_exchangers[0][0],
+            port: 993,
+            ssl: true,
+            user: user,
+            password: params[:password],
           },
         },
         {
-          :adapter => 'imap',
-          :options => {
-            :host     => mail_exchangers[0][0],
-            :port     => 993,
-            :ssl      => true,
-            :user     => params[:email],
-            :password => params[:password],
+          adapter: 'imap',
+          options: {
+            host: mail_exchangers[0][0],
+            port: 993,
+            ssl: true,
+            user: params[:email],
+            password: params[:password],
           },
         },
       ]
@@ -287,103 +287,103 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     end
     inboundAuto = [
       {
-        :adapter => 'imap',
-        :options => {
-          :host     => "mail.#{domain}",
-          :port     => 993,
-          :ssl      => true,
-          :user     => user,
-          :password => params[:password],
+        adapter: 'imap',
+        options: {
+          host: "mail.#{domain}",
+          port: 993,
+          ssl: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'imap',
-        :options => {
-          :host     => "mail.#{domain}",
-          :port     => 993,
-          :ssl      => true,
-          :user     => params[:email],
-          :password => params[:password],
+        adapter: 'imap',
+        options: {
+          host: "mail.#{domain}",
+          port: 993,
+          ssl: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
       {
-        :adapter => 'imap',
-        :options => {
-          :host     => "imap.#{domain}",
-          :port     => 993,
-          :ssl      => true,
-          :user     => user,
-          :password => params[:password],
+        adapter: 'imap',
+        options: {
+          host: "imap.#{domain}",
+          port: 993,
+          ssl: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'imap',
-        :options => {
-          :host     => "imap.#{domain}",
-          :port     => 993,
-          :ssl      => true,
-          :user     => params[:email],
-          :password => params[:password],
+        adapter: 'imap',
+        options: {
+          host: "imap.#{domain}",
+          port: 993,
+          ssl: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
       {
-        :adapter => 'pop3',
-        :options => {
-          :host     => "mail.#{domain}",
-          :port     => 995,
-          :ssl      => true,
-          :user     => user,
-          :password => params[:password],
+        adapter: 'pop3',
+        options: {
+          host: "mail.#{domain}",
+          port: 995,
+          ssl: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'pop3',
-        :options => {
-          :host     => "mail.#{domain}",
-          :port     => 995,
-          :ssl      => true,
-          :user     => params[:email],
-          :password => params[:password],
+        adapter: 'pop3',
+        options: {
+          host: "mail.#{domain}",
+          port: 995,
+          ssl: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
       {
-        :adapter => 'pop3',
-        :options => {
-          :host     => "pop.#{domain}",
-          :port     => 995,
-          :ssl      => true,
-          :user     => user,
-          :password => params[:password],
+        adapter: 'pop3',
+        options: {
+          host: "pop.#{domain}",
+          port: 995,
+          ssl: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'pop3',
-        :options => {
-          :host     => "pop.#{domain}",
-          :port     => 995,
-          :ssl      => true,
-          :user     => params[:email],
-          :password => params[:password],
+        adapter: 'pop3',
+        options: {
+          host: "pop.#{domain}",
+          port: 995,
+          ssl: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
       {
-        :adapter => 'pop3',
-        :options => {
-          :host     => "pop3.#{domain}",
-          :port     => 995,
-          :ssl      => true,
-          :user     => user,
-          :password => params[:password],
+        adapter: 'pop3',
+        options: {
+          host: "pop3.#{domain}",
+          port: 995,
+          ssl: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'pop3',
-        :options => {
-          :host     => "pop3.#{domain}",
-          :port     => 995,
-          :ssl      => true,
-          :user     => params[:email],
-          :password => params[:password],
+        adapter: 'pop3',
+        options: {
+          host: "pop3.#{domain}",
+          port: 995,
+          ssl: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
     ]
@@ -402,8 +402,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     }
 
     if !success
-      render :json => {
-        :result => 'failed',
+      render json: {
+        result: 'failed',
       }
       return
     end
@@ -413,43 +413,43 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
       outboundMx = [
         {
-          :adapter => 'smtp',
-          :options => {
-            :host      => mail_exchangers[0][0],
-            :port      => 25,
-            :start_tls => true,
-            :user      => user,
-            :password  => params[:password],
+          adapter: 'smtp',
+          options: {
+            host: mail_exchangers[0][0],
+            port: 25,
+            start_tls: true,
+            user: user,
+            password: params[:password],
           },
         },
         {
-          :adapter => 'smtp',
-          :options => {
-            :host      => mail_exchangers[0][0],
-            :port      => 25,
-            :start_tls => true,
-            :user      => params[:email],
-            :password  => params[:password],
+          adapter: 'smtp',
+          options: {
+            host: mail_exchangers[0][0],
+            port: 25,
+            start_tls: true,
+            user: params[:email],
+            password: params[:password],
           },
         },
         {
-          :adapter => 'smtp',
-          :options => {
-            :host      => mail_exchangers[0][0],
-            :port      => 465,
-            :start_tls => true,
-            :user      => user,
-            :password  => params[:password],
+          adapter: 'smtp',
+          options: {
+            host: mail_exchangers[0][0],
+            port: 465,
+            start_tls: true,
+            user: user,
+            password: params[:password],
           },
         },
         {
-          :adapter => 'smtp',
-          :options => {
-            :host      => mail_exchangers[0][0],
-            :port      => 465,
-            :start_tls => true,
-            :user      => params[:email],
-            :password  => params[:password],
+          adapter: 'smtp',
+          options: {
+            host: mail_exchangers[0][0],
+            port: 465,
+            start_tls: true,
+            user: params[:email],
+            password: params[:password],
           },
         },
       ]
@@ -457,83 +457,83 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     end
     outboundAuto = [
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "mail.#{domain}",
-          :port      => 25,
-          :start_tls => true,
-          :user      => user,
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "mail.#{domain}",
+          port: 25,
+          start_tls: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "mail.#{domain}",
-          :port      => 25,
-          :start_tls => true,
-          :user      => params[:email],
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "mail.#{domain}",
+          port: 25,
+          start_tls: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "mail.#{domain}",
-          :port      => 465,
-          :start_tls => true,
-          :user      => user,
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "mail.#{domain}",
+          port: 465,
+          start_tls: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "mail.#{domain}",
-          :port      => 465,
-          :start_tls => true,
-          :user      => params[:email],
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "mail.#{domain}",
+          port: 465,
+          start_tls: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "smtp.#{domain}",
-          :port      => 25,
-          :start_tls => true,
-          :user      => user,
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "smtp.#{domain}",
+          port: 25,
+          start_tls: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "smtp.#{domain}",
-          :port      => 25,
-          :start_tls => true,
-          :user      => params[:email],
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "smtp.#{domain}",
+          port: 25,
+          start_tls: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "smtp.#{domain}",
-          :port      => 465,
-          :start_tls => true,
-          :user      => user,
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "smtp.#{domain}",
+          port: 465,
+          start_tls: true,
+          user: user,
+          password: params[:password],
         },
       },
       {
-        :adapter => 'smtp',
-        :options => {
-          :host      => "smtp.#{domain}",
-          :port      => 465,
-          :start_tls => true,
-          :user      => params[:email],
-          :password  => params[:password],
+        adapter: 'smtp',
+        options: {
+          host: "smtp.#{domain}",
+          port: 465,
+          start_tls: true,
+          user: params[:email],
+          password: params[:password],
         },
       },
     ]
@@ -551,15 +551,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     }
 
     if !success
-      render :json => {
-        :result => 'failed',
+      render json: {
+        result: 'failed',
       }
       return
     end
 
-    render :json => {
-      :result  => 'ok',
-      :setting => settings,
+    render json: {
+      result: 'ok',
+      setting: settings,
     }
   end
 
@@ -570,8 +570,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
 
     # validate params
     if !params[:adapter]
-      render :json => {
-        :result => 'invalid',
+      render json: {
+        result: 'invalid',
       }
       return
     end
@@ -579,7 +579,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     # connection test
     result = email_probe_outbound( params, params[:email] )
 
-    render :json => result
+    render json: result
   end
 
   def email_inbound
@@ -589,8 +589,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
 
     # validate params
     if !params[:adapter]
-      render :json => {
-        :result => 'invalid',
+      render json: {
+        result: 'invalid',
       }
       return
     end
@@ -598,7 +598,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     # connection test
     result = email_probe_inbound( params )
 
-    render :json => result
+    render json: result
     return
   end
 
@@ -623,15 +623,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
 
       begin
         if params[:inbound][:adapter] =~ /^imap$/i
-          found = Channel::IMAP.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
+          found = Channel::IMAP.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
         else
-          found = Channel::POP3.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
+          found = Channel::POP3.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
         end
       rescue Exception => e
-        render :json => {
-          :result  => 'invalid',
-          :message => e.to_s,
-          :subject => subject,
+        render json: {
+          result: 'invalid',
+          message: e.to_s,
+          subject: subject,
         }
         return
       end
@@ -639,70 +639,70 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
       if found && found == 'verify ok'
 
         # remember address
-        address = EmailAddress.where( :email => params[:meta][:email] ).first
+        address = EmailAddress.where( email: params[:meta][:email] ).first
         if !address
           address = EmailAddress.first
         end
         if address
           address.update_attributes(
-            :realname      => params[:meta][:realname],
-            :email         => params[:meta][:email],
-            :active        => 1,
-            :updated_by_id => 1,
-            :created_by_id => 1,
+            realname: params[:meta][:realname],
+            email: params[:meta][:email],
+            active: 1,
+            updated_by_id: 1,
+            created_by_id: 1,
           )
         else
           EmailAddress.create(
-            :realname      => params[:meta][:realname],
-            :email         => params[:meta][:email],
-            :active        => 1,
-            :updated_by_id => 1,
-            :created_by_id => 1,
+            realname: params[:meta][:realname],
+            email: params[:meta][:email],
+            active: 1,
+            updated_by_id: 1,
+            created_by_id: 1,
           )
         end
 
         # store mailbox
         Channel.create(
-          :area          => 'Email::Inbound',
-          :adapter       => params[:inbound][:adapter],
-          :options       => params[:inbound][:options],
-          :group_id      => 1,
-          :active        => 1,
-          :updated_by_id => 1,
-          :created_by_id => 1,
+          area: 'Email::Inbound',
+          adapter: params[:inbound][:adapter],
+          options: params[:inbound][:options],
+          group_id: 1,
+          active: 1,
+          updated_by_id: 1,
+          created_by_id: 1,
         )
 
         # save settings
         if params[:outbound][:adapter] =~ /^smtp$/i
-          smtp = Channel.where( :adapter  => 'SMTP', :area => 'Email::Outbound' ).first
+          smtp = Channel.where( adapter: 'SMTP', area: 'Email::Outbound' ).first
           smtp.options = params[:outbound][:options]
           smtp.active  = true
           smtp.save!
-          sendmail = Channel.where( :adapter => 'Sendmail' ).first
+          sendmail = Channel.where( adapter: 'Sendmail' ).first
           sendmail.active = false
           sendmail.save!
         else
-          sendmail = Channel.where( :adapter => 'Sendmail', :area => 'Email::Outbound' ).first
+          sendmail = Channel.where( adapter: 'Sendmail', area: 'Email::Outbound' ).first
           sendmail.options = {}
           sendmail.active  = true
           sendmail.save!
-          smtp = Channel.where( :adapter => 'SMTP' ).first
+          smtp = Channel.where( adapter: 'SMTP' ).first
           smtp.active = false
           smtp.save
         end
 
-        render :json => {
-          :result => 'ok',
+        render json: {
+          result: 'ok',
         }
         return
       end
     }
 
     # check delivery for 30 sek.
-    render :json => {
-      :result  => 'invalid',
-      :message => 'Verification Email not found in mailbox.',
-      :subject => subject,
+    render json: {
+      result: 'invalid',
+      message: 'Verification Email not found in mailbox.',
+      subject: subject,
     }
   end
 
@@ -713,8 +713,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     # validate params
     if !params[:adapter]
       result = {
-        :result  => 'invalid',
-        :message => 'Invalid, need adapter!',
+        result: 'invalid',
+        message: 'Invalid, need adapter!',
       }
       return result
     end
@@ -729,10 +729,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
       }
     else
       mail = {
-        :from    => email,
-        :to      => 'emailtrytest@znuny.com',
-        :subject => 'test',
-        :body    => 'test',
+        from: email,
+        to: 'emailtrytest@znuny.com',
+        subject: 'test',
+        body: 'test',
       }
     end
 
@@ -758,7 +758,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
         Channel::SMTP.new.send(
           mail,
           {
-            :options => params[:options]
+            options: params[:options]
           }
         )
       rescue Exception => e
@@ -771,9 +771,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
           whiteMap.each {|key, message|
             if e.message =~ /#{Regexp.escape(key)}/i
               result = {
-                :result   => 'ok',
-                :settings => params,
-                :notice   => e.message,
+                result: 'ok',
+                settings: params,
+                notice: e.message,
               }
               return result
             end
@@ -786,15 +786,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
           end
         }
         result = {
-          :result        => 'invalid',
-          :settings      => params,
-          :message       => e.message,
-          :message_human => message_human,
+          result: 'invalid',
+          settings: params,
+          message: e.message,
+          message_human: message_human,
         }
         return result
       end
       result = {
-        :result => 'ok',
+        result: 'ok',
       }
       return result
     end
@@ -812,15 +812,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
         end
       }
       result = {
-        :result        => 'invalid',
-        :settings      => params,
-        :message       => e.message,
-        :message_human => message_human,
+        result: 'invalid',
+        settings: params,
+        message: e.message,
+        message_human: message_human,
       }
       return result
     end
     result = {
-      :result => 'ok',
+      result: 'ok',
     }
     return result
   end
@@ -843,7 +843,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     if params[:adapter] =~ /^imap$/i
 
       begin
-        Channel::IMAP.new.fetch( { :options => params[:options] }, 'check' )
+        Channel::IMAP.new.fetch( { options: params[:options] }, 'check' )
       rescue Exception => e
         message_human = ''
         translationMap.each {|key, message|
@@ -852,21 +852,21 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
           end
         }
         result = {
-          :result        => 'invalid',
-          :settings      => params,
-          :message       => e.message,
-          :message_human => message_human,
+          result: 'invalid',
+          settings: params,
+          message: e.message,
+          message_human: message_human,
         }
         return result
       end
       result = {
-        :result => 'ok',
+        result: 'ok',
       }
       return result
     end
 
     begin
-      Channel::POP3.new.fetch( { :options => params[:options] }, 'check' )
+      Channel::POP3.new.fetch( { options: params[:options] }, 'check' )
     rescue Exception => e
       message_human = ''
       translationMap.each {|key, message|
@@ -875,15 +875,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
         end
       }
       result = {
-        :result        => 'invalid',
-        :settings      => params,
-        :message       => e.message,
-        :message_human => message_human,
+        result: 'invalid',
+        settings: params,
+        message: e.message,
+        message_human: message_human,
       }
       return result
     end
     result = {
-      :result => 'ok',
+      result: 'ok',
     }
     return result
   end
@@ -917,18 +917,18 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
     end
 
     # get all groups
-    groups = Group.where( :active => true )
+    groups = Group.where( active: true )
 
     # get email addresses
-    addresses = EmailAddress.where( :active => true )
-
-    render :json => {
-      :setup_done            => true,
-      :import_mode           => Setting.get('import_mode'),
-      :import_backend        => Setting.get('import_backend'),
-      :system_online_service => Setting.get('system_online_service'),
-      :addresses             => addresses,
-      :groups                => groups,
+    addresses = EmailAddress.where( active: true )
+
+    render json: {
+      setup_done: true,
+      import_mode: Setting.get('import_mode'),
+      import_backend: Setting.get('import_backend'),
+      system_online_service: Setting.get('system_online_service'),
+      addresses: addresses,
+      groups: groups,
     }
     true
   end

+ 13 - 13
app/controllers/ical_tickets_controller.rb

@@ -74,8 +74,8 @@ class IcalTicketsController < ApplicationController
     condition = {
       'tickets.owner_id' => current_user.id,
       'tickets.state_id' => Ticket::State.where(
-        :state_type_id => Ticket::StateType.where(
-          :name => [
+        state_type_id: Ticket::StateType.where(
+          name: [
             'new',
             'open',
           ],
@@ -84,8 +84,8 @@ class IcalTicketsController < ApplicationController
     }
 
     tickets = Ticket.search(
-      :current_user => current_user,
-      :condition    => condition,
+      current_user: current_user,
+      condition: condition,
     )
 
     events_data = []
@@ -109,8 +109,8 @@ class IcalTicketsController < ApplicationController
     condition = {
       'tickets.owner_id' => current_user.id,
       'tickets.state_id' => Ticket::State.where(
-        :state_type_id => Ticket::StateType.where(
-          :name => [
+        state_type_id: Ticket::StateType.where(
+          name: [
             'pending reminder',
             'pending action',
           ],
@@ -119,8 +119,8 @@ class IcalTicketsController < ApplicationController
     }
 
     tickets = Ticket.search(
-      :current_user => current_user,
-      :condition    => condition,
+      current_user: current_user,
+      condition: condition,
     )
 
     events_data = []
@@ -148,8 +148,8 @@ class IcalTicketsController < ApplicationController
     ]
 
     tickets = Ticket.search(
-      :current_user => current_user,
-      :condition    => condition,
+      current_user: current_user,
+      condition: condition,
     )
 
     events_data = []
@@ -186,9 +186,9 @@ class IcalTicketsController < ApplicationController
 
     send_data(
       cal.to_ical,
-      :filename    => 'zammad.ical',
-      :type        => 'text/plain',
-      :disposition => 'inline'
+      filename: 'zammad.ical',
+      type: 'text/plain',
+      disposition: 'inline'
     )
   end
 

+ 23 - 23
app/controllers/import_otrs_controller.rb

@@ -8,9 +8,9 @@ class ImportOtrsController < ApplicationController
 
     # validate
     if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/
-      render :json => {
-        :result  => 'invalid',
-        :message => 'Invalid!',
+      render json: {
+        result: 'invalid',
+        message: 'Invalid!',
       }
       return
     end
@@ -32,10 +32,10 @@ class ImportOtrsController < ApplicationController
           message_human = message
         end
       }
-      render :json => {
-        :result        => 'invalid',
-        :message_human => message_human,
-        :message       => response.error.to_s,
+      render json: {
+        result: 'invalid',
+        message_human: message_human,
+        message: response.error.to_s,
       }
       return
     end
@@ -53,9 +53,9 @@ class ImportOtrsController < ApplicationController
       Setting.set('import_otrs_endpoint', url)
       Setting.set('import_otrs_endpoint_key', '01234567899876543210')
       if response.body =~ /zammad migrator/
-        render :json => {
-          :url    => url,
-          :result => 'ok',
+        render json: {
+          url: url,
+          result: 'ok',
         }
         return
       elsif response.body =~ /(otrs\sag|otrs.com|otrs.org)/i
@@ -65,9 +65,9 @@ class ImportOtrsController < ApplicationController
 
 
     # return result
-    render :json => {
-        :result        => 'invalid',
-        :message_human => message_human,
+    render json: {
+        result: 'invalid',
+        message_human: message_human,
     }
   end
 
@@ -77,9 +77,9 @@ class ImportOtrsController < ApplicationController
     Setting.set('import_mode', true)
     welcome = Import::OTRS2.connection_test
     if !welcome
-      render :json => {
-        :message => 'Migrator can\'t read OTRS output!',
-        :result  => 'invalid',
+      render json: {
+        message: 'Migrator can\'t read OTRS output!',
+        result: 'invalid',
       }
       return
     end
@@ -87,8 +87,8 @@ class ImportOtrsController < ApplicationController
     # start migration
     Import::OTRS2.delay.start
 
-    render :json => {
-      :result  => 'ok',
+    render json: {
+      result: 'ok',
     }
   end
 
@@ -97,9 +97,9 @@ class ImportOtrsController < ApplicationController
 
     state = Import::OTRS2.get_current_state
 
-    render :json => {
-      :data   => state,
-      :result => 'in_progress',
+    render json: {
+      data: state,
+      result: 'in_progress',
     }
   end
 
@@ -119,8 +119,8 @@ class ImportOtrsController < ApplicationController
     if !setup_done
       return false
     end
-    render :json => {
-      :setup_done => true,
+    render json: {
+      setup_done: true,
     }
     true
   end

+ 16 - 16
app/controllers/links_controller.rb

@@ -6,8 +6,8 @@ class LinksController < ApplicationController
   # GET /api/v1/links
   def index
     links = Link.list(
-      :link_object       => params[:link_object],
-      :link_object_value => params[:link_object_value],
+      link_object: params[:link_object],
+      link_object_value: params[:link_object_value],
     )
 
     assets = {}
@@ -15,15 +15,15 @@ class LinksController < ApplicationController
     links.each { |item|
       link_list.push item
       if item['link_object'] == 'Ticket'
-        ticket = Ticket.lookup( :id => item['link_object_value'] )
+        ticket = Ticket.lookup( id: item['link_object_value'] )
         assets = ticket.assets(assets)
       end
     }
 
     # return result
-    render :json => {
-      :links  => link_list,
-      :assets => assets,
+    render json: {
+      links: link_list,
+      assets: assets,
     }
   end
 
@@ -31,19 +31,19 @@ class LinksController < ApplicationController
   def add
 
     # lookup object id
-    object_id = Ticket.where( :number => params[:link_object_source_number] ).first.id
+    object_id = Ticket.where( number: params[:link_object_source_number] ).first.id
     link = Link.add(
-      :link_type                => params[:link_type],
-      :link_object_target       => params[:link_object_target],
-      :link_object_target_value => params[:link_object_target_value],
-      :link_object_source       => params[:link_object_source],
-      :link_object_source_value => object_id
+      link_type: params[:link_type],
+      link_object_target: params[:link_object_target],
+      link_object_target_value: params[:link_object_target_value],
+      link_object_source: params[:link_object_source],
+      link_object_source_value: object_id
     )
 
     if link
-      render :json => link, :status => :created
+      render json: link, status: :created
     else
-      render :json => link.errors, :status => :unprocessable_entity
+      render json: link.errors, status: :unprocessable_entity
     end
   end
 
@@ -52,9 +52,9 @@ class LinksController < ApplicationController
     link = Link.remove(params)
 
     if link
-      render :json => link, :status => :created
+      render json: link, status: :created
     else
-      render :json => link.errors, :status => :unprocessable_entity
+      render json: link.errors, status: :unprocessable_entity
     end
   end
 

+ 9 - 9
app/controllers/long_polling_controller.rb

@@ -50,7 +50,7 @@ class LongPollingController < ApplicationController
       # send spool:sent event to client
       sleep 0.2
       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
 
 
@@ -62,7 +62,7 @@ class LongPollingController < ApplicationController
         user = User.find( user_id ).attributes
       end
       log 'notice', "send auth login (user_id #{user_id})", client_id
-      Sessions.create( client_id, user, { :type => 'ajax' } )
+      Sessions.create( client_id, user, { type: 'ajax' } )
 
       # broadcast
     elsif params['data']['action'] == 'broadcast'
@@ -92,10 +92,10 @@ class LongPollingController < ApplicationController
     end
 
     if new_connection
-      result = { :client_id => client_id }
-      render :json => result
+      result = { client_id: client_id }
+      render json: result
     else
-      render :json => {}
+      render json: {}
     end
   end
 
@@ -105,7 +105,7 @@ class LongPollingController < ApplicationController
     # check client id
     client_id = client_id_verify
     if !client_id
-      render :json => { :error => 'Invalid client_id receive!' }, :status => :unprocessable_entity
+      render json: { error: 'Invalid client_id receive!' }, status: :unprocessable_entity
       return
     end
 
@@ -126,7 +126,7 @@ class LongPollingController < ApplicationController
         queue = Sessions.queue( client_id )
         if queue && queue[0]
           #          puts "send " + queue.inspect + client_id.to_s
-          render :json => queue
+          render json: queue
           return
         end
         8.times {|loop|
@@ -134,14 +134,14 @@ class LongPollingController < ApplicationController
         }
         #sleep 2
         if count == 0
-          render :json => { :action => 'pong' }
+          render json: { action: 'pong' }
           return
         end
       end
     rescue Exception => e
       puts e.inspect
       puts e.backtrace
-      render :json => { :error => 'Invalid client_id in receive loop!' }, :status => :unprocessable_entity
+      render json: { error: 'Invalid client_id in receive loop!' }, status: :unprocessable_entity
       return
     end
   end

Some files were not shown because too many files changed in this diff