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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b310c7d130d7ad5995a56a634e32a0feb1c3643e8d1a64e04b890a3208ffe45
4
- data.tar.gz: 67d00de81602c11d24bff7f99d900e39adf1635d140dc8ced8bdc52d4c63bd61
3
+ metadata.gz: 6c113ca549c5124f156e161c4ee009384ee9f224d71bb7fada1213a5ac701202
4
+ data.tar.gz: 7f7de77cf3daf442f3562e3a138e13a156ef8c8c7727d41d84a58a084c7b59ac
5
5
  SHA512:
6
- metadata.gz: 6b59e75386751558d5f3bb667c8c8beca1a99fe218a394ffd67ed5e5f99d6163587cfb11cbef54607bad1767e92b7c1337ffea1f04e3beaa2dc28ce0b4cc2ba2
7
- data.tar.gz: a7e73748bc86a2ebf33d8359faef4a47275715c2b5a9798751ff658710c4d0ff066d93b07bcbe02fe75505625c0b8befe406f5ad94b9cd5096515778ed69bbbb
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"
@@ -25,6 +25,7 @@ class Date
25
25
  alias :in_stringa :to_s
26
26
  alias :in_data :to_date
27
27
  alias :giorno_della_settimana :cwday
28
+ alias :formatta :strftime
28
29
 
29
30
  def due_anni_fa
30
31
  self.prev_year.prev_year
@@ -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? :gsub
21
- path.gsub("/Users/fballardin/.italian-ruby/translations", "")
21
+ return path unless path.respond_to? :partition
22
+ path.partition(".italian-ruby/translations").last
22
23
  end
23
24
  end
@@ -5,4 +5,7 @@ module JSON
5
5
  def self.processa(*args)
6
6
  self.parse(*args)
7
7
  end
8
+ def self.in_stringa(*args)
9
+ self.dump(*args)
10
+ end
8
11
  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| Dir["#{dir}/**/#{name}.ir"] }.flatten.compact.first
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
- traduci_e_carica file_to_require
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
- traduci_e_carica file_to_require
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
- traduci_e_carica file
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 traduci_e_carica(file_to_require)
65
- file_to_require_dir = File.dirname file_to_require
66
- file_to_require_ext = File.extname file_to_require
67
- file_to_require_basename = File.basename file_to_require, file_to_require_ext
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, file_to_require_dir
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, "#{file_to_require_basename}.rb"
75
+ parsed_file = File.join parsed_dir, "#{file_to_translate_basename}.rb"
72
76
 
73
- if file_to_require_ext == ".rb"
74
- parsed_code = File.read file_to_require
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 file_to_require
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
@@ -12,6 +12,7 @@ class Time
12
12
 
13
13
  alias :in_stringa :to_s
14
14
  alias :in_numero :to_i
15
+ alias :formatta :strftime
15
16
 
16
17
  def in_data
17
18
  self.to_date
@@ -1,5 +1,5 @@
1
1
  module Italian
2
2
  module Ruby
3
- VERSION = "0.7.7"
3
+ VERSION = "0.8.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: 0.7.7
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-03 00:00:00.000000000 Z
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