verbs 2.0.10 → 2.1.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,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -1,6 +1,6 @@
1
1
  = verbs
2
2
 
3
- Conjugates most common english verbs for all persons in all tenses and all standard aspects (with active diathesis and indicative mood). Standard and exceptional spelling rules are obeyed.
3
+ Conjugates most common english verbs for all persons, tenses, standard aspects, and modern moods (with active diathesis). Standard and exceptional spelling rules are obeyed.
4
4
 
5
5
  >> Verbs::Conjugator.conjugate :be, :tense => :past, :person => :second, :plurality => :singular, :aspect => :perfective
6
6
  => :were
@@ -9,7 +9,6 @@ Conjugates most common english verbs for all persons in all tenses and all stand
9
9
  >> :sleep.verb.conjugate :tense => :future, :person => :first, :plurality => :singular, :aspect => :progressive, :subject => true
10
10
  => :"I will be sleeping"
11
11
 
12
-
13
12
  == Installation
14
13
 
15
14
  The gem is hosted at http://gemcutter.org/gems/verbs
@@ -38,6 +37,10 @@ One of <tt>:habitual</tt>, <tt>:perfect</tt>, <tt>:perfective</tt>, <tt>:progres
38
37
 
39
38
  See below for a guide to verb aspect.
40
39
 
40
+ === <tt>:mood</tt>
41
+
42
+ One of <tt>:indicative</tt>, <tt>:imperative</tt>, or <tt>:subjunctive</tt>. Defaults to <tt>:indicative</tt>.
43
+
41
44
  === <tt>:subject</tt>
42
45
 
43
46
  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.
data/Rakefile CHANGED
@@ -1,53 +1,27 @@
1
1
  require 'rubygems'
2
- require 'rake'
3
2
 
4
3
  begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "verbs"
8
- gem.summary = %Q{English verb conjugation in Ruby}
9
- gem.description = %Q{Conjugates most common english verbs for all persons in all tenses and all standard aspects (with active diathesis and indicative mood). Standard and exceptional spelling rules are obeyed.}
10
- gem.email = "andy@rossmeissl.net"
11
- gem.homepage = "http://github.com/rossmeissl/verbs"
12
- gem.authors = ["Andy Rossmeissl"]
13
- gem.add_dependency 'activesupport', '>=2.3.4'
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
4
+ require 'bundler'
17
5
  rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
6
+ $stderr.puts "You must install bundler - run `gem install bundler`"
7
+ end
8
+
9
+ begin
10
+ Bundler.setup
11
+ rescue Bundler::BundlerError => e
12
+ $stderr.puts e.message
13
+ $stderr.puts "Run `bundle install` to install missing gems"
14
+ exit e.status_code
19
15
  end
20
16
 
17
+ require 'bueller'
18
+ Bueller::Tasks.new
19
+
20
+ require 'rake'
21
21
  require 'rake/testtask'
22
22
  Rake::TestTask.new(:test) do |test|
23
23
  test.libs << 'lib' << 'test'
24
24
  test.pattern = 'test/**/test_*.rb'
25
25
  test.verbose = true
26
26
  end
27
-
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
- task :test => :check_dependencies
42
-
43
27
  task :default => :test
44
-
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
-
49
- rdoc.rdoc_dir = 'rdoc'
50
- rdoc.title = "verbs #{version}"
51
- rdoc.rdoc_files.include('README*')
52
- rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
@@ -5,6 +5,7 @@ require 'verbs/verb'
5
5
  require 'verbs/conjugator'
6
6
  require 'verbs/conjugations'
7
7
  require 'verbs/verblike'
8
+ require 'verbs/improper_construction'
8
9
 
9
10
  module Verbs
10
11
  CONSONANTS = %w(b c d f g h j k l m n p q r s t v w x z)
@@ -11,6 +11,8 @@ Verbs::Conjugator.conjugations do |conjugate|
11
11
  verb.form :were, :tense => :past, :person => :second, :plurality => :singular
12
12
  verb.form :were, :tense => :past, :person => :first, :plurality => :plural
13
13
  verb.form :were, :tense => :past, :person => :third, :plurality => :plural
14
+ verb.form :were, :tense => :past, :mood => :subjunctive
15
+ verb.form :be, :tense => :present, :mood => :subjunctive
14
16
  verb.form :being, :tense => :present, :derivative => :participle
15
17
  verb.form :been, :tense => :past, :derivative => :participle
16
18
  end
@@ -39,12 +39,14 @@ module Verbs
39
39
  person = options[:person] || :third # first, second, third
40
40
  plurality = options[:plurality] || :singular # singular, plural
41
41
  diathesis = options[:diathesis] || :active # active, passive
42
- mood = options[:mood] || :indicative # conditional, imperative, indicative, injunctive, optative, potential, subjunctive
42
+ mood = options[:mood] || :indicative # imperative, subjunctive
43
43
  aspect = options[:aspect] || :habitual # perfective, habitual, progressive, perfect, prospective
44
-
44
+
45
+ check_for_improper_constructions(tense, person, mood)
46
+
45
47
  form = form_for(tense, aspect)
