respanol 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3deb9c078f27c7b848676d994ed1d8f65b1fba9e
4
- data.tar.gz: c6712d1856f68e8bc8f65213d8478600f5e42524
3
+ metadata.gz: d9e5972b737d1d8b180da611aa4364daf00b7e5c
4
+ data.tar.gz: 3d0d5a36190505bdf44b6bd60b31ff6f10616086
5
5
  SHA512:
6
- metadata.gz: 817314e47c56d2600b852571f5eb5a9d013ca2b12196b9df5de786a9632d23351cce6ce79ee335ff8b28c47f5f44e0b48618ac7362c99056f19636fe5d3ccb6a
7
- data.tar.gz: 76d104905279b24c37b06256b7c1b957588f0816210fea0171d54230145d6756717afeafa508b0d3b2fa67eaeed321f48fbfb9df216582925a6a6ebed4bc034b
6
+ metadata.gz: bb1adbda60892e8fd07742c1f5764c8ad483e8caeb70364de8922dbf999a919d679ab3c8485ea0d2fbc2ccc5d13b4fa110e9b5f9ae69aa4ea1b115f31e505438
7
+ data.tar.gz: 6ed047a3e2bc8fe5dedfd67a2212cc8cd4f7f5728dd85f88ebca408f180f8797ce297176f2a7343c2749f9d959937464450c34f36420ec11e7e5eeede6600d09
data/Gemfile CHANGED
@@ -11,5 +11,6 @@ end
11
11
 
12
12
  group :test do
13
13
  gem 'rspec'
14
- gem 'simplecov', require: false
14
+ gem 'simplecov'
15
+ gem 'codeclimate-test-reporter', '~> 1.0.0'
15
16
  end
