lato_core 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -12
  3. data/app/controllers/lato_core/api/v1/api_controller.rb +2 -3
  4. data/app/controllers/lato_core/application_controller.rb +1 -1
  5. data/app/controllers/lato_core/back/authentication_controller.rb +12 -11
  6. data/app/controllers/lato_core/back/back_controller.rb +13 -19
  7. data/app/controllers/lato_core/back/superusers_controller.rb +123 -148
  8. data/app/mailers/lato_core/application_mailer.rb +3 -4
  9. data/app/mailers/lato_core/superusers_mailer.rb +5 -7
  10. data/app/models/lato_core/superuser.rb +27 -19
  11. data/app/views/lato_core/back/authentication/login.html.erb +12 -9
  12. data/app/views/lato_core/back/authentication/password_edit.html.erb +9 -14
  13. data/app/views/lato_core/back/authentication/password_forget.html.erb +26 -27
  14. data/app/views/lato_core/back/back/home.html.erb +5 -5
  15. data/app/views/lato_core/back/superusers/edit.html.erb +12 -3
  16. data/app/views/lato_core/back/superusers/index.html.erb +23 -13
  17. data/app/views/lato_core/back/superusers/new.html.erb +12 -3
  18. data/app/views/lato_core/back/superusers/shared/_form.html.erb +3 -6
  19. data/config/config.yml +1 -1
  20. data/config/example.yml +3 -3
  21. data/config/initializers/init.rb +4 -5
  22. data/{test/dummy/log/test.log → config/initializers/lists.rb} +0 -0
  23. data/config/initializers/ram.rb +1 -37
  24. data/config/routes.rb +4 -5
  25. data/lib/lato_core.rb +2 -6
  26. data/lib/lato_core/engine.rb +6 -6
  27. data/lib/lato_core/interface.rb +12 -15
  28. data/lib/lato_core/interface/authentication.rb +19 -27
  29. data/lib/lato_core/interface/cache.rb +17 -23
  30. data/lib/lato_core/interface/communication.rb +68 -85
  31. data/lib/lato_core/interface/languages.rb +38 -47
  32. data/lib/lato_core/interface/navigation.rb +79 -93
  33. data/lib/lato_core/interface/session.rb +47 -61
  34. data/lib/lato_core/interface/superusers.rb +113 -122
  35. data/lib/tasks/lato_core_tasks.rake +2 -5
  36. metadata +4 -99
  37. data/test/controllers/lato_core/api/v1/api_controller_test.rb +0 -9
  38. data/test/controllers/lato_core/application_controller_test.rb +0 -9
  39. data/test/controllers/lato_core/back/authentication_controller_test.rb +0 -13
  40. data/test/controllers/lato_core/back/back_controller_test.rb +0 -9
  41. data/test/controllers/lato_core/back/session_controller_test.rb +0 -13
  42. data/test/controllers/lato_core/back/superusers_controller_test.rb +0 -13
  43. data/test/dummy/README.rdoc +0 -28
  44. data/test/dummy/Rakefile +0 -6
  45. data/test/dummy/app/assets/javascripts/application.js +0 -13
  46. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  47. data/test/dummy/app/controllers/application_controller.rb +0 -5
  48. data/test/dummy/app/helpers/application_helper.rb +0 -2
  49. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  50. data/test/dummy/bin/bundle +0 -3
  51. data/test/dummy/bin/rails +0 -4
  52. data/test/dummy/bin/rake +0 -4
  53. data/test/dummy/bin/setup +0 -29
  54. data/test/dummy/config.ru +0 -4
  55. data/test/dummy/config/application.rb +0 -25
  56. data/test/dummy/config/boot.rb +0 -5
  57. data/test/dummy/config/database.yml +0 -25
  58. data/test/dummy/config/environment.rb +0 -5
  59. data/test/dummy/config/environments/development.rb +0 -41
  60. data/test/dummy/config/environments/production.rb +0 -79
  61. data/test/dummy/config/environments/test.rb +0 -42
  62. data/test/dummy/config/initializers/assets.rb +0 -11
  63. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  64. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  65. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  66. data/test/dummy/config/initializers/inflections.rb +0 -16
  67. data/test/dummy/config/initializers/mime_types.rb +0 -4
  68. data/test/dummy/config/initializers/session_store.rb +0 -3
  69. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  70. data/test/dummy/config/locales/en.yml +0 -23
  71. data/test/dummy/config/routes.rb +0 -4
  72. data/test/dummy/config/secrets.yml +0 -22
  73. data/test/dummy/public/404.html +0 -67
  74. data/test/dummy/public/422.html +0 -67
  75. data/test/dummy/public/500.html +0 -66
  76. data/test/dummy/public/favicon.ico +0 -0
  77. data/test/fixtures/lato_core/superusers.yml +0 -11
  78. data/test/integration/navigation_test.rb +0 -8
  79. data/test/lato_core_test.rb +0 -7
  80. data/test/mailers/lato_core/lato_core_mailer_test.rb +0 -9
  81. data/test/mailers/previews/lato_core/lato_core_mailer_preview.rb +0 -6
  82. data/test/models/lato_core/superuser_test.rb +0 -9
  83. data/test/test_helper.rb +0 -21
@@ -1,50 +1,14 @@
1
1
  include LatoCore::Interface
2
2
 
3
- # Insieme di variabili globali che mantengono dati altrimenti
4
- # memorizzati in file yaml.
5
- # Solitamente contengono la lettura del file di configurazione.
6
- # Cambiare l'ordine in cui sono inserite potrebbe compromettere il corretto
7
- # funzionamento del modulo.
3
+ # This file contains list of informations for the application.
8
4
 
9
- # IMPOSTAZIONE VOCI DI NAVIGAZIONE
10
- # Contiene la lista di voci di navigazione di lato
11
5
  CORE_NAVIGATION = core_getNavbarItems
12
-
13
- # IMPOSTAZIONE NOME APPLICAZIONE
14
- # Contiene il nome dell'applicazione
15
6
  CORE_APPNAME = core_getApplicationName
16
-
17
- # IMPOSTAZIONE URL APPLICAZIONE
18
- # Cotiene l'url base del progetto
19
7
  CORE_APPURL = core_getApplicationURL
20
-
21
- # IMPOSTAZIONE ROOT PANNELLO GESTIONALE
22
- # Contiene l'url della pagina di benvenuto custom
23
8
  CORE_APPLOGINROOT = core_getApplicationLoginRoot
24
-
25
- # IMPOSTAZIONE LINGUE DELL'APPLICAZIONE
26
- # Continene la lista delle lingue dell'applicazione gestita con lato
27
9
  CORE_APPLANGUAGES = core_getApplicationLanguages
28
-
29
- # IMPOSTAZIONE INDIRIZZO EMAIL DI SERVIZIO
30
- # Contiene l'indirizzo email usato cdi default come mittente del mailer
31
10
  CORE_APPSERVICEMAIL = core_getApplicationServiceEmail
32
-
33
- # IMPOSTAZIONE DATI SU UTENTI NASCOSTI
34
- # Contiene la lista di permessi utente che rappresentano gli utenti da non
35
- # mostrare nella pagina users.
36
11
  CORE_SUPERUSERSHIDESETTINGS = core_getHideUsersSettings
37
-
38
- # IMPOSTAZIONE PERMESSI UTENTE DA NASCONDERE ALL'UTENTE
39
- # Contiene la lista di permessi utente da non mostrare nel form di creazione/modifica
40
- # utenti
41
12
  CORE_SUPERUSERSPERMISSIONSHIDESETTINGS = core_getHideUsersPermissionsSettings
42
-
43
- # IMPOSTAZIONE NOMI DEI PERMESSI UTENTE
44
- # Contiene la lista di traduzioni da numero permesso utente a valore testuale
45
13
  CORE_SUPERUSERSPERMISSIONSNAMESSETTINGS = core_getUsersPermissionsNamesSettings
