verbs 2.1.2 → 2.3.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 39ca9a05484aea9907d487a1fd2d6c51bbe969040ae748411640076ae9cb4b50
4
+ data.tar.gz: fd81415cc5cad33a4ae06c1e7b45d26edb64bfc94acbf2fc2c0e29f576a228c1
5
+ SHA512:
6
+ metadata.gz: 81bc1a48d71745e5443985abc0a7bb14c9e5548820eb1fa8c6455d81a14baa2928009a07a00e4d6561fac7afdfa3ba313b1e610a8af14e949c505fa6ec7f27cf
7
+ data.tar.gz: c16c9318396e3edf0f9b13c78f8c9e84e35bed61bc9fd05714e9009022e2df79c59b1d5057cbeafd22a8bda172c9292d15a35773e2b281f0753cc68c6552f66f
@@ -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
@@ -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
@@ -70,7 +74,9 @@ Set this to a string to prepend the conjugated verb with it. When set to <tt>tru
70
74
  * {Lingua::Conjugate}[http://cpansearch.perl.org/src/RWG/Lingua-EN-Conjugate-0.308/lib/Lingua/EN/Conjugate.pm]
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]
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]
73
79
 
74
80
  == Copyright
75
81
 
76
- Copyright (c) 2009 Andy Rossmeissl. See LICENSE for details.
82
+ Copyright (c) 2012 Andy Rossmeissl. See LICENSE for details.
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|
@@ -10,7 +10,7 @@ require 'verbs/improper_construction'
10
10
  module Verbs
11
11
  CONSONANTS = %w(b c d f g h j k l m n p q r s t v w x z)
12
12
  CONSONANT_PATTERN = "[#{CONSONANTS.join}]"
13
- DOUBLED_CONSONANTS = %w(b c d f g h j k l m n p q r s t w z)
13
+ DOUBLED_CONSONANTS = %w(b c d f g h j k l m n p q r s t z)
14
14
  DOUBLED_CONSONANT_PATTERN = "[#{DOUBLED_CONSONANTS.join}]"
15
15
  VOWELS = %w(a e i o u y)
16
16
  VOWEL_PATTERN = "[#{VOWELS.join}]"
@@ -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
@@ -128,6 +132,7 @@ Verbs::Conjugator.conjugations do |conjugate|
128
132
  conjugate.irregular :put, :put, :put
129
133
  conjugate.irregular :quit, :quit, :quit
130
134
  conjugate.irregular :read, :read, :read
135
+ conjugate.irregular :reset, :reset, :reset
131
136
  conjugate.irregular :rid, :rid, :rid
132
137
  conjugate.irregular :ride, :rode, :ridden
133
138
  conjugate.irregular :ring, :rang, :rung
@@ -181,7 +186,7 @@ Verbs::Conjugator.conjugations do |conjugate|
181
186
  conjugate.irregular :strive, :strove, :striven
182
187
  conjugate.irregular :swear, :swore, :sworn
183
188
  conjugate.irregular :sweep, :swept, :swept
184
- conjugate.irregular :swell, :swelled, :swelled
189
+ conjugate.irregular :swell, :swelled, :swelled
185
190
  conjugate.irregular :swim, :swam, :swum
186
191
  conjugate.irregular :swing, :swung, :swung
187
192
  conjugate.irregular :take, :took, :taken
@@ -198,7 +203,7 @@ Verbs::Conjugator.conjugations do |conjugate|
198
203
  conjugate.irregular :upset, :upset, :upset
199
204
  conjugate.irregular :wake, :woke, :woken
200
205
  conjugate.irregular :wear, :wore, :worn
201
- conjugate.irregular :weave, :weaved, :weaved
206
+ conjugate.irregular :weave, :wove, :woven
202
207
  conjugate.irregular :wed, :wed, :wed
203
208
  conjugate.irregular :weep, :wept, :wept
204
209
  conjugate.irregular :wind, :wound, :wound
