conjugate 1.3.13 → 1.4.0
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.
- data/conjugate.gemspec +1 -1
- data/lib/conjugate/common.rb +82 -0
- data/lib/conjugate/french.rb +30 -0
- data/lib/conjugate/french_templates/irregular_verbs.rb +342 -0
- data/lib/conjugate/french_templates/templates.rb +4671 -0
- data/lib/conjugate/spanish.rb +4 -76
- data/lib/conjugate/{templates/spanish_irregular_verbs.rb → spanish_templates/irregular_verbs.rb} +0 -0
- data/lib/conjugate/{templates/spanish_templates.rb → spanish_templates/templates.rb} +0 -0
- data/lib/conjugate.rb +3 -0
- metadata +7 -3
data/lib/conjugate/spanish.rb
CHANGED
@@ -1,67 +1,24 @@
|
|
1
|
-
require 'conjugate/templates
|
2
|
-
require 'conjugate/
|
1
|
+
require 'conjugate/spanish_templates/templates'
|
2
|
+
require 'conjugate/spanish_templates/irregular_verbs'
|
3
|
+
require 'conjugate/common'
|
3
4
|
|
4
5
|
module Conjugate
|
5
6
|
module Spanish
|
6
7
|
extend self
|
8
|
+
extend Common
|
7
9
|
|
8
10
|
def generate_list_of_know_irregular_verbs
|
9
11
|
puts "- " + SpanishIrregularVerbs.keys.sort.join("\n- ")
|
10
12
|
end
|
11
13
|
|
12
|
-
@dividing_infinitive_regex = /\{{3}\d+\}{3}(\w+)/
|
13
|
-
|
14
|
-
|
15
|
-
def conjugate(opts ={})
|
16
|
-
@debug = opts[:debug].nil? ? false : true
|
17
|
-
|
18
|
-
template = template(opts)
|
19
|
-
debug(template)
|
20
|
-
tense = tense(opts[:tense])
|
21
|
-
|
22
|
-
verb = opts[:verb]
|
23
|
-
debug(verb)
|
24
|
-
|
25
|
-
infinitive = template[:infinitive].dup
|
26
|
-
debug(infinitive)
|
27
|
-
|
28
|
-
verb_parts = divide_infinitive(infinitive, verb)
|
29
|
-
debug(verb_parts)
|
30
|
-
|
31
|
-
return nil if template[tense].nil? || template[tense][opts[:pronoun].to_sym].nil?
|
32
|
-
|
33
|
-
conjugation_template = template[tense][opts[:pronoun].to_sym].dup
|
34
|
-
debug(conjugation_template)
|
35
|
-
|
36
|
-
positions = conjugation_template.scan(/\{{3}(\d+)\}{3}/).flatten
|
37
|
-
debug(positions)
|
38
|
-
|
39
|
-
positions.each do |p|
|
40
|
-
if opts[:highlight]
|
41
|
-
conjugation_template.gsub!(/\{{3}#{p}\}{3}/, "<span class='regular'>#{ verb_parts[p.to_i - 1] }</span>")
|
42
|
-
else
|
43
|
-
conjugation_template.gsub!(/\{{3}#{p}\}{3}/, verb_parts[p.to_i - 1])
|
44
|
-
end
|
45
|
-
end
|
46
|
-
conjugation_template
|
47
|
-
end
|
48
|
-
|
49
14
|
def find_irregular(verb)
|
50
15
|
SpanishIrregularVerbs[verb.downcase]
|
51
16
|
end
|
52
17
|
|
53
|
-
def regular_ending(verb)
|
54
|
-
verb[-2..-1]
|
55
|
-
end
|
56
|
-
|
57
18
|
def template(opts)
|
58
19
|
SpanishTemplates[(opts[:template] || find_irregular(opts[:verb]) || regular_ending(opts[:verb])).to_sym]
|
59
20
|
end
|
60
21
|
|
61
|
-
def tense(t)
|
62
|
-
(common_name(t) || :present).to_sym
|
63
|
-
end
|
64
|
-
|
65
22
|
def common_name(t)
|
66
23
|
return nil unless t
|
67
24
|
changable_names = {:past => :preterite}
|
@@ -69,34 +26,5 @@ module Conjugate
|
|
69
26
|
tense
|
70
27
|
end
|
71
28
|
|
72
|
-
def divide_infinitive(infinitive, verb)
|
73
|
-
inserts = infinitive.scan(@dividing_infinitive_regex).flatten
|
74
|
-
debug(inserts)
|
75
|
-
|
76
|
-
word_parts = []
|
77
|
-
word_copy = verb.dup
|
78
|
-
|
79
|
-
inserts.each do |letters|
|
80
|
-
sub_word = ""
|
81
|
-
if letters.length <= 1
|
82
|
-
sub_word = word_copy.scan(/(.[^#{letters}]*)#{letters}/).flatten.first
|
83
|
-
else
|
84
|
-
sub_word = word_copy.scan(/(.+)#{letters}/).flatten.first
|
85
|
-
end
|
86
|
-
sub_word ||= ""
|
87
|
-
|
88
|
-
word_parts << sub_word
|
89
|
-
word_copy = word_copy.gsub(/^#{sub_word}#{letters}/, '')
|
90
|
-
end
|
91
|
-
word_parts << word_copy unless word_copy == ""
|
92
|
-
word_parts
|
93
|
-
end
|
94
|
-
|
95
|
-
def debug(info)
|
96
|
-
if @debug
|
97
|
-
puts info.inspect
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
29
|
end
|
102
30
|
end
|
data/lib/conjugate/{templates/spanish_irregular_verbs.rb → spanish_templates/irregular_verbs.rb}
RENAMED
File without changes
|
File without changes
|
data/lib/conjugate.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjugate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -23,9 +23,13 @@ files:
|
|
23
23
|
- lib/.DS_Store
|
24
24
|
- lib/conjugate.rb
|
25
25
|
- lib/conjugate/.DS_Store
|
26
|
+
- lib/conjugate/common.rb
|
27
|
+
- lib/conjugate/french.rb
|
28
|
+
- lib/conjugate/french_templates/irregular_verbs.rb
|
29
|
+
- lib/conjugate/french_templates/templates.rb
|
26
30
|
- lib/conjugate/spanish.rb
|
27
|
-
- lib/conjugate/
|
28
|
-
- lib/conjugate/templates
|
31
|
+
- lib/conjugate/spanish_templates/irregular_verbs.rb
|
32
|
+
- lib/conjugate/spanish_templates/templates.rb
|
29
33
|
homepage: https://github.com/JeremyGeros/Conjugate
|
30
34
|
licenses: []
|
31
35
|
post_install_message:
|