46
-
47
- # IMPOSTAZIONI VISUALIZZAZIONE SEZIONE RECUPERO PASSWORD
48
- # Contiene un valore booleano indicante se e' possibile o meno utilizzare il
49
- # recupero password per gli utenti
50
14
  CORE_RECOVERYPASSWORDPERMISSION = core_getRecoveryPasswordPermission
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  LatoCore::Engine.routes.draw do
2
+
2
3
  root 'back/back#home'
3
4
 
4
5
  # Authentication
@@ -6,15 +7,13 @@ LatoCore::Engine.routes.draw do
6
7
  post 'exec_login', to: 'back/authentication#exec_login', as: 'exec_login'
7
8
  delete 'exec_logout', to: 'back/authentication#exec_logout', as: 'exec_logout'
8
9
 
9
- # view richiesta email
10
+ # Password recovery
10
11
  get 'password_forget', to: 'back/authentication#password_forget', as: 'password_forget'
11
- # invio email recupero psw
12
12
  post 'password_recover', to: 'back/authentication#password_recover', as: 'password_recover'
13
- # view inserimento nuova psw
14
13
  get 'password_edit/:token', to: 'back/authentication#password_edit', as: 'password_edit'
15
- # aggiornamento password
16
14
  post 'password_update', to: 'back/authentication#password_update', as: 'password_update'
17
- # Users
15
+
16
+ # Superusers
18
17
  resources :superusers, module: 'back'
19
18
 
20
19
  end
data/lib/lato_core.rb CHANGED
@@ -1,11 +1,7 @@
1
- # Lato Core e' una gemma che si occupa di generare un pannello di amministrazione
2
- # con gestione delle utenze da utilizzare nello sviluppo di cms e gestionali.
3
- # Lato Core e' stato sviluppato per supportare l'integrazione con altri moduli
4
- # e necessita della gemma 'lato_view' per funzionare in modo corretto.
5
1
  module LatoCore
6
2
 
7
- # Includo interface e engine
3
+ # include engine and interface
8
4
  require "lato_core/engine"
9
5
  require "lato_core/interface"
10
-
6
+
11
7
  end
@@ -1,11 +1,8 @@
1
1
  module LatoCore
2
- # Classe che gestisce l'inizializzazione del modulo.
3
- # Principalmente si occupa di rendere obbligatorie le migrazioni nell'app
4
- # principale e di inserire nel Rails.application.routes le routes del modulo.
5
2
  class Engine < ::Rails::Engine
6
3
  isolate_namespace LatoCore
7
4
 
8
- # Aggiunta del supporto alle migrazioni
5
+ # Add migration support
9
6
  initializer 'Add migration support' do |app|
10
7
  unless app.root.to_s.match root.to_s
11
8
  config.paths['db/migrate'].expanded.each do |expanded_path|
@@ -14,13 +11,16 @@ module LatoCore
14
11
  end
15
12
  end
16
13
 
17
- # Aggiunta del supporto ai routes
14
+ # Add routes support
18
15
  initializer 'Add gem routes to application',
19
16
  before: :load_config_initializers do
20
17
  Rails.application.routes.append do
21
- # modificare '/lato/starter' con l'url di base dei routes del modulo
22
18
  mount LatoCore::Engine, at: '/lato/core'
23
19
  end
24
20
  end
21
+
22
+ # Add interface to main application
23
+ config.autoload_paths << LatoCore::Engine.root.join('lib/interface')
24
+
25
25
  end
26
26
  end
@@ -1,27 +1,24 @@
1
1
  module LatoCore
2
- # L'interfaccia contiene un insieme di funzioni utilizzabili in maniera
3
- # universale dall'applicazione principale o da alti moduli
4
2
  module Interface
5
3
 
6
- # Azioni principali per la gestione della cache
4
+ require 'lato_core/interface/authentication'
5
+ include LatoCore::Interface::Authentication
6
+
7
7
  require 'lato_core/interface/cache'
