verbs 2.1.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 46ce7e5cfe62a82289b8c7770e9bf9905106d776c960a309007b41782bf1b6fa
4
+ data.tar.gz: f92d5047b6743da58b2669744fd04e6400e913c2c7221b83f657b8f2f39cef25
5
+ SHA512:
6
+ metadata.gz: aff4a218c912eaa3266f416e79b2de1420179e3c282ef30777d155a84560d83cade09d850a85ae546a8f52f714372cd7a1a2f4daa4140e52c68dd24da757221b
7
+ data.tar.gz: '0798baa0c945dad303ac4c8c569f7a7d30bd55faa50d40f09168983ed4868ea18d214f55dea71a6f81336bec04f64a0b1a6a58eee11bfec8e2d65b11322974fc'
@@ -0,0 +1,33 @@
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
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -47,7 +47,7 @@ Set this to a string to prepend the conjugated verb with it. When set to tru
47
47
 
48
48
  EXAMPLE TENSE ASPECT
49
49
 
50
- I usually accepted past habitual
50
+ I used to accept past habitual
51
51
  I had accepted past perfect
52
52
  I accepted past perfective
53
53
  I was accepting past progressive
@@ -70,7 +70,8 @@ Set this to a string to prepend the conjugated verb with it. When set to tru
70
70
  * {Lingua::Conjugate}[http://cpansearch.perl.org/src/RWG/Lingua-EN-Conjugate-0.308/lib/Lingua/EN/Conjugate.pm]
71
71
  * {Pat Byrd and Tom McKlin}[http://www2.gsu.edu/~wwwesl/egw/pluralsv.htm]
72
72
  * {Rick Harrison}[http://www.rickharrison.com/language/aspect.html]
73
+ * {Anatoli Makarevich}[https://github.com/makaroni4] for {#6}[https://github.com/rossmeissl/verbs/pull/6]
73
74
 
74
75
  == Copyright
75
76
 
76
- Copyright (c) 2009 Andy Rossmeissl. See LICENSE for details.
77
+ 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(tense, person, mood) # find incompatabilities
83
+ form = form_for(tense, aspect) # 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,20 +170,28 @@ 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
185
+ elsif infinitive.to_s.match(/e$/)
186
+ infinitive.to_s[0..-2].concat('ing').to_sym
120
187
  else
121
188
  infinitive.to_s[0..-1].concat('ing').to_sym
122
189
  end
123
190
  end
124
191
 
192
+ # Forming verb to apply past tense endings
193
+ # Params:
194
+ # * infinitive, the given verb
125
195
  def past_participle(infinitive)
126
196
  if verb = conjugations.irregulars[infinitive]
127
197
  conjugate_irregular(verb, :tense => :past, :derivative => :participle)
@@ -130,6 +200,10 @@ module Verbs
130
200
  end
131
201
  end
132
202
 
203
+ #
204
+ # Params:
205
+ # * verb,
206
+ # * options,
133
207
  def conjugate_irregular(verb, options)
134
208
  return verb[options] if verb[options]
135
209
 
@@ -149,30 +223,30 @@ module Verbs
149
223
  end
150
224
  end
151
225
 
226
+ # Apply thir person rules to the verb for the conjugation
227
+ # Params:
228
+ # * verb, apply proper third person rules to this
152
229
  def present_third_person_singular_form_for(verb)
153
- infinitive = case verb
154
- when Verb
155
- verb.infinitive
156
- when String, Symbol
157
- verb.to_sym
158
- end
159
- if infinitive.to_s.match(/#{CONSONANT_PATTERN}y$/)
160
- infinitive.to_s.gsub(/y$/, 'ies').to_sym
161
- elsif infinitive.to_s.match(/[szx]$/) or infinitive.to_s.match(/[sc]h$/)
162
- 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'
163
238
  else
164
- infinitive.to_s.concat('s').to_sym
239
+ infinitive + 's'
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
- infinitive = case verb
170
- when Verb
171
- verb.infinitive
172
- when String, Symbol
173
- verb.to_sym
174
- end
175
- 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)
176
250
  regular_preterite_with_doubled_terminal_consonant_for verb
177
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$/)
178
252
  infinitive.to_s.concat('d').to_sym
@@ -183,14 +257,24 @@ module Verbs
183
257
  end
184
258
  end
185
259
 
260
+ # Apply proper rules to consonant endings
261
+ # Params:
262
+ # * verb, apply doule consonant to this
186
263
  def regular_preterite_with_doubled_terminal_consonant_for(verb)
187
264
  regular_preterite_for verb.to_s.concat(verb.to_s[-1,1]).to_sym
188
265
  end
189
266
 
267
+ # Apply proper rules to consonant endings
268
+ # Params:
269
+ # * verb, apply doule consonant to this
190
270
  def present_participle_with_doubled_terminal_consonant_for(verb)
191
271
  present_participle verb.to_s.concat(verb.to_s[-1,1]).to_sym
192
272
  end
193
273
 
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
194
278
  def form_for(tense, aspect)
195
279
  form = []
196
280
  if tense == :future
@@ -201,7 +285,7 @@ module Verbs
201
285
  form.concat ['be', :present_participle] if aspect == :progressive
202
286
  form.concat ['be about to', :infinitive] if aspect == :prospective
203
287
  else
204
- form.concat ['usually', :past_participle] if [tense, aspect] == [:past, :habitual]
288
+ form.concat ['used to', :infinitive] if [tense, aspect] == [:past, :habitual]
205
289
  form.concat [:have, :past_participle] if aspect == :perfect
206
290
  form << :past if [tense, aspect] == [:past, :perfective]
207
291
  form.concat [:be, :present_participle] if aspect == :progressive
@@ -211,7 +295,12 @@ module Verbs
211
295
  end
212
296
  form
213
297
  end
214
-
298
+
299
+ # Confirm an imperative mood contains the present tense and second person
300
+ # Params:
301
+ # * tense, an option given by the user
302
+ # * person, how the conjugation refers to the subject
303
+ # * mood, an option given by the user
215
304
  def check_for_improper_constructions(tense, person, mood)
216
305
  if mood == :imperative and not (person == :second and tense == :present)
217
306
  raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'
@@ -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.1"
3
- end
1
+ module Verbs
2
+ VERSION = "2.2.1"
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)
@@ -65,6 +82,7 @@ class TestVerbs < Test::Unit::TestCase
65
82
  end
66
83
  def test_regular_conjugation_with_terminal_e
67
84
  assert_equal 'created', Verbs::Conjugator.conjugate(:create, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
85
+ assert_equal 'was hiding', Verbs::Conjugator.conjugate(:hide, :tense => :past, :person => :first, :plurality => :singular, :aspect => :progressive)
68
86
  end
69
87
  def test_regular_conjugation_with_unusual_terminal_e
70
88
  assert_equal 'dyed', Verbs::Conjugator.conjugate(:dye, :tense => :past, :person => :first, :plurality => :singular, :aspect => :perfective)
@@ -75,6 +93,7 @@ class TestVerbs < Test::Unit::TestCase
75
93
  end
76
94
  def test_conjugation_with_terminal_sibilance
77
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)
78
97
  assert_equal 'buzzes', Verbs::Conjugator.conjugate(:buzz, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
79
98
  assert_equal 'coaxes', Verbs::Conjugator.conjugate(:coax, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
80
99
  assert_equal 'washes', Verbs::Conjugator.conjugate(:wash, :tense => :present, :person => :third, :plurality => :singular, :aspect => :habitual)
@@ -93,7 +112,7 @@ class TestVerbs < Test::Unit::TestCase
93
112
  end
94
113
  def test_aspects
95
114
  Verbs::Conjugator.with_options :person => :first, :plurality => :singular, :subject => true do |standard|
96
- 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)
97
116
  assert_equal 'I had accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
98
117
  assert_equal 'I accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
99
118
  assert_equal 'I was accepting', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
@@ -122,4 +141,37 @@ class TestVerbs < Test::Unit::TestCase
122
141
  Verbs::Conjugator.conjugate(:accept, :mood => :imperative)
123
142
  end
124
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
125
177
  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.1
5
- prerelease:
4
+ version: 2.2.1
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-05-25 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,8 +74,9 @@ 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
@@ -86,32 +94,26 @@ files:
86
94
  - verbs.gemspec
87
95
  homepage: http://github.com/rossmeissl/verbs
88
96
  licenses: []
97
+ metadata: {}
89
98
  post_install_message:
90
99
  rdoc_options: []
91
100
  require_paths:
92
101
  - lib
93
102
  required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
103
  requirements:
96
- - - ! '>='
104
+ - - ">="
97
105
  - !ruby/object:Gem::Version
98
106
  version: '0'
99
- segments:
100
- - 0
101
- hash: 856194337
102
107
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
108
  requirements:
105
- - - ! '>='
109
+ - - ">="
106
110
  - !ruby/object:Gem::Version
107
111
  version: '0'
108
- segments:
109
- - 0
110
- hash: 856194337
111
112
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 1.8.24
113
+ rubygems_version: 3.0.1
114
114
  signing_key:
115
- specification_version: 3
115
+ specification_version: 4
116
116
  summary: English verb conjugation in Ruby
117
- test_files: []
117
+ test_files:
118
+ - test/helper.rb
119
+ - test/test_verbs.rb