italian-ruby 0.1.2 → 0.1.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: e77bc57386211592f254fc0a17f9b2ce05c31453d5115bb23aacb3fa56759192
4
- data.tar.gz: 03b44542875df8c82407332db861544a5766fd12551e0dc1dbcb8ad8f9697b7e
3
+ metadata.gz: e13700d6b40a1bc4f9ee4d845c80af9fe4ae332f2288528e6c147635c77a2c4a
4
+ data.tar.gz: d58597618f2be747a849f21661ac214cd635c872f472573242da2793d84b1cad
5
5
  SHA512:
6
- metadata.gz: d0b5e0f98b9333652a89af5cb893f1e9e8aab144882053bfc27eb85f000870d0f3a4dea38be185d191f1cbb0c2f11e2af942f0ea92858fb7368b5806a51fb69d
7
- data.tar.gz: 717a0ebc33dc4ab89e3df7c1cb739ce1238121a5e705db031cef09e59b39c6725692a0ebd393e0c7bb992bc85fb3274afd5ac49ffeafbe3dc2295f526773c87d
6
+ metadata.gz: 42101231651471d35934bb0d82743f710d406b516d8c4bcd2f12d5fe72eac1829bcfcab4664dd01e818e485595bdb07b45921838c502263749d30e1e8f509d2c
7
+ data.tar.gz: 732f903acf2f910ed472debace2c58865144973ae5583a3de55fff7aa70f0025f07ab736df3e5261ce1e81c1408148b0b1319bd69880f2f38e9b76784c2e6ce9
data/bin/italian-rspec CHANGED
@@ -4,14 +4,14 @@
4
4
  require "rspec"
5
5
  require "italian/ruby"
6
6
 
7
- def translate_spec(file)
8
- spec_file = "#{File.dirname file}/#{File.basename(file, ".ir")}.rb"
9
- File.write spec_file, Italian::Ruby::Traduttore.traduci(file)
7
+ def translate_spec(spec_file)
8
+ translated_spec_file = "#{File.dirname spec_file}/#{File.basename(spec_file, ".ir")}.rb"
9
+ File.write translated_spec_file, Italian::Ruby::Traduttore.traduci(spec_file)
10
+ translated_spec_file
10
11
  end
11
12
 
12
- def destroy_spec(file)
13
- spec_file = "#{File.dirname file}/#{File.basename(file, ".ir")}.rb"
14
- File.delete spec_file if File.exist? spec_file
13
+ def destroy_spec(translated_spec_file)
14
+ File.delete translated_spec_file if File.exist? translated_spec_file
15
15
  end
16
16
 
17
17
  if ARGV[0].nil?
@@ -24,6 +24,6 @@ else
24
24
  spec_files = ARGV
25
25
  end
26
26
 
27
- spec_files.each { |file| translate_spec file }
28
- RSpec::Core::Runner.run([ "spec" ], STDIN, STDOUT)
29
- spec_files.each { |file| destroy_spec file }
27
+ translated_spec_files = spec_files.map { |file| translate_spec file }
28
+ RSpec::Core::Runner.run(translated_spec_files, STDIN, STDOUT)
29
+ translated_spec_files.each { |file| destroy_spec file }
@@ -3,8 +3,12 @@
3
3
  original_verbosity = $VERBOSE
4
4
  $VERBOSE = nil
5
5
 
6
- require_relative "core_ext/kernel"
7
6
  require_relative "core_ext/main"
7
+ require_relative "core_ext/class"
8
+ require_relative "core_ext/module"
9
+ require_relative "core_ext/file"
10
+ require_relative "core_ext/kernel"
11
+ require_relative "core_ext/nil_class"
8
12
  require_relative "core_ext/object"
9
13
  require_relative "core_ext/array"
10
14
  require_relative "core_ext/hash"
@@ -14,6 +14,19 @@ class Array
14
14
  alias :prima :first
15
15
  alias :ultimo :last
16
16
  alias :ultima :last
17
+ alias :uno_a_caso :sample
18
+ alias :una_a_caso :sample
19
+ alias :prendine_a_caso :sample
20
+ alias :unisci :join
21
+ alias :appiattisci :flatten
22
+ alias :compatta :compact
23
+ alias :conteggio :count
24
+ alias :tutti? :all?
25
+ alias :tutte? :all?
26
+ alias :alcuni? :any?
27
+ alias :alcune? :any?
28
+ alias :nessuno? :none?
29
+ alias :nessuna? :none?
17
30
 
