italian-ruby 0.7.2 → 0.7.7

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: b589fd000be0d0e27a8e4bb9fa847d771d8f0b2ae0dbab458d8c526c3b13070e
4
- data.tar.gz: 6cf44046cd2838b05d47e59250b25510f9529150f233ef69527a4d4661d10090
3
+ metadata.gz: 8b310c7d130d7ad5995a56a634e32a0feb1c3643e8d1a64e04b890a3208ffe45
4
+ data.tar.gz: 67d00de81602c11d24bff7f99d900e39adf1635d140dc8ced8bdc52d4c63bd61
5
5
  SHA512:
6
- metadata.gz: 4d6ef447970787404649ac1935504df3c1a0b2820cd8a5275053db0ceba429acbd8d5a51491147bc7911351ab0d371894e147abcbed23b385c278911c8dfd949
7
- data.tar.gz: ba46632ff6d881d95bbf8ddee8b7034273b110c86798da70e5cd51b3ed2a546fe099f980acc2bffb38f64eac2f9ded0e29cb85b0c233b08646b9e5c7711c42f0
6
+ metadata.gz: 6b59e75386751558d5f3bb667c8c8beca1a99fe218a394ffd67ed5e5f99d6163587cfb11cbef54607bad1767e92b7c1337ffea1f04e3beaa2dc28ce0b4cc2ba2
7
+ data.tar.gz: a7e73748bc86a2ebf33d8359faef4a47275715c2b5a9798751ff658710c4d0ff066d93b07bcbe02fe75505625c0b8befe406f5ad94b9cd5096515778ed69bbbb
@@ -11,6 +11,8 @@ require_relative "core_ext/kernel"
11
11
  require_relative "core_ext/proc"
12
12
  require_relative "core_ext/errors"
13
13
  require_relative "core_ext/nil_class"
14
+ require_relative "core_ext/false_class"
15
+ require_relative "core_ext/true_class"
14
16
  require_relative "core_ext/json"
15
17
  require_relative "core_ext/object"
16
18
  require_relative "core_ext/array"
@@ -0,0 +1,6 @@
1
+ ##
2
+ # Core Ext - False Class
3
+
4
+ class FalseClass
5
+ alias :in_stringa :to_s
6
+ end
@@ -5,6 +5,7 @@
5
5
 
6
6
  class File
7
7
  class << self
8
+ alias :espandi :expand_path
8
9
  alias :nome_file :basename
9
10
  alias :nome_cartella :dirname
10
11
  alias :esiste? :exists?
@@ -14,4 +15,9 @@ class File
14
15
 
15
16
  alias :scrivi :write
16
17
  alias :stampa :puts
18
+
19
+ def self.percorso_non_tradotto(path)
20
+ return path unless path.respond_to? :gsub
21
+ path.gsub("/Users/fballardin/.italian-ruby/translations", "")
22
+ end
17
23
  end
@@ -6,6 +6,10 @@ module BSON
6
6
 
7
7
  alias :in_stringa :to_s
8
8
 
9
+ def in_id
10
+ self
11
+ end
12
+
9
13
  def to_json(*args)
10
14
  "\"#{self.to_s}\""
11
15
  end
@@ -13,7 +13,6 @@ class Hash
13
13
  alias :vuoto? :empty?
14
14
  alias :vuota? :empty?
15
15
  alias :ha_chiave? :has_key?
16
- alias :ottieni :fetch
17
16
  alias :prendi :fetch
18
17
  alias :deposita :store
19
18
  alias :scava :dig
@@ -17,7 +17,12 @@ module Kernel
17
17
  file_to_require = $:.map { |dir| Dir["#{dir}/**/#{name}.ir"] }.flatten.compact.first
18
18
 
19
19
  if file_to_require.nil?
20
- require name
20
+ begin
21
+ require name
22
+ rescue SyntaxError => errore
23
+ riga = errore.message.split("\n").first.split(":")[1].to_i rescue 0
24
+ Italian::Ruby::Errore::Sintassi.new("Errore di sintassi.", name, riga, 0).stampa
25
+ end
21
26
  else
22
27
  traduci_e_carica file_to_require
23
28
  end
@@ -72,10 +77,12 @@ module Kernel
72
77
  end
73
78
 
74
79
  File.write parsed_file, parsed_code
75
- require parsed_file
76
- # require_output = require tmp_parsed_file
77
- # File.delete tmp_parsed_file if File.exist? tmp_parsed_file
78
- #require_output
80
+ begin
81
+ require parsed_file
82
+ rescue SyntaxError => errore
83
+ riga = errore.message.split("\n").first.split(":")[1].to_i rescue 0
84
+ Italian::Ruby::Errore::Sintassi.new("Errore di sintassi.", parsed_file, riga, 0).stampa
85
+ end
79
86
  end
80
87
 
81
88
  end
@@ -0,0 +1,6 @@
1
+ ##
2
+ # Core Ext - True Class
3
+
4
+ class TrueClass
5
+ alias :in_stringa :to_s
6
+ end
@@ -0,0 +1,52 @@
1
+ require_relative "utils/debug"
2
+
3
+ module Italian
4
+ module Ruby
5
+ class Errore < StandardError
6
+ class Sintassi < Errore; end
7
+ class NonSupportato < Errore; end
8
+ class IndividuazioneStringa < Errore; end
9
+
10
+ def initialize(messaggio = nil, file = nil, riga = 0, posizione = 0)
11
+ @messaggio = messaggio
12
+ @file = file
13
+ @riga = riga
14
+ @posizione = posizione
15
+ begin
16
+ @linea = File.readlines(@file)[@riga - 1]
17
+ rescue StandardError => e
18
+ @linea = "Non è stato possibile recuperare la riga #{@riga} del file."
19
+ end
20
+ end
21
+
22
+ def stampa
23
+ prova_ad_ottenere_maggiori_informazioni
24
+ puts "-----------------------------------------------------------------------------".alzavola
25
+ puts "Si è verificato un errore durante la traduzione del file `#{@file}`."
26
+ print "L'errore è: "
27
+ puts "#{self.class}.".rosso
28
+ puts @messaggio
29
+ puts
30
+ print "Riga: "
31
+ puts "#{@riga}".ciano
32
+ puts @linea
33
+ puts "^".rjust(@posizione + 1, " ").verde_lime
34
+ puts
35
+ puts "-----------------------------------------------------------------------------".alzavola
36
+ exit 1
37
+ end
38
+
39
+ private
40
+
41
+ ##
42
+ # Prova a recuperare maggiori informazioni su errore.
43
+ def prova_ad_ottenere_maggiori_informazioni
44
+ case
45
+ when self.class.is_a?(Sintassi)
46
+ # TO DO
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require "rainbow"
3
3
  require_relative "utils/debug"
4
+ require_relative "errore"
4
5
 
5
6
  module Italian
6
7
  module Ruby
@@ -8,43 +9,22 @@ module Italian
8
9
 
9
10
  STAMPA_DETTAGLI_TRADUZIONE = false
10
11
 
11
- class Errore < StandardError
12
- attr_accessor :messaggio, :file, :linea, :riga, :posizione
13
-
14
- def initialize(messaggio: nil, file: nil, linea: nil, riga: 0, posizione: 0)
15
- @messaggio = messaggio
16
- @file = file
17
- @linea = linea
18
- @riga = riga
19
- @posizione = posizione
20
- end
21
-
22
- class NonSupportato < Errore; end
23
- class IndividuazioneStringa < Errore; end
24
- end
25
-
26
12
  class << self
27
13
 
28
- def traduci(file)
29
- begin
14
+ def traduci(file = nil, &block)
15
+ if not file.nil?
30
16
  codice_tradotto = File.readlines(file).map.with_index do |linea, riga|
31
17
  traduci_linea file, linea, riga
32
18
  end
33
19
  codice_tradotto.join
34
- rescue Italian::Ruby::Traduttore::Errore => errore
35
- puts "-----------------------------------------------------------------------------".alzavola
36
- puts "Si è verificato un errore durante la traduzione del file `#{errore.file}`."
37
- print "L'errore è: "
38
- puts "#{errore.classe}.".rosso
39
- puts errore.messaggio
40
- puts
41
- print "Riga: "
42
- puts "#{errore.riga}".ciano
43
- puts errore.linea
44
- puts "^".rjust(errore.posizione + 1, " ").verde_lime
45
- puts
46
- puts "-----------------------------------------------------------------------------".alzavola
47
- exit 1
20
+ else
21
+ if block_given?
22
+ begin
23
+ block.call
24
+ rescue StandardError => errore
25
+ Italian::Ruby::Errore.new([ errore.message, errore.backtrace ].join("\n"), "-", 0, 0).stampa
26
+ end
27
+ end
48
28
  end
49
29
  end
50
30
 
@@ -85,13 +65,11 @@ module Italian
85
65
 
86
66
  private
87
67
 
88
- def errore!(classe, messaggio, file, linea, riga, posizione)
89
- raise classe.new(messaggio: messaggio, file: file, linea: linea, riga: riga, posizione: posizione)
90
- end
91
-
92
68
  def controlla_stringa_singola(file, linea, riga, posizione_commento, posizione_stringa_singola, posizione_stringa_doppia)
93
69
  if posizione_stringa_singola < posizione_commento and posizione_stringa_singola < posizione_stringa_doppia
94
- errore! Errore::NonSupportato, "Le stringhe con singolo apice non sono supportate.", file, linea, riga, posizione_stringa_singola
70
+ Italian::Ruby::Errore::NonSupportato.new(
71
+ "Le stringhe con singolo apice non sono supportate.",
72
+ file, riga, posizione_stringa_singola).stampa
95
73
  end
96
74
  end
97
75
 
@@ -100,7 +78,9 @@ module Italian
100
78
 
101
79
  prossima_posizione_stringa_doppia = linea[posizione_stringa_doppia + 1..].index %{"}
102
80
  if prossima_posizione_stringa_doppia.nil?
103
- errore! Errore::IndividuazioneStringa, "Non è stato possibile trovare la terminazione della stringa.", file, linea, riga, posizione_stringa_doppia
81
+ Italian::Ruby::Errore::IndividuazioneStringa.new(
82
+ "Non è stato possibile trovare la terminazione della stringa.",
83
+ file, riga, posizione_stringa_doppia).stampa
104
84
  end
105
85
  end
106
86
 
@@ -1,5 +1,5 @@
1
1
  module Italian
2
2
  module Ruby
3
- VERSION = "0.7.2"
3
+ VERSION = "0.7.7"
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: 0.7.2
4
+ version: 0.7.7
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-05-21 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - lib/italian/ruby/core_ext/date.rb
79
79
  - lib/italian/ruby/core_ext/enumerator.rb
80
80
  - lib/italian/ruby/core_ext/errors.rb
81
+ - lib/italian/ruby/core_ext/false_class.rb
81
82
  - lib/italian/ruby/core_ext/file.rb
82
83
  - lib/italian/ruby/core_ext/float.rb
83
84
  - lib/italian/ruby/core_ext/gems/bson.rb
@@ -99,6 +100,8 @@ files:
99
100
  - lib/italian/ruby/core_ext/string.rb
100
101
  - lib/italian/ruby/core_ext/symbol.rb
101
102
  - lib/italian/ruby/core_ext/time.rb
103
+ - lib/italian/ruby/core_ext/true_class.rb
104
+ - lib/italian/ruby/errore.rb
102
105
  - lib/italian/ruby/traduttore.rb
103
106
  - lib/italian/ruby/utils/debug.rb
104
107
  - lib/italian/ruby/version.rb