@@ -2,11 +2,13 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  respanol (0.0.1)
5
- glosbe (>= 0.0.10)
5
+ glosbe (~> 0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ codeclimate-test-reporter (1.0.7)
11
+ simplecov
10
12
  coderay (1.1.1)
11
13
  diff-lcs (1.3)
12
14
  docile (1.1.5)
@@ -83,6 +85,7 @@ PLATFORMS
83
85
  ruby
84
86
 
85
87
  DEPENDENCIES
88
+ codeclimate-test-reporter (~> 1.0.0)
86
89
  glosbe
87
90
  guard
88
91
  guard-bundler
data/Guardfile CHANGED
@@ -45,7 +45,7 @@ module ::Guard
45
45
  end
46
46
  end
47
47
 
48
- def run_on_removals(paths)
48
+ def run_on_removals(_paths)
49
49
  reload
50
50
  end
51
51
  end
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
+ [![Gem Version](https://badge.fury.io/rb/respanol.svg)](https://badge.fury.io/rb/respanol)
2
+ [![Test Coverage](https://codeclimate.com/github/tiev/respanol/badges/coverage.svg)](https://codeclimate.com/github/tiev/respanol/coverage)
3
+ [![Code Climate](https://codeclimate.com/github/tiev/respanol/badges/gpa.svg)](https://codeclimate.com/github/tiev/respanol)
4
+
1
5
  # Respanol
2
6
  Some ruby scripts to help learning Espanol.
3
7
  These scripts are developed while I started studying Spanish.
4
8
 
5
- **IN PROGRESS**: some might not be correct for whole situations but so far it's coped with what I've learnt
9
+ **IN PROGRESS**: some might not be correct for whole situations but so far it's coped with what I've learnt about Español
6
10
 
7
11
  # What's included?
8
12
  These scripts test your Espanol knownledge in many aspects:
@@ -13,9 +17,118 @@ These scripts test your Espanol knownledge in many aspects:
13
17
  * Months of the year
14
18
  * Verb Conjugations
15
19
 
16
- # How to run
17
- You should have installed Ruby. Then bundle to install gems `bundle install`.
20
+ # Installation
21
+ You should have installed Ruby.
22
+
23
+ Install respanol gem: `gem install respanol`
24
+
25
+ Require: `require 'respanol'`
26
+
27
+ Then, enjoy studying!
28
+
29
+ # Features & Exams
30
+
31
+ ## Test your number reading and writing
32
+
33
+ Using `Respanol::Examen::NumeroExamen`
34
+
35
+ Test reading a random number in a range
36
+
37
+ `Respanol::Examen::NumeroExamen.new.leer(<rango>)`
38
+
39
+ * **rango**: ruby range or maximum (excluded) number. Default: `(1...100)`
40
+
41
+ Examples:
42
+ ```ruby
43
+ > Respanol::Examen::NumeroExamen.new.leer
44
+ > cincuenta y tres = 53
45
+ => Muy bien!
46
+ > Respanol::Examen::NumeroExamen.new.leer(10)
47
+ > cinco = 3
48
+ => No!
49
+ cinco = 5
50
+ => Muy bien!
51
+ ```
52
+
53
+ Test writing a random number in a range
54
+
55
+ `Respanol::Examen::NumeroExamen.new.escribir(<rango>)`
56
+
57
+ * **rango**: ruby range or maximum (excluded) number. Default: `(1...100)`
58
+
59
+ Examples:
60
+ ```ruby
61
+ > Respanol::Examen::NumeroExamen.new.escribir
62
+ > 64 = sesenta y cuatro
63
+ => Muy bien!
64
+ ```
65
+
66
+ You can configure the test to use feminine number or default maximum
67
+
68
+ ```ruby
69
+ > Respanol::Examen::NumeroExamen.new.tap { |e| e.feminino!.maximo = 50 }.leer
70
+ ```
71
+ is the same as:
72
+ ```ruby
73
+ > e = Respanol::Examen::NumeroExamen.new.feminino
74
+ > e.leer(50)
75
+ > e.escribir(50)
76
+ ```
77
+
78
+ ## Verbs Conjugations
79
+ In this version, these exams support present tense only.
80
+
81
+ All verbs implemented is in namespace `Respanol::Verbo`.
82
+
83
+ Test verbs conjugations:
84
+
85
+ `Respanol::Examen::ConjugacionExamen.new.conjugado(<verbos>)`
86
+
87
+ * **verbos**: accept a single verb class or an array of verb classes to be tested
88
+
89
+ ```ruby
90
+ > Respanol::Examen::ConjugacionExamen.new.conjugado(Respanol::Verbo::Poder)
91
+ Poder:: > Tu puedes
92
+ => Muy bien!
93
+ ```
94
+
95
+ You can configure a default list of verbs:
96
+
97
+ ```ruby
98
+ Respanol::Examen::ConjugacionExamen.new([Respanol::Verbo::Poder, Respanol::Verbo::Tener]).conjugado
99
+ Poder:: > Yo puedo
100
+ => Muy bien!
101
+ Tener:: > Nosotros tenemos
102
+ => Muy bien!
103
+ ```
104
+
105
+ ## Repeat a test many times
106
+
107
+ You can repeat a test many times to practice more:
108
+
109
+ `Respanol::Examen::ConjugacionExamen.gaza(<conde>, [<test instance>])`
110
+
111
+ Method gaza works with all Respanol::Examen classes.
112
+
113
+ Example: 3 following snippets have the same effect - test conjugation for Poder 5 times.
114
+
115
+ ```ruby
116
+ Respanol::Examen::ConjugacionExamen.gaza(5) do |t|
117
+ t.conjugado(Respanol::Verbo::Poder)
118
+ end
119
+ ```
120
+
121
+ or
122
+
123
+ ```ruby
124
+ t = Respanol::Examen::ConjugacionExamen.new(Respanol::Verbo::Poder)
125
+ Respanol::Examen::ConjugacionExamen.gaza(5, t)
126
+ ```
127
+
128
+ or
18
129
 
19
- Then include library in irb: `irb -I lib -r espanol`. Enjoy studying!!!
130
+ ```ruby
131
+ Respanol::Examen::ConjugacionExamen.new(Respanol::Verbo::Poder).gaza(5)
132
+ ```
20
133
 
21
- I will published this as a gem when I feel it's ready.
134
+ If no repeat count given to `gaza()`, the default is `50`
@@ -1,8 +1,8 @@
1
1
  module Respanol
2
2
  class Ano
3
- MESES = %W{ #{''}
3
+ MESES = %w[
4
4
  Enero Febrero Marzo Abril Mayo Junio
5
5
  Julio Agosto Septiembre Octubre Noviembre Diciembre
6
- }
6
+ ].unshift('')
7
7
  end
8
8
  end
@@ -10,7 +10,7 @@ module Respanol
10
10
  klases = klases | Array(klase) unless klase.nil?
11
11
  kl = klases.sample
12
12
  pro = Pronombre.todos.sample
13
- kl.prefijo
13
+ prefijo(kl)
14
14
  ensayar("#{pro} ") do |v|
15
15
  kl::CONJUGACION.find_index(v) == Pronombre.verbo_indice(pro)
16
16
  end
@@ -20,6 +20,14 @@ module Respanol
20
20
  self.class.gaza(conde, self, &Proc.new)
21
21
  end
22
22
 
23
+ def self.emparejar?(s1, s2)
24
+ s1.gsub(/\s+/, ' ').strip.downcase == s2.gsub(/\s+/, ' ').strip.downcase
25
+ end
26
+
27
+ def emparejar?(*args)
28
+ self.class.emparejar?(*args)
29
+ end
30
+
23
31
  def ensayar(*args)
24
32
  print "> "
25
33
  exito = true
@@ -14,7 +14,7 @@ module Respanol
14
14
  def escribir(fecha_rango = (Date.civil(1900,1,1)..Date.today))
15
15
  fe = rand(fecha_rango)
16
16
  ensayar("Fecha #{fe.strftime('%A %Y-%m-%d')}: ") do |v|
17
- v.gsub(/\s+/, ' ').strip.downcase == Fecha.fecha_en_palabras(fe).downcase
17
+ emparejar?(v, Fecha.fecha_en_palabras(fe))
18
18
  end
19
19
  end
20
20
  end
@@ -16,8 +16,7 @@ module Respanol
16
16
  fe = Date.today
17
17
  ho = Time.local(fe.year, fe.month, fe.day, rand(from..to), rand(0..60), rand(0..60))
18
18
  ensayar("#{ho.strftime('%I:%M:%S %p')} = ") do |v|
19
- v.gsub(/\s+/, ' ').strip.downcase ==
20
- Hora.responder_hora_en_palabras(ho).downcase
19
+ emparejar?(v, Hora.responder_hora_en_palabras(ho))
21
20
  end
22
21
  end
23
22
  end
@@ -2,6 +2,7 @@ module Respanol
2
2
  module Examen
3
3
  class NumeroExamen < ExamenBase
4
4
  attr_accessor :klase
5
+ attr_writer :maximo
5
6
 
6
7
  MAXIMO = 100
7
8
 
@@ -20,7 +21,11 @@ module Respanol
20
21
  self
21
22
  end
22
23
 
23
- def leer(rango = (1...MAXIMO))
24
+ def maximo
25
+ @maximo || MAXIMO
26
+ end
27
+
28
+ def leer(rango = (1...maximo))
24
29
  num = rand(rango)
25
30
  ensayar("#{@klase.numero_en_palabras(num)} = ") do |v|
26
31
  v.to_i == num
@@ -1,18 +1,24 @@
1
1
  module Respanol
2
2
  module Impresion
3
3
  module ClassMethods
4
- def prefijo
5
- print "#{self.name.split('::').last}:: "
4
+ def prefijo(klase)
5
+ print "#{klase.name.split('::').last}:: "
6
6
  end
7
7
 
8
- def impresion(*args)
9
- prefijo
8
+ def impresion(klase, *args)
9
+ prefijo(klase)
10
10
  print(*args)
11
11
  end
12
12
  end
13
13
 
14
14
  module InstanceMethods
15
+ def prefijo(*args)
16
+ self.class.prefijo(*args)
17
+ end
15
18
 
19
+ def impresion(*args)
20
+ self.class.impresion(*args)
21
+ end
16
22
  end
17
23
 
18
24
  def self.included(receiver)
@@ -2,10 +2,10 @@ module Respanol
2
2
  class Numero
3
3
  UNIDADES = %w( cero uno dos tres cuatro cinco seis siete ocho nueve )
4
4
  DECENA = %w( diez once doce trece catorce quince dieciseis diecisiete dieciocho diecinueve )
5
- DECENAS = %W( #{''} diez viente treinta cuarenta cincuenta sesenta setenta ochenta noventa )
6
- CENTENARES = %W( #{''} ciento doscientos trescientos cuatrocientos quinientos seiscientos setecientos ochocientos novecientos )
5
+ DECENAS = %w[ diez viente treinta cuarenta cincuenta sesenta setenta ochenta noventa ].unshift('')
6
+ CENTENARES = %w[ ciento doscientos trescientos cuatrocientos quinientos seiscientos setecientos ochocientos novecientos ].unshift('')
7
7
  UNO_APOCOPE = 'un'
8
- MILLONS = %W( #{''} millon billon trillon cuatrillon quintillon sextillon septillon octillon nonillon decillon undecillon duodecillon tredecillon cuatordecillon quindecillon sexdecillon septendecillon octodecillon novendecillon vigintillon )
8
+ MILLONS = %w[ millon billon trillon cuatrillon quintillon sextillon septillon octillon nonillon decillon undecillon duodecillon tredecillon cuatordecillon quindecillon sexdecillon septendecillon octodecillon novendecillon vigintillon ].unshift('')
9
9
  UNIDAD_1K = 'mil'
10
10
  DECIMAL = 'coma'
11
11
 
@@ -96,7 +96,7 @@ module Respanol
96
96
 
97
97
  class FemininoNumero < Numero
98
98
  UNIDADES = %w( cero una dos tres cuatro cinco seis siete ocho nueve )
99
- CENTENARES = %W( #{''} ciento doscientas trescientas cuatrocientas quinientas seiscientas setecientas ochocientas novecientas )
99
+ CENTENARES = %w[ ciento doscientas trescientas cuatrocientas quinientas seiscientas setecientas ochocientas novecientas ].unshift('')
100
100
  UNO_APOCOPE = 'una'
101
101
  end
102
102
  end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Cantar < VerboBase
4
+ CONJUGACION = %w[ canto cantas canta cantamos cantais cantan ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Correr < VerboBase
4
+ CONJUGACION = %w[ corro corres corre corremos correis corren ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Describir < VerboBase
4
+ CONJUGACION = %w[ describo describes describe describimos describis describen ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Escribir < VerboBase
4
+ CONJUGACION = %w[ escribo escribes escribe escribimos escribis escriben ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Escuchar < VerboBase
4
+ CONJUGACION = %w[ escucho escuchas escucha escuchamos escuchais escuchan ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Nadar < VerboBase
4
+ CONJUGACION = %w[ nado nadas nada nadamos nadais nadan ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Querer < VerboBase
4
+ CONJUGACION = %w[ quiero quieres quiere queremos quereis quieren ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Respanol
2
+ module Verbo
3
+ class Trabajar < VerboBase
4
+ CONJUGACION = %w[ trabajo trabajas trabaja trabajamos trabajais trabajan ]
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Respanol
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -13,7 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.description = 'Makes learning Spanish fun and easy! With all the core and tests'
14
14
  s.homepage = 'https://github.com/tiev/respanol'
15
15
 
16
-
17
16
  s.required_ruby_version = '>= 1.9.0'
18
17
 
19
18
  s.add_runtime_dependency 'glosbe', '~> 0.0'
@@ -1,15 +1,16 @@
1
1
  RSpec.describe Respanol::Impresion do
2
2
  before :all do
3
- Klase = Class.new.include(Respanol::Impresion)
4
- Respanol::KlaseInterna = Class.new.include(Respanol::Impresion)
3
+ ImpresionKlase = Class.new.include(Respanol::Impresion)
4
+ Klase = Class.new
5
+ Respanol::KlaseInterna = Class.new
5
6
  end
6
7
 
7
8
  describe '.prefijo' do
8
- it { expect { Klase.prefijo }.to output('Klase:: ').to_stdout }
9
- it { expect { Respanol::KlaseInterna.prefijo }.to output('KlaseInterna:: ').to_stdout }
9
+ it { expect { ImpresionKlase.prefijo(Klase) }.to output('Klase:: ').to_stdout }
10
+ it { expect { ImpresionKlase.prefijo(Respanol::KlaseInterna) }.to output('KlaseInterna:: ').to_stdout }
10
11
  end
11
12
 
12
13
  describe '.impresion' do
13
- it { expect { Klase.impresion('test') }.to output('Klase:: test').to_stdout }
14
+ it { expect { ImpresionKlase.impresion(Klase, 'test') }.to output('Klase:: test').to_stdout }
14
15
  end
15
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: respanol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drake Tran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-10 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glosbe
@@ -126,17 +126,25 @@ files:
126
126
  - lib/respanol/traductor.rb
127
127
  - lib/respanol/verbos/aprender.rb
128
128
  - lib/respanol/verbos/caminar.rb
129
+ - lib/respanol/verbos/cantar.rb
130
+ - lib/respanol/verbos/correr.rb
131
+ - lib/respanol/verbos/describir.rb
129
132
  - lib/respanol/verbos/dormir.rb
130
133
  - lib/respanol/verbos/entender.rb
134
+ - lib/respanol/verbos/escribir.rb
135
+ - lib/respanol/verbos/escuchar.rb
131
136
  - lib/respanol/verbos/hablar.rb
132
137
  - lib/respanol/verbos/hacer.rb
133
138
  - lib/respanol/verbos/jugar.rb
134
139
  - lib/respanol/verbos/leer.rb
140
+ - lib/respanol/verbos/nadar.rb
135
141
  - lib/respanol/verbos/poder.rb
142
+ - lib/respanol/verbos/querer.rb
136
143
  - lib/respanol/verbos/ser.rb
137
144
  - lib/respanol/verbos/subir.rb
138
145
  - lib/respanol/verbos/tener.rb
139
146
  - lib/respanol/verbos/tocar.rb
147
+ - lib/respanol/verbos/trabajar.rb
140
148
  - lib/respanol/verbos/verbo_base.rb
141
149
  - lib/respanol/verbos/viajar.rb
142
150
  - lib/respanol/verbos/vivir.rb
@@ -172,10 +180,4 @@ rubygems_version: 2.4.8
172
180
  signing_key:
173
181
  specification_version: 4
174
182
  summary: Makes learning Spanish fun and easy!
175
- test_files:
176
- - spec/respanol/fecha_spec.rb
177
- - spec/respanol/hora_spec.rb
178
- - spec/respanol/impresion_spec.rb
179
- - spec/respanol/numero_spec.rb
180
- - spec/respanol_spec.rb
181
- - spec/spec_helper.rb
183
+ test_files: []