18
31
  def esiste?
19
32
  !nil? && !empty?
@@ -0,0 +1,12 @@
1
+ ##
2
+ # CoreExt - Class
3
+
4
+ class Class
5
+ alias :privati :private
6
+ alias :protetti :protected
7
+ alias :pubblici :public
8
+
9
+ alias :accessore :attr_accessor
10
+
11
+ alias :definisci_metodo :define_method
12
+ end
@@ -0,0 +1,14 @@
1
+ ##
2
+ # Core Ext - File
3
+ #
4
+ # Alias di metodi della classe File.
5
+
6
+ class File
7
+ class << self
8
+ alias :nome_file :basename
9
+ alias :nome_cartella :dirname
10
+ alias :esiste? :exists?
11
+ alias :scrivi :write
12
+ alias :apri :open
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ ##
2
+ # Core Ext - Fabrication
3
+
4
+ class Fabricate
5
+ class << self
6
+ alias :produci :create
7
+ alias :assembla :build
8
+ alias :materie_prime :attributes_for
9
+ end
10
+ end
11
+
12
+ Fabbrica = Fabricate
@@ -1,7 +1,9 @@
1
1
  ##
2
- # Core Ext - Hanami::Interactor
2
+ # Core Ext - Hanami
3
3
 
4
4
  module Hanami
5
+ ##
6
+ # Interactor
5
7
  module Interactor
6
8
  alias :fallisci! :error!
7
9
  alias :errore! :error!
@@ -47,4 +49,16 @@ module Hanami
47
49
  end
48
50
  end
49
51
  end
52
+
53
+ ##
54
+ # Mongoid - Repository
55
+ module Mongoid
56
+ class Repository
57
+
58
+ def tutti(*args, &block)
59
+ all *args, &block
60
+ end
61
+
62
+ end
63
+ end
50
64
  end
@@ -1,5 +1,5 @@
1
1
  ##
2
- # Core Ext - Mongoid Criteria
2
+ # Core Ext - Mongoid
3
3
 
4
4
  module Mongoid
5
5
  class Criteria
@@ -15,5 +15,6 @@ module Mongoid
15
15
  entries
16
16
  end
17
17
  alias :voci :dati
18
+ alias :lista :dati
18
19
  end
19
20
  end
@@ -0,0 +1,102 @@
1
+ ##
2
+ # Core Ext - Rspec
3
+
4
+ module RSpec
5
+ def self.descrivi(*args, &block)
6
+ describe *args, &block
7
+ end
8
+
9
+ ##
10
+ # Core
11
+ module Core
12
+ class ExampleGroup
13
+ alias :classe_descritta :described_class
14
+ define_example_group_method :contesto
15
+ end
16
+
17
+ module Hooks
18
+ alias :prima :before
19
+ alias :dopo :after
20
+ end
21
+
22
+ module MemoizedHelpers
23
+ module ClassMethods
24
+ alias :sia :let
25
+ alias :sia! :let!
26
+ alias :soggetto :subject
27
+ alias :soggetto! :subject!
28
+ end
29
+ end
30
+ end
31
+
32
+ ##
33
+ # Expectations
34
+ module Expectations
35
+ class ExpectationTarget
36
+ module InstanceMethods
37
+ def che(*args, &block)
38
+ to *args, &block
39
+ end
40
+
41
+ def che_non(*args, &block)
42
+ not_to *args, &block
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ ##
49
+ # Mocks
50
+ module Mocks
51
+ module ExampleMethods
52
+ alias :imita :instance_double
53
+ alias :imita_classe :class_double
54
+ end
55
+
56
+ class TargetBase
57
+ def che(*args)
58
+ to *args
59
+ end
60
+ def che_non(*args)
61
+ not_to *args
62
+ end
63
+
64
+ private
65
+
66
+ def matcher_allowed?(matcher)
67
+ matcher.class.name.start_with?("RSpec::Mocks::Matchers".freeze) or
68
+ matcher.class.name.start_with?("RSpec::Matchers::AliasedMatcher".freeze)
69
+ end
70
+ end
71
+
72
+ class MessageExpectation
73
+ alias :e_ritorni :and_return
74
+ end
75
+
76
+ class VerifyingMessageExpectation
77
+ alias :con :with
78
+ end
79
+
80
+ module Matchers
81
+ class Receive
82
+ alias :con :with
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ RSpec.configure do |config|
89
+ RSpec::Matchers.alias_matcher :sia, :be
90
+ RSpec::Matchers.alias_matcher :equivalga_a, :eq
91
+ RSpec::Matchers.alias_matcher :alzi_errore, :raise_error
92
+ RSpec::Matchers.alias_matcher :riceva, :receive
93
+ RSpec::Matchers.alias_matcher :abbia_ricevuto, :have_received
94
+
95
+ config.alias_example_to :esso
96
+ config.alias_example_to :essa
97
+
98
+ config.before :each do
99
+ alias :verifica :expect
100
+ alias :consenti :allow
101
+ end
102
+ end
@@ -12,7 +12,10 @@ class Hash
12
12
  alias :mappa :map