8
8
  include LatoCore::Interface::Cache
9
- # Azioni principali per la gestione delle comunicazioni
9
+
10
10
  require 'lato_core/interface/communication'
11
11
  include LatoCore::Interface::Communication
12
- # Azioni principali per la gestione delle sessioni
13
- require 'lato_core/interface/session'
14
- include LatoCore::Interface::Session
15
- # Azioni principali per la gestione della navigazione
16
- require 'lato_core/interface/navigation'
17
- include LatoCore::Interface::Navigation
18
- # Azioni principali per il controllo dell'autenticazione
19
- require 'lato_core/interface/authentication'
20
- include LatoCore::Interface::Authentication
21
- # Azioni principali per la gestione delle lingue
12
+
22
13
  require 'lato_core/interface/languages'
23
14
  include LatoCore::Interface::Languages
24
- # Azioni principali per la gestione delle impostazioni superusers
15
+
16
+ require 'lato_core/interface/navigation'
17
+ include LatoCore::Interface::Navigation
18
+
19
+ require 'lato_core/interface/session'
20
+ include LatoCore::Interface::Session
21
+
25
22
  require 'lato_core/interface/superusers'
26
23
  include LatoCore::Interface::Superusers
27
24
 
@@ -1,34 +1,26 @@
1
1
  module LatoCore
2
- module Interface
3
- # Insieme di funzioni che permettono di gestire l'autenticazione degli
4
- # utenti che vogliono accedere al backoffice
5
- module Authentication
2
+ # This module contains functions for authetication.
3
+ module Interface::Authentication
6
4
 
7
- # Funzione che controlla se l'utente ha i permessi di accedere al
8
- # backoffice. Se l'utente non ha i permessi viene rimandato alla pagina di login.
9
- def core_controlUser
10
- redirect_to lato_core.login_path unless core_controlSession
11
- end
12
-
13
- # Funzione che ritorna l'oggetto utente loggato.
14
- # * *Returns* :
15
- # - user_id se la sessione dell'utente risulta valida
16
- # - false se la sessione non esiste o non e' valida
17
- def core_getCurrentUser
18
- user = LatoCore::Superuser.find(session[:user])
19
- return user if session[:user] && session[:session_code] && user
20
- end
5
+ # This function check if user is logged and redirect to login path if
6
+ # is not logged.
7
+ def core_controlUser
8
+ redirect_to lato_core.login_path unless core_controlSession
9
+ end
21
10
 
22
- # Funzione che controlla se i permessi dell'utente sono superiori al
23
- # livello ricevuto come parametro
24
- # * *Returns* :
25
- # - true se la sessione dell'utente ha permessi maggiori o uguali del parametro ricevuto
26
- # - false se la sessione non esiste o non ha i permessi necessari
27
- def core_controlPermission(permission)
28
- user = core_getCurrentUser
29
- user && user.permission >= permission
30
- end
11
+ # This function search current user on database and return it if is
12
+ # logged.
13
+ def core_getCurrentUser
14
+ user = LatoCore::Superuser.find(session[:user])
15
+ return user if session[:user] && session[:session_code] && user
16
+ end
31
17
 
18
+ # This function control if current user has a permission level like
19
+ # value set as params and return a boolean value.
20
+ def core_controlPermission(permission)
21
+ user = core_getCurrentUser
22
+ user && user.permission >= permission
32
23
  end
24
+
33
25
  end
34
26
  end
@@ -1,28 +1,22 @@
1
1
  module LatoCore
