in_italiano 0.0.3 → 0.0.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: 76ccd429a768aee90037da68e21200594d37209af466dd3febf719277db1316c
4
- data.tar.gz: ae9d018353e44378bfc4601b120101a3be179e84a02e016677ac2a9567478bea
3
+ metadata.gz: 7162825f59115a2179b49ff3c0388112148d14d73be5573aae89380fc0ef553b
4
+ data.tar.gz: 964d92db612b411a576c606ff9fc4b71d75ed8f38314d3400bf41cd8e87b9db1
5
5
  SHA512:
6
- metadata.gz: ddc0555576c8085acecfacce18358e31802f557971fd5b6825dc1c9d4557f7ee3b2f8bcc7f60b5a911971dd88e91e84cf29ee09d7d497dc8ae1d7f247eadeebe
7
- data.tar.gz: 3de27897e1e3aa34d8db8424876cbd9fdc1a1c3dfed6e417899d26846e62e6ec3a7cce7320902f6c8a3b49727c1820ccedfece42f27cb0380a159c4e498aa486
6
+ metadata.gz: be4ff49a7e3d35c1b8615cf5b8ef80f5d81f8b6864e81ed805534e4fe8e7ad948e0548e77d17e327c58d81b9fbc4817ef6fd2c30768da219f65fce7f575832b8
7
+ data.tar.gz: eeca95a144e1426b9c018ebc08691268a8e371486388ffe1934cf85f2de5a81df84d1df8ea63a26324ec19188cefa0da6a8f90216d8fc705aa99d5462196e477
@@ -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[::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[:string][method_name]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,18 +2,43 @@ module InItaliano
2
2
  module Classes
3
3
  module String
4
4
  module Patch
5
+ # String Class Documentation:
6
+ # https://docs.ruby-lang.org/en/3.4/String.html
7
+
8
+ # Instance Methods
9
+ def append_as_bytes(*objects)
10
+ ::InItaliano.last_class = :string
11
+ ::InItaliano.last_method = :append_as_bytes
12
+
13
+ super
14
+ end
15
+
16
+ def ascii_only?
17
+ ::InItaliano.last_class = :string
18
+ ::InItaliano.last_method = :ascii_only?
19
+
20
+ super
21
+ end
22
+
23
+ def bytes
24
+ ::InItaliano.last_class = :string
25
+ ::InItaliano.last_method = :bytes
26
+
27
+ super
28
+ end
29
+
5
30
  def capitalize
6
- @@last_class = :string
7
- @@last_method = :capitalize
31
+ ::InItaliano.last_class = :string
32
+ ::InItaliano.last_method = :capitalize
8
33
 
9
34
  super
10
35
  end
11
36
 
12
37
  def method_missing(symbol, *args)
13
38
  if symbol === :in_italiano
14
- translation = TRANSLATIONS[@@last_class][@@last_method]
15
- @@last_class = nil
16
- @@last_method = nil
39
+ translation = TRANSLATIONS[::InItaliano.last_class][::InItaliano.last_method]
40
+ ::InItaliano.last_class = nil
41
+ ::InItaliano.last_method = nil
17
42
  translation
18
43
  else
19
44
  super(symbol, *args)
@@ -0,0 +1,21 @@
1
+ module InItaliano
2
+ module Classes
3
+ module TrueClass
4
+ module Patch
5
+ # True Class Documentation:
6
+ # https://docs.ruby-lang.org/en/3.4/TrueClass.html
7
+
8
+ def method_missing(symbol, *args)
9
+ if symbol === :in_italiano
10
+ translation = TRANSLATIONS[::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,11 @@
1
+ module InItaliano
2
+ class History
3
+ attr_accessor :last_class
4
+ attr_accessor :last_method
5
+
6
+ def intialize
7
+ @last_class = nil
8
+ @last_method = nil
9
+ end
10
+ end
11
+ end
data/lib/in_italiano.rb CHANGED
@@ -1,16 +1,50 @@
1
+ require 'in_italiano/history'
2
+
3
+ require 'in_italiano/classes/array/patch'
1
4
  require 'in_italiano/classes/string/patch'
5
+ require 'in_italiano/classes/string/class_methods_patch'
6
+ require 'in_italiano/classes/true_class/patch'
2
7
 
3
8
  module InItaliano
4
- @@last_class = nil
5
- @@last_method = nil
6
-
7
9
  TRANSLATIONS = {
8
10
  string: {
11
+ append_as_bytes: "aggiungere come byte",
12
+ ascii_only?: "solo ascii?",
13
+ bytes: "i byte",
9
14
  capitalize: "capitalizzare"
10
15
  }
11
16
  }
17
+
18
+ def self.last_class=(_class)
19
+ @history ||= History.new
20
+ @history.last_class = _class
21
+ end
22
+
23
+ def self.last_class
24
+ @history ||= History.new
25
+ @history.last_class
26
+ end
27
+
28
+ def self.last_method=(_method)
29
+ @history ||= History.new
30
+ @history.last_method = _method
31
+ end
32
+
33
+ def self.last_method
34
+ @history ||= History.new
35
+ @history.last_method
36
+ end
37
+ end
38
+
39
+ class Array
40
+ prepend InItaliano::Classes::Array::Patch
12
41
  end
13
42
 
14
43
  class String
44
+ extend InItaliano::Classes::String::ClassMethodsPatch
15
45
  prepend InItaliano::Classes::String::Patch
46
+ end
47
+
48
+ class TrueClass
49
+ prepend InItaliano::Classes::TrueClass::Patch
16
50
  end
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.3
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - dgonzdev
@@ -15,8 +15,11 @@ 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
21
+ - lib/in_italiano/classes/true_class/patch.rb
22
+ - lib/in_italiano/history.rb
20
23
  homepage: https://rubygems.org/gems/in_italiano
21
24
  licenses: []
22
25
  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