13
13
  alias :vuoto? :empty?
14
14
  alias :vuota? :empty?
15
+ alias :ha_chiave? :has_key?
15
16
  alias :ottieni :fetch
17
+ alias :prendi :fetch
18
+ alias :deposita :store
16
19
  alias :scava :dig
17
20
  alias :trasforma_chiavi :transform_keys
18
21
  alias :trasforma_valori :transform_values
@@ -9,6 +9,9 @@
9
9
  # scritti in Italian Ruby che in file sorgenti scritti in Ruby standard.
10
10
 
11
11
  module Kernel
12
+ alias :classe :class
13
+ alias :ottieni_variabile_istanza :instance_variable_get
14
+ alias :imposta_variabile_istanza :instance_variable_set
12
15
 
13
16
  def richiedi(name)
14
17
  file_to_require = $:.map { |dir| Dir["#{dir}/**/#{name}.ir"] }.flatten.compact.first
@@ -17,23 +17,9 @@ def estendi(*args)
17
17
  extend *args
18
18
  end
19
19
 
20
- def privati(*args)
21
- private
22
- end
23
- def protetti(*args)
24
- protected
25
- end
26
- def pubblici(*args)
27
- public
28
- end
29
-
30
20
  def alza(*args)
31
21
  raise *args
32
22
  end
33
23
  def fallisci(*args)
34
24
  fail *args
35
- end
36
-
37
- def non_in?(*args)
38
- !in? *args
39
25
  end
@@ -0,0 +1,8 @@
1
+ ##
2
+ # CoreExt - Module
3
+
4
+ class Module
5
+ alias :privati :private
6
+ alias :protetti :protected
7
+ alias :pubblici :public
8
+ end
@@ -0,0 +1,11 @@
1
+ ##
2
+ # Core Ext - Nil Class
3
+
4
+ class NilClass
5
+ alias :nullo? :nil?
6
+ alias :nulla? :nil?
7
+
8
+ def esiste?
9
+ !nil?
10
+ end
11
+ end
@@ -5,25 +5,41 @@
5
5
 
6
6
  class Object
7
7
  class << self
8
- alias_method :nuovo, :new
9
- alias_method :nuova, :new
8
+ alias :nuovo :new
9
+ alias :nuova :new
10
10
  end
11
11
 
12
12
  alias :nullo? :nil?
13
13
  alias :nulla? :nil?
14
14
  alias :risponde_a? :respond_to?
15
+ alias :manda :send
16
+ alias :ispeziona :inspect
15
17
 
16
18
  def esiste?
17
19
  !nil?
18
20
  end
19
21
 
22
+ def non_risponde_a?(method)
23
+ !respond_to? method
24
+ end
25
+
26
+ def in?(array)
27
+ raise ArgumentError.new("Argument passed to `in?` must respond to `include?`") unless
28
+ array.respond_to? :include?
29
+ array.include? self
30
+ end
31
+
32
+ def non_in?(array)
33
+ !in? array
34
+ end
35
+
20
36
  private
21
37
 
22
- def inizializzatore(*args, &block)
38
+ def inizializzatore(*args, **options, &block)
23
39
  end
24
40
 
25
- def initialize(*args, &block)
26
- inizializzatore *args, &block
41
+ def initialize(*args, **options, &block)
42
+ inizializzatore *args, **options, &block
27
43
  end
28
44
 
29
45
  end
@@ -5,4 +5,6 @@
5
5
 
6
6
  class String
7
7
  alias :congela :freeze
8
- end
8
+ end
9
+
10
+ Stringa = String
@@ -1,5 +1,5 @@
1
1
  module Italian
2
2
  module Ruby
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -293,7 +293,7 @@
293
293
  },
