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 CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -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
- conjugate_regular(infinitive, options)
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
@@ -3,6 +3,7 @@ require 'verbs/verb'
3
3
  require 'verbs/conjugator'
4
4
  require 'verbs/conjugations'
5
5
  require 'andand'
6
+ require 'activesupport'
6
7
 
7
8
  module Verbs
8
9
  CONSONANTS = %w(b c d f g h j k l m n p q r s t v w x z)
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{verbs}
8
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andy Rossmeissl"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Rossmeissl