verbs 2.1.4 → 3.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f0be8c541f264896e8f106be8bd64f97504c6261
4
- data.tar.gz: 654aee13d012ace83b367b599edaf43b35a03fb8
2
+ SHA256:
3
+ metadata.gz: e723eb9d358a2b674c497f70192e6172ba18d20fa472e588e38adcbf9f318a54
4
+ data.tar.gz: 8f88abec47d56529a4ec23c1b45b58d940fc1b7c6b6ceaf3f86d46b75c3591a8
5
5
  SHA512:
6
- metadata.gz: 4b248c62b8c8b6ce14f144bf1bd719471d09ee0303ca68872e9635ee3e914b624cdb15a4baac647415e5080cc6b015d9174a31b7a2332ebdb1d933ee63711d85
7
- data.tar.gz: fdbb938f6809c81ef825d16b9f3ff62bec2740efe75e6629833a58c7fd766df90259c243c37ab9e0a72f0d4d0311a3b50fb6927c5c5c73a27808a13752d1bded
6
+ metadata.gz: 708d985dffabeee18e46906f1e976dc988a92c85e12db77a04f0319b0f73f8e25c03d884fee19393b4909160c8a631abc12dfcdbef80c739217e67cfb1becf5c
7
+ data.tar.gz: 64cab548cb88b306788ac88f05ee26628cbd60c72d7b7a9987b54ab988b03ca24782fb84870917ee06c6790abefea4a1029e6fdb8f0710a9f27dd2a9f9b464d9
@@ -0,0 +1,29 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: 2.6
26
+ - name: Install dependencies
27
+ run: bundle install
28
+ - name: Run tests
29
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -17,6 +17,8 @@ tmtags
17
17
  coverage
18
18
  rdoc
19
19
  pkg
20
+ vendor
21
+ .bundle
20
22
 
21
23
  ## PROJECT::SPECIFIC
22
24
  Gemfile.lock
@@ -31,7 +31,7 @@ Either <tt>:singular</tt> or <tt>:plural</tt>. Defaults to <tt>:singular</tt>.
31
31
 
32
32
  === <tt>:aspect</tt>
33
33
 
34
- One of <tt>:habitual</tt>, <tt>:perfect</tt>, <tt>:perfective</tt>, <tt>:progressive</tt>, or <tt>:prospective</tt>. Defaults to <tt>:habitual</tt>.
34
+ One of <tt>:habitual</tt>, <tt>:perfect</tt>, <tt>:perfective</tt>, <tt>:progressive</tt>, or <tt>:prospective</tt>. Defaults to <tt>:habitual</tt> (<tt>:perfective</tt> for past tense).
35
35
 
36
36
  See below for a guide to verb aspect.
37
37
 
@@ -43,11 +43,15 @@ One of <tt>:indicative</tt>, <tt>:imperative</tt>, or <tt>:subjunctive</tt>. Def
43
43
 
44
44
  Set this to a string to prepend the conjugated verb with it. When set to <tt>true</tt>, a standard personal pronoun will be used.
45
45
 
46
+ === <tt>:diathesis</tt>
47
+
48
+ One of <tt>:active</tt> or <tt>:passive</tt>. Defaults to <tt>:active</tt>.
49
+
46
50
  == Tense/aspect quick reference
47
51
 
48
52
  EXAMPLE TENSE ASPECT
49
53
 
50
- I usually accepted past habitual
54
+ I used to accept past habitual
51
55
  I had accepted past perfect
52
56
  I accepted past perfective
53
57
  I was accepting past progressive
@@ -71,6 +75,7 @@ Set this to a string to prepend the conjugated verb with it. When set to <tt>tru
71
75
  * {Pat Byrd and Tom McKlin}[http://www2.gsu.edu/~wwwesl/egw/pluralsv.htm]
72
76
  * {Rick Harrison}[http://www.rickharrison.com/language/aspect.html]
73
77
  * {Anatoli Makarevich}[https://github.com/makaroni4] for {#6}[https://github.com/rossmeissl/verbs/pull/6]
78
+ * {Nikita Kamaev}[https://github.com/nerixim] for {#35}[https://github.com/rossmeissl/verbs/pull/35]
74
79
 
75
80
  == Copyright
76
81
 
data/Rakefile CHANGED
@@ -14,9 +14,6 @@ rescue Bundler::BundlerError => e
14
14
  exit e.status_code
15
15
  end
16
16
 
17
- require 'bueller'
18
- Bueller::Tasks.new
19
-
20
17
  require 'rake'
21
18
  require 'rake/testtask'
22
19
  Rake::TestTask.new(:test) do |test|
@@ -1,14 +1,16 @@
1
1
  Verbs::Conjugator.conjugations do |conjugate|
2
2
 
3
- conjugate.irregular :be do |verb| # copular
3
+ conjugate.irregular :be do |verb| # copular
4
4
  verb.form :am, :tense => :present, :person => :first, :plurality => :singular
5
5
  verb.form :is, :tense => :present, :person => :third, :plurality => :singular
6
6
  verb.form :are, :tense => :present, :person => :second, :plurality => :singular
7
+ verb.form :are, :tense => :present, :person => :second, :plurality => :plural
7
8
  verb.form :are, :tense => :present, :person => :first, :plurality => :plural
8
9
  verb.form :are, :tense => :present, :person => :third, :plurality => :plural
9
10
  verb.form :was, :tense => :past, :person => :first, :plurality => :singular
10
11
  verb.form :was, :tense => :past, :person => :third, :plurality => :singular
11
12
  verb.form :were, :tense => :past, :person => :second, :plurality => :singular
13
+ verb.form :were, :tense => :past, :person => :second, :plurality => :plural
12
14
  verb.form :were, :tense => :past, :person => :first, :plurality => :plural
13
15
  verb.form :were, :tense => :past, :person => :third, :plurality => :plural
14
16
  verb.form :were, :tense => :past, :mood => :subjunctive
@@ -17,15 +19,17 @@ Verbs::Conjugator.conjugations do |conjugate|
17
19
  verb.form :been, :tense => :past, :derivative => :participle
18
20
  end
19
21
 
20
- conjugate.irregular :have do |verb|
22
+ conjugate.irregular :have do |verb|
21
23
  verb.form :have, :tense => :present, :person => :first, :plurality => :singular
22
24
  verb.form :has, :tense => :present, :person => :third, :plurality => :singular
23
25
  verb.form :have, :tense => :present, :person => :second, :plurality => :singular
26
+ verb.form :have, :tense => :present, :person => :second, :plurality => :plural
24
27
  verb.form :have, :tense => :present, :person => :first, :plurality => :plural
25
28
  verb.form :have, :tense => :present, :person => :third, :plurality => :plural
26
29
  verb.form :had, :tense => :past, :person => :first, :plurality => :singular
27
30
  verb.form :had, :tense => :past, :person => :third, :plurality => :singular
28
31
  verb.form :had, :tense => :past, :person => :second, :plurality => :singular
32
+ verb.form :had, :tense => :past, :person => :second, :plurality => :plural
29
33
  verb.form :had, :tense => :past, :person => :first, :plurality => :plural
30
34
  verb.form :had, :tense => :past, :person => :third, :plurality => :plural
31
35
  verb.form :having, :tense => :present, :derivative => :participle
@@ -182,7 +186,7 @@ Verbs::Conjugator.conjugations do |conjugate|
182
186
  conjugate.irregular :strive, :strove, :striven
183
187
  conjugate.irregular :swear, :swore, :sworn
184
188
  conjugate.irregular :sweep, :swept, :swept
185
- conjugate.irregular :swell, :swelled, :swelled
189
+ conjugate.irregular :swell, :swelled, :swelled
186
190
  conjugate.irregular :swim, :swam, :swum
187
191
  conjugate.irregular :swing, :swung, :swung
188
192
  conjugate.irregular :take, :took, :taken
@@ -264,6 +268,7 @@ Verbs::Conjugator.conjugations do |conjugate|
264
268
  conjugate.single_terminal_consonant :decipher
265
269
  conjugate.single_terminal_consonant :deflower
266
270
  conjugate.single_terminal_consonant :delimit
271
+ conjugate.single_terminal_consonant :deliver
267
272
  conjugate.single_terminal_consonant :deposit
268
273
  conjugate.single_terminal_consonant :develop
269
274
  conjugate.single_terminal_consonant :differ
@@ -309,6 +314,7 @@ Verbs::Conjugator.conjugations do |conjugate|
309
314
  conjugate.single_terminal_consonant :flounder
310
315
  conjugate.single_terminal_consonant :fluster
311
316
  conjugate.single_terminal_consonant :flutter
317
+ conjugate.single_terminal_consonant :follow
312
318
  conjugate.single_terminal_consonant :foreshorten
313
319
  conjugate.single_terminal_consonant :founder
314
320
  conjugate.single_terminal_consonant :fritter
@@ -1,31 +1,60 @@
1
+ # The program conjugates most common english verbs with the following option:
2
+ # * :tense => :past or :present or :future (default: :present)
3
+ # * :person => :first or :second or :third (default: :third)
4
+ # * :plurality => :singular or :plural (default: :singular)
5
+ # * :aspect => :habitual or :perfect or :perfective or :progressive or :prospective (default: :habitual, or :perfective for past tense)
6
+ # * :mood => :indicative or :imperative or :subjunctive (default: :indicative)
7
+ # * :diathesis => :active or :passive (default: :active)
8
+ #
9
+ # Author:: Andy Rossmeissl
10
+ # Copyright:: Copyright (c) 2009 Andy Rossmeissl
11
+ # License:: Found in LICENSE file
12
+
1
13
  module Verbs
2
14
  module Conjugator
3
15
  extend self
4
16
 
17
+ # This class determines the conjugations from the given options (or defaults)
18
+ # conjugations are then applied to the verb
5
19
  class Conjugations
6
20
  include Singleton
7
21
 
22
+ # permit outside functions access to these variables
8
23
  attr_reader :irregulars, :single_terminal_consonants, :copulars
9
24
 
25
+ # Creates initial variables for class
10
26
  def initialize
11
27
  @irregulars, @single_terminal_consonants, @copulars = {}, [], {}
12
28
  end
13
29
 
30
+ # Determines irregular verbs from the expression
31
+ # Params:
32
+ # * infinitive, the given verb
33
+ # * preterite, denote events that took place in the past
34
+ # * past_participle, form of a verb, ending in 'ed'
35
+ # * &blk, block of code that may be run
14
36
  def irregular(infinitive, preterite = nil, past_participle = nil, &blk)
15
37
  if block_given?
38
+ # create new Verb object with infinitive and &blk
16
39
  irregular = ::Verbs::Verb.new infinitive, &blk
17
40
  else
18
41
  raise ArgumentError, "Standard irregular verbs must specify preterite and past participle forms" unless preterite and past_participle
42
+ # create new Verb object with infinitive, preterite and past_participle
19
43
  irregular = ::Verbs::Verb.new infinitive, :preterite => preterite, :past_participle => past_participle
20
44
  end
21
45
  @irregulars[infinitive] = irregular
22
46
  end
23
47
 
48
+ # Find single terminal consonant with the infinitive
49
+ # Params:
50
+ # * infinitive, the given verb
24
51
  def single_terminal_consonant(infinitive)
25
52
  @single_terminal_consonants << infinitive
26
53
  end
27
54
  end
28
55
 
56
+ # Runs a block of code if given in a class instance
57
+ # else only class instance is created
29
58
  def conjugations
30
59
  if block_given?
31
60
  yield Conjugations.instance
@@ -34,28 +63,40 @@ module Verbs
34
63
  end
35
64
  end
36
65
 
66
+ # Using options given, determine the conjugation and the subject
67
+ # Return the subject, if there is one, and the proper conjugation
68
+ # Params:
69
+ # * infinitive, the given verb
70
+ # * options, the list of parameters to alter the conjugation
37
71
  def conjugate(infinitive, options = {})
72
+ infinitive = infinitive.dup if infinitive.is_a?(String)
73
+
74
+ # set all options according to parameter, or the default
38
75
  tense = options[:tense] || :present # present, past, future
39
76
  person = options[:person] || :third # first, second, third
40
77
  plurality = options[:plurality] || :singular # singular, plural
41
78
  diathesis = options[:diathesis] || :active # active, passive
42
79
  mood = options[:mood] || :indicative # imperative, subjunctive
43
- aspect = options[:aspect] || :habitual # perfective, habitual, progressive, perfect, prospective
44
-
45
- check_for_improper_constructions(tense, person, mood)
46
-
47
- form = form_for(tense, aspect)
80
+ aspect = options[:aspect] || default_aspect(options) # perfective, habitual, progressive, perfect, prospective
48
81
 
82
+ check_for_improper_constructions(infinitive, tense, person, mood, diathesis) # find incompatabilities
83
+ form = form_for(tense, aspect, diathesis) # find form array based on tense and aspect
84
+
85
+ # map form array to conjugation array, applying infinitive and options to the array
49
86
  conjugation = form.map { |e| resolve e, infinitive, tense, person, plurality, mood }.join(' ').strip
50
87
 
51
- if options[:subject]
52
- actor = options.delete(:subject)
88
+ if options[:subject] # When options includes a subject,
89
+ actor = options.delete(:subject) # remove from options and make subject humanized
53
90
  actor = subject(options).humanize if actor.is_a?(TrueClass)
54
91
  end
55
92
 
56
93
  "#{actor} #{conjugation}".strip
57
94
  end
58
95
 
96
+ # Finds the pronoun associated with the subject for the conjugation
97
+ # Returns the pronoun
98
+ # Params:
99
+ # * options, list of options given to determine conjugation
59
100
  def subject(options)
60
101
  case [options[:person], options[:plurality]]
61
102
  when [:first, :singular]
@@ -73,6 +114,14 @@ module Verbs
73
114
 
74
115
  private
75
116
 
117
+ # Resolves conflictions between options of the conjugation
118
+ # Params:
119
+ # * element,
120
+ # * infinitive, the given verb
121
+ # * tense, an option given by the user
122
+ # * person, an option given by the user
123
+ # * plurality, an option given by the user
124
+ # * mood, an option given by the user
76
125
  def resolve(element, infinitive, tense, person, plurality, mood)
77
126
  case element
78
127
  when String
@@ -86,6 +135,13 @@ module Verbs
86
135
  end
87
136
  end
88
137
 
138
+ # Change the form to express the proper grammatical function
139
+ # Params:
140
+ # * infinitive,the given verb
141
+ # * inflection, form to be changed
142
+ # * person, an option given by the user
143
+ # * plurality, an option given by the user
144
+ # * mood, an option given by the user
89
145
  def inflect(infinitive, inflection, person, plurality, mood)
90
146
  send(*([inflection, infinitive, person, plurality, mood][0, method(inflection).arity + 1]))
91
147
  end
@@ -100,6 +156,12 @@ module Verbs
100
156
  end
101
157
  end
102
158
 
159
+ # Conjugate verb to past with relevent options determining outcome
160
+ # Params:
161
+ # * infinitive, the given verb
162
+ # * person, the subject of the verb
163
+ # * plurality, an option given by the user
164
+ # * mood, an option given by the user
103
165
  def past(infinitive, person, plurality, mood)
104
166
  if verb = conjugations.irregulars[infinitive]
105
167
  conjugate_irregular(verb, :tense => :past, :person => person, :plurality => plurality, :mood => mood)
@@ -108,12 +170,15 @@ module Verbs
108
170
  end
109
171
  end
110
172
 
173
+ # Forming verb to apply present tense endings
174
+ # Params:
175
+ # * infinitive, the given verb
111
176
  def present_participle(infinitive)
112
- if infinitive.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(infinitive)
177
+ if infinitive.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(infinitive.to_sym)
113
178
  present_participle_with_doubled_terminal_consonant_for infinitive
114
179
  elsif infinitive.to_s.match(/c$/)
115
180
  infinitive.to_s.concat('king').to_sym
116
- elsif infinitive.to_s.match(/ye$/) or infinitive.to_s.match(/oe$/) or infinitive.to_s.match(/nge$/) or infinitive.to_s.match(/ee$/)
181
+ elsif infinitive.to_s.match(/^be$/) or infinitive.to_s.match(/ye$/) or infinitive.to_s.match(/oe$/) or infinitive.to_s.match(/nge$/) or infinitive.to_s.match(/ee$/)
117
182
  infinitive.to_s.concat('ing').to_sym
118
183
  elsif infinitive.to_s.match(/ie$/)
119
184
  infinitive.to_s[0..-2].concat('ying').to_sym
@@ -124,6 +189,9 @@ module Verbs
124
189
  end
125
190
  end
126
191
 
192
+ # Forming verb to apply past tense endings
193
+ # Params:
194
+ # * infinitive, the given verb
127
195
  def past_participle(infinitive)
128
196
  if verb = conjugations.irregulars[infinitive]
129
197
  conjugate_irregular(verb, :tense => :past, :derivative => :participle)
@@ -132,6 +200,10 @@ module Verbs
132
200
  end
133
201
  end
134
202
 
203
+ #
204
+ # Params:
205
+ # * verb,
206
+ # * options,
135
207
  def conjugate_irregular(verb, options)
136
208
  return verb[options] if verb[options]
137
209
 
@@ -151,6 +223,9 @@ module Verbs
151
223
  end
152
224
  end
153
225
 
226
+ # Apply thir person rules to the verb for the conjugation
227
+ # Params:
228
+ # * verb, apply proper third person rules to this
154
229
  def present_third_person_singular_form_for(verb)
155
230
  infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
156
231
 
@@ -165,10 +240,13 @@ module Verbs
165
240
  end
166
241
  end
167
242
 
243
+ # Apply the regular past tense to a given verb for the conjugation
244
+ # Params:
245
+ # * verb, apply regular past tense rules to this
168
246
  def regular_preterite_for(verb)
169
247
  infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
170
-
171
- if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(verb)
248
+
249
+ if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(verb.to_sym)
172
250
  regular_preterite_with_doubled_terminal_consonant_for verb
173
251
  elsif verb.to_s.match(/#{CONSONANT_PATTERN}e$/) or verb.to_s.match(/ye$/) or verb.to_s.match(/oe$/) or verb.to_s.match(/nge$/) or verb.to_s.match(/ie$/) or verb.to_s.match(/ee$/)
174
252
  infinitive.to_s.concat('d').to_sym
@@ -179,39 +257,80 @@ module Verbs
179
257
  end
180
258
  end
181
259
 
260
+ # Apply proper rules to consonant endings
261
+ # Params:
262
+ # * verb, apply doule consonant to this
182
263
  def regular_preterite_with_doubled_terminal_consonant_for(verb)
183
264
  regular_preterite_for verb.to_s.concat(verb.to_s[-1,1]).to_sym
184
265
  end
185
266
 
267
+ # Apply proper rules to consonant endings
268
+ # Params:
269
+ # * verb, apply doule consonant to this
186
270
  def present_participle_with_doubled_terminal_consonant_for(verb)
187
271
  present_participle verb.to_s.concat(verb.to_s[-1,1]).to_sym
188
272
  end
189
273
 
190
- def form_for(tense, aspect)
274
+ # Add appropriate aspects to the tense of the conjugation
275
+ # Params:
276
+ # * tense, an option given by the user
277
+ # * aspect, an option given by the user
278
+ # * diathesis, an option given by the user
279
+ def form_for(tense, aspect, diathesis)
191
280
  form = []
192
- if tense == :future
193
- form << 'will'
194
- form << :infinitive if aspect == :habitual
195
- form.concat ['have', :past_participle] if aspect == :perfect
196
- form.concat ['be having', :past_participle] if aspect == :perfective
197
- form.concat ['be', :present_participle] if aspect == :progressive
198
- form.concat ['be about to', :infinitive] if aspect == :prospective
199
- else
200
- form.concat ['usually', :past_participle] if [tense, aspect] == [:past, :habitual]
201
- form.concat [:have, :past_participle] if aspect == :perfect
202
- form << :past if [tense, aspect] == [:past, :perfective]
203
- form.concat [:be, :present_participle] if aspect == :progressive
204
- form.concat [:be, 'about to', :infinitive] if aspect == :prospective
205
- form << :present if [tense, aspect] == [:present, :habitual]
206
- form.concat [:be, 'having', :past_participle] if [tense, aspect] == [:present, :perfective]
281
+ if diathesis == :active
282
+ if tense == :future
283
+ form << 'will'
284
+ form << :infinitive if aspect == :habitual
285
+ form.concat ['have', :past_participle] if aspect == :perfect
286
+ form.concat ['be having', :past_participle] if aspect == :perfective
287
+ form.concat ['be', :present_participle] if aspect == :progressive
288
+ form.concat ['be about to', :infinitive] if aspect == :prospective
289
+ else
290
+ form.concat ['used to', :infinitive] if [tense, aspect] == [:past, :habitual]
291
+ form.concat [:have, :past_participle] if aspect == :perfect
292
+ form << :past if [tense, aspect] == [:past, :perfective]
293
+ form.concat [:be, :present_participle] if aspect == :progressive
294
+ form.concat [:be, 'about to', :infinitive] if aspect == :prospective
295
+ form << :present if [tense, aspect] == [:present, :habitual]
296
+ form.concat [:be, 'having', :past_participle] if [tense, aspect] == [:present, :perfective]
297
+ end
298
+ elsif diathesis == :passive
299
+ if tense == :future
300
+ form << 'will'
301
+ form.concat ['be', :past_participle] if aspect == :habitual
302
+ form.concat ['have been', :past_participle] if aspect == :perfect
303
+ form.concat ['be being', :past_participle] if aspect == :progressive
304
+ form.concat ['be about to be', :past_participle] if aspect == :prospective
305
+ else
306
+ form.concat ['used to be', :past_participle] if [tense, aspect] == [:past, :habitual]
307
+ form.concat [:have, 'been', :past_participle] if aspect == :perfect
308
+ form.concat [:be, :past_participle] if [tense, aspect] == [:past, :perfective]
309
+ form.concat [:be, 'being', :past_participle] if aspect == :progressive
310
+ form.concat [:be, 'about to be', :past_participle] if aspect == :prospective
311
+ form.concat [:be, :past_participle] if [tense, aspect] == [:present, :habitual]
312
+ end
207
313
  end
208
314
  form
209
315
  end
210
-
211
- def check_for_improper_constructions(tense, person, mood)
316
+
317
+ # Confirm an imperative mood contains the present tense and second person
318
+ # Params:
319
+ # * tense, an option given by the user
320
+ # * person, how the conjugation refers to the subject
321
+ # * mood, an option given by the user
322
+ # * diathesis, an option given by the user
323
+ def check_for_improper_constructions(infinitive, tense, person, mood, diathesis)
212
324
  if mood == :imperative and not (person == :second and tense == :present)
213
325
  raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'
214
326
  end
327
+ if infinitive.to_sym == :be and diathesis == :passive
328
+ raise Verbs::ImproperConstruction, 'There is no passive diathesis for the copula'
329
+ end
330
+ end
331
+
332
+ def default_aspect(options)
333
+ options[:tense] == :past ? :perfective : :habitual
215
334
  end
216
335
  end
217
336
  end
@@ -4,17 +4,17 @@ module Verbs
4
4
  def initialize(base)
5
5
  @base = base
6
6
  end
7
-
7
+
8
8
  def conjugate(options)
9
9
  words = @base.to_s.split(' ')
10
10
  words.shift if words.first.downcase == 'to'
11
- infinitive = words.shift.to_sym
11
+ infinitive = words.shift.downcase.to_sym
12
12
  conjugation = ::Verbs::Conjugator.conjugate infinitive, options
13
13
  conjugated = words.unshift(conjugation.to_s).join(' ')
14
14
  @base.is_a?(Symbol) ? conjugated.to_sym : conjugated
15
15
  end
16
16
  end
17
-
17
+
18
18
  module Access
19
19
  def verb
20
20
  ::Verbs::Verblike::Wrapper.new self
@@ -1,3 +1,3 @@
1
1
  module Verbs
2
- VERSION = "2.1.4"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -2,16 +2,32 @@ require 'helper'
2
2
 
3
3
  class TestVerbs < Test::Unit::TestCase
4
4
  def test_copular_conjugation
5
+ # present habitual
5
6
  assert_equal 'am', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :first, :plurality => :singular, :aspect => :habitual)
6
7
  assert_equal 'are', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :second, :plurality => :singular, :aspect => :habitual)
7
8
  assert_equal 'is', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
8
9
  assert_equal 'are', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :first, :plurality => :plural, :aspect => :habitual)
9
10
  assert_equal 'are', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :third, :plurality => :plural, :aspect => :habitual)
11
+
12
+ # past
13
+ assert_equal 'was', Verbs::Conjugator.conjugate(:be, :tense => :past)
14
+
15
+ # past habitual
16
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :singular, :aspect => :habitual)
17
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :second, :plurality => :singular, :aspect => :habitual)
18
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :singular, :aspect => :habitual)
19
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :plural, :aspect => :habitual)
20
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :plural, :aspect => :habitual)
21
+
10
22
  assert_equal 'was', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
11
23
  assert_equal 'were', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :second, :plurality => :singular, :aspect => :perfective)
12
24
  assert_equal 'was', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :singular, :aspect => :perfective)
13
25
  assert_equal 'were', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :plural, :aspect => :perfective)
14
26
  assert_equal 'were', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :plural, :aspect => :perfective)
27
+
28
+ assert_equal 'was being', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :aspect => :progressive)
29
+ assert_equal 'is being', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :third, :aspect => :progressive)
30
+ assert_equal 'will be being', Verbs::Conjugator.conjugate(:be, :tense => :future, :person => :third, :aspect => :progressive)
15
31
  end
16
32
  def test_irregular_conjugation
17
33
  assert_equal 'break', Verbs::Conjugator.conjugate(:break, :tense => :present, :person => :first, :plurality => :singular, :aspect => :habitual)
@@ -27,6 +43,7 @@ class TestVerbs < Test::Unit::TestCase
27
43
  assert_equal 'has', Verbs::Conjugator.conjugate(:have, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
28
44
  end
29
45
  def test_know
46
+ assert_equal 'knew', Verbs::Conjugator.conjugate(:know, :tense => :past)
30
47
  assert_equal 'had known', Verbs::Conjugator.conjugate(:know, :tense => :past, :person => :third, :plurality => :singular, :aspect => :perfect)
31
48
  assert_equal 'knew', Verbs::Conjugator.conjugate(:know, :tense => :past, :person => :third, :plurality => :singular, :aspect => :perfective)
32
49
  assert_equal 'was knowing', Verbs::Conjugator.conjugate(:know, :tense => :past, :person => :third, :plurality => :singular, :aspect => :progressive)
@@ -53,8 +70,10 @@ class TestVerbs < Test::Unit::TestCase
53
70
  end
54
71
  def test_regular_conjugation_with_irregular_terminal_consonant
55
72
  assert_equal 'abandoned', Verbs::Conjugator.conjugate(:abandon, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
73
+ assert_equal 'followed', Verbs::Conjugator.conjugate(:follow, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
56
74
  assert_equal 'triggered', Verbs::Conjugator.conjugate(:trigger, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
57
75
  assert_equal 'colored', Verbs::Conjugator.conjugate(:color, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
76
+ assert_equal 'delivered', Verbs::Conjugator.conjugate(:deliver, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
58
77
  end
59
78
  def test_regular_conjugation_with_ean_suffix
60
79
  assert_equal 'cleaned', Verbs::Conjugator.conjugate(:clean, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
@@ -94,10 +113,11 @@ class TestVerbs < Test::Unit::TestCase
94
113
  def test_core_access
95
114
  assert_equal :accepts, :accept.verb.conjugate(:tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
96
115
  assert_equal 'accepts', 'accept'.verb.conjugate(:tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
116
+ assert_equal 'Girl is Near', 'Be Near'.verb.conjugate(:subject => 'Girl')
97
117
  end
98
118
  def test_aspects
99
119
  Verbs::Conjugator.with_options :person => :first, :plurality => :singular, :subject => true do |standard|
100
- assert_equal 'I usually accepted', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
120
+ assert_equal 'I used to accept', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
101
121
  assert_equal 'I had accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
102
122
  assert_equal 'I accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
103
123
  assert_equal 'I was accepting', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
@@ -144,4 +164,57 @@ class TestVerbs < Test::Unit::TestCase
144
164
  assert_equal 'changes', standard.conjugate('change')
145
165
  end
146
166
  end
167
+
168
+ def test_immutability
169
+ verb = 'like'
170
+ Verbs::Conjugator.conjugate(verb, :tense => :past, :aspect => :perfective)
171
+ assert_equal 'like', verb
172
+ end
173
+
174
+ def test_second_person_plural_forms
175
+ Verbs::Conjugator.with_options :person => :second, :plurality => :plural, :subject => true do |standard|
176
+ assert_equal 'You had accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
177
+ assert_equal 'You accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
178
+ assert_equal 'You were accepting', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
179
+ assert_equal 'You were about to accept', standard.conjugate(:accept, :tense => :past, :aspect => :prospective)
180
+ end
181
+ end
182
+
183
+ def test_passive
184
+ Verbs::Conjugator.with_options :diathesis => :passive, :person => :first, :plurality => :singular, :subject => true do |standard|
185
+ assert_equal 'I used to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
186
+ assert_equal 'I had been accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
187
+ assert_equal 'I was accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
188
+ assert_equal 'I was being accepted', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
189
+ assert_equal 'I was about to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :prospective)
190
+ assert_equal 'I am accepted', standard.conjugate(:accept, :tense => :present, :aspect => :habitual)
191
+ assert_equal 'I have been accepted', standard.conjugate(:accept, :tense => :present, :aspect => :perfect)
192
+ assert_equal 'I am being accepted', standard.conjugate(:accept, :tense => :present, :aspect => :progressive)
193
+ assert_equal 'I am about to be accepted', standard.conjugate(:accept, :tense => :present, :aspect => :prospective)
194
+ assert_equal 'I will be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :habitual)
195
+ assert_equal 'I will have been accepted', standard.conjugate(:accept, :tense => :future, :aspect => :perfect)
196
+ assert_equal 'I will be being accepted', standard.conjugate(:accept, :tense => :future, :aspect => :progressive)
197
+ assert_equal 'I will be about to be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :prospective)
198
+ end
199
+
200
+ Verbs::Conjugator.with_options :diathesis => :passive, :person => :third, :plurality => :plural, :subject => true do |standard|
201
+ assert_equal 'They used to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
202
+ assert_equal 'They had been accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
203
+ assert_equal 'They were accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
204
+ assert_equal 'They were being accepted', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
205
+ assert_equal 'They were about to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :prospective)
206
+ assert_equal 'They are accepted', standard.conjugate(:accept, :tense => :present, :aspect => :habitual)
207
+ assert_equal 'They have been accepted', standard.conjugate(:accept, :tense => :present, :aspect => :perfect)
208
+ assert_equal 'They are being accepted', standard.conjugate(:accept, :tense => :present, :aspect => :progressive)
209
+ assert_equal 'They are about to be accepted', standard.conjugate(:accept, :tense => :present, :aspect => :prospective)
210
+ assert_equal 'They will be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :habitual)
211
+ assert_equal 'They will have been accepted', standard.conjugate(:accept, :tense => :future, :aspect => :perfect)
212
+ assert_equal 'They will be being accepted', standard.conjugate(:accept, :tense => :future, :aspect => :progressive)
213
+ assert_equal 'They will be about to be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :prospective)
214
+ end
215
+
216
+ assert_raise Verbs::ImproperConstruction do
217
+ Verbs::Conjugator.conjugate(:be, :diathesis => :passive)
218
+ end
219
+ end
147
220
  end
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_development_dependency 'bueller'
20
+ s.add_development_dependency 'test-unit'
21
+ s.add_development_dependency 'rake'
21
22
  s.add_dependency 'activesupport', '>= 2.3.4'
22
23
  s.add_dependency 'i18n'
23
24
  end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Rossmeissl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bueller
14
+ name: test-unit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
@@ -61,12 +75,12 @@ extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
77
  - ".document"
78
+ - ".github/workflows/ruby.yml"
64
79
  - ".gitignore"
65
80
  - Gemfile
66
81
  - LICENSE
67
82
  - README.rdoc
68
83
  - Rakefile
69
- - VERSION
70
84
  - lib/verbs.rb
71
85
  - lib/verbs/conjugations.rb
72
86
  - lib/verbs/conjugator.rb
@@ -95,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.2.0
112
+ rubygems_version: 3.1.2
100
113
  signing_key:
101
114
  specification_version: 4
102
115
  summary: English verb conjugation in Ruby
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.0.10