294
294
  {
295
295
  "comment": " everything being a method but having a special function is a..",
296
- "match": "\\b(inizializzatore|nuovo|nuova|cicla|includi|estendi|preponi|fallisci|alza|attr_reader|attr_writer|attr_accessor|attr|catch|throw|privati|private_class_method|module_function|pubblici|public_class_method|protetti|refine|using)\\b(?![?!])",
296
+ "match": "\\b(inizializzatore|nuovo|nuova|cicla|includi|estendi|preponi|fallisci|alza|accessore|accessore_di_classe|attr_reader|attr_writer|attr_accessor|attr|catch|throw|privati|private_class_method|module_function|pubblici|public_class_method|protetti|refine|using)\\b(?![?!])",
297
297
  "name": "keyword.other.special-method.ruby"
298
298
  },
299
299
  {
@@ -313,7 +313,7 @@
313
313
  "name": "variable.language.self.ruby"
314
314
  },
315
315
  {
316
- "begin": "\\b(?<!\\.|::)(require|require_relative|richiedi|richiedi_relativo)\\b",
316
+ "begin": "\\b(?<!\\.|::)(require|require_relative|richiedi|richiedi_relativo|richiedi_tutti)\\b",
317
317
  "captures": {
318
318
  "1": {
319
319
  "name": "keyword.other.special-method.ruby"
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.1.2
4
+ version: 0.1.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-03-27 00:00:00.000000000 Z
11
+ date: 2020-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2ruby
@@ -88,15 +88,18 @@ files:
88
88
  - lib/italian/ruby.rb
89
89
  - lib/italian/ruby/core_ext.rb
90
90
  - lib/italian/ruby/core_ext/array.rb
91
- - lib/italian/ruby/core_ext/hanami/interactor.rb
92
- - lib/italian/ruby/core_ext/hanami/mongoid.rb
91
+ - lib/italian/ruby/core_ext/class.rb
92
+ - lib/italian/ruby/core_ext/file.rb
93
+ - lib/italian/ruby/core_ext/gems/fabrication.rb
94
+ - lib/italian/ruby/core_ext/gems/hanami.rb
95
+ - lib/italian/ruby/core_ext/gems/mongoid.rb
96
+ - lib/italian/ruby/core_ext/gems/rspec.rb
93
97
  - lib/italian/ruby/core_ext/hash.rb
94
98
  - lib/italian/ruby/core_ext/kernel.rb
95
99
  - lib/italian/ruby/core_ext/main.rb
96
- - lib/italian/ruby/core_ext/mongoid/criteria.rb
100
+ - lib/italian/ruby/core_ext/module.rb
101
+ - lib/italian/ruby/core_ext/nil_class.rb
97
102
  - lib/italian/ruby/core_ext/object.rb
98
- - lib/italian/ruby/core_ext/rspec/core.rb
99
- - lib/italian/ruby/core_ext/rspec/expectations.rb
100
103
  - lib/italian/ruby/core_ext/string.rb
101
104
  - lib/italian/ruby/richiedi_test.ir
102
105
  - lib/italian/ruby/ruby_parser_patches.rb
@@ -1,14 +0,0 @@
1
- ##
2
- # Core Ext - Hanami Mongoid
3
-
4
- module Hanami
5
- module Mongoid
6
- class Repository
7
-
8
- def tutti(*args, &block)
9
- all *args, &block
10
- end
11
-
12
- end
13
- end
14
- end
@@ -1,27 +0,0 @@
1
- ##
2
- # Core Ext - Rspec Core
3
-
4
- module RSpec
5
- def self.descrivi(*args, &block)
6
- describe *args, &block
7
- end
8
-
9
- module Core
10
- module Hooks
11
- alias_method :prima, :before
12
- alias_method :dopo, :after
13
- end
14
- end
15
- end
16
-
17
- RSpec.configure do |config|
18
- RSpec::Matchers.alias_matcher :sia, :be
19
- RSpec::Matchers.alias_matcher :equivalga_a, :eq
20
-
21
- config.alias_example_to :esso
22
- config.alias_example_to :essa
23
-
24
- config.before :each do
25
- alias :verifica :expect
26
- end
27
- end
@@ -1,18 +0,0 @@
1
- ##
2
- # Core Ext - Rspec Expectations
3
-
4
- module RSpec
5
- module Expectations
6
- class ExpectationTarget
7
- module InstanceMethods
8
- def che(*args, &block)
9
- to *args, &block
10
- end
11
-
12
- def che_non(*args, &block)
13
- not_to *args, &block
14
- end
15
- end
16
- end
17
- end
18
- end