2
- module Interface
3
- # Insieme di funzioni che gestiscono la cache dei moduli sulla
4
- # applicazione principale.
5
- module Cache
6
-
7
- # Funzione che ritorna il percorso alla directory di cache usata dai
8
- # moduli lato per memorizzare informazioni sull'applicazione principale.
9
- # La directory dell'app principale usata come cache si trova nel percorso
10
- # #{Rails.root}/config/lato
11
- def core_getCacheDirectory
12
- # creo le directory per gli assets se non esistono
13
- dirname = "#{Rails.root}/app/assets/images/lato"
14
- FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
15
- dirname = "#{Rails.root}/app/assets/stylesheets/lato"
16
- FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
17
- dirname = "#{Rails.root}/app/assets/javascripts/lato"
18
- FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
19
- # creo la directory di cache se non esiste
20
- dirname = "#{Rails.root}/config/lato"
21
- FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
22
- # ritorno la directory di cache
23
- return dirname
24
- end
2
+ # This module contains functions for cache information.
3
+ module Interface::Cache
25
4
 
5
+ # This function return a string with the path of cache directory on
6
+ # main project.
7
+ def core_getCacheDirectory
8
+ # directories for assets
9
+ dirname = "#{Rails.root}/app/assets/images/lato"
10
+ FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
11
+ dirname = "#{Rails.root}/app/assets/stylesheets/lato"
12
+ FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
13
+ dirname = "#{Rails.root}/app/assets/javascripts/lato"
14
+ FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
15
+ # main cache directory
16
+ dirname = "#{Rails.root}/config/lato"
17
+ FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
18
+ # return directory
19
+ return dirname
26
20
  end
27
21
 
28
22
  end
@@ -1,103 +1,86 @@
1
1
  module LatoCore
2
- module Interface
3
- # Insieme di funzioni che permettono di ottenere informazioni sulla
4
- # applicazione principale e sulle altre gemme che lavorano su di essa
5
- module Communication
2
+ # This module contains functions for the communication with other modules.
3
+ module Interface::Communication
6
4
 
7
- # Ritorna l'url relativo della directory a cui rimandare dopo
8
- # aver effettuato il login in lato. Se tale valore non e' settato
9
- # nel file di configurazione di lato allora ritorna semplicemente false.
10
- def core_getApplicationLoginRoot
11
- return CORE_APPLOGINROOT if defined? CORE_APPLOGINROOT
12
- directory = core_getCacheDirectory
13
- if File.exist? "#{directory}/config.yml"
14
- config = YAML.load(
15
- File.read(File.expand_path("#{directory}/config.yml", __FILE__))
16
- )
17
- return config['login_home'] if config && config['login_home']
18
- else
19
- return false
20
- end
21
- end
22
-
23
- # Ritorna il nome dell'applicazione principale settato nel file
24
- # config/lato/config.yml.
25
- # Se l'applicazione principale non specifica nessun nome allora
26
- # la funzione ritorna il valore 'Lato'
27
- def core_getApplicationName
28
- return CORE_APPNAME if defined? CORE_APPNAME
29
- directory = core_getCacheDirectory
30
- if File.exist? "#{directory}/config.yml"
31
- config = YAML.load(
32
- File.read(File.expand_path("#{directory}/config.yml", __FILE__))
33
- )
34
- if config && config['app_name']
35
- return config['app_name']
36
- else
37
- return 'Lato'
38
- end
39
- end
5
+ # This function return the login root set for the application (the url
6
+ # where user is redirect after login).
7
+ def core_getApplicationLoginRoot
8
+ return CORE_APPLOGINROOT if defined? CORE_APPLOGINROOT
9
+ directory = core_getCacheDirectory
10
+ if File.exist? "#{directory}/config.yml"
11
+ config = YAML.load(
12
+ File.read(File.expand_path("#{directory}/config.yml", __FILE__))
13
+ )
14
+ return config['login_home'] if config && config['login_home']
15
+ else
16
+ return false
40
17
  end
18
+ end
41
19
 
