italian-ruby 1.2.7 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc1ddca741526dbf25e8befc266aeeabf579ddc3b2c4fbb258230f717d5fdc8b
4
- data.tar.gz: a549443641fbcc4687b346b98e117feed2b8c808c0141b8c7ec6c1076cea8afe
3
+ metadata.gz: 2f6505ead6d72fed78f1d4d7c48534491a91a0e536dc7faae5dc804604b9572f
4
+ data.tar.gz: a770607fc0744fc593604b33bc4c31431e44aafaf4be80717eea1ad4779e08a1
5
5
  SHA512:
6
- metadata.gz: 0cb851f9a7c77448ccf4288804336b2eba80c7cf3ec43ce8db57956a2ac3205c1cf02667d70f12e824305ad6b49daac5e9bb6855b32c2971b5ed8ae0eebdd459
7
- data.tar.gz: b2c0e8b598bf18873e55ba87c5193f25569aecf49418e948420df2f4bd12ff17885daef212044b066eca9f75c4c3ea85814e73d587c2df8486c0ba33dca0bab0
6
+ metadata.gz: '03193021e1d62380c0a9b73e9a9c6a2a66963fe207a43ca312fe3598b1e7e7df8d6cde855c8c9724d5d5aaf8b1e633b9eed7f0e662a002e98a63264842f0de4f'
7
+ data.tar.gz: 691daf3b737720b0e206acb33ecf71a28aaa9c13a322948cbb0b8550d87281044cfdc34c78d65c94620c6ea3bbab2f8eca77a0a90b71e4ec1728edaff5919bda
@@ -7,6 +7,7 @@ class Array
7
7
  alias :per_ognuno :each
8
8
  alias :per_ognuna :each
9
9
  alias :in_fette_da :each_slice
10
+ alias :in_gruppi_da :each_slice
10
11
  alias :mappa :map
11
12
  alias :mappa! :map!
12
13
  alias :vuoto? :empty?
@@ -3,6 +3,11 @@
3
3
  class Enumerator
4
4
 
5
5
  alias :mappa :map
6
+ alias :per_ognuno :each
7
+ alias :per_ognuna :each
8
+ alias :lista :to_a
9
+ alias :in_lista :to_a
10
+ alias :in_liste :to_a
6
11
  alias :con_indice :with_index
7
12
 
8
13
  end
@@ -25,6 +25,23 @@ class Date
25
25
  end
26
26
 
27
27
  ##
28
+ # Restituisce la data di inizio anno.
29
+ def inizio_anno
30
+ Date.new self.year, 1, 1
31
+ end
32
+
33
+ ##
34
+ # Restituisce la data di fine anno.
35
+ def fine_anno
36
+ Date.new self.year, 12, 31
37
+ end
38
+
39
+ ##
40
+ # Restituisce il tempo all'ora specificata.
41
+ def alle(ore, minuti = 0, secondi = 0)
42
+ self.in_tempo.alle ore, minuti, secondi
43
+ end
44
+
28
45
  # Formatta la data secondo la rappresentazione passata.
29
46
  def formatta_locale(format)
30
47
  formattazione = strftime format
@@ -38,12 +38,8 @@ module Kernel
38
38
  ##
39
39
  # Richiede un archivio cercandolo come percorso relativo.
40
40
  def richiedi_relativo(percorso_archivio)
41
- sorgente_chiamante = Italian::Ruby.percorso_archivio_non_tradotto caller_locations.first.absolute_path
42
- linea_chiamante = caller_locations.first.lineno
43
- cartella_chiamante = File.dirname sorgente_chiamante
44
- archivio_da_richiedere = File.expand_path File.join(cartella_chiamante, percorso_archivio)
45
- archivio_da_richiedere = Dir["#{archivio_da_richiedere}.{ir,rb}"].compact.first
46
-
41
+ sorgente_chiamante, linea_chiamante = ottieni_sorgente_e_linea_chiamante caller_locations
42
+ archivio_da_richiedere = archivio_relativo sorgente_chiamante, percorso_archivio
47
43
  raise LoadError, "cannot load such file -- #{percorso_archivio}" if archivio_da_richiedere.nil?
48
44
  traduci_e_richiedi archivio_da_richiedere
49
45
  rescue LoadError => errore
@@ -53,12 +49,8 @@ module Kernel
53
49
  ##
54
50
  # Richiede tutti gli archivi di una cartella.
55
51
  def richiedi_tutti(percorso_cartella)
56
- sorgente_chiamante = Italian::Ruby.percorso_archivio_non_tradotto caller_locations.first.absolute_path
57
- linea_chiamante = caller_locations.first.lineno
58
- cartella_chiamante = File.dirname sorgente_chiamante
59
- cartella_da_richiedere = File.expand_path File.join(cartella_chiamante, percorso_cartella)
60
- cartella_da_richiedere = nil unless Dir.exist? cartella_da_richiedere
61
-
52
+ sorgente_chiamante, linea_chiamante = ottieni_sorgente_e_linea_chiamante caller_locations
53
+ cartella_da_richiedere = cartella_relativa sorgente_chiamante, percorso_cartella
62
54
  raise LoadError, "cannot load such directory -- #{percorso_cartella}" if cartella_da_richiedere.nil?
63
55
  Dir["#{cartella_da_richiedere}/**/*.ir"].sort_by { |file| file.count("/") }.each do |archivio|
64
56
  traduci_e_richiedi archivio
