italian-ruby 1.0.6 → 1.1.1

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: df61637bb79990e91a2b9ce6e6aaae4f60d1e12fdc929e56d3bd96e3c782ffaf
4
- data.tar.gz: d02455a3b1b8bed2bc1de1e237b08ef99b83e1d2d71cbb5126dc7933d4fd5984
3
+ metadata.gz: 7d68a553838d25e66987fdfe7389fa82cefd6fd1cb4edb8209749113f972e644
4
+ data.tar.gz: ddbfccb52ba45a6f18b7c8d717feb33ed122a033d8989d0b4a9122a8f1cc9100
5
5
  SHA512:
6
- metadata.gz: 3acc5b5df5d64eae58e3df7a9394dec340e0c219bbec197bfb34bd2fa02064689fb35694c1a4e4f5ba6d5acab54185f7f0929206e5ceeff5863f6181deab84af
7
- data.tar.gz: d963ee57535dcdcdd82a76830ad0721f675651c9b3d96fdcb48e5c0dbeade380c1ab2bb2e84377a7ba40c9c2ef21199644216b50159e47801e26320c4451555a
6
+ metadata.gz: bfa8a802086a6b23fc24a29535e1c031771326933618f47e6cc309818759d7fcaaa32bb8ff5acf404f484c52472872d56fb96c4a101e664fe82b80713db96147
7
+ data.tar.gz: 99d9326fcbaca9e9b711af733e828e7697c437506c71f77eb484a9915b75bed47e4563e9ed3685e5c9ff56bfaacbf695f7e1bb24b5ec1142d1d96cb9e83ebd4d
@@ -0,0 +1,14 @@
1
+ require_relative "lib/italian/ruby/versione"
2
+ versione = Italian::Ruby::VERSIONE
3
+
4
+ comandi = [
5
+ "gem uninstall -Ix italian-ruby",
6
+ "rm pkg/*.gem",
7
+ "gem build italian-ruby.gemspec -o pkg/italian-ruby-#{versione}.gem",
8
+ "gem install pkg/italian-ruby-#{versione}.gem",
9
+ ]
10
+
11
+ comandi.each do |comando|
12
+ puts comando
13
+ %x{#{comando}}
14
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "alias/array"
4
+ require_relative "alias/binding"
4
5
  require_relative "alias/class"
5
6
  require_relative "alias/date"
6
7
  require_relative "alias/enumerator"
@@ -19,6 +20,7 @@ require_relative "alias/numeric"
19
20
  require_relative "alias/object"
20
21
  require_relative "alias/open_struct"
21
22
  require_relative "alias/proc"
23
+ require_relative "alias/process"
22
24
  require_relative "alias/range"
23
25
  require_relative "alias/rational"
24
26
  require_relative "alias/regexp"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Binding
4
+
5
+ alias :ricevitore :receiver
6
+ alias :esecutore :receiver
7
+
8
+ end
9
+
10
+ Contesto = Binding
@@ -16,6 +16,7 @@ class Class
16
16
  alias :scrittore :attr_writer
17
17
  alias :definisci_metodo :define_method
18
18
  alias :apri_classe :class_eval
19
+ alias :valuta_in_classe :class_eval
19
20
  alias :moduli_inclusi :included_modules
20
21
 
21
22
  end
@@ -4,6 +4,7 @@ module Kernel
4
4
 
5
5
  alias :classe :class
6
6
  alias :traccia_chiamante :caller_locations
7
+ alias :variabili_istanza :instance_variables
7
8
  alias :ottieni_variabile_istanza :instance_variable_get
8
9
  alias :imposta_variabile_istanza :instance_variable_set
9
10
  alias :rimuovi_variabile_istanza :remove_instance_variable
@@ -10,4 +10,7 @@ alias :blocco_dato? :block_given?
10
10
  alias :cattura :catch
11
11
  alias :lancia :throw
12
12
  alias :carica :load
13
+ alias :nuovo_processo :fork
14
+ alias :biforca :fork
15
+ alias :blocco :proc
13
16
  alias :Mappa :Hash
@@ -4,5 +4,6 @@ class Proc
4
4
 
5
5
  alias :avvia :call
6
6
  alias :chiama :call
7
+ alias :contesto :binding
7
8
 
8
9
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Process
4
+
5
+ class << self
6
+ alias :attendi :wait
7
+ alias :attendi_tutti :waitall
8
+ alias :segnala :kill
9
+ end
10
+
11
+ end
12
+
13
+ Processo = Process
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "metodi/array"
4
4
  require_relative "metodi/date"
5
+ require_relative "metodi/false_class"
5
6
  require_relative "metodi/hash"
6
7
  require_relative "metodi/integer"
7
8
  require_relative "metodi/json"
@@ -9,9 +10,12 @@ require_relative "metodi/kernel"
9
10
  require_relative "metodi/main"
10
11
  require_relative "metodi/module"
11
12
  require_relative "metodi/nil_class"
13
+ require_relative "metodi/numeric"
12
14
  require_relative "metodi/object"
13
15
  require_relative "metodi/open_struct"
14
16
  require_relative "metodi/range"
15
17
  require_relative "metodi/socket"
16
18
  require_relative "metodi/string"
19
+ require_relative "metodi/symbol"
17
20
  require_relative "metodi/time"
21
+ require_relative "metodi/true_class"
@@ -14,6 +14,22 @@ class Array
14
14
  !include? *args
15
15
  end
16
16
 
17
+ ##
18
+ # Esegue i metodi specificati per ogni elemento della lista.
19
+ def campiona(*method_names)
20
+ self.map do |element|
21
+ method_names.map do |method_name|
22
+ if element.respond_to? method_name
23
+ element.send method_name
24
+ elsif element.is_a? Hash
25
+ element[method_name]
26
+ else
27
+ raise ArgumentError, "Array elements do not respond to #{method_name}."
28
+ end
29
+ end
30
+ end
31
+ end
32
+
17
33
  ##
18
34
  # Esegue il metodo specificato con gli argomenti specificati
19
35
  # per ogni elemento della lista.
@@ -102,4 +118,18 @@ class Array
102
118
  self.drop 1
103
119
  end
104
120
 
121
+ ##
122
+ # Rappresentazione per stampa.
123
+ def _stampa(i = 0)
124
+ return "[]" if empty?
125
+ spazi = i.times.map { " " }.join
126
+ spazi_valori = (i + 2).times.map { " " }.join
127
+ [ "[",
128
+ *self.map do |e|
129
+ "#{spazi_valori}#{e._stampa(i + 2)},"
130
+ end,
131
+ "#{spazi}]"
132
+ ].join("\r\n")
133
+ end
134
+
105
135
  end
@@ -43,4 +43,10 @@ class Date
43
43
  .gsub(/December/i, "Dicembre")
44
44
  end
45
45
 
46
+ ##
47
+ # Rappresentazione per stampa.
48
+ def _stampa(*args)
49
+ formatta("%d %B %Y").arancione
50
+ end
51
+
46
52
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FalseClass
4
+
5
+ ##
6
+ # Rappresentazione per stampa.
7
+ def _stampa(*args)
8
+ "no".rosso
9
+ end
10
+
11
+ end
@@ -54,4 +54,52 @@ class Hash
54
54
  self.select { |key, value| key.in? keys }
55
55
  end
56
56
 
57
+ ##
58
+ # Ritorna una rappresentazione a singolo livello, con notazione ".".
59
+ def puntifica(*prefissi)
60
+ mappa_puntificata = {}
61
+
62
+ self.each do |chiave, valore|
63
+ case valore
64
+ when Hash
65
+ valore.puntifica *prefissi, chiave do |chiave_prefissa, valore_finale|
66
+ if block_given?
67
+ yield chiave_prefissa, valore_finale
68
+ else
69
+ mappa_puntificata.store chiave_prefissa, valore_finale
70
+ end
71
+ end
72
+ else
73
+ prefisso = [ *prefissi, chiave ].unisci "."
74
+ if block_given?
75
+ yield prefisso, valore
76
+ else
77
+ mappa_puntificata.store prefisso, valore
78
+ end
79
+ end
80
+ end
81
+
82
+ mappa_puntificata
83
+ end
84
+
85
+ ##
86
+ # Rappresentazione per stampa.
87
+ def _stampa(i = 0)
88
+ return "{}" if empty?
89
+ spazi = i.times.map { " " }.join
90
+ spazi_chiavi = (i + 2).times.map { " " }.join
91
+ [ "{",
92
+ *self.map do |k, v|
93
+ if k.is_a? Symbol
94
+ "#{spazi_chiavi}#{k}: #{v._stampa(i + 2)},"
95
+ elsif k.is_a? String
96
+ "#{spazi_chiavi}\"#{k}\" => #{v._stampa(i + 2)},"
97
+ else
98
+ "#{spazi_chiavi}#{k._stampa(i + 2)} => #{v._stampa(i + 2)},"
99
+ end
100
+ end,
101
+ "#{spazi}}"
102
+ ].join("\r\n")
103
+ end
104
+
57
105
  end
@@ -29,3 +29,9 @@ end
29
29
  def fallisci(*args)
30
30
  fail *args
31
31
  end
32
+
33
+ ##
34
+ # Definisce un metodo mancante.
35
+ def metodo_mancante(nome, *args, &block)
36
+ method_missing nome, *args, &block
37
+ end
@@ -8,4 +8,10 @@ class NilClass
8
8
  !nil?
9
9
  end
10
10
 
11
+ ##
12
+ # Rappresentazione per stampa.
13
+ def _stampa(*args)
14
+ "nullo".azzurro
15
+ end
16
+
11
17
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Numeric
4
+
5
+ ##
6
+ # Rappresentazione per stampa.
7
+ def _stampa(*args)
8
+ self.to_s.verde
9
+ end
10
+
11
+ end
@@ -53,6 +53,12 @@ class Object
53
53
  to_json
54
54
  end
55
55
 
56
+ ##
57
+ # Rappresentazione per stampa.
58
+ def _stampa(*args)
59
+ inspect
60
+ end
61
+
56
62
  private
57
63
 
58
64
  ##
@@ -5,13 +5,14 @@ class String
5
5
  ##
6
6
  # Codici colori.
7
7
  CODICI_COLORI = Hash[
8
- rosso: "31",
9
- verde: "32",
10
- giallo: "33",
11
- blu: "34",
12
- magenta: "35",
13
- azzurro: "36",
14
- arancione: "38;5;214"
8
+ rosso: "31",
9
+ verde: "32",
10
+ giallo: "33",
11
+ blu: "34",
12
+ magenta: "35",
13
+ azzurro: "36",
14
+ arancione: "38;5;214",
15
+ verde_pallido: "38;5;157"
15
16
  ].freeze
16
17
 
17
18
  ##
@@ -53,18 +54,21 @@ class String
53
54
  colorize CODICI_COLORI[:arancione]
54
55
  end
55
56
 
57
+ def verde_pallido
58
+ colorize CODICI_COLORI[:verde_pallido]
59
+ end
60
+
56
61
  def decolorizza
57
62
  self.gsub /(\u001b\[3\dm|\u001b\[3\d;\d;\d\d\dm|\u001b\[0m)/, ""
58
63
  end
59
64
 
60
65
  def disaccoppia_colore
61
- indice_inizio_colore = self.index "m"
62
- codice_colore = self[2..indice_inizio_colore - 1]
63
-
64
- porzione_decolorizzata = self[indice_inizio_colore + 1..-5]
66
+ return [ nil, self ] if self.decolorizza == self
67
+ parte_colore = self.scansiona /\u001b\[3[\d;]+m/
68
+ codice_colore = parte_colore.prima[2..-2]
65
69
  colore = CODICI_COLORI.invert.fetch codice_colore
66
70
 
67
- [ colore, porzione_decolorizzata ]
71
+ [ colore, self.decolorizza ]
68
72
  end
69
73
 
70
74
  ##
@@ -171,4 +175,10 @@ class String
171
175
  self.length - 1
172
176
  end
173
177
 
178
+ ##
179
+ # Rappresentazione per stampa.
180
+ def _stampa(*args)
181
+ %{"#{self}"}.giallo
182
+ end
183
+
174
184
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Symbol
4
+
5
+ ##
6
+ # Rappresentazione per stampa.
7
+ def _stampa(*args)
8
+ ":#{self}".blu
9
+ end
10
+
11
+ end
@@ -48,4 +48,10 @@ class Time
48
48
  Time.new(self.year, self.month, self.day, self.hour, self.min, 59)
49
49
  end
50
50
 
51
+ ##
52
+ # Rappresentazione per stampa.
53
+ def _stampa(*args)
54
+ "#{in_data.formatta "%d %B %Y"} #{strftime "%H:%M:%S %z"}".arancione
55
+ end
56
+
51
57
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TrueClass
4
+
5
+ ##
6
+ # Rappresentazione per stampa.
7
+ def _stampa(*args)
8
+ "si".verde
9
+ end
10
+
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Italian
2
2
  module Ruby
3
- VERSIONE = "1.0.6"
3
+ VERSIONE = "1.1.1"
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.0.6
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Ballardin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-25 00:00:00.000000000 Z
11
+ date: 2020-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,10 +73,12 @@ files:
73
73
  - dev/vim/syntax/ir.vim
74
74
  - dev/vim/vimrc
75
75
  - dev/vscode/italianruby.tmGrammar.json
76
+ - install.rb
76
77
  - italian-ruby.gemspec
77
78
  - lib/italian/ruby.rb
78
79
  - lib/italian/ruby/alias.rb
79
80
  - lib/italian/ruby/alias/array.rb
81
+ - lib/italian/ruby/alias/binding.rb
80
82
  - lib/italian/ruby/alias/class.rb
81
83
  - lib/italian/ruby/alias/date.rb
82
84
  - lib/italian/ruby/alias/enumerator.rb
@@ -95,6 +97,7 @@ files:
95
97
  - lib/italian/ruby/alias/object.rb
96
98
  - lib/italian/ruby/alias/open_struct.rb
97
99
  - lib/italian/ruby/alias/proc.rb
100
+ - lib/italian/ruby/alias/process.rb
98
101
  - lib/italian/ruby/alias/range.rb
99
102
  - lib/italian/ruby/alias/rational.rb
100
103
  - lib/italian/ruby/alias/regexp.rb
@@ -109,6 +112,7 @@ files:
109
112
  - lib/italian/ruby/metodi.rb
110
113
  - lib/italian/ruby/metodi/array.rb
111
114
  - lib/italian/ruby/metodi/date.rb
115
+ - lib/italian/ruby/metodi/false_class.rb
112
116
  - lib/italian/ruby/metodi/hash.rb
113
117
  - lib/italian/ruby/metodi/integer.rb
114
118
  - lib/italian/ruby/metodi/json.rb
@@ -116,13 +120,16 @@ files:
116
120
  - lib/italian/ruby/metodi/main.rb
117
121
  - lib/italian/ruby/metodi/module.rb
118
122
  - lib/italian/ruby/metodi/nil_class.rb
123
+ - lib/italian/ruby/metodi/numeric.rb
119
124
  - lib/italian/ruby/metodi/object.rb
120
125
  - lib/italian/ruby/metodi/open_struct.rb
121
126
  - lib/italian/ruby/metodi/range.rb
122
127
  - lib/italian/ruby/metodi/rspec.rb
123
128
  - lib/italian/ruby/metodi/socket.rb
124
129
  - lib/italian/ruby/metodi/string.rb
130
+ - lib/italian/ruby/metodi/symbol.rb
125
131
  - lib/italian/ruby/metodi/time.rb
132
+ - lib/italian/ruby/metodi/true_class.rb
126
133
  - lib/italian/ruby/traduttore.rb
127
134
  - lib/italian/ruby/traduttore/linea.rb
128
135
  - lib/italian/ruby/traduttore/pezzo.rb