in_italiano 0.0.5 → 0.0.8

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: 33f98443c874dcc1f7b57f80fcde96e0501d3924cc3b8dbb0a8a27d179206fff
4
- data.tar.gz: e11241569ea2b125886607c6f453a6e96c81d84b68da03b8e273be5063d189d1
3
+ metadata.gz: 1f268779065eaa251240df69ff4f9ead3d62e3a9a275acd192f80c5536189623
4
+ data.tar.gz: f12571dcffa7367940cf07a540ab3e135c0021c95ff345eb9bb408d3dab8adfd
5
5
  SHA512:
6
- metadata.gz: 16f5b0b6978c9c4f0b31960994fe844f271421866c9c75557d14edd20bb3575f146c729598755f39245b260bc9ae1302c51825e86521dc92483c3c40f901068b
7
- data.tar.gz: a052e38d3fe4acf6d01181497d33757e15cff72817ee3613461c21e63d5ca6ae7a28e7940fca5ffe6f788bfd07c71cdf415f276c1b43e4c9df7991f66471d479
6
+ metadata.gz: 9045279ccfcf93f79669cda99f25d2140e642f4afc70baff6a70c00ca2ad090213f6a72515b013ee484bd1f86794a49e6d803a70747d2edee1f89e2bb828be65
7
+ data.tar.gz: 318599a1e221ab81aeb8e0f1ca4d05a9d850baea28586aeae464c4ab102b59395058b7e7b70122ed5ede828441015bd7b4687d79479af10d315ed1d06b0dd92a
@@ -0,0 +1,21 @@
1
+ module InItaliano
2
+ module Classes
3
+ module Array
4
+ module Patch
5
+ # Array Class Documentation:
6
+ # https://docs.ruby-lang.org/en/3.4/Array.html
7
+
8
+ def method_missing(symbol, *args)
9
+ if symbol === :in_italiano
10
+ translation = Translations.find(::InItaliano.last_class, ::InItaliano.last_method)
11
+ ::InItaliano.last_class = nil
12
+ ::InItaliano.last_method = nil
13
+ translation
14
+ else
15
+ super(symbol, *args)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ module InItaliano
2
+ module Classes
3
+ module String
4
+ module ClassMethodsPatch
5
+ # String Class Documentation:
6
+ # https://docs.ruby-lang.org/en/3.4/String.html
7
+
8
+ def in_italiano(method_name = nil)
9
+ if method_name.nil?
10
+ return "Cordicella"
11
+ end
12
+
13
+ Translations.find(:string, method_name)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -20,6 +20,13 @@ module InItaliano
20
20
  super
21
21
  end
22
22
 
23
+ def bytes
24
+ ::InItaliano.last_class = :string
25
+ ::InItaliano.last_method = :bytes
26
+
27
+ super
28
+ end
29
+
23
30
  def capitalize
24
31
  ::InItaliano.last_class = :string
25
32
  ::InItaliano.last_method = :capitalize
@@ -29,7 +36,7 @@ module InItaliano
29
36
 
30
37
  def method_missing(symbol, *args)
31
38
  if symbol === :in_italiano
32
- translation = TRANSLATIONS[::InItaliano.last_class][::InItaliano.last_method]
39
+ translation = Translations.find(::InItaliano.last_class, ::InItaliano.last_method)
33
40
  ::InItaliano.last_class = nil
34
41
  ::InItaliano.last_method = nil
35
42
  translation
@@ -7,7 +7,7 @@ module InItaliano
7
7
 
8
8
  def method_missing(symbol, *args)
9
9
  if symbol === :in_italiano
10
- translation = TRANSLATIONS[::InItaliano.last_class][::InItaliano.last_method]
10
+ translation = Translations.find(::InItaliano.last_class, ::InItaliano.last_method)
11
11
  ::InItaliano.last_class = nil
12
12
  ::InItaliano.last_method = nil
13
13
  translation
@@ -8,6 +8,4 @@ module InItaliano
8
8
  @last_method = nil
9
9
  end
10
10
  end
11
-
12
-
13
11
  end
@@ -0,0 +1,16 @@
1
+ module InItaliano
2
+ class Translations
3
+ STRING = {
4
+ append_as_bytes: "aggiungere come byte",
5
+ ascii_only?: "solo ascii?",
6
+ bytes: "i byte",
7
+ capitalize: "capitalizzare"
8
+ }
9
+
10
+ def self.find(class_name, method_name)
11
+ if class_name == :string
12
+ STRING[method_name]
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/in_italiano.rb CHANGED
@@ -1,17 +1,7 @@
1
1
  require 'in_italiano/history'
2
-
3
- require 'in_italiano/classes/string/patch'
4
- require 'in_italiano/classes/true_class/patch'
2
+ require 'in_italiano/translations'
5
3
 
6
4
  module InItaliano
7
- TRANSLATIONS = {
8
- string: {
9
- append_as_bytes: "aggiungere come byte",
10
- ascii_only?: "solo ascii?",
11
- capitalize: "capitalizzare"
12
- }
13
- }
14
-
15
5
  def self.last_class=(_class)
16
6
  @history ||= History.new
17
7
  @history.last_class = _class
@@ -33,7 +23,17 @@ module InItaliano
33
23
  end
34
24
  end
35
25
 
26
+ require 'in_italiano/classes/array/patch'
27
+ require 'in_italiano/classes/string/patch'
28
+ require 'in_italiano/classes/string/class_methods_patch'
29
+ require 'in_italiano/classes/true_class/patch'
30
+
31
+ class Array
32
+ prepend InItaliano::Classes::Array::Patch
33
+ end
34
+
36
35
  class String
36
+ extend InItaliano::Classes::String::ClassMethodsPatch
37
37
  prepend InItaliano::Classes::String::Patch
38
38
  end
39
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: in_italiano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - dgonzdev
@@ -15,10 +15,12 @@ extensions: []
15
15
  extra_rdoc_files: []
16
16
  files:
17
17
  - lib/in_italiano.rb
18
- - lib/in_italiano/array_translations.rb
18
+ - lib/in_italiano/classes/array/patch.rb
19
+ - lib/in_italiano/classes/string/class_methods_patch.rb
19
20
  - lib/in_italiano/classes/string/patch.rb
20
21
  - lib/in_italiano/classes/true_class/patch.rb
21
22
  - lib/in_italiano/history.rb
23
+ - lib/in_italiano/translations.rb
22
24
  homepage: https://rubygems.org/gems/in_italiano
23
25
  licenses: []
24
26
  metadata: {}
@@ -1,14 +0,0 @@
1
- module InItaliano
2
- module StringTranslations
3
- def method_missing(symbol, *args)
4
- if symbol === :in_italiano
5
- translation = TRANSLATIONS[@@last_class][@@last_method]
6
- @@last_class = nil
7
- @@last_method = nil
8
- translation
9
- else
10
- super(symbol, *args)
11
- end
12
- end
13
- end
14
- end