@@ -67,20 +59,75 @@ module Kernel
67
59
  Italian::Ruby::Errori.recupera errore, sorgente_chiamante, linea_chiamante
68
60
  end
69
61
 
62
+ ##
63
+ # Rimanda la costante alla definizione in archivio. La prima volta che viene
64
+ # incontrata la definizione della costante nel codice, allora l'archivio
65
+ # verrà richiesto.
66
+ def rimanda(costante, archivio)
67
+ archivi_in_memoria = $:.map do |cartella|
68
+ Dir["#{cartella}/**/#{archivio}.ir"]
69
+ end
70
+ archivio_da_tradurre = archivi_in_memoria.flatten.compact.first
71
+ archivio_da_richiedere = Italian::Ruby.percorso_archivio_tradotto archivio_in_italiano_da_tradurre
72
+ traduci archivio_da_tradurre
73
+ Object.autoload costante, archivio_da_richiedere
74
+ end
75
+
76
+ ##
77
+ # Come il rimanda, ma usando un percorso relativo.
78
+ def rimanda_relativo(costante, percorso_archivio)
79
+ sorgente_chiamante, linea_chiamante = ottieni_sorgente_e_linea_chiamante caller_locations
80
+ archivio_da_tradurre = archivio_relativo sorgente_chiamante, percorso_archivio
81
+ archivio_da_richiedere = Italian::Ruby.percorso_archivio_tradotto archivio_da_tradurre
82
+ traduci archivio_da_tradurre
83
+ Object.autoload costante, archivio_da_richiedere
84
+ end
85
+
70
86
  private
71
87
 
88
+ ##
89
+ # Traduce un file da ItalianRuby a Ruby.
90
+ def traduci(archivio)
91
+ Italian::Ruby::Traduttore.traduci archivio
92
+ end
93
+
72
94
  ##
73
95
  # Traduce un file da ItalianRuby a Ruby e lo carica in memoria.
74
96
  def traduci_e_carica(archivio)
75
- archivio_tradotto = Italian::Ruby::Traduttore.traduci archivio
76
- load archivio_tradotto
97
+ load traduci(archivio)
77
98
  end
78
99
 
79
100
  ##
80
101
  # Traduce un file da ItalianRuby a Ruby e lo richiede.
81
102
  def traduci_e_richiedi(archivio)
82
- archivio_tradotto = Italian::Ruby::Traduttore.traduci archivio
83
- require archivio_tradotto
103
+ require traduci(archivio)
104
+ end
105
+
106
+ ##
107
+ # Ottiene sorgente e linea chiamante.
108
+ def ottieni_sorgente_e_linea_chiamante(traccia_chiamata)
109
+ sorgente_chiamante = Italian::Ruby.percorso_archivio_non_tradotto traccia_chiamata.first.absolute_path
110
+ linea_chiamante = traccia_chiamata.first.lineno
111
+
112
+ [ sorgente_chiamante, linea_chiamante ]
113
+ end
114
+
115
+ ##
116
+ # Ottiene il percorso archivio relativo del sorgente chiamante.
117
+ def archivio_relativo(sorgente_chiamante, percorso_archivio)
118
+ cartella_chiamante = File.dirname sorgente_chiamante
119
+ archivio_da_richiedere = File.expand_path File.join(cartella_chiamante, percorso_archivio)
120
+ archivio_da_richiedere = Dir["#{archivio_da_richiedere}.{ir,rb}"].compact.first
121
+ archivio_da_richiedere
122
+ end
123
+
124
+ ##
125
+ # Ottiene il percorso cartella relativo del sorgente chiamante.
126
+ def cartella_relativa(sorgente_chiamante, percorso_cartella)
127
+ cartella_chiamante = File.dirname sorgente_chiamante
128
+ cartella_da_richiedere = File.expand_path File.join(cartella_chiamante, percorso_cartella)
129
+ cartella_da_richiedere = nil unless Dir.exist? cartella_da_richiedere
130
+ cartella_da_richiedere
84
131
  end
85
132
 
86
133
  end
@@ -14,4 +14,11 @@ class Set
14
14
  self
15
15
  end
16
16
 
17
+ ##
18
+ # Converte l'insieme in una mappa.
19
+ def in_mappa(&block)
20
+ return self.map(&block).to_h if block_given?
21
+ raise ArgumentError, "must pass a block in order to convert a Set into a Hash"
22
+ end
23
+
17
24
  end
@@ -24,6 +24,24 @@ class Time
24
24
  end
25
25
  end
26
26
 
27
+ ##
28
+ # Sposta il tempo alle ore specificate.
29
+ def alle(ore, minuti = 0, secondi = 0)
30
+ Time.new(self.year, self.month, self.day, ore, minuti, secondi)
31
+ end
32
+
33
+ ##
34
+ # Ritorna il tempo all'inizio del giorno.
35
+ def inizio_giorno
36
+ Time.new(self.year, self.month, self.day)
37
+ end
38
+
39
+ ##
40
+ # Ritorna il tempo alla fine del giorno.
41
+ def fine_giorno
42
+ Time.new(self.year, self.month, self.day, 23, 59, 59)
43
+ end
44
+
27
45
  ##
28
46
  # Ritorna il tempo all'inizio dell'ora.
29
47
  def inizio_ora
@@ -1,5 +1,5 @@
1
1
  module Italian
2
2
  module Ruby
3
- VERSIONE = "1.2.7"
3
+ VERSIONE = "1.3.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: italian-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Ballardin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler