conjugate 1.5.0 → 1.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4fa1d49b881834a7a9257ec44a60ebc30f571a9
4
- data.tar.gz: 2ce5eb47a58c5b83303d6f5f04ddab6ab0ee0267
3
+ metadata.gz: df25562c7b30bebf362cd32ebee17284aca23b49
4
+ data.tar.gz: 4f01c56fe1d9665bd2ba6715d11f276b289984c2
5
5
  SHA512:
6
- metadata.gz: ce1789b185fdbd54c5efbd5bde91cad55b5350c9b0ec7536919d2bb98ed9a7df9dd0769da7ef3c99da2f88a9e7f8e1ee303864347eab4cc8a2d533ffb0b53936
7
- data.tar.gz: 61739dc171da26e2518f3c7692dcd641ad0dfee25248006b16862c54d5779566f4cfc6bf44a497edeff6a3f8a55cf9fb1ce2513165bd7fa686834f61a00cc6ee
6
+ metadata.gz: 484d6989392dc8e747975983d24a7a3ff60fadc5f1b0feb1a687e9ff218bcc8866540efaefda7ebdde9da27cc450499a636b36ab8f8fff542a15f8e538df62c5
7
+ data.tar.gz: 1fa557846689ba6745080f8116ff0c06a3c3bd1f8a07a9f121902c63a8e19af2c6739cce15ba2140a3427b6f36bdcad9ab42f989df083f4ff05b88fd4ac883df
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in edmodo-api.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ conjugate (1.6.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ rake (10.1.1)
11
+ rspec (2.14.1)
12
+ rspec-core (~> 2.14.0)
13
+ rspec-expectations (~> 2.14.0)
14
+ rspec-mocks (~> 2.14.0)
15
+ rspec-core (2.14.8)
16
+ rspec-expectations (2.14.5)
17
+ diff-lcs (>= 1.1.3, < 2.0)
18
+ rspec-mocks (2.14.6)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ conjugate!
25
+ rake
26
+ rspec
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/README.markdown CHANGED
@@ -1,5 +1,6 @@
1
1
  Conjugate
2
2
  =========
3
+ [![Build Status](https://travis-ci.org/JeremyGeros/Conjugate.png?branch=master)](https://travis-ci.org/JeremyGeros/Conjugate)
3
4
 
4
5
  Conjugates verbs into their proper form given a pronoun. Can conjugate irregular verbs that are in this list https://gist.github.com/1841995
5
6
  Currently only has support for Spanish.
@@ -22,6 +23,21 @@ Conjugate::French.conjugate(:pronoun => :je, :verb => 'acheter', :tense => :pres
22
23
  => achète
23
24
  ```
24
25
 
26
+ There is also a helper method to pass a language option, either the name or language code
27
+ ```
28
+ Conjugate.conjugate({language: 'french', verb: 'jouer', tense: :present, pronoun: :je})
29
+ => joue
30
+
31
+ Conjugate.conjugate({language: 'fr', verb: 'jouer', tense: :present, pronoun: :je})
32
+ => joue
33
+
34
+ Conjugate.conjugate({language: 'spanish', verb: 'comprar', tense: :present, pronoun: :yo})
35
+ => compro
36
+
37
+ Conjugate.conjugate({language: 'es', verb: 'comprar', tense: :present, pronoun: :yo})
38
+ => compro
39
+ ```
40
+
25
41
  License
26
42
  =======
27
43
 
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ RSpec::Core::RakeTask.new :spec
6
+
7
+ task :default => :spec
data/conjugate.gemspec CHANGED
@@ -1,15 +1,20 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'conjugate'
3
- s.version = '1.5.0'
4
- s.date = '2012-02-15'
5
- s.summary = "Conjugate Verbs using a version of the templates defined here http://en.wiktionary.org/wiki/Category:Spanish_verb_inflection-table_templates"
6
- s.description = s.summary
7
- s.authors = ["Jeremy Geros"]
8
- s.email = 'jeremy@govocab.com'
9
- s.license = 'MIT'
10
-
11
- s.files = `git ls-files`.split("\n")
12
- s.require_paths = ["lib"]
13
-
14
- s.homepage = 'https://github.com/JeremyGeros/Conjugate'
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'conjugate'
3
+ gem.version = '1.6.0'
4
+ gem.date = '2015-07-08'
5
+ gem.summary = "Conjugate Verbs using a version of the templates defined here http://en.wiktionary.org/wiki/Category:Spanish_verb_inflection-table_templates"
6
+ gem.description = gem.summary
7
+ gem.authors = ["Jeremy Geros"]
8
+ gem.email = 'jeremy@govocab.com'
9
+ gem.license = 'MIT'
10
+
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.require_paths = ["lib"]
13
+
14
+ gem.homepage = 'https://github.com/JeremyGeros/Conjugate'
15
+
16
+ gem.required_ruby_version = '>= 1.9.2'
17
+
18
+ gem.add_development_dependency 'rspec'
19
+ gem.add_development_dependency 'rake'
15
20
  end
@@ -1,26 +1,17 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Common
3
-
4
3
  @@dividing_infinitive_regex = /\{{3}\d+\}{3}([[:alpha:]]+)/
5
-
4
+
6
5
  def conjugate(opts ={})
7
- @debug = opts[:debug].nil? ? false : true
8
-
9
6
  template = template(opts)
10
- debug(template)
11
7
  tense = tense(opts[:tense])
12
-
13
8
  verb = opts[:verb]
14
- debug(verb)
15
-
16
9
  infinitive = template[:infinitive].dup
17
- debug(infinitive)
18
-
10
+
19
11
  verb_parts = divide_infinitive(infinitive, verb)
20
- debug(verb_parts)
21
- debug(tense)
12
+
22
13
  return nil if (tense != :passe_compose) && (template[tense].nil? || template[tense][opts[:pronoun].to_sym].nil?)
23
- debug('v')
14
+
24
15
  conjugation_template = nil
25
16
 
26
17
  if defined? conjugation_template_finder
@@ -28,11 +19,9 @@ module Common
28
19
  else
29
20
  conjugation_template = template[tense][opts[:pronoun].to_sym].dup
30
21
  end
31
- debug(conjugation_template)
32
-
22
+
33
23
  positions = conjugation_template.scan(/\{{3}(\d+)\}{3}/).flatten
34
- debug(positions)
35
-
24
+
36
25
  positions.each do |p|
37
26
  if opts[:highlight]
38
27
  conjugation_template.gsub!(/\{{3}#{p}\}{3}/, "<span class='regular'>#{ verb_parts[p.to_i - 1] }</span>")
@@ -42,26 +31,25 @@ module Common
42
31
  end
43
32
  conjugation_template
44
33
  end
45
-
34
+
46
35
  # def conjugation_template_finder(template, tense, opts)
47
- #
36
+ #
48
37
  # end
49
-
38
+
50
39
  def regular_ending(verb)
51
40
  verb[-2..-1]
52
41
  end
53
-
42
+
54
43
  def tense(t)
55
44
  (common_name(t) || :present).to_sym
56
45
  end
57
-
46
+
58
47
  def divide_infinitive(infinitive, verb)
59
48
  inserts = infinitive.scan(@@dividing_infinitive_regex).flatten
60
- debug(inserts)
61
-
49
+
62
50
  word_parts = []
63
51
  word_copy = verb.dup
64
-
52
+
65
53
  inserts.each do |letters|
66
54
  sub_word = ""
67
55
  if letters.length <= 1
@@ -70,27 +58,11 @@ module Common
70
58
  sub_word = word_copy.scan(/(.+)#{letters}/).flatten.first
71
59
  end
72
60
  sub_word ||= ""
73
-
61
+
74
62
  word_parts << sub_word
75
- word_copy = word_copy.gsub(/^#{sub_word}#{letters}/, '')
63
+ word_copy = word_copy.gsub(/^#{sub_word}#{letters}/, '')
76
64
  end
77
65
  word_parts << word_copy unless word_copy == ""
78
66
  word_parts
79
67
  end
80
-
81
- def debug(info)
82
- if @debug
83
- puts info.inspect
84
- end
85
- end
86
-
87
- # stubbed method individual languages override this to support multiple tenses names
88
- def common_name(t)
89
- return nil unless t
90
- actual_tense = t.to_s.gsub(' ', '_').to_sym
91
- @changable_names ||= {:past => :preterite, :past => :passe_compose, :passé_composé => :passe_compose}
92
- actual_tense = @changable_names[actual_tense] || actual_tense
93
- actual_tense
94
- end
95
-
96
- end
68
+ end
@@ -5,28 +5,28 @@ require 'conjugate/common'
5
5
 
6
6
  module Conjugate
7
7
  module French
8
+ @@language = 'french'
9
+
8
10
  extend Common
9
11
  extend self
10
-
12
+
13
+
14
+
11
15
  def generate_list_of_know_irregular_verbs
12
16
  puts "- " + FrenchIrregularVerbs.keys.sort.join("\n- ")
13
17
  end
14
-
18
+
15
19
  def find_irregular(verb)
16
20
  FrenchIrregularVerbs[verb.downcase]
17
21
  end
18
-
22
+
19
23
  def template(opts)
20
24
  FrenchTemplates[(opts[:template] || find_irregular(opts[:verb]) || regular_ending(opts[:verb])).to_sym]
21
25
  end
22
-
26
+
23
27
  def conjugation_template_finder(template, tense, opts)
24
28
  if tense == :passe_compose
25
29
  if is_etre_verb(opts[:verb])
26
- debug(FrenchTemplates[:être])
27
- debug(FrenchTemplates[:être][:present])
28
- debug(FrenchTemplates[:être][:present][opts[:pronoun].to_sym])
29
- debug(template)
30
30
  FrenchTemplates[:être][:present][opts[:pronoun].to_sym] + ' ' + template[:past_participle]
31
31
  else
32
32
  FrenchTemplates[:avoir][:present][opts[:pronoun].to_sym] + ' ' + template[:past_participle]
@@ -35,10 +35,19 @@ module Conjugate
35
35
  template[tense][opts[:pronoun].to_sym]
36
36
  end
37
37
  end
38
-
38
+
39
39
  def is_etre_verb(verb)
40
40
  ['monter', 'rester', 'sortir', 'venir', 'aller', 'naître', 'descendre', 'entrer', 'retourner', 'tomber', 'renter', 'arriver', 'mourir', 'partir', 'passer', 'décéder', 'redescendre', 'rentrer', 'remonter', 'repartir', 'renaître', 'retomber', 'ressortir', 'devenir', 'parvenir', 'revenir', 'survenir', 'provenir', 'intervenir', 'convenir', 'contrevenir', 'advenir'].include? verb.downcase
41
41
  end
42
-
42
+
43
+ # stubbed method individual languages override this to support multiple tenses names
44
+ def common_name(t)
45
+ return nil unless t
46
+ actual_tense = t.to_s.gsub(' ', '_').to_sym
47
+ @changable_names ||= {:past => :passe_compose, :passé_composé => :passe_compose}
48
+ actual_tense = @changable_names[actual_tense] || actual_tense
49
+ actual_tense
50
+ end
51
+
43
52
  end
44
- end
53
+ end
@@ -8,7 +8,7 @@ FrenchIrregularVerbs = {
8
8
  'dire' => :dire,
9
9
 
10
10
  'avoir' => :avoir,
11
-
11
+
12
12
  'lire' => :lire,
13
13
 
14
14
  'aller' => :aller,
@@ -162,7 +162,7 @@ FrenchIrregularVerbs = {
162
162
  'peser' => :e_er,
163
163
 
164
164
  'promener' => :e_er,
165
-
165
+
166
166
  'acheter' => :e_er,
167
167
 
168
168
  'céder' => :é_er,
@@ -340,50 +340,50 @@ FrenchIrregularVerbs = {
340
340
  'enjoindre' => :re_gn,
341
341
 
342
342
  'rejoindre' => :re_gn,
343
-
343
+
344
344
  'venir' => :venir,
345
-
345
+
346
346
  'devenir' => :venir,
347
-
347
+
348
348
  'advenir ' => :venir,
349
-
349
+
350
350
  'contrevenir' => :venir,
351
-
351
+
352
352
  'circonvenir' => :venir,
353
-
353
+
354
354
  'convenir' => :venir,
355
-
355
+
356
356
  'intervenir' => :venir,
357
-
358
- 'parvenir' => :venir,
359
-
357
+
358
+ 'parvenir' => :venir,
359
+
360
360
  'prévenir' => :venir,
361
-
361
+
362
362
  'provenir' => :venir,
363
-
363
+
364
364
  'revenir' => :venir,
365
-
365
+
366
366
  'subvenir' => :venir,
367
-
367
+
368
368
  'survenir' => :venir,
369
-
369
+
370
370
  'revoir' => :revoir,
371
-
371
+
372
372
  'dormir' => :dormir,
373
-
373
+
374
374
  'appartenir' => :tenir,
375
-
375
+
376
376
  'contenir' => :tenir,
377
-
378
- 'obtenir' => :tenir,
379
-
377
+
378
+ 'obtenir' => :tenir,
379
+
380
380
  'retenir' => :tenir,
381
-
381
+
382
382
  'soutenir' => :tenir,
383
-
383
+
384
384
  'tenir' => :tenir,
385
-
385
+
386
386
  'devoir' => :devoir,
387
-
387
+
388
388
  'valoir' => :valoir
389
389
  }
@@ -7,18 +7,28 @@ module Conjugate
7
7
  module Spanish
8
8
  extend self
9
9
  extend Common
10
-
10
+
11
+ @@language = 'spanish'
12
+
11
13
  def generate_list_of_know_irregular_verbs
12
14
  puts "- " + SpanishIrregularVerbs.keys.sort.join("\n- ")
13
15
  end
14
-
16
+
15
17
  def find_irregular(verb)
16
18
  SpanishIrregularVerbs[verb.downcase]
17
19
  end
18
-
20
+
19
21
  def template(opts)
20
22
  SpanishTemplates[(opts[:template] || find_irregular(opts[:verb]) || regular_ending(opts[:verb])).to_sym]
21
23
  end
22
-
24
+
25
+ def common_name(t)
26
+ return nil unless t
27
+ actual_tense = t.to_s.gsub(' ', '_').to_sym
28
+ @changable_names ||= {:past => :preterite}
29
+ actual_tense = @changable_names[actual_tense] || actual_tense
30
+ actual_tense
31
+ end
32
+
23
33
  end
24
- end
34
+ end