46
48
 
47
- conjugation = form.map { |e| resolve e, infinitive, tense, person, plurality }.join(' ').strip
49
+ conjugation = form.map { |e| resolve e, infinitive, tense, person, plurality, mood }.join(' ').strip
48
50
 
49
51
  if options[:subject]
50
52
  actor = options.delete(:subject)
@@ -71,36 +73,36 @@ module Verbs
71
73
 
72
74
  private
73
75
 
74
- def resolve(element, infinitive, tense, person, plurality)
76
+ def resolve(element, infinitive, tense, person, plurality, mood)
75
77
  case element
76
78
  when String
77
79
  element
78
80
  when :infinitive
79
81
  infinitive
80
82
  when :present, :past, :present_participle, :past_participle
81
- inflect infinitive, element, person, plurality
83
+ inflect infinitive, element, person, plurality, mood
82
84
  when Symbol
83
- inflect element, tense, person, plurality
85
+ inflect element, tense, person, plurality, mood
84
86
  end
85
87
  end
86
88
 
87
- def inflect(infinitive, inflection, person, plurality)
88
- send(*([inflection, infinitive, person, plurality][0, method(inflection).arity + 1]))
89
+ def inflect(infinitive, inflection, person, plurality, mood)
90
+ send(*([inflection, infinitive, person, plurality, mood][0, method(inflection).arity + 1]))
89
91
  end
90
92
 
91
- def present(infinitive, person, plurality)
93
+ def present(infinitive, person, plurality, mood)
92
94
  if verb = conjugations.irregulars[infinitive]
93
- conjugate_irregular(verb, :tense => :present, :person => person, :plurality => plurality)
94
- elsif person == :third and plurality == :singular
95
+ conjugate_irregular(verb, :tense => :present, :person => person, :plurality => plurality, :mood => mood)
96
+ elsif person == :third and plurality == :singular and not mood == :subjunctive
95
97
  present_third_person_singular_form_for infinitive
96
98
  else
97
99
  infinitive
98
100
  end
99
101
  end
100
102
 
101
- def past(infinitive, person, plurality)
103
+ def past(infinitive, person, plurality, mood)
102
104
  if verb = conjugations.irregulars[infinitive]
103
- conjugate_irregular(verb, :tense => :past, :person => person, :plurality => plurality)
105
+ conjugate_irregular(verb, :tense => :past, :person => person, :plurality => plurality, :mood => mood)
104
106
  else
105
107
  regular_preterite_for infinitive
106
108
  end
@@ -209,5 +211,11 @@ module Verbs
209
211
  end
210
212
  form
211
213
  end
214
+
215
+ def check_for_improper_constructions(tense, person, mood)
216
+ if mood == :imperative and not (person == :second and tense == :present)
217
+ raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'
218
+ end
219
+ end
212
220
  end
213
221
  end
@@ -0,0 +1,4 @@
1
+ module Verbs
2
+ class ImproperConstruction < ArgumentError;
3
+ end
4
+ end
@@ -14,7 +14,7 @@ module Verbs
14
14
  end
15
15
 
16
16
  def form(word, options = {})
17
- raise ArgumentError, 'Irregular verb specifications must identify tense and must identify either derivative or person and plurality' unless options[:tense] and (options[:derivative] or (options[:person] and options[:plurality]))
17
+ raise ArgumentError, 'Irregular verb specifications must identify tense and must identify either derivative, mood, or person and plurality' unless options[:tense] and (options[:derivative] or options[:mood] or (options[:person] and options[:plurality]))
18
18
 
19
19
  tense = options[:tense]
20
20
 
@@ -22,6 +22,8 @@ module Verbs
22
22
  @forms[:past] ||= {}
23
23
  if derivative = options[:derivative]
24
24
  @forms[tense][derivative] = word
25
+ elsif mood = options[:mood]
26
+ @forms[tense][mood] = word
25
27
  elsif person = options[:person]
26
28
  @forms[tense][person] ||= {}
27
29
  @forms[tense][person][options[:plurality]] = word
@@ -29,9 +31,9 @@ module Verbs
29
31
  end
30
32
 
31
33
  def [](options = {})
32
- tense, person, plurality, derivative = options[:tense], options[:person], options[:plurality], options[:derivative]
33
- if tense and person and plurality
34
- @forms[tense].try(:[], person).try(:[], plurality)
34
+ tense, person, plurality, derivative, mood = options[:tense], options[:person], options[:plurality], options[:derivative], options[:mood]
35
+ if tense and person and plurality and mood
36
+ @forms[tense].try(:[], mood) || @forms[tense].try(:[], person).try(:[], plurality)
35
37
  elsif tense and derivative
36
38
  @forms[tense].try(:[], derivative)
37
39
  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
@@ -0,0 +1,3 @@
1
+ module Verbs
2
+ VERSION = "2.1.0"
3
+ end
@@ -105,4 +105,16 @@ class TestVerbs < Test::Unit::TestCase
105
105
  assert_equal 'I will be about to accept', standard.conjugate(:accept, :tense => :future, :aspect => :prospective)
106
106
  end
107
107
  end