42
- # Legge il file di configurazione e verifica se e' stato impostato un root url
43
- # per l'applicazione. Se non è stato impostato utilizza di default 'localhost'
44
- def core_getApplicationURL
45
- return CORE_APPURL if defined? CORE_APPURL
46
- directory = core_getCacheDirectory
47
- if File.exist? "#{directory}/config.yml"
48
- config = YAML.load(
49
- File.read(File.expand_path("#{directory}/config.yml", __FILE__))
50
- )
51
- if config && config['root_url']
52
- return config['root_url']
53
- else
54
- return 'http://localhost:3000'
55
- end
20
+ # This function return the application name.
21
+ def core_getApplicationName
22
+ return CORE_APPNAME if defined? CORE_APPNAME
23
+ directory = core_getCacheDirectory
24
+ if File.exist? "#{directory}/config.yml"
25
+ config = YAML.load(
26
+ File.read(File.expand_path("#{directory}/config.yml", __FILE__))
27
+ )
28
+ if config && config['app_name']
29
+ return config['app_name']
30
+ else
31
+ return 'Lato'
56
32
  end
57
33
  end
34
+ end
58
35
 
59
- # Legge il file di configurazione e verifica se è stato impostato un indirizzo
60
- # email di servizio. Se non e' stata impostata allora utilizza quella di
61
- # default 'service@lato.com'
62
- def core_getApplicationServiceEmail
63
- return CORE_APPSERVICEMAIL if defined? CORE_APPSERVICEMAIL
64
- directory = core_getCacheDirectory
65
- if File.exist? "#{directory}/config.yml"
66
- config = YAML.load(
67
- File.read(File.expand_path("#{directory}/config.yml", __FILE__))
68
- )
69
- if config && config['service_email']
70
- return config['service_email']
71
- else
72
- return 'service@lato.com'
73
- end
36
+ # This function return the application url set on the config file.
37
+ def core_getApplicationURL
38
+ return CORE_APPURL if defined? CORE_APPURL
39
+ directory = core_getCacheDirectory
40
+ if File.exist? "#{directory}/config.yml"
41
+ config = YAML.load(
42
+ File.read(File.expand_path("#{directory}/config.yml", __FILE__))
43
+ )
44
+ if config && config['root_url']
45
+ return config['root_url']
46
+ else
47
+ return 'http://localhost:3000'
74
48
  end
75
49
  end
50
+ end
76
51
 
77
- # Esamina tutte le gemme della applicazione principale e ritorna
78
- # solamente quelle appartenenti al progetto Lato.
79
- # * *Returns* :
80
- # - array di stringhe con i nomi delle gemme del progetto Lato usate dall'applicazione
81
- def core_getLatoGems
82
- gems = core_getGems
83
- lato_gems = []
84
- # controllo ogni gemma
85
- gems.each do |name|
86
- lato_gems.push(name) if name.start_with? 'lato'
52
+ # This function return the default service email set on the config file.
53
+ def core_getApplicationServiceEmail
54
+ return CORE_APPSERVICEMAIL if defined? CORE_APPSERVICEMAIL
55
+ directory = core_getCacheDirectory
56
+ if File.exist? "#{directory}/config.yml"
57
+ config = YAML.load(
58
+ File.read(File.expand_path("#{directory}/config.yml", __FILE__))
59
+ )
60
+ if config && config['service_email']
61
+ return config['service_email']
62
+ else
63
+ return 'service@lato.com'
87
64
  end
88
- # ritorno il risultato
89
- lato_gems
90
65
  end
66
+ end
91
67
 
92
- # Ritorna la lista dei nomi delle gemme utilizzate dalla applicazione
93
- # principale
94
- # * *Returns* :
95
- # - array di stringhe con i nomi delle gemme dell'applicazione
96
- def core_getGems
97
- require 'bundler'
98
- Bundler.load.specs.map { |spec| spec.name }
68
+ # This function return the list of lato gems used by the application.
69
+ def core_getLatoGems
70
+ gems = core_getGems
71
+ lato_gems = []
72
+ # check every gem
73
+ gems.each do |name|
74
+ lato_gems.push(name) if name.start_with? 'lato'
99
75
  end
76
+ # return result
77
+ lato_gems
78
+ end
100
79
 
80
+ # This function return the list of gems used by the application.
81
+ def core_getGems
82
+ require 'bundler'
83
+ Bundler.load.specs.map { |spec| spec.name }
101
84
  end
102
85
 
103
86
  end
