verbs 2.2.0 → 2.2.1

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
2
  SHA256:
3
- metadata.gz: 1f3cb83b9097ea8bf2c6535df39c6bec057723e6ba9d9656fea24d07c408669d
4
- data.tar.gz: 843f283457646d40e231aca31596583bf6d6de0aa010475fbc69646b08e4f4f8
3
+ metadata.gz: 46ce7e5cfe62a82289b8c7770e9bf9905106d776c960a309007b41782bf1b6fa
4
+ data.tar.gz: f92d5047b6743da58b2669744fd04e6400e913c2c7221b83f657b8f2f39cef25
5
5
  SHA512:
6
- metadata.gz: ce1045dc949010c62482dc97a5d65964d12779a772855cac9fe504cc7e26b9e735281934926b13306f43dc843cba58bae7088b2548a7211b7416756471d8fdf8
7
- data.tar.gz: 8dc5fb226b59469fb5264210dcc88ed7dad49ed568f02b603299ee8cd0815a161512860a8b4315cd81c9ecea6a918238bc3736c6b8cf7f87d526e0d20183288e
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
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|
@@ -4,11 +4,13 @@ Verbs::Conjugator.conjugations do |conjugate|
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
@@ -21,11 +23,13 @@ Verbs::Conjugator.conjugations do |conjugate|
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
@@ -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,9 +63,15 @@ 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 = {})
38
72
  infinitive = infinitive.dup if infinitive.is_a?(String)
39
73
 
74
+ # set all options according to parameter, or the default
40
75
  tense = options[:tense] || :present # present, past, future
41
76
  person = options[:person] || :third # first, second, third
42
77
  plurality = options[:plurality] || :singular # singular, plural
@@ -44,20 +79,24 @@ module Verbs
44
79
  mood = options[:mood] || :indicative # imperative, subjunctive
45
80
  aspect = options[:aspect] || :habitual # perfective, habitual, progressive, perfect, prospective
46
81
 
47
- check_for_improper_constructions(tense, person, mood)
48
-
49
- form = form_for(tense, aspect)
82
+ check_for_improper_constructions(tense, person, mood) # find incompatabilities
83
+ form = form_for(tense, aspect) # find form array based on tense and aspect
50
84
 
85
+ # map form array to conjugation array, applying infinitive and options to the array
51
86
  conjugation = form.map { |e| resolve e, infinitive, tense, person, plurality, mood }.join(' ').strip
52
87
 
53
- if options[:subject]
54
- 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
55
90
  actor = subject(options).humanize if actor.is_a?(TrueClass)
56
91
  end
57
92
 
58
93
  "#{actor} #{conjugation}".strip
59
94
  end
60
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
61
100
  def subject(options)
62
101
  case [options[:person], options[:plurality]]
63
102
  when [:first, :singular]
@@ -75,6 +114,14 @@ module Verbs
75
114
 
76
115
  private
77
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
78
125
  def resolve(element, infinitive, tense, person, plurality, mood)
79
126
  case element
80
127
  when String
@@ -88,6 +135,13 @@ module Verbs
88
135
  end
89
136
  end
90
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
91
145
  def inflect(infinitive, inflection, person, plurality, mood)
92
146
  send(*([inflection, infinitive, person, plurality, mood][0, method(inflection).arity + 1]))
93
147
  end
@@ -102,6 +156,12 @@ module Verbs
102
156
  end
103
157
  end
104
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
105
165
  def past(infinitive, person, plurality, mood)
106
166
  if verb = conjugations.irregulars[infinitive]
107
167
  conjugate_irregular(verb, :tense => :past, :person => person, :plurality => plurality, :mood => mood)
@@ -110,6 +170,9 @@ module Verbs
110
170
  end
111
171
  end
112
172
 
173
+ # Forming verb to apply present tense endings
174
+ # Params:
175
+ # * infinitive, the given verb
113
176
  def present_participle(infinitive)
114
177
  if infinitive.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(infinitive.to_sym)
115
178
  present_participle_with_doubled_terminal_consonant_for infinitive
@@ -126,6 +189,9 @@ module Verbs
126
189
  end
127
190
  end
128
191
 
192
+ # Forming verb to apply past tense endings
193
+ # Params:
194
+ # * infinitive, the given verb
129
195
  def past_participle(infinitive)
130
196
  if verb = conjugations.irregulars[infinitive]
131
197
  conjugate_irregular(verb, :tense => :past, :derivative => :participle)
@@ -134,6 +200,10 @@ module Verbs
134
200
  end
135
201
  end
136
202
 
203
+ #
204
+ # Params:
205
+ # * verb,
206
+ # * options,
137
207
  def conjugate_irregular(verb, options)
138
208
  return verb[options] if verb[options]
139
209
 
@@ -153,6 +223,9 @@ module Verbs
153
223
  end
154
224
  end
155
225
 
226
+ # Apply thir person rules to the verb for the conjugation
227
+ # Params:
228
+ # * verb, apply proper third person rules to this
156
229
  def present_third_person_singular_form_for(verb)
157
230
  infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
158
231
 
@@ -167,6 +240,9 @@ module Verbs
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
247
  infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
172
248
 
@@ -181,14 +257,24 @@ module Verbs
181
257
  end
182
258
  end
183
259
 
260
+ # Apply proper rules to consonant endings
261
+ # Params:
262
+ # * verb, apply doule consonant to this
184
263
  def regular_preterite_with_doubled_terminal_consonant_for(verb)
185
264
  regular_preterite_for verb.to_s.concat(verb.to_s[-1,1]).to_sym
186
265
  end
187
266
 
267
+ # Apply proper rules to consonant endings
268
+ # Params:
269
+ # * verb, apply doule consonant to this
188
270
  def present_participle_with_doubled_terminal_consonant_for(verb)
189
271
  present_participle verb.to_s.concat(verb.to_s[-1,1]).to_sym
190
272
  end
191
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
192
278
  def form_for(tense, aspect)
193
279
  form = []
194
280
  if tense == :future
@@ -199,7 +285,7 @@ module Verbs
199
285
  form.concat ['be', :present_participle] if aspect == :progressive
200
286
  form.concat ['be about to', :infinitive] if aspect == :prospective
201
287
  else
202
- form.concat ['usually', :past_participle] if [tense, aspect] == [:past, :habitual]
288
+ form.concat ['used to', :infinitive] if [tense, aspect] == [:past, :habitual]
203
289
  form.concat [:have, :past_participle] if aspect == :perfect
204
290
  form << :past if [tense, aspect] == [:past, :perfective]
205
291
  form.concat [:be, :present_participle] if aspect == :progressive
@@ -210,6 +296,11 @@ module Verbs
210
296
  form
211
297
  end
212
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
213
304
  def check_for_improper_constructions(tense, person, mood)
214
305
  if mood == :imperative and not (person == :second and tense == :present)
215
306
  raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'
@@ -1,3 +1,3 @@
1
1
  module Verbs
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -2,11 +2,20 @@ 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)
@@ -103,7 +112,7 @@ class TestVerbs < Test::Unit::TestCase
103
112
  end
104
113
  def test_aspects
105
114
  Verbs::Conjugator.with_options :person => :first, :plurality => :singular, :subject => true do |standard|
106
- 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)
107
116
  assert_equal 'I had accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfect)
108
117
  assert_equal 'I accepted', standard.conjugate(:accept, :tense => :past, :aspect => :perfective)
109
118
  assert_equal 'I was accepting', standard.conjugate(:accept, :tense => :past, :aspect => :progressive)
@@ -156,4 +165,13 @@ class TestVerbs < Test::Unit::TestCase
156
165
  Verbs::Conjugator.conjugate(verb, :tense => :past, :aspect => :perfective)
157
166
  assert_equal 'like', verb
158
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
159
177
  end
@@ -17,8 +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'
21
20
  s.add_development_dependency 'test-unit'
21
+ s.add_development_dependency 'rake'
22
22
  s.add_dependency 'activesupport', '>= 2.3.4'
23
23
  s.add_dependency 'i18n'
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Rossmeissl
@@ -11,7 +11,7 @@ cert_chain: []
11
11
  date: 2020-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bueller
14
+ name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: test-unit
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".document"
78
+ - ".github/workflows/ruby.yml"
78
79
  - ".gitignore"
79
80
  - Gemfile
80
81
  - LICENSE