verbs 1.0.5 → 1.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.5
1
+ 1.1.0
@@ -2,6 +2,7 @@ require 'singleton'
2
2
  require 'verbs/verb'
3
3
  require 'verbs/conjugator'
4
4
  require 'verbs/conjugations'
5
+ require 'verbs/verblike'
5
6
  require 'andand'
6
7
  require 'activesupport'
7
8
 
@@ -0,0 +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
@@ -82,4 +82,8 @@ class TestVerbs < Test::Unit::TestCase
82
82
  assert_equal 'Matz is', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :third, :plurality => :singular, :subject => 'Matz')
83
83
  assert_equal 'We are', Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :first, :plurality => :plural, :subject => true)
84
84
  end
85
+ def test_core_access
86
+ assert_equal :accepts, :accept.verb.conjugate(:tense => :present, :person => :third, :plurality => :singular)
87
+ assert_equal 'accepts', 'accept'.verb.conjugate(:tense => :present, :person => :third, :plurality => :singular)
88
+ end
85
89
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{verbs}
8
- s.version = "1.0.5"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andy Rossmeissl"]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "lib/verbs/conjugations.rb",
28
28
  "lib/verbs/conjugator.rb",
29
29
  "lib/verbs/verb.rb",
30
+ "lib/verbs/verblike.rb",
30
31
  "test/helper.rb",
31
32
  "test/test_verbs.rb",
32
33
  "verbs.gemspec"
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: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Rossmeissl
@@ -33,6 +33,7 @@ files:
33
33
  - lib/verbs/conjugations.rb
34
34
  - lib/verbs/conjugator.rb
35
35
  - lib/verbs/verb.rb
36
+ - lib/verbs/verblike.rb
36
37
  - test/helper.rb
37
38
  - test/test_verbs.rb
38
39
  - verbs.gemspec