@@ -1,59 +1,50 @@
1
1
  module LatoCore
2
- module Interface
3
- # Insieme di funzioni che determinano e gestiscono le informazioni riguardo
4
- # alle lingue dell'applicazione tra le sezioni offerte dai moduli lato
5
- module Languages
2
+ # This module contains functions used to get languages info.
3
+ module Interface::Languages
6
4
 
7
- # Funzione che ritorna true se l'applicazione ha piu' lingue, false se
8
- # l'applicazione ha una singola lingua
9
- def core_applicationHasLanguages
10
- return (CORE_APPLANGUAGES.length > 1) if defined? CORE_APPLANGUAGES
11
- languages = core_getApplicationLanguages
12
- languages.length > 1
13
- end
5
+ # This function return a boolean value to tells if applications has
6
+ # languages set to config file.
7
+ def core_applicationHasLanguages
8
+ return (CORE_APPLANGUAGES.length > 1) if defined? CORE_APPLANGUAGES
9
+ languages = core_getApplicationLanguages
10
+ return languages.length > 1
11
+ end
14
12
 
15
- # Funzione che ritorna un array contenente le lingue gestite
16
- # dall'applicazione
17
- def core_getApplicationLanguages
18
- return CORE_APPLANGUAGES if defined? CORE_APPLANGUAGES
19
- # definisco variabile di ritorno
20
- languages = false
21
- if File.exist? "#{Rails.root}/config/lato/config.yml"
22
- # accedo al config.yml
23
- config = YAML.load(
24
- File.read(File.expand_path("#{Rails.root}/config/lato/config.yml",
25
- __FILE__))
26
- )
27
- if config['languages']
28
- languages = config['languages'].split(',')
13
+ # This function return an array of languages used by application.
14
+ def core_getApplicationLanguages
15
+ return CORE_APPLANGUAGES if defined? CORE_APPLANGUAGES
16
+ languages = false
17
+ if File.exist? "#{Rails.root}/config/lato/config.yml"
18
+ config = YAML.load(
19
+ File.read(File.expand_path("#{Rails.root}/config/lato/config.yml", __FILE__))
20
+ )
21
+ if config['languages']
22
+ languages = config['languages'].split(',')
29
23
 
30
- languages.each do |language|
31
- language.downcase.delete(' ')
32
- end
24
+ languages.each do |language|
25
+ language.downcase.delete(' ')
33
26
  end
34
27
  end
35
- # ritorno il risultato
36
- return languages
37
28
  end
29
+ # return result
30
+ return languages
31
+ end
38
32
 
39
- # Funzione che ritorna la lettura del file di lingua corretto per
40
- # il modulo il cui nome e' ricevuto come parametro
41
- def core_loadModuleLanguages(module_name)
42
- module_root = module_name.camelize.constantize::Engine.root
43
- application_lang = Rails.application.config.i18n.default_locale
44
- if File.exist? "#{module_root}/lang/#{application_lang}.yml"
45
- return YAML.load(
46
- File.read(File.expand_path("#{module_root}/lang/#{application_lang}.yml",
47
- __FILE__))
48
- )
49
- else
50
- return YAML.load(
51
- File.read(File.expand_path("#{module_root}/lang/default.yml",
52
- __FILE__))
53
- )
54
- end
33
+ # This function load and return the languages for a lato module.
34
+ def core_loadModuleLanguages(module_name)
35
+ module_root = module_name.camelize.constantize::Engine.root
36
+ application_lang = Rails.application.config.i18n.default_locale
37
+ if File.exist? "#{module_root}/lang/#{application_lang}.yml"
38
+ return YAML.load(
39
+ File.read(File.expand_path("#{module_root}/lang/#{application_lang}.yml",
40
+ __FILE__))
41
+ )
42
+ else
43
+ return YAML.load(
44
+ File.read(File.expand_path("#{module_root}/lang/default.yml",
45
+ __FILE__))
46
+ )
55
47
  end
56
-
57
48
  end
58
49
 
59
50
  end