@@ -250,6 +255,7 @@ Verbs::Conjugator.conjugations do |conjugate|
250
255
  conjugate.single_terminal_consonant :cocker
251
256
  conjugate.single_terminal_consonant :coedit
252
257
  conjugate.single_terminal_consonant :cohabit
258
+ conjugate.single_terminal_consonant :color
253
259
  conjugate.single_terminal_consonant :concenter
254
260
  conjugate.single_terminal_consonant :corner
255
261
  conjugate.single_terminal_consonant :cover
@@ -262,6 +268,7 @@ Verbs::Conjugator.conjugations do |conjugate|
262
268
  conjugate.single_terminal_consonant :decipher
263
269
  conjugate.single_terminal_consonant :deflower
264
270
  conjugate.single_terminal_consonant :delimit
271
+ conjugate.single_terminal_consonant :deliver
265
272
  conjugate.single_terminal_consonant :deposit
266
273
  conjugate.single_terminal_consonant :develop
267
274
  conjugate.single_terminal_consonant :differ
@@ -307,6 +314,7 @@ Verbs::Conjugator.conjugations do |conjugate|
307
314
  conjugate.single_terminal_consonant :flounder
308
315
  conjugate.single_terminal_consonant :fluster
309
316
  conjugate.single_terminal_consonant :flutter
317
+ conjugate.single_terminal_consonant :follow
310
318
  conjugate.single_terminal_consonant :foreshorten
311
319
  conjugate.single_terminal_consonant :founder
312
320
  conjugate.single_terminal_consonant :fritter
@@ -427,6 +435,7 @@ Verbs::Conjugator.conjugations do |conjugate|
427
435
  conjugate.single_terminal_consonant :toughen
428
436
  conjugate.single_terminal_consonant :tower
429
437
  conjugate.single_terminal_consonant :transit
438
+ conjugate.single_terminal_consonant :trigger
430
439
  conjugate.single_terminal_consonant :tucker
431
440
  conjugate.single_terminal_consonant :unburden
432
441
  conjugate.single_terminal_consonant :uncover
@@ -1,31 +1,60 @@
1
+ # The program conjugates most common english verbs with the following option:
2
+ # * :tense => :past or :present or :future
3
+ # * :person => :first or :second or :third
4
+ # * :plurality => :singular or :plural
5
+ # * :aspect => :habitual or :perfect or :perfective or :progressive or :prospective
6
+ # * :mood => :indicative or :imperative or :subjunctive
7
+ # Respective defaults are :present, :third, :singular, :habitual, and :indicative
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
80
  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)
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,30 +223,30 @@ 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
- infinitive = case verb
156
- when Verb
157
- verb.infinitive
158
- when String, Symbol
159
- verb.to_sym
160
- end
161
- if infinitive.to_s.match(/#{CONSONANT_PATTERN}y$/)
162
- infinitive.to_s.gsub(/y$/, 'ies').to_sym
163
- elsif infinitive.to_s.match(/[szx]$/) or infinitive.to_s.match(/[sc]h$/)
164
- infinitive.to_s.concat('es').to_sym
230
+ infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
231
+
232
+ if infinitive =~ /[a-z&&#{CONSONANT_PATTERN}]y$/i
233
+ infinitive[0..-2] + 'ies'
234
+ elsif infinitive =~ /(ss|sh|t?ch|zz|x|#{CONSONANT_PATTERN}o)$/i
235
+ infinitive + 'es'
236
+ elsif infinitive =~ /[^s]s$/i
237
+ infinitive + 'ses'
165
238
  else
166
- infinitive.to_s.concat('s').to_sym
239
+ infinitive + 's'
167
240
  end
168
241
  end
169
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
170
246
  def regular_preterite_for(verb)
171
- infinitive = case verb
172
- when Verb
173
- verb.infinitive
174
- when String, Symbol
175
- verb.to_sym
176
- end
177
- if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(verb)
247
+ infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
248
+
249
+ if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(verb.to_sym)
178
250
  regular_preterite_with_doubled_terminal_consonant_for verb
179
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$/)
180
252
  infinitive.to_s.concat('d').to_sym
@@ -185,39 +257,76 @@ module Verbs
185
257
  end
186
258
  end
187
259
 
260
+ # Apply proper rules to consonant endings
261
+ # Params:
262
+ # * verb, apply doule consonant to this
188
263
  def regular_preterite_with_doubled_terminal_consonant_for(verb)
189
264
  regular_preterite_for verb.to_s.concat(verb.to_s[-1,1]).to_sym
190
265
  end
191
266
 
267
+ # Apply proper rules to consonant endings
268
+ # Params:
269
+ # * verb, apply doule consonant to this
192
270
  def present_participle_with_doubled_terminal_consonant_for(verb)
193
271
  present_participle verb.to_s.concat(verb.to_s[-1,1]).to_sym
194
272
  end
195
273
 
196
- 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)
197
280
  form = []
198
- if tense == :future
199
- form << 'will'
200
- form << :infinitive if aspect == :habitual
201
- form.concat ['have', :past_participle] if aspect == :perfect
202
- form.concat ['be having', :past_participle] if aspect == :perfective
203
- form.concat ['be', :present_participle] if aspect == :progressive
204
- form.concat ['be about to', :infinitive] if aspect == :prospective
205
- else
206
- form.concat ['usually', :past_participle] if [tense, aspect] == [:past, :habitual]
207
- form.concat [:have, :past_participle] if aspect == :perfect
208
- form << :past if [tense, aspect] == [:past, :perfective]
209
- form.concat [:be, :present_participle] if aspect == :progressive
210
- form.concat [:be, 'about to', :infinitive] if aspect == :prospective
211
- form << :present if [tense, aspect] == [:present, :habitual]
212
- 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
213
313
  end
214
314
  form
215
315
  end
216
-
217
- 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)
218
324
  if mood == :imperative and not (person == :second and tense == :present)