108
+ def test_mood
109
+ assert_equal Verbs::Conjugator.conjugate(:accept, :person => :third), Verbs::Conjugator.conjugate(:accept, :person => :third, :mood => :indicative)
110
+ assert_equal 'accept', Verbs::Conjugator.conjugate(:accept, :person => :third, :mood => :subjunctive)
111
+ assert_equal 'be', Verbs::Conjugator.conjugate(:be, :mood => :subjunctive, :tense => :present)
112
+ assert_equal 'were', Verbs::Conjugator.conjugate(:be, :mood => :subjunctive, :tense => :past, :aspect => :perfective)
113
+ assert_equal 'accept', Verbs::Conjugator.conjugate(:accept, :person => :second, :mood => :imperative)
114
+ end
115
+ def test_improper_construction
116
+ assert_raise Verbs::ImproperConstruction do
117
+ Verbs::Conjugator.conjugate(:accept, :mood => :imperative)
118
+ end
119
+ end
108
120
  end
@@ -1,51 +1,23 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{verbs}
8
- s.version = "2.0.10"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Andy Rossmeissl"]
12
- s.date = %q{2011-06-09}
13
- s.description = %q{Conjugates most common english verbs for all persons in all tenses and all standard aspects (with active diathesis and indicative mood). Standard and exceptional spelling rules are obeyed.}
14
- s.email = %q{andy@rossmeissl.net}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "lib/verbs.rb",
26
- "lib/verbs/conjugations.rb",
27
- "lib/verbs/conjugator.rb",
28
- "lib/verbs/verb.rb",
29
- "lib/verbs/verblike.rb",
30
- "test/helper.rb",
31
- "test/test_verbs.rb",
32
- "verbs.gemspec"
33
- ]
34
- s.homepage = %q{http://github.com/rossmeissl/verbs}
35
- s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.6.2}
37
- s.summary = %q{English verb conjugation in Ruby}
38
-
39
- if s.respond_to? :specification_version then
40
- s.specification_version = 3
41
-
42
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
- s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
44
- else
45
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
46
- end
47
- else
48
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
49
- end
50
- end
51
-
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
+ end
23
+
metadata CHANGED
@@ -1,39 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: verbs
3
- version: !ruby/object:Gem::Version
4
- version: 2.0.10
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
5
  prerelease:
6
+ segments:
7
+ - 2
8
+ - 1
9
+ - 0
10
+ version: 2.1.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Andy Rossmeissl
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-06-09 00:00:00.000000000 -05:00
17
+
18
+ date: 2011-08-09 00:00:00 -05:00
13
19
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ name: bueller
24
+ type: :development
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
16
37
  name: activesupport
17
- requirement: &2159015740 !ruby/object:Gem::Requirement
38
+ type: :runtime
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
18
40
  none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 11
45
+ segments:
46
+ - 2
47
+ - 3
48
+ - 4
22
49
  version: 2.3.4
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: *2159015740
26
- description: Conjugates most common english verbs for all persons in all tenses and
27
- all standard aspects (with active diathesis and indicative mood). Standard and exceptional
28
- spelling rules are obeyed.
50
+ requirement: *id002
51
+ description: Conjugates most common english verbs for all persons, tenses, standard aspects, and modern moods (with active diathesis). Standard and exceptional spelling rules are obeyed.
29
52
  email: andy@rossmeissl.net
30
53
  executables: []
54
+
31
55
  extensions: []
32
- extra_rdoc_files:
33
- - LICENSE
34
- - README.rdoc
35
- files:
56
+
57
+ extra_rdoc_files: []
58
+
59
+ files:
36
60
  - .document
61
+ - .gitignore
62
+ - Gemfile
37
63
  - LICENSE
38
64
  - README.rdoc
39
65
  - Rakefile
@@ -41,34 +67,46 @@ files:
41
67
  - lib/verbs.rb
42
68
  - lib/verbs/conjugations.rb
43
69
  - lib/verbs/conjugator.rb
70
+ - lib/verbs/improper_construction.rb
44
71
  - lib/verbs/verb.rb
45
72
  - lib/verbs/verblike.rb
73
+ - lib/verbs/version.rb
46
74
  - test/helper.rb
47
75
  - test/test_verbs.rb
48
76
  - verbs.gemspec
49
77
  has_rdoc: true
50
78
  homepage: http://github.com/rossmeissl/verbs
51
79
  licenses: []
80
+
52
81
  post_install_message:
53
82
  rdoc_options: []
54
- require_paths:
83
+
84
+ require_paths:
55
85
  - lib
56
- required_ruby_version: !ruby/object:Gem::Requirement
86
+ required_ruby_version: !ruby/object:Gem::Requirement
57
87
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
96
  none: false
64
- requirements:
65
- - - ! '>='
66
- - !ruby/object:Gem::Version
67
- version: '0'
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
68
104
  requirements: []
105
+
69
106
  rubyforge_project:
70
107
  rubygems_version: 1.6.2
71
108
  signing_key:
72
109
  specification_version: 3
73
110
  summary: English verb conjugation in Ruby
74
111
  test_files: []
112
+