kono_utils_helpers 0.1.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 725c9d6e6ea464bbba4bab1091b31f8264452ce0e2564b5243860dea72cc3063
4
+ data.tar.gz: 35e7c5a4541001bab8771b2709efadbfbf9c0d6eaeaad91c15790514317a9567
5
+ SHA512:
6
+ metadata.gz: 1e6483106a879ceea62af861cac2a6af3764fc053dfa58df28dc2635a4d4e080463f51cd893a5299002a63f36f4d4e838e25a7683b5c513d024b8b3d0c519a27
7
+ data.tar.gz: 693db9838645ecb58dfb014bb576f717ec2b3216ef1df694ac3af87dff6cf7eb55829926f0272600abfea10a0c31361552e618302809b76141d8b2004192e318
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .idea
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,4 @@
1
+ ruby=ruby-2.6.5
2
+ ruby-gemset=KonoUtilsBootstrap
3
+ #ruby-gem-install=bundler rake
4
+ #ruby-bundle-install=true
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in kono_utils_helpers.gemspec
6
+ gemspec
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kono_utils_helpers (0.1.0.pre.rc.1)
5
+ actionview
6
+ active_type
7
+ activesupport (>= 4.2)
8
+ zeitwerk
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actionview (6.1.1)
14
+ activesupport (= 6.1.1)
15
+ builder (~> 3.1)
16
+ erubi (~> 1.4)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
19
+ active_type (1.5.0)
20
+ activerecord (>= 3.2)
21
+ activemodel (6.1.1)
22
+ activesupport (= 6.1.1)
23
+ activerecord (6.1.1)
24
+ activemodel (= 6.1.1)
25
+ activesupport (= 6.1.1)
26
+ activesupport (6.1.1)
27
+ concurrent-ruby (~> 1.0, >= 1.0.2)
28
+ i18n (>= 1.6, < 2)
29
+ minitest (>= 5.1)
30
+ tzinfo (~> 2.0)
31
+ zeitwerk (~> 2.3)
32
+ builder (3.2.4)
33
+ concurrent-ruby (1.1.7)
34
+ crass (1.0.6)
35
+ diff-lcs (1.3)
36
+ erubi (1.10.0)
37
+ i18n (1.8.7)
38
+ concurrent-ruby (~> 1.0)
39
+ loofah (2.9.0)
40
+ crass (~> 1.0.2)
41
+ nokogiri (>= 1.5.9)
42
+ mini_portile2 (2.5.0)
43
+ minitest (5.14.3)
44
+ nokogiri (1.11.1)
45
+ mini_portile2 (~> 2.5.0)
46
+ racc (~> 1.4)
47
+ racc (1.5.2)
48
+ rails-dom-testing (2.0.3)
49
+ activesupport (>= 4.2.0)
50
+ nokogiri (>= 1.6)
51
+ rails-html-sanitizer (1.3.0)
52
+ loofah (~> 2.3)
53
+ rake (10.5.0)
54
+ rspec (3.8.0)
55
+ rspec-core (~> 3.8.0)
56
+ rspec-expectations (~> 3.8.0)
57
+ rspec-mocks (~> 3.8.0)
58
+ rspec-core (3.8.2)
59
+ rspec-support (~> 3.8.0)
60
+ rspec-expectations (3.8.4)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.8.0)
63
+ rspec-mocks (3.8.1)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.8.0)
66
+ rspec-support (3.8.2)
67
+ tzinfo (2.0.4)
68
+ concurrent-ruby (~> 1.0)
69
+ zeitwerk (2.4.2)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ bundler (~> 1.16)
76
+ kono_utils_helpers!
77
+ rake (~> 10.0)
78
+ rspec (~> 3.0)
79
+
80
+ BUNDLED WITH
81
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Marino Bonetti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,104 @@
1
+ # KonoUtilsHelpers
2
+
3
+ Collection of Classes used in KonoUtils
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kono_utils_helpers'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kono_utils_helpers
20
+
21
+ ## Usage
22
+
23
+
24
+ ### TmpFile
25
+ Classe Funzionante prettamente con RAILS
26
+
27
+ La classe si occupa dei files temporanei creando una cartella dentro a tmp del progetto,
28
+ per ovviare al problema di duplicazioni dei nomi, viene generata una nuova cartella con
29
+ timestamp univoco per ogni file.
30
+
31
+ Estende Tempfile,
32
+ la root della struttura è quella di Rails.root
33
+ e di default la classe scrive dentro a tmp della root di rails.
34
+
35
+ Non c'è bisogno di preoccuparsi di svuotare la cartella tmp contenente i file temporanei dato che la classe
36
+ avrà l'onere di controllare e ripulire eventuali files dopo 1.day di default.
37
+
38
+ #### Utilizzo:
39
+ ```ruby
40
+ tmp = KonoUtils::TmpFile.new('nomefile.ext')
41
+ tmp.path -> path completa
42
+ tmp.write(valore_da_scrivere_dentro_a_file)
43
+ tmp.original_filename -> restituisce il nome inizialmente passato alla classe
44
+ tmp.unique_filename -> restoituisce il nome univoco del file
45
+ tmp.path -> restituisce la path del file
46
+ ```
47
+
48
+
49
+
50
+ ### Encoder
51
+ Classe che si occupa di decodificare una qualsiasi stringa in formato utf8,
52
+ cercando di trovare l'encoding iniziale a tentativi.
53
+ Ha anche a disposizione una funzione per la rimozione dei caratteri BOM dalla stringa(http://en.wikipedia.org/wiki/Byte_order_mark)
54
+
55
+ #### Utilizzo
56
+ str="stringa di un encoding sconosciuto"
57
+ en = KonoUtils::Encoder.new(str)
58
+ en.string_encoder -> normale tentativo di encoding restituendo stringa in utf8
59
+ en.remove_bom -> rimozione del carattere BOM e encoding con la funzione precedente
60
+
61
+ ### Percentage
62
+ Classe che si occupa di rappresentare un numero in percentuale.
63
+ Per maggiori info sulle funzionalità controllare la documentazione sulla classe
64
+
65
+ #### Utilizzo
66
+ p = KonoUtils::Percentage.new(100,20)
67
+ p.percentage -> ritorna il valore percentuale float
68
+ p.to_i -> ritorna percentuale intera con relativi arrotondamenti
69
+ p.to_percentage -> si comporta come l'helper number_to_percentage
70
+
71
+ ### Params Hash Array
72
+
73
+ Si occupa di trasformare un hash con elementi che sono chiramente array in un hash con elementi array:
74
+ ```
75
+ {"DatiOrdineAcquisto"=>{"0"=>{"RiferimentoNumeroLinea"=>{"0"=>""}, "IdDocumento"=>"", "Data"=>"", "NumItem"=>"", "CodiceCommessaConvenzione"=>"", "CodiceCUP"=>"", "CodiceCIG"=>""}}}
76
+ {"DatiOrdineAcquisto"=>[{"RiferimentoNumeroLinea"=>[""], "IdDocumento"=>"", "Data"=>"", "NumItem"=>"", "CodiceCommessaConvenzione"=>"", "CodiceCUP"=>"", "CodiceCIG"=>""}]}
77
+ ```
78
+
79
+ #### Utilizzo
80
+ includere nel controller o dove si vuole utilizzare il concern
81
+ include KonoUtils::ParamsHashArray
82
+
83
+ e richiamare la funzione:
84
+ elaborate_params_to_hash_array(params)
85
+
86
+ ### Virtual Model
87
+ Server per avere un modello virtuale in Rails
88
+
89
+ #### Utilizzo
90
+ Praticamente è come avere un active record ma senza avere una tabella
91
+ ```ruby
92
+
93
+ class Session < KonoUtils::VirtualModel
94
+
95
+ attr_accessor :username, :password, :token
96
+
97
+
98
+ validates :token,:presence=>true
99
+
100
+ end
101
+
102
+ Session.new(:username=>'ciao',:password=>'pippo').valid? => false
103
+
104
+ ```
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kono_utils_helpers"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "kono_utils_helpers/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "kono_utils_helpers"
7
+ spec.version = KonoUtilsHelpers::VERSION
8
+ spec.authors = ["Marino Bonetti"]
9
+ spec.email = ["marinobonetti@gmail.com"]
10
+
11
+ spec.summary = "Gem containing all KonoUtils Helpers external of the core"
12
+ spec.description = %q{Gem containing all KonoUtils Helpers external of the core}
13
+ spec.homepage = "https://github.com/ArchimediaZerogroup/KonoUtilsHelpers"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f)}
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency 'active_type'
24
+ spec.add_dependency 'activesupport', '>= 4.2'
25
+ spec.add_dependency 'actionview'
26
+ spec.add_dependency 'zeitwerk'
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
@@ -0,0 +1,47 @@
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
+ attr_accessor :string
7
+
8
+ ##
9
+ # * *Attributes* :
10
+ # - string -> Stringa da elaborare
11
+ def initialize(string)
12
+ self.string = string
13
+ end
14
+
15
+ ##
16
+ # Funcione di rimozione del carattere BOM http://en.wikipedia.org/wiki/Byte_order_mark
17
+ # e encoding normale
18
+ def remove_bom
19
+ string_encoder.gsub("\xEF\xBB\xBF".force_encoding('UTF-8'), '')
20
+ end
21
+
22
+ ##
23
+ # Funzione di encoding semplice
24
+ def string_encoder
25
+ return string if string.valid_encoding?
26
+ str = string
27
+ Encoding.list.each do |e|
28
+ begin
29
+ str.force_encoding(e.name)
30
+ tmp_string = str.encode('UTF-8')
31
+ return tmp_string if tmp_string.valid_encoding?
32
+ rescue
33
+ Rails.logger.debug { "Rescue -> #{e.name}" } if defined?(::Rails)
34
+ end
35
+ end
36
+
37
+ impossible_encoding
38
+
39
+ string
40
+ end
41
+
42
+ ##
43
+ # Metodo placeholder, volendo si può estendere la funzione e sovrascrivere questa funzione
44
+ # per essere notificati in caso di mancata decodifica
45
+ def impossible_encoding; end
46
+ end
47
+ 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,82 @@
1
+ require 'fileutils'
2
+ require 'tempfile'
3
+ module KonoUtils
4
+ ##
5
+ # Classe Funzionante prettamente con RAILS
6
+ # la classe si occupa dei files temporanei creando una cartella dentro a tmp del progetto
7
+ # crea una cartella random per ogni file per ovviare al problema di duplicazioni dei nomi
8
+ # Estende Tempfile,
9
+ # la root della struttura è quella di Rails.root
10
+ # e di default la classe scrive dentro a tmp
11
+ # non ha bisogno di essere cancellata, ci penserà in automatico la classe una
12
+ # la prossima volta che viene chiamata cancellando tutti i files con un TTL
13
+ # maggiore di 1.day di default
14
+ ## Utilizzo:
15
+ # tmp = Ptmpfile.new('nomefile.ext')
16
+ # tmp.path -> path completa
17
+ # tmp.write.....
18
+ # tmp.original_filename.......
19
+ # tmp.unique_filename.......
20
+ #
21
+ #
22
+ class TmpFile < ::Tempfile
23
+
24
+ PATH = 'tmp/ptmpfile'
25
+ TIME_LIMIT = 1*60*60*24 # 1day
26
+ attr_accessor :root_dir
27
+ attr_accessor :tmp_dir
28
+ attr_accessor :original_filename, :unique_filename
29
+
30
+
31
+ ##
32
+ # Generate a new file with a given name
33
+ #
34
+ # * *Args* :
35
+ # - name -> String of the name file
36
+ # * *Returns* :
37
+ # - Tempfile
38
+ #
39
+ def initialize(name)
40
+ self.original_filename=name
41
+ self.root_dir = controll_root
42
+ clean_tmpdir
43
+ #creo una nuova cartella per il file attuale
44
+ self.tmp_dir= "#{self.root_dir.path}/#{Time.now.to_f}"
45
+ Dir.mkdir(self.tmp_dir)
46
+ ext =File.extname(name)
47
+ name = [File.basename(name), ext] unless ext.blank?
48
+ super(name, self.tmp_dir)
49
+ self.unique_filename= File.basename(self.path)
50
+ end
51
+
52
+
53
+ private
54
+
55
+ ##
56
+ # controll presence of root dir
57
+ # if not exists create it
58
+ # * *Returns* :
59
+ # - Dir
60
+ #
61
+ def controll_root
62
+ unless File.exist?(::Rails.root.join(PATH))
63
+ Dir.mkdir(::Rails.root.join(PATH))
64
+ end
65
+ Dir.open(::Rails.root.join(PATH))
66
+ end
67
+
68
+ ##
69
+ # Clean the directory
70
+ #
71
+ def clean_tmpdir
72
+ self.root_dir.each do |d|
73
+ if d != '..' and d!='.'
74
+ if d.to_i < Time.now.to_i-TIME_LIMIT
75
+ FileUtils.rm_rf(File.join(self.root_dir.path, d))
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_type'
2
+ module KonoUtils
3
+ class VirtualModel < ActiveType::Object
4
+ def self.inherited(*)
5
+ ::ActiveSupport::Deprecation.warn 'KonoUtils::VirtualModel is deprecated! Use ActiveType::Object instead.'
6
+ super
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ require "kono_utils"
2
+
3
+ require "zeitwerk"
4
+ loader = Zeitwerk::Loader.for_gem
5
+ loader.enable_reloading # you need to opt-in before setup
6
+ loader.setup
7
+ module KonoUtilsHelpers
8
+ # Your code goes here...
9
+ end
10
+ loader.eager_load
@@ -0,0 +1,3 @@
1
+ module KonoUtilsHelpers
2
+ VERSION = "0.1.0-rc.1"
3
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kono_utils_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.rc.1
5
+ platform: ruby
6
+ authors:
7
+ - Marino Bonetti
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: active_type
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionview
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: zeitwerk
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description: Gem containing all KonoUtils Helpers external of the core
112
+ email:
113
+ - marinobonetti@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - ".versions.conf"
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - kono_utils_helpers.gemspec
130
+ - lib/kono_utils/encoder.rb
131
+ - lib/kono_utils/fiscal_code.rb
132
+ - lib/kono_utils/params_hash_array.rb
133
+ - lib/kono_utils/percentage.rb
134
+ - lib/kono_utils/tmp_file.rb
135
+ - lib/kono_utils/virtual_model.rb
136
+ - lib/kono_utils_helpers.rb
137
+ - lib/kono_utils_helpers/version.rb
138
+ homepage: https://github.com/ArchimediaZerogroup/KonoUtilsHelpers
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">"
154
+ - !ruby/object:Gem::Version
155
+ version: 1.3.1
156
+ requirements: []
157
+ rubygems_version: 3.0.8
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Gem containing all KonoUtils Helpers external of the core
161
+ test_files: []