kono_utils 0.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +442 -0
  4. data/Rakefile +23 -0
  5. data/app/assets/javascripts/kono_utils/utilities.coffee +456 -0
  6. data/app/assets/stylesheets/kono_utils/utils.css.scss +43 -0
  7. data/app/controllers/kono_utils/change_log_controller.rb +6 -0
  8. data/app/input/bs_aceeditor_input.rb +53 -0
  9. data/app/input/bs_autocomplete_input.rb +60 -0
  10. data/app/input/bs_datepicker_input.rb +16 -0
  11. data/app/input/bs_datetimepicker_input.rb +80 -0
  12. data/app/input/bs_file_download_input.rb +35 -0
  13. data/app/input/bs_image_input.rb +35 -0
  14. data/app/input/bs_label_with_container_input.rb +22 -0
  15. data/app/input/bs_location_picker_input.rb +95 -0
  16. data/app/input/bs_readonly_input.rb +52 -0
  17. data/app/input/bs_timepicker_input.rb +14 -0
  18. data/app/policies/kono_utils/base_editing_policy_concern.rb +27 -0
  19. data/app/views/kono_utils/base_editing/_edit.html.erb +3 -0
  20. data/app/views/kono_utils/base_editing/_edit_page_side_title_header.html.erb +3 -0
  21. data/app/views/kono_utils/base_editing/_edit_page_title_header.html.erb +3 -0
  22. data/app/views/kono_utils/base_editing/_form.html.erb +15 -0
  23. data/app/views/kono_utils/base_editing/_index_buttons.html.erb +2 -0
  24. data/app/views/kono_utils/base_editing/_index_page_side_title_header.html.erb +3 -0
  25. data/app/views/kono_utils/base_editing/_index_page_title_header.html.erb +3 -0
  26. data/app/views/kono_utils/base_editing/_index_tfoot.html.erb +0 -0
  27. data/app/views/kono_utils/base_editing/_new.html.erb +3 -0
  28. data/app/views/kono_utils/base_editing/_new_page_side_title_header.html.erb +3 -0
  29. data/app/views/kono_utils/base_editing/_new_page_title_header.html.erb +3 -0
  30. data/app/views/kono_utils/base_editing/_search_form.html.erb +1 -0
  31. data/app/views/kono_utils/base_editing/application/_edit_page_side_title_header.html.erb +1 -0
  32. data/app/views/kono_utils/base_editing/application/_edit_page_title_header.html.erb +1 -0
  33. data/app/views/kono_utils/base_editing/application/_index_page_side_title_header.html.erb +1 -0
  34. data/app/views/kono_utils/base_editing/application/_index_page_title_header.html.erb +1 -0
  35. data/app/views/kono_utils/base_editing/application/_new_page_side_title_header.html.erb +1 -0
  36. data/app/views/kono_utils/base_editing/application/_new_page_title_header.html.erb +1 -0
  37. data/app/views/kono_utils/base_editing/application/edit.html.erb +1 -0
  38. data/app/views/kono_utils/base_editing/application/new.html.erb +1 -0
  39. data/app/views/kono_utils/base_editing/edit.html.erb +1 -0
  40. data/app/views/kono_utils/base_editing/index.html.erb +36 -0
  41. data/app/views/kono_utils/base_editing/new.html.erb +1 -0
  42. data/app/views/kono_utils/change_log/index.html.erb +3 -0
  43. data/config/initializers/mysql.rb +12 -0
  44. data/config/initializers/time.rb +12 -0
  45. data/config/locales/it.yml +18 -0
  46. data/lib/generators/kono_utils/install/install_generator.rb +24 -0
  47. data/lib/generators/templates/initializer.rb +3 -0
  48. data/lib/kono_utils.rb +41 -0
  49. data/lib/kono_utils/application_helper.rb +625 -0
  50. data/lib/kono_utils/base_editing_helper.rb +194 -0
  51. data/lib/kono_utils/base_search.rb +173 -0
  52. data/lib/kono_utils/concerns.rb +10 -0
  53. data/lib/kono_utils/concerns/active_record_translation.rb +47 -0
  54. data/lib/kono_utils/concerns/base_editing.rb +195 -0
  55. data/lib/kono_utils/concerns/base_modals.rb +97 -0
  56. data/lib/kono_utils/concerns/success_message.rb +25 -0
  57. data/lib/kono_utils/encoder.rb +55 -0
  58. data/lib/kono_utils/engine.rb +13 -0
  59. data/lib/kono_utils/fiscal_code.rb +47 -0
  60. data/lib/kono_utils/params_hash_array.rb +37 -0
  61. data/lib/kono_utils/percentage.rb +60 -0
  62. data/lib/kono_utils/search_attribute.rb +57 -0
  63. data/lib/kono_utils/tmp_file.rb +81 -0
  64. data/lib/kono_utils/version.rb +3 -0
  65. data/lib/kono_utils/virtual_model.rb +22 -0
  66. data/lib/tasks/kono_utils_tasks.rake +4 -0
  67. data/spec/dummy/README.rdoc +28 -0
  68. data/spec/dummy/Rakefile +6 -0
  69. data/spec/dummy/app/assets/images/.keep +0 -0
  70. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  71. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  72. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  73. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  74. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  75. data/spec/dummy/app/mailers/.keep +0 -0
  76. data/spec/dummy/app/models/.keep +0 -0
  77. data/spec/dummy/app/models/concerns/.keep +0 -0
  78. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  79. data/spec/dummy/bin/bundle +3 -0
  80. data/spec/dummy/bin/rails +4 -0
  81. data/spec/dummy/bin/rake +4 -0
  82. data/spec/dummy/bin/setup +29 -0
  83. data/spec/dummy/config.ru +4 -0
  84. data/spec/dummy/config/application.rb +32 -0
  85. data/spec/dummy/config/boot.rb +5 -0
  86. data/spec/dummy/config/database.yml +25 -0
  87. data/spec/dummy/config/environment.rb +5 -0
  88. data/spec/dummy/config/environments/development.rb +41 -0
  89. data/spec/dummy/config/environments/production.rb +79 -0
  90. data/spec/dummy/config/environments/test.rb +42 -0
  91. data/spec/dummy/config/initializers/assets.rb +11 -0
  92. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  93. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  94. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  95. data/spec/dummy/config/initializers/inflections.rb +16 -0
  96. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  97. data/spec/dummy/config/initializers/session_store.rb +3 -0
  98. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  99. data/spec/dummy/config/locales/en.yml +23 -0
  100. data/spec/dummy/config/routes.rb +56 -0
  101. data/spec/dummy/config/secrets.yml +22 -0
  102. data/spec/dummy/lib/assets/.keep +0 -0
  103. data/spec/dummy/log/.keep +0 -0
  104. data/spec/dummy/public/404.html +67 -0
  105. data/spec/dummy/public/422.html +67 -0
  106. data/spec/dummy/public/500.html +66 -0
  107. data/spec/dummy/public/favicon.ico +0 -0
  108. data/spec/lib/kono_utils/fiscal_code_spec.rb +56 -0
  109. data/spec/rails_helper.rb +53 -0
  110. data/spec/spec_helper.rb +92 -0
  111. data/vendor/assets/javascripts/EventEmitter.js +473 -0
  112. metadata +425 -0
@@ -0,0 +1,97 @@
1
+ require 'active_support/concern'
2
+ module KonoUtils::Concerns
3
+ module BaseModals
4
+ extend ActiveSupport::Concern
5
+
6
+ def create
7
+ authorize @obj if defined? Pundit
8
+ save_response
9
+ end
10
+
11
+ def destroy
12
+ authorize @obj if defined? Pundit
13
+ @obj.destroy
14
+ respond_to do |f|
15
+ f.json { render json: {success: true} }
16
+ end
17
+ end
18
+
19
+
20
+ def update
21
+ authorize @obj if defined? Pundit
22
+ @obj.assign_attributes(update_params)
23
+ save_response
24
+ end
25
+
26
+ included do
27
+ before_action :load_parent_assoc
28
+ before_action :load_obj, :only => [:destroy, :update]
29
+
30
+ private
31
+ ##
32
+ # Metodo promemoria per caricare il modello padre
33
+ def load_parent_assoc
34
+ @parent_model = nil
35
+ raise 'Sovrascrivi funzione "load_parent_assoc" nei figli la definizione di questa variabile: @parent_model'
36
+ end
37
+
38
+ ##
39
+ # Metodo promemoria per caricare l'oggetto dell'aggiornamento
40
+ # ES:
41
+ # @obj = @person.person_contacts.find(params[:id])
42
+ def load_obj
43
+ @obj=nil
44
+ raise 'Sovrascrivi funzione "load_obj" in figli la definizione di questa variabile: @obj'
45
+ end
46
+
47
+ ##
48
+ # Metodo promemoria per pulire i parametri
49
+ # ES:
50
+ # params.require(:person_contact).permit(:contacttype_id, :contact)
51
+ def update_params
52
+ raise 'Sovrascrivi in figli'
53
+ end
54
+
55
+
56
+ def render_part_to_json(partial, locals, status=200)
57
+ render json: {
58
+ partial: (
59
+ render_to_string(
60
+ :partial => partial,
61
+ :layout => false, :locals => locals)
62
+ )
63
+ }, status: status
64
+ end
65
+
66
+ def save_response
67
+ raise "Sovrascrivere:
68
+ def save_response
69
+ respond_to do |f|
70
+ if @obj.valid?
71
+ @obj.save
72
+ f.json do
73
+ render_part_to_json('tikal_core/people/person_contacts/panel.html', {:contact => @obj})
74
+ end
75
+ else
76
+ f.json do
77
+ render_part_to_json('tikal_core/people/person_contacts/modal_form.html', {:contact => @obj, :id => ''}, 400)
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ ed aggiungere se non già fatto:
84
+ def create
85
+ @obj = @person.person_contacts.build(update_params)
86
+ super
87
+ end
88
+ def update_params
89
+ params.require(:person_contact).permit(:contacttype_id, :contact)
90
+ end
91
+ "
92
+ end
93
+ end
94
+
95
+
96
+ end
97
+ end
@@ -0,0 +1,25 @@
1
+ require 'active_support/concern'
2
+ module KonoUtils::Concerns
3
+ module SuccessMessage
4
+
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ private
9
+ def success_create_message(model)
10
+ t('activerecord.successful.messages.created', :model => model.mn)
11
+ end
12
+
13
+ def success_update_message(model)
14
+ t('activerecord.successful.messages.updated', :model => model.mn)
15
+ end
16
+
17
+ def success_destroy_message(model)
18
+ t('activerecord.successful.messages.destroyed', :model => model.mn)
19
+ end
20
+
21
+ end
22
+
23
+
24
+ end
25
+ end
@@ -0,0 +1,55 @@
1
+ module KonoUtils
2
+ ##
3
+ # Classe che si occupa di decodificare una qualsiasi stringa in formato utf8,
4
+ # cercando di trovare l'encoding iniziale a tentativi.
5
+ class Encoder
6
+
7
+
8
+ attr_accessor :string
9
+
10
+
11
+ ##
12
+ # * *Attributes* :
13
+ # - string -> Stringa da elaborare
14
+ def initialize(string)
15
+ self.string = string
16
+ end
17
+
18
+
19
+ ##
20
+ # Funcione di rimozione del carattere BOM http://en.wikipedia.org/wiki/Byte_order_mark
21
+ # e encoding normale
22
+ def remove_bom
23
+ string_encoder.gsub("\xEF\xBB\xBF".force_encoding("UTF-8"), '')
24
+ end
25
+
26
+ ##
27
+ # Funzione di encoding semplice
28
+ def string_encoder
29
+ return self.string if self.string.valid_encoding?
30
+ str = self.string
31
+ Encoding.list.each do |e|
32
+ begin
33
+ str.force_encoding(e.name)
34
+ tmp_string = str.encode("UTF-8")
35
+ return tmp_string if tmp_string.valid_encoding?
36
+ rescue
37
+ logger.debug { "Rescue -> #{e.name}" }
38
+ end
39
+ end
40
+
41
+ impossible_encoding
42
+
43
+ self.string
44
+ end
45
+
46
+ ##
47
+ # Metodo placeholder, volendo si può estendere la funzione e sovrascrivere questa funzione
48
+ # per essere notificati in caso di mancata decodifica
49
+ def impossible_encoding
50
+
51
+ end
52
+
53
+
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ module KonoUtils
2
+ class Engine < ::Rails::Engine
3
+
4
+ require 'bootstrap3-datetimepicker-rails'
5
+ require 'momentjs-rails'
6
+ require 'font-awesome-rails'
7
+ require 'rails-assets-bootstrap-treeview'
8
+ require 'will_paginate'
9
+ require 'will_paginate-bootstrap'
10
+ require 'rdiscount'
11
+
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ module KonoUtils
2
+ module FiscalCode
3
+ class ControllaCF
4
+ LT = [[1, '0'], [0, '1'], [5, '2'], [7, '3'], [9, '4'], [13, '5'], [15, '6'], [17, '7'], [19, '8'], [21, '9'], [1, 'A'], [0, 'B'], [5, 'C'], [7, 'D'], [9, 'E'], [13, 'F'], [15, 'G'], [17, 'H'], [19, 'I'], [21, 'J'], [2, 'K'], [4, 'L'], [18, 'M'], [20, 'N'], [11, 'O'], [3, 'P'], [6, 'Q'], [8, 'R'], [12, 'S'], [14, 'T'], [16, 'U'], [10, 'V'], [22, 'W'], [25, 'X'], [24, 'Y'], [23, 'Z']]
5
+ Z9 = ('0'..'9').to_a
6
+ AZ = ('A'..'Z').to_a
7
+ class EmptyString < Exception;
8
+ end
9
+ class InvalidLength < Exception;
10
+ end
11
+ class CaseError < Exception;
12
+ end
13
+
14
+ def self.valid?(cf, strict = false)
15
+ cf = cf.to_s
16
+ raise EmptyString.new("codice fiscale non può essere lasciato in bianco") if cf.empty?
17
+ raise InvalidLength.new("codice fiscale dev'essere composto da 16 caratteri alfanumerici") if cf.size != 16
18
+ if strict==true && cf != cf.upcase;
19
+ raise CaseError.new("i caratteri del codice fiscale devono essere maiuscoli");
20
+ else
21
+ cf.upcase!
22
+ end;
23
+ s = (0..14).collect { |i| (i&1)!=0 ? ([Z9.include?(cf[i, 1]) ? cf[i, 1].to_i : AZ.index(cf[i, 1]), cf[i, 1]]) : LT.rassoc(cf[i, 1]) }
24
+ s.include?(nil) ? false : AZ.at((s.transpose[0].inject(0) { |t, n| t+n })%26) == cf[-1, 1]
25
+ end
26
+
27
+
28
+ end
29
+
30
+ class ControllaPI
31
+ NU = ('0'..'9').to_a
32
+ class EmptyString < Exception;
33
+ end
34
+ class InvalidLength < Exception;
35
+ end
36
+
37
+ def self.valid?(pi)
38
+ pi = pi.to_s
39
+ raise EmptyString.new("partita iva non può essere lasciata in bianco") if pi.empty?
40
+ raise InvalidLength.new("partita iva dev'essere composta da 11 cifre") if pi.size != 11
41
+ s = (0..9).collect { |i| NU.include?(pi[i, 1]) ? ((i&1)!=0 ? (pi[i, 1].to_i > 4 ? ((pi[i, 1].to_i*2) - 9) : pi[i, 1].to_i * 2) : pi[i, 1].to_i) : nil }
42
+ r = s.include?(nil) ? false : ((s.inject(0) { |t, n| t+n }) % 10)
43
+ r != false && (r==0 ? r : 10-r) == pi[-1, 1].to_i
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,37 @@
1
+ module KonoUtils
2
+ module ParamsHashArray
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ ##
7
+ # Si occupa di trasformare un hash con elementi che sono chiramente array in un hash con elementi array:
8
+ #
9
+ # {"DatiOrdineAcquisto"=>{"0"=>{"RiferimentoNumeroLinea"=>{"0"=>""}, "IdDocumento"=>"", "Data"=>"", "NumItem"=>"", "CodiceCommessaConvenzione"=>"", "CodiceCUP"=>"", "CodiceCIG"=>""}}}
10
+ # {"DatiOrdineAcquisto"=>[{"RiferimentoNumeroLinea"=>[""], "IdDocumento"=>"", "Data"=>"", "NumItem"=>"", "CodiceCommessaConvenzione"=>"", "CodiceCUP"=>"", "CodiceCIG"=>""}]}
11
+ #
12
+ def elaborate_params_to_hash_array(params)
13
+
14
+ out = params
15
+ ##Controllo se abbiamo solamente chiavi che rappresentano numeri
16
+ if params.is_a?(Hash)
17
+
18
+ if params.keys.select { |k| !(k.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true) }.length==0
19
+ out = []
20
+ params.each_value do |v|
21
+ out << elaborate_params_to_hash_array(v)
22
+ end
23
+ else
24
+ out={}
25
+ params.keys.each do |k|
26
+ out[k.to_sym] = elaborate_params_to_hash_array(params[k])
27
+ end
28
+ end
29
+ end
30
+
31
+ Rails.logger.debug "DEBUG #{out.inspect}"
32
+ out
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,60 @@
1
+ require 'action_view'
2
+ module KonoUtils
3
+ ##
4
+ # Classe che si occupa di rappresentare un numero percentuale
5
+ # ES:
6
+ # p = Percentage.new(100,20)
7
+ # p.percentage -> ritorna il valore percentuale float
8
+ # p.to_i -> ritorna percentuale intera con relativi arrotondamenti
9
+ # p.to_percentage -> si comporta come l'helper number_to_percentage
10
+ class Percentage
11
+
12
+ include ActionView::Helpers::NumberHelper
13
+
14
+ attr_accessor :total, :partial
15
+
16
+ def initialize(total=0, partial=0)
17
+ @total = total
18
+ @partial = partial
19
+ end
20
+
21
+ ##
22
+ #
23
+ # * *Args* :
24
+ # - options -> Hash :
25
+ # :locale - Sets the locale to be used for formatting (defaults to current locale).
26
+ #
27
+ # :precision - Sets the precision of the number (defaults to 3).
28
+ #
29
+ # :significant - If true, precision will be the # of significant_digits. If false, the # of fractional digits (defaults to false).
30
+ #
31
+ # :separator - Sets the separator between the fractional and integer digits (defaults to “.”).
32
+ #
33
+ # :delimiter - Sets the thousands delimiter (defaults to “”).
34
+ #
35
+ # :strip_insignificant_zeros - If true removes insignificant zeros after the decimal separator (defaults to false).
36
+ #
37
+ # :format - Specifies the format of the percentage string The number field is %n (defaults to “%n%”).
38
+ #
39
+ # :raise - If true, raises InvalidNumberError when the argument is invalid.
40
+ # * *Returns* :
41
+ # - String
42
+ #
43
+ def to_percentage(options = {})
44
+ number_to_percentage(percentage, options)
45
+ end
46
+
47
+ def percentage
48
+ return 0 if @partial==0
49
+ return 0 if @total<@partial
50
+ @partial.to_f/@total.to_f*100.0
51
+ end
52
+
53
+ def to_i
54
+ return 100 if @total.to_s == @partial.to_s
55
+ percentage.to_i
56
+ end
57
+
58
+
59
+ end
60
+ end
@@ -0,0 +1,57 @@
1
+ module KonoUtils
2
+ ##
3
+ # Classe che mi rappresenta un attributo di ricerca
4
+ # Di default utilizza il tipo string come renderizzazione
5
+ #
6
+ # * *Args* :
7
+ # - form_options -> Hash con opzioni da passare a formtastic
8
+ # - field_options -> Hash con opzioni:
9
+ # cast -> Proc per eseguire il cast del valore
10
+ class SearchAttribute
11
+
12
+ attr_accessor :field, :form_options, :field_options
13
+
14
+ def initialize(field, options = {})
15
+ self.field = field
16
+
17
+ self.field_options = {}
18
+ unless options.is_a? Proc
19
+ if options[:field_options]
20
+ self.field_options = options[:field_options]
21
+ options.delete(:field_options)
22
+ end
23
+ end
24
+
25
+ self.form_options = options
26
+ end
27
+
28
+ ##
29
+ # Esegue un casting dei valori rispetto al tipo di campo da utilizzare per formtastic
30
+ def cast_value(value)
31
+ return value if value.blank?
32
+ return value if form_options.is_a? Proc
33
+ return field_options[:cast].call(value) if field_options[:cast].is_a? Proc
34
+ case form_options[:as]
35
+ when :bs_datetimepicker
36
+ if value.is_a? String
37
+ DateTime.parse(value)
38
+ elsif value.is_a? Date
39
+ value.to_time
40
+ else
41
+ value
42
+ end
43
+ when :bs_datepicker
44
+ if value.is_a? String
45
+ DateTime.parse(value).to_date
46
+ elsif value.is_a? DateTime
47
+ value.to_date
48
+ else
49
+ value
50
+ end
51
+ else
52
+ value
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,81 @@
1
+ require 'fileutils'
2
+ module KonoUtils
3
+ ##
4
+ # Classe Funzionante prettamente con RAILS
5
+ # la classe si occupa dei files temporanei creando una cartella dentro a tmp del progetto
6
+ # crea una cartella random per ogni file per ovviare al problema di duplicazioni dei nomi
7
+ # Estende Tempfile,
8
+ # la root della struttura è quella di Rails.root
9
+ # e di default la classe scrive dentro a tmp
10
+ # non ha bisogno di essere cancellata, ci penserà in automatico la classe una
11
+ # la prossima volta che viene chiamata cancellando tutti i files con un TTL
12
+ # maggiore di 1.day di default
13
+ ## Utilizzo:
14
+ # tmp = Ptmpfile.new('nomefile.ext')
15
+ # tmp.path -> path completa
16
+ # tmp.write.....
17
+ # tmp.original_filename.......
18
+ # tmp.unique_filename.......
19
+ #
20
+ #
21
+ class TmpFile < Tempfile
22
+
23
+ PATH = 'tmp/ptmpfile'
24
+ TIME_LIMIT = 1.day
25
+ attr_accessor :root_dir
26
+ attr_accessor :tmp_dir
27
+ attr_accessor :original_filename, :unique_filename
28
+
29
+
30
+ ##
31
+ # Generate a new file with a given name
32
+ #
33
+ # * *Args* :
34
+ # - name -> String of the name file
35
+ # * *Returns* :
36
+ # - Tempfile
37
+ #
38
+ def initialize(name)
39
+ self.original_filename=name
40
+ self.root_dir = controll_root
41
+ clean_tmpdir
42
+ #creo una nuova cartella per il file attuale
43
+ self.tmp_dir= "#{self.root_dir.path}/#{Time.now.to_f}"
44
+ Dir.mkdir(self.tmp_dir)
45
+ ext =File.extname(name)
46
+ name = [File.basename(name), ext] unless ext.blank?
47
+ super(name, self.tmp_dir)
48
+ self.unique_filename= File.basename(self.path)
49
+ end
50
+
51
+
52
+ private
53
+
54
+ ##
55
+ # controll presence of root dir
56
+ # if not exists create it
57
+ # * *Returns* :
58
+ # - Dir
59
+ #
60
+ def controll_root
61
+ unless File.exist?(::Rails.root.join(PATH))
62
+ Dir.mkdir(::Rails.root.join(PATH))
63
+ end
64
+ Dir.open(::Rails.root.join(PATH))
65
+ end
66
+
67
+ ##
68
+ # Clean the directory
69
+ #
70
+ def clean_tmpdir
71
+ self.root_dir.each do |d|
72
+ if d != '..' and d!='.'
73
+ if d.to_i < Time.now.to_i-TIME_LIMIT
74
+ FileUtils.rm_rf(File.join(self.root_dir.path, d))
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ end
81
+ end