219
325
  raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'
220
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
221
330
  end
222
331
  end
223
332
  end
@@ -1,32 +1,32 @@
1
- module Verbs
2
- module Verblike
3
- class Wrapper
4
- def initialize(base)
5
- @base = base
6
- end
7
-
8
- def conjugate(options)
9
- words = @base.to_s.split(' ')
10
- words.shift if words.first.downcase == 'to'
11
- infinitive = words.shift.to_sym
12
- conjugation = ::Verbs::Conjugator.conjugate infinitive, options
13
- conjugated = words.unshift(conjugation.to_s).join(' ')
14
- @base.is_a?(Symbol) ? conjugated.to_sym : conjugated
15
- end
16
- end
17
-
18
- module Access
19
- def verb
20
- ::Verbs::Verblike::Wrapper.new self
21
- end
22
- end
23
- end
24
- end
25
-
26
- class String
27
- include ::Verbs::Verblike::Access
28
- end
29
-
30
- class Symbol
31
- include ::Verbs::Verblike::Access
32
- end
1
+ module Verbs
2
+ module Verblike
3
+ class Wrapper
4
+ def initialize(base)
5
+ @base = base
6
+ end
7
+
8
+ def conjugate(options)
9
+ words = @base.to_s.split(' ')
10
+ words.shift if words.first.downcase == 'to'
11
+ infinitive = words.shift.to_sym
12
+ conjugation = ::Verbs::Conjugator.conjugate infinitive, options
13
+ conjugated = words.unshift(conjugation.to_s).join(' ')
14
+ @base.is_a?(Symbol) ? conjugated.to_sym : conjugated
15
+ end
16
+ end
17
+
18
+ module Access
19
+ def verb
20
+ ::Verbs::Verblike::Wrapper.new self
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ class String
27
+ include ::Verbs::Verblike::Access
28
+ end
29
+
30
+ class Symbol
31
+ include ::Verbs::Verblike::Access
32
+ end
@@ -1,3 +1,3 @@
1
- module Verbs
2
- VERSION = "2.1.2"
3
- end
1
+ module Verbs
2
+ VERSION = "2.3.0"
3
+ end
@@ -2,16 +2,29 @@ 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 habitual
13
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :singular, :aspect => :habitual)
14
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :second, :plurality => :singular, :aspect => :habitual)
15
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :singular, :aspect => :habitual)
16
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :plural, :aspect => :habitual)
17
+ assert_equal 'used to be', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :plural, :aspect => :habitual)
18
+
10
19
  assert_equal 'was', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
