conjugate 1.3.7 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/conjugate.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'conjugate'
3
- s.version = '1.3.7'
3
+ s.version = '1.3.8'
4
4
  s.date = '2012-02-15'
5
5
  s.summary = "Conjugate Verbs using a version of the templates defined here http://en.wiktionary.org/wiki/Category:Spanish_conjugation-table_templates"
6
6
  s.description = s.summary
@@ -13,18 +13,28 @@ module Conjugate
13
13
 
14
14
 
15
15
  def conjugate(opts ={})
16
+ @debug = opts[:debug].nil? ? false : true
17
+
16
18
  template = template(opts)
19
+ debug(template)
17
20
  tense = tense(opts[:tense])
18
21
 
19
22
  verb = opts[:verb]
23
+ debug(verb)
20
24
 
21
25
  infinitive = template[:infinitive].dup
26
+ debug(infinitive)
27
+
22
28
  verb_parts = divide_infinitive(infinitive, verb)
29
+ debug(verb_parts)
23
30
 
24
31
  return nil if template[tense].nil? || template[tense][opts[:pronoun].to_sym].nil?
25
32
 
26
33
  conjugation_template = template[tense][opts[:pronoun].to_sym].dup
34
+ debug(conjugation_template)
35
+
27
36
  positions = conjugation_template.scan(/\{{3}(\d+)\}{3}/).flatten
37
+ debug(positions)
28
38
 
29
39
  positions.each do |p|
30
40
  if opts[:highlight]
@@ -61,12 +71,13 @@ module Conjugate
61
71
 
62
72
  def divide_infinitive(infinitive, verb)
63
73
  inserts = infinitive.scan(@dividing_infinitive_regex).flatten
74
+ debug(inserts)
64
75
 
65
76
  word_parts = []
66
77
  word_copy = verb.dup
67
78
 
68
79
  inserts.each do |letters|
69
- sub_word = word_copy.scan(/(.+)#{letters}/).flatten.first
80
+ sub_word = word_copy.scan(/(.[^#{letters}]*)#{letters}/).flatten.first
70
81
  sub_word ||= ""
71
82
 
72
83
  word_parts << sub_word
@@ -76,5 +87,11 @@ module Conjugate
76
87
  word_parts
77
88
  end
78
89
 
90
+ def debug(info)
91
+ if @debug
92
+ puts info.inspect
93
+ end
94
+ end
95
+
79
96
  end
80
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjugate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: