italian-ruby 0.7.7 → 0.8.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 +4 -4
- data/lib/italian/ruby/core_ext.rb +1 -0
- data/lib/italian/ruby/core_ext/date.rb +1 -0
- data/lib/italian/ruby/core_ext/file.rb +3 -2
- data/lib/italian/ruby/core_ext/json.rb +3 -0
- data/lib/italian/ruby/core_ext/kernel.rb +34 -13
- data/lib/italian/ruby/core_ext/open_struct.rb +21 -0
- data/lib/italian/ruby/core_ext/time.rb +1 -0
- data/lib/italian/ruby/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c113ca549c5124f156e161c4ee009384ee9f224d71bb7fada1213a5ac701202
|
4
|
+
data.tar.gz: 7f7de77cf3daf442f3562e3a138e13a156ef8c8c7727d41d84a58a084c7b59ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94b6f13346394792a3117ad0a65b1d591360b80ab52d39f7e637d47618f1f1c4fad60a2994df16b6ac1e5e9524c776df9ae08758e31a101c368a359383b110d0
|
7
|
+
data.tar.gz: 404683834d956fbfb04f22d65379761be1c5f5bb68f6605377b72b8fd890bdb2e6025de80e717ee5ef31729c80f75fee46bb460ca42b3de8178f4f285cd91045
|
@@ -14,6 +14,7 @@ require_relative "core_ext/nil_class"
|
|
14
14
|
require_relative "core_ext/false_class"
|
15
15
|
require_relative "core_ext/true_class"
|
16
16
|
require_relative "core_ext/json"
|
17
|
+
require_relative "core_ext/open_struct"
|
17
18
|
require_relative "core_ext/object"
|
18
19
|
require_relative "core_ext/array"
|
19
20
|
require_relative "core_ext/range"
|
@@ -10,6 +10,7 @@ class File
|
|
10
10
|
alias :nome_cartella :dirname
|
11
11
|
alias :esiste? :exists?
|
12
12
|
alias :scrivi :write
|
13
|
+
alias :leggi :read
|
13
14
|
alias :apri :open
|
14
15
|
end
|
15
16
|
|
@@ -17,7 +18,7 @@ class File
|
|
17
18
|
alias :stampa :puts
|
18
19
|
|
19
20
|
def self.percorso_non_tradotto(path)
|
20
|
-
return path unless path.respond_to? :
|
21
|
-
path.
|
21
|
+
return path unless path.respond_to? :partition
|
22
|
+
path.partition(".italian-ruby/translations").last
|
22
23
|
end
|
23
24
|
end
|
@@ -13,8 +13,12 @@ module Kernel
|
|
13
13
|
alias :ottieni_variabile_istanza :instance_variable_get
|
14
14
|
alias :imposta_variabile_istanza :instance_variable_set
|
15
15
|
|
16
|
+
def carica(name)
|
17
|
+
traduci_e_carica File.expand_path(name)
|
18
|
+
end
|
19
|
+
|
16
20
|
def richiedi(name)
|
17
|
-
file_to_require = $:.map { |dir|
|
21
|
+
file_to_require = $:.map { |dir| Dir["#{dir}/**/#{name}.ir"] }.flatten.compact.first
|
18
22
|
|
19
23
|
if file_to_require.nil?
|
20
24
|
begin
|
@@ -24,7 +28,7 @@ module Kernel
|
|
24
28
|
Italian::Ruby::Errore::Sintassi.new("Errore di sintassi.", name, riga, 0).stampa
|
25
29
|
end
|
26
30
|
else
|
27
|
-
|
31
|
+
traduci_e_richiedi file_to_require
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
@@ -39,12 +43,12 @@ module Kernel
|
|
39
43
|
file_to_require = Dir["#{caller_location_file}.{ir,rb}"].compact.first
|
40
44
|
raise LoadError.new("cannot load such file -- #{name}") unless File.exist? file_to_require
|
41
45
|
|
42
|
-
|
46
|
+
traduci_e_richiedi file_to_require
|
43
47
|
end
|
44
48
|
|
45
49
|
def richiedi_assoluto(file)
|
46
50
|
raise LoadError.new("cannot load such file -- #{file}") unless File.exist? file
|
47
|
-
|
51
|
+
traduci_e_richiedi file
|
48
52
|
end
|
49
53
|
|
50
54
|
def richiedi_tutti(dir)
|
@@ -61,22 +65,28 @@ module Kernel
|
|
61
65
|
|
62
66
|
private
|
63
67
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
def traduci_file(file_to_translate)
|
69
|
+
file_to_translate_dir = File.dirname file_to_translate
|
70
|
+
file_to_translate_ext = File.extname file_to_translate
|
71
|
+
file_to_translate_basename = File.basename file_to_translate, file_to_translate_ext
|
68
72
|
|
69
|
-
parsed_dir = File.join Italian::Ruby.translations_dir_path,
|
73
|
+
parsed_dir = File.join Italian::Ruby.translations_dir_path, file_to_translate_dir
|
70
74
|
FileUtils.mkdir_p parsed_dir unless Dir.exists? parsed_dir
|
71
|
-
parsed_file = File.join parsed_dir, "#{
|
75
|
+
parsed_file = File.join parsed_dir, "#{file_to_translate_basename}.rb"
|
72
76
|
|
73
|
-
if
|
74
|
-
parsed_code = File.read
|
77
|
+
if file_to_translate_ext == ".rb"
|
78
|
+
parsed_code = File.read file_to_translate
|
75
79
|
else
|
76
|
-
parsed_code = Italian::Ruby::Traduttore.traduci
|
80
|
+
parsed_code = Italian::Ruby::Traduttore.traduci file_to_translate
|
77
81
|
end
|
78
82
|
|
79
83
|
File.write parsed_file, parsed_code
|
84
|
+
parsed_file
|
85
|
+
end
|
86
|
+
|
87
|
+
def traduci_e_richiedi(file_to_require)
|
88
|
+
parsed_file = traduci_file file_to_require
|
89
|
+
|
80
90
|
begin
|
81
91
|
require parsed_file
|
82
92
|
rescue SyntaxError => errore
|
@@ -85,4 +95,15 @@ module Kernel
|
|
85
95
|
end
|
86
96
|
end
|
87
97
|
|
98
|
+
def traduci_e_carica(file_to_load)
|
99
|
+
parsed_file = traduci_file file_to_load
|
100
|
+
|
101
|
+
begin
|
102
|
+
load parsed_file
|
103
|
+
rescue SyntaxError => errore
|
104
|
+
riga = errore.message.split("\n").first.split(":")[1].to_i rescue 0
|
105
|
+
Italian::Ruby::Errore::Sintassi.new("Errore di sintassi.", parsed_file, riga, 0).stampa
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
88
109
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
##
|
4
|
+
# Core Ext - OpenStruct
|
5
|
+
#
|
6
|
+
# Alias di metodi della classe OpenStruct.
|
7
|
+
|
8
|
+
class OpenStruct
|
9
|
+
def in_mappa(*args)
|
10
|
+
hash = to_h *args
|
11
|
+
hash.in_mappa do |key, value|
|
12
|
+
if value.respond_to? :to_h
|
13
|
+
[ key, value.to_h ]
|
14
|
+
else
|
15
|
+
[ key, value ]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Archivio = OpenStruct
|
data/lib/italian/ruby/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.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: 2020-06-
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/italian/ruby/core_ext/nil_class.rb
|
96
96
|
- lib/italian/ruby/core_ext/numeric.rb
|
97
97
|
- lib/italian/ruby/core_ext/object.rb
|
98
|
+
- lib/italian/ruby/core_ext/open_struct.rb
|
98
99
|
- lib/italian/ruby/core_ext/proc.rb
|
99
100
|
- lib/italian/ruby/core_ext/range.rb
|
100
101
|
- lib/italian/ruby/core_ext/string.rb
|