11
20
  assert_equal 'were', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :second, :plurality => :singular, :aspect => :perfective)
12
21
  assert_equal 'was', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :singular, :aspect => :perfective)
13
22
  assert_equal 'were', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :first, :plurality => :plural, :aspect => :perfective)
14
23
  assert_equal 'were', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :plurality => :plural, :aspect => :perfective)
24
+
25
+ assert_equal 'was being', Verbs::Conjugator.conjugate(:be, :tense => :past, :person => :third, :aspect => :progressive)
26
+ assert_equal 'is being', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :third, :aspect => :progressive)
27
+ assert_equal 'will be being', Verbs::Conjugator.conjugate(:be, :tense => :future, :person => :third, :aspect => :progressive)
15
28
  end
16
29
  def test_irregular_conjugation
17
30
  assert_equal 'break', Verbs::Conjugator.conjugate(:break, :tense => :present, :person => :first, :plurality => :singular, :aspect => :habitual)
@@ -53,6 +66,10 @@ class TestVerbs < Test::Unit::TestCase
53
66
  end
54
67
  def test_regular_conjugation_with_irregular_terminal_consonant
55
68
  assert_equal 'abandoned', Verbs::Conjugator.conjugate(:abandon, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
69
+ assert_equal 'followed', Verbs::Conjugator.conjugate(:follow, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
70
+ assert_equal 'triggered', Verbs::Conjugator.conjugate(:trigger, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
71
+ assert_equal 'colored', Verbs::Conjugator.conjugate(:color, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
72
+ assert_equal 'delivered', Verbs::Conjugator.conjugate(:deliver, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
56
73
  end
57
74
  def test_regular_conjugation_with_ean_suffix
58
75
  assert_equal 'cleaned', Verbs::Conjugator.conjugate(:clean, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
@@ -76,6 +93,7 @@ class TestVerbs < Test::Unit::TestCase
76
93
  end
77
94
  def test_conjugation_with_terminal_sibilance
78
95
  assert_equal 'passes', Verbs::Conjugator.conjugate(:pass, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
96
+ assert_equal 'focusses', Verbs::Conjugator.conjugate(:focus, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
79
97
  assert_equal 'buzzes', Verbs::Conjugator.conjugate(:buzz, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
80
98
  assert_equal 'coaxes', Verbs::Conjugator.conjugate(:coax, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
81
99
  assert_equal 'washes', Verbs::Conjugator.conjugate(:wash, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
@@ -94,7 +112,7 @@ class TestVerbs < Test::Unit::TestCase
94
112
  end
95
113
  def test_aspects
96
114
  Verbs::Conjugator.with_options :person => :first, :plurality => :singular, :subject => true do |standard|
97
- assert_equal 'I usually accepted', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
115
+ assert_equal 'I used to accept', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
98
116
  assert_equal 'I had accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
99
117
  assert_equal 'I accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
100
118
  assert_equal 'I was accepting', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
@@ -123,4 +141,75 @@ class TestVerbs < Test::Unit::TestCase
123
141
  Verbs::Conjugator.conjugate(:accept, :mood => :imperative)
124
142
  end
125
143
  end
144
+
145
+ def test_s_forms
146
+ Verbs::Conjugator.with_options :person => :third, :tense => :present do |standard|
147
+ assert_equal 'does', standard.conjugate('do')
148
+ assert_equal 'flies', standard.conjugate('fly')
149
+ assert_equal 'assesses', standard.conjugate('assess')
150
+ assert_equal 'blushes', standard.conjugate('blush')
151
+ assert_equal 'catches', standard.conjugate('catch')
152
+ assert_equal 'fizzes', standard.conjugate('fizz')
153
+ assert_equal 'relaxes', standard.conjugate('relax')
154
+ assert_equal 'bakes', standard.conjugate('bake')
155
+ assert_equal 'calls', standard.conjugate('call')
156
+ assert_equal 'dies', standard.conjugate('die')
157
+ assert_equal 'glues', standard.conjugate('glue')
158
+ assert_equal 'moos', standard.conjugate('moo')
159
+ assert_equal 'changes', standard.conjugate('change')
160
+ end
161
+ end
162
+
163
+ def test_immutability
164
+ verb = 'like'
165
+ Verbs::Conjugator.conjugate(verb, :tense => :past, :aspect => :perfective)
166
+ assert_equal 'like', verb
167
+ end
168
+
169
+ def test_second_person_plural_forms
170
+ Verbs::Conjugator.with_options :person => :second, :plurality => :plural, :subject => true do |standard|
171
+ assert_equal 'You had accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
172
+ assert_equal 'You accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
173
+ assert_equal 'You were accepting', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
174
+ assert_equal 'You were about to accept', standard.conjugate(:accept, :tense => :past, :aspect => :prospective)
175
+ end
176
+ end
177
+
178
+ def test_passive
179
+ Verbs::Conjugator.with_options :diathesis => :passive, :person => :first, :plurality => :singular, :subject => true do |standard|
180
+ assert_equal 'I used to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
181
+ assert_equal 'I had been accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
182
+ assert_equal 'I was accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
183
+ assert_equal 'I was being accepted', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
184
+ assert_equal 'I was about to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :prospective)
185
+ assert_equal 'I am accepted', standard.conjugate(:accept, :tense => :present, :aspect => :habitual)
186
+ assert_equal 'I have been accepted', standard.conjugate(:accept, :tense => :present, :aspect => :perfect)
187
+ assert_equal 'I am being accepted', standard.conjugate(:accept, :tense => :present, :aspect => :progressive)
188
+ assert_equal 'I am about to be accepted', standard.conjugate(:accept, :tense => :present, :aspect => :prospective)
189
+ assert_equal 'I will be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :habitual)
190
+ assert_equal 'I will have been accepted', standard.conjugate(:accept, :tense => :future, :aspect => :perfect)
191
+ assert_equal 'I will be being accepted', standard.conjugate(:accept, :tense => :future, :aspect => :progressive)
192
+ assert_equal 'I will be about to be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :prospective)
193
+ end
194
+
195
+ Verbs::Conjugator.with_options :diathesis => :passive, :person => :third, :plurality => :plural, :subject => true do |standard|
196
+ assert_equal 'They used to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :habitual)
197
+ assert_equal 'They had been accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
198
+ assert_equal 'They were accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
199
+ assert_equal 'They were being accepted', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
200
+ assert_equal 'They were about to be accepted', standard.conjugate(:accept, :tense => :past, :aspect => :prospective)
201
+ assert_equal 'They are accepted', standard.conjugate(:accept, :tense => :present, :aspect => :habitual)
202
+ assert_equal 'They have been accepted', standard.conjugate(:accept, :tense => :present, :aspect => :perfect)
203
+ assert_equal 'They are being accepted', standard.conjugate(:accept, :tense => :present, :aspect => :progressive)
204
+ assert_equal 'They are about to be accepted', standard.conjugate(:accept, :tense => :present, :aspect => :prospective)
205
+ assert_equal 'They will be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :habitual)
206
+ assert_equal 'They will have been accepted', standard.conjugate(:accept, :tense => :future, :aspect => :perfect)
207
+ assert_equal 'They will be being accepted', standard.conjugate(:accept, :tense => :future, :aspect => :progressive)
208
+ assert_equal 'They will be about to be accepted', standard.conjugate(:accept, :tense => :future, :aspect => :prospective)
209
+ end
210
+
211
+ assert_raise Verbs::ImproperConstruction do
212
+ Verbs::Conjugator.conjugate(:be, :diathesis => :passive)
213
+ end
214
+ end
126
215
  end
@@ -1,24 +1,25 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "verbs/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'verbs'
7
- s.version = Verbs::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Andy Rossmeissl"]
10
- s.description = %q{Conjugates most common english verbs for all persons, tenses, standard aspects, and modern moods (with active diathesis). Standard and exceptional spelling rules are obeyed.}
11
- s.summary = %q{English verb conjugation in Ruby}
12
- s.email = %q{andy@rossmeissl.net}
13
- s.homepage = %q{http://github.com/rossmeissl/verbs}
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
-
20
- s.add_development_dependency 'bueller'
21
- s.add_dependency 'activesupport', '>= 2.3.4'
22
- s.add_dependency 'i18n'
23
- end
24
-
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "verbs/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'verbs'
7
+ s.version = Verbs::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Andy Rossmeissl"]
10
+ s.description = %q{Conjugates most common english verbs for all persons, tenses, standard aspects, and modern moods (with active diathesis). Standard and exceptional spelling rules are obeyed.}
11
+ s.summary = %q{English verb conjugation in Ruby}
12
+ s.email = %q{andy@rossmeissl.net}
13
+ s.homepage = %q{http://github.com/rossmeissl/verbs}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_development_dependency 'test-unit'
21
+ s.add_development_dependency 'rake'
22
+ s.add_dependency 'activesupport', '>= 2.3.4'
23
+ s.add_dependency 'i18n'
24
+ end
25
+
metadata CHANGED
@@ -1,62 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
5
- prerelease:
4
+ version: 2.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andy Rossmeissl
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: bueller
14
+ name: test-unit
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
28
39
  - !ruby/object:Gem::Version
29
40
  version: '0'
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: activesupport
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ! '>='
45
+ - - ">="
36
46
  - !ruby/object:Gem::Version
37
47
  version: 2.3.4
38
48
  type: :runtime
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ! '>='
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: 2.3.4
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: i18n
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
61
  version: '0'
54
62
  type: :runtime
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  description: Conjugates most common english verbs for all persons, tenses, standard
@@ -67,13 +74,13 @@ executables: []
67
74
  extensions: []
68
75
  extra_rdoc_files: []
69
76
  files:
70
- - .document
71
- - .gitignore
77
+ - ".document"
78
+ - ".github/workflows/ruby.yml"
79
+ - ".gitignore"
72
80
  - Gemfile
73
81
  - LICENSE
74
82
  - README.rdoc
75
83
  - Rakefile
76
- - VERSION
77
84
  - lib/verbs.rb
78
85
  - lib/verbs/conjugations.rb
79
86
  - lib/verbs/conjugator.rb
@@ -86,32 +93,26 @@ files:
86
93
  - verbs.gemspec
87
94
  homepage: http://github.com/rossmeissl/verbs
88
95
  licenses: []
96
+ metadata: {}
89
97
  post_install_message:
90
98
  rdoc_options: []
91
99
  require_paths:
92
100
  - lib
93
101
  required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
102
  requirements:
96
- - - ! '>='
103
+ - - ">="
97
104
  - !ruby/object:Gem::Version
98
105
  version: '0'
99
- segments:
100
- - 0
101
- hash: -499867661
102
106
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
107
  requirements:
105
- - - ! '>='
108
+ - - ">="
106
109
  - !ruby/object:Gem::Version
107
110
  version: '0'
108
- segments:
109
- - 0
110
- hash: -499867661
111
111
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 1.8.24
112
+ rubygems_version: 3.1.2
114
113
  signing_key:
115
- specification_version: 3
114
+ specification_version: 4
116
115
  summary: English verb conjugation in Ruby
117
- test_files: []
116
+ test_files:
117
+ - test/helper.rb
118
+ - test/test_verbs.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.0.10