verbs 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/verbs/conjugator.rb +33 -8
- data/lib/verbs.rb +1 -0
- data/test/test_verbs.rb +4 -0
- data/verbs.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.5
|
data/lib/verbs/conjugator.rb
CHANGED
@@ -35,17 +35,42 @@ module Verbs
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def conjugate(infinitive, options = {})
|
38
|
-
tense = options[:tense] || :present # present, past, future
|
39
|
-
person = options[:person] || :third # first, second, third
|
40
|
-
plurality = options[:plurality] || :singular # singular, plural
|
41
|
-
diathesis = options[:diathesis] || :active # active, passive
|
42
|
-
mood = options[:mood] || :indicative # conditional, imperative, indicative, injunctive, optative, potential, subjunctive
|
43
|
-
aspect = options[:aspect] || :habitual # perfective, habitual, progressive, perfect, prospective
|
38
|
+
# tense = options[:tense] || :present # present, past, future
|
39
|
+
# person = options[:person] || :third # first, second, third
|
40
|
+
# plurality = options[:plurality] || :singular # singular, plural
|
41
|
+
# diathesis = options[:diathesis] || :active # active, passive
|
42
|
+
# mood = options[:mood] || :indicative # conditional, imperative, indicative, injunctive, optative, potential, subjunctive
|
43
|
+
# aspect = options[:aspect] || :habitual # perfective, habitual, progressive, perfect, prospective
|
44
|
+
|
45
|
+
if actor = options.delete(:subject)
|
46
|
+
actor = subject(options).humanize if actor.is_a?(TrueClass)
|
47
|
+
end
|
44
48
|
|
45
49
|
if verb = conjugations.irregulars[infinitive]
|
46
|
-
verb[options] || conjugate_irregular(verb, options)
|
50
|
+
conjugation = verb[options] || conjugate_irregular(verb, options)
|
51
|
+
else
|
52
|
+
conjugation = conjugate_regular(infinitive, options)
|
53
|
+
end
|
54
|
+
|
55
|
+
if actor
|
56
|
+
"#{actor} #{conjugation}"
|
47
57
|
else
|
48
|
-
|
58
|
+
conjugation
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def subject(options)
|
63
|
+
case [options[:person], options[:plurality]]
|
64
|
+
when [:first, :singular]
|
65
|
+
'I'
|
66
|
+
when [:first, :plural]
|
67
|
+
'we'
|
68
|
+
when [:second, :singular], [:second, :plural]
|
69
|
+
'you'
|
70
|
+
when [:third, :singular]
|
71
|
+
'he'
|
72
|
+
when [:third, :plural]
|
73
|
+
'they'
|
49
74
|
end
|
50
75
|
end
|
51
76
|
|
data/lib/verbs.rb
CHANGED
data/test/test_verbs.rb
CHANGED
@@ -78,4 +78,8 @@ class TestVerbs < Test::Unit::TestCase
|
|
78
78
|
assert_equal :washes, Verbs::Conjugator.conjugate(:wash, :tense => :present, :person => :third, :plurality => :singular)
|
79
79
|
assert_equal :watches, Verbs::Conjugator.conjugate(:watch, :tense => :present, :person => :third, :plurality => :singular)
|
80
80
|
end
|
81
|
+
def test_conjugation_with_subject
|
82
|
+
assert_equal 'Matz is', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :third, :plurality => :singular, :subject => 'Matz')
|
83
|
+
assert_equal 'We are', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :first, :plurality => :plural, :subject => true)
|
84
|
+
end
|
81
85
|
end
|
data/verbs.gemspec
CHANGED