tracinho 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7eda141f70817d4d6b65a379300aeed6111b022a
4
- data.tar.gz: 150a0710365d85a6a1e1d618075e88100a7f6ffb
3
+ metadata.gz: 9c70051cae7ac844bab71d7b3f6edad29e7202cb
4
+ data.tar.gz: f678f3b6464af23f130cdb4607940ea624dd6507
5
5
  SHA512:
6
- metadata.gz: 41d70c0dff0edea402bb56afc199cdb75251e808d3013bf7dca8268170574084c4df1c6311dfbb23787c93cfd220c9272921ea26dc0915f58033f86e37b408ce
7
- data.tar.gz: 820dbd16d1f1a9ec2a813d45f87fb9f741ea1e94e4007b6caa453324976f2389e6ff9934a5a1b7f36bf5a40d3e538bb6d72b5d986ea345a9896b94181e796833
6
+ metadata.gz: 2b6ca80265f4ae7d337cadfd724e44bf5a7a365df1fe37f279ef99d0017defffc0ecb76351960dc6084129fe5afa77f7998090e490d5aeb64efa9ad3b5903281
7
+ data.tar.gz: 3cff9737f23c7df6d47dce9158d522c9135db61f6f7b0daf8fc6cd13340befdc93e56cd42c55b9f2df4e82b5eb8d33de1712e65391d1a3b5752e2ab62586904c
data/.gitignore CHANGED
@@ -20,15 +20,13 @@ build/
20
20
  /doc/
21
21
  /rdoc/
22
22
 
23
- ## Environment normalisation:
23
+ ## Environment normalization:
24
24
  /.bundle/
25
25
  /lib/bundler/man/
26
26
 
27
- # for a library or gem, you might want to ignore these files since the code is
28
- # intended to run in multiple environments; otherwise, check them in:
29
- # Gemfile.lock
30
- # .ruby-version
31
- # .ruby-gemset
27
+ # rvm files
28
+ .ruby-version
29
+ .ruby-gemset
32
30
 
33
31
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
32
  .rvmrc
data/.travis.yml CHANGED
@@ -3,4 +3,6 @@ rvm:
3
3
  - 2.1.0
4
4
  - 2.1.3
5
5
  - 2.2.0
6
+ - 2.2.2
6
7
  script: bundle exec rspec
8
+ sudo: false
data/Gemfile.lock CHANGED
@@ -1,63 +1,66 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tracinho (0.0.1)
4
+ tracinho (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.0.0)
10
- astrolabe (1.3.0)
11
- parser (>= 2.2.0.pre.3, < 3.0)
9
+ ast (2.1.0)
10
+ astrolabe (1.3.1)
11
+ parser (~> 2.2)
12
12
  coderay (1.1.0)
13
13
  diff-lcs (1.2.5)
14
14
  docile (1.1.5)
15
+ json (1.8.3)
15
16
  method_source (0.8.2)
16
- multi_json (1.10.1)
17
- parser (2.2.0.pre.5)
17
+ parser (2.2.3.0)
18
18
  ast (>= 1.1, < 3.0)
19
- slop (~> 3.4, >= 3.4.5)
20
- powerpack (0.0.9)
21
- pry (0.10.1)
19
+ powerpack (0.1.1)
20
+ pry (0.10.3)
22
21
  coderay (~> 1.1.0)
23
22
  method_source (~> 0.8.1)
24
23
  slop (~> 3.4)
25
24
  rainbow (2.0.0)
26
- rake (10.3.2)
27
- rspec (3.1.0)
28
- rspec-core (~> 3.1.0)
29
- rspec-expectations (~> 3.1.0)
30
- rspec-mocks (~> 3.1.0)
31
- rspec-core (3.1.7)
32
- rspec-support (~> 3.1.0)
33
- rspec-expectations (3.1.2)
25
+ rake (10.4.2)
26
+ rspec (3.3.0)
27
+ rspec-core (~> 3.3.0)
28
+ rspec-expectations (~> 3.3.0)
29
+ rspec-mocks (~> 3.3.0)
30
+ rspec-core (3.3.2)
31
+ rspec-support (~> 3.3.0)
32
+ rspec-expectations (3.3.1)
34
33
  diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.1.0)
36
- rspec-mocks (3.1.3)
37
- rspec-support (~> 3.1.0)
38
- rspec-support (3.1.2)
39
- rubocop (0.26.1)
34
+ rspec-support (~> 3.3.0)
35
+ rspec-mocks (3.3.2)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.3.0)
38
+ rspec-support (3.3.0)
39
+ rubocop (0.35.0)
40
40
  astrolabe (~> 1.3)
41
- parser (>= 2.2.0.pre.4, < 3.0)
42
- powerpack (~> 0.0.6)
41
+ parser (>= 2.2.3.0, < 3.0)
42
+ powerpack (~> 0.1)
43
43
  rainbow (>= 1.99.1, < 3.0)
44
- ruby-progressbar (~> 1.4)
45
- ruby-progressbar (1.6.0)
46
- simplecov (0.9.1)
44
+ ruby-progressbar (~> 1.7)
45
+ ruby-progressbar (1.7.5)
46
+ simplecov (0.10.0)
47
47
  docile (~> 1.1.0)
48
- multi_json (~> 1.0)
49
- simplecov-html (~> 0.8.0)
50
- simplecov-html (0.8.0)
48
+ json (~> 1.8)
49
+ simplecov-html (~> 0.10.0)
50
+ simplecov-html (0.10.0)
51
51
  slop (3.6.0)
52
52
 
53
53
  PLATFORMS
54
54
  ruby
55
55
 
56
56
  DEPENDENCIES
57
- bundler (~> 1.7)
58
- pry
59
- rake (~> 10.0)
60
- rspec
61
- rubocop
62
- simplecov
57
+ bundler (~> 1.10)
58
+ pry (~> 0.10)
59
+ rake (~> 10.4)
60
+ rspec (~> 3.3)
61
+ rubocop (~> 0.35)
62
+ simplecov (~> 0.10)
63
63
  tracinho!
64
+
65
+ BUNDLED WITH
66
+ 1.10.6
data/README.md CHANGED
@@ -3,4 +3,5 @@
3
3
  tracinho
4
4
  ========
5
5
 
6
- tracinho.com library to convert words with dash in the version without dash and vice-versa and classify the word verb.
6
+ tracinho.com library to convert words with dash in the version without dash and vice-versa and
7
+ classify the word verb.
@@ -7,15 +7,13 @@ module Tracinho
7
7
 
8
8
  # Builds the complementary word.
9
9
  #
10
- # Examples:
11
- #
12
10
  # ComplementBuilder.new(Word.new('fizeste')).build
13
11
  # # => #<Tracinho::Word:0x007f8a9b0ba928 @text="fize-te">
14
12
  #
15
13
  # ComplementBuilder.new(Word.new('passa-mos')).build
16
14
  # # => #<Tracinho::Word:0x007f8a9b10f270 @text="passamos">
17
15
  def build
18
- text = @word.hyphenated? ? remove_dash(@word.text) : add_dash(@word.text)
16
+ text = @word.hyphenated? ? remove_dash(@word.to_s) : add_dash(@word.to_s)
19
17
 
20
18
  Word.new(text)
21
19
  end
@@ -31,7 +29,7 @@ module Tracinho
31
29
  when /os$/
32
30
  text.insert(-4, '-')
33
31
  else
34
- text.insert(-3, '-').sub('s-', '-')
32
+ text.insert(-3, '-')
35
33
  end
36
34
  end
37
35
  end
@@ -1,5 +1,5 @@
1
1
  # This gem converts words with dash in the version without it and vice-versa. It also gets the verb
2
2
  # name from a word and gives the full grammar classification of the verb.
3
3
  module Tracinho
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/tracinho/word.rb CHANGED
@@ -1,13 +1,11 @@
1
1
  module Tracinho
2
2
  class Word
3
- attr_accessor :text
4
-
5
3
  def initialize(text)
6
- self.text = text
4
+ @text = text
7
5
  end
8
6
 
9
7
  def hyphenated?
10
- text.include?('-')
8
+ @text.include?('-')
11
9
  end
12
10
 
13
11
  def complement
@@ -15,10 +13,11 @@ module Tracinho
15
13
  end
16
14
 
17
15
  def grammar_class
16
+ WordClassifier.new(self).full_classification
18
17
  end
19
18
 
20
19
  def to_s
21
- text
20
+ @text
22
21
  end
23
22
  end
24
23
  end
@@ -1,20 +1,43 @@
1
1
  module Tracinho
2
+ # WordClassifier is the responsible for classifying a word. It gives the verb, the verb tense and
3
+ # the full classification of a Word.
4
+ #
5
+ # Example:
6
+ #
7
+ # word = Tracinho::Word.new('comeste')
8
+ #
9
+ # classifier = Tracinho::WordClassifier.new(word)
10
+ # classifier.verb
11
+ # # => "comer"
12
+ #
13
+ # classifier.verb_tense
14
+ # # => "pretérito perfeito do indicativo"
15
+ #
16
+ # classifier.full_classification
17
+ # # => "Segunda pessoa do singular do pretérito perfeito do indicativo do verbo comer."
2
18
  class WordClassifier
3
- ENDINGS = /(?:(ste)|(sse)|[^-](mos)|(-(se|mos))|[^s](-te)|(s-te))$/
19
+ ENDINGS = /(?:(ste)|(sse)|[^-](mos)|(-(se|mos))|[^s](-te)|(s-te))$/ #:nodoc:
4
20
 
5
21
  def initialize(word)
6
22
  @word = word
7
23
  end
8
24
 
25
+ # Returns the full classification of a word
26
+ #
27
+ # word = Tracinho::Word.new('matas-te')
28
+ #
29
+ # classifier = Tracinho::WordClassifier.new(word)
30
+ # classifier.full_classification
31
+ # # => "Conjugação pronominal reflexa da segunda pessoa do presente do indicativo do verbo matar."
9
32
  def full_classification
10
- case @word.text
33
+ case @word.to_s
11
34
  when /ste$/
12
35
  "Segunda pessoa do singular do #{full_verb}."
13
36
  when /sse$/
14
37
  "Primeira ou terceira pessoa do singular do #{full_verb}."
15
38
  when /[^-]mos$/
16
39
  "Primeira pessoa do plural do #{full_verb}."
17
- when /(-te | -se)$/
40
+ when /(-te|-se)$/
18
41
  "Conjugação pronominal reflexa da segunda pessoa do #{full_verb}."
19
42
  when /-mos$/
20
43
  "Conjugação pronominal da segunda pessoa do singular do #{full_verb}."
@@ -22,9 +45,9 @@ module Tracinho
22
45
  end
23
46
 
24
47
  def verb
25
- endings = @word.text.match(ENDINGS).captures.compact
48
+ endings = @word.to_s.match(ENDINGS).captures.compact
26
49
 
27
- verb = @word.text.sub(endings.first, 'r')
50
+ verb = @word.to_s.sub(endings.first, 'r')
28
51
  verb.sub!(/rr$/, 'r')
29
52
  verb.sub!(/our$/, 'ar')
30
53
 
@@ -35,14 +58,14 @@ module Tracinho
35
58
  end
36
59
 
37
60
  def verb_tense
38
- case @word.text
61
+ case @word.to_s
39
62
  when /ste$/
40
63
  'pretérito perfeito do indicativo'
41
64
  when /sse$/
42
65
  'pretérito imperfeito do conjuntivo'
43
66
  when /[^-]mos$/
44
67
  'presente do indicativo ou pretérito perfeito do indicativo'
45
- when /(-te | -se)$/
68
+ when /(-te|-se)$/
46
69
  'presente do indicativo'
47
70
  when /-mos$/
48
71
  'imperativo'
@@ -1,4 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ComplementBuilder do
4
+ let(:hyphenated) { %w(passa-mos cala-te matas-te conhecer-te morde-mos mata-te) }
5
+ let(:not_hyphenated) { %w(passamos calate mataste conhecerte mordemos matate) }
6
+
7
+ describe '#build' do
8
+ it 'complements hyphenated words correctly' do
9
+ hyphenated.each_with_index do |word, index|
10
+ word = Tracinho::Word.new(word)
11
+
12
+ expect(described_class.new(word).build.to_s).to eq(not_hyphenated[index])
13
+ end
14
+ end
15
+
16
+ it 'complements not hyphenated words correctly' do
17
+ not_hyphenated.each_with_index do |word, index|
18
+ word = Tracinho::Word.new(word)
19
+
20
+ expect(described_class.new(word).build.to_s).to eq(hyphenated[index])
21
+ end
22
+ end
23
+ end
4
24
  end
@@ -31,7 +31,6 @@ describe WordClassifier do
31
31
  context 'for irregular verbs' do
32
32
  it 'correctly returns the verb of the word' do
33
33
  irregular_words.each_with_index do |word, index|
34
- puts word
35
34
  classifier = described_class.new(Word.new(word))
36
35
 
37
36
  expect(classifier.verb).to eq(irregular_verbs[index])
data/spec/word_spec.rb CHANGED
@@ -7,31 +7,44 @@ describe Word do
7
7
  describe '#hyphenated?' do
8
8
  it 'returns true if the word has a hyphen' do
9
9
  hyphenated.each do |w|
10
- expect(Word.new(w).hyphenated?).to be_truthy
10
+ expect(described_class.new(w).hyphenated?).to be_truthy
11
11
  end
12
12
  end
13
13
 
14
14
  it 'returns false if the word does not have a hyphen' do
15
15
  not_hyphenated.each do |w|
16
- expect(Word.new(w).hyphenated?).to be_falsey
16
+ expect(described_class.new(w).hyphenated?).to be_falsey
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#complement' do
22
22
  it 'returns the complement of a word' do
23
- word = Word.new('fizes-te')
23
+ word = described_class.new('mataste')
24
24
 
25
25
  complement = word.complement
26
26
 
27
- expect(complement.text).to eq('fizeste')
27
+ expect(complement.to_s).to eq('matas-te')
28
+ end
29
+ end
30
+
31
+ describe '#grammar_class' do
32
+ it 'returns the class of a word' do
33
+ word = described_class.new('matas-te')
34
+
35
+ classification = word.grammar_class
36
+
37
+ klass = 'Conjugação pronominal reflexa da segunda pessoa do presente do indicativo do verbo' \
38
+ ' matar.'
39
+
40
+ expect(classification).to eq(klass)
28
41
  end
29
42
  end
30
43
 
31
44
  describe '#to_s' do
32
45
  it 'returns the text attribute of the word' do
33
46
  (hyphenated + not_hyphenated).each do |w|
34
- expect(Word.new(w).to_s).to eq(w)
47
+ expect(described_class.new(w).to_s).to eq(w)
35
48
  end
36
49
  end
37
50
  end
data/tracinho.gemspec CHANGED
@@ -10,21 +10,21 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['Ricardo Otero']
11
11
  spec.email = ['oterosantos@gmail.com']
12
12
  spec.summary = 'Tracinho.com gem.'
13
- spec.description = 'This gem converts words with dash in the version without it and
14
- vice-versa. It also gets the verb name from a word and gives the full grammar classification of
15
- the verb.'
16
13
  spec.homepage = 'https://github.com/rikas/tracinho'
17
14
  spec.license = 'MIT'
15
+ spec.description = 'This gem converts words with dash in the version without it and vice-versa.
16
+ It also gets the verb name from a word and gives the full grammar
17
+ classification of the verb.'
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0")
20
- spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
21
- spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^spec/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.7'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'pry'
27
- spec.add_development_dependency 'rubocop'
28
- spec.add_development_dependency 'rspec'
29
- spec.add_development_dependency 'simplecov'
24
+ spec.add_development_dependency 'bundler', '~> 1.10'
25
+ spec.add_development_dependency 'rake', '~> 10.4'
26
+ spec.add_development_dependency 'pry', '~> 0.10'
27
+ spec.add_development_dependency 'rubocop', '~> 0.35'
28
+ spec.add_development_dependency 'rspec', '~> 3.3'
29
+ spec.add_development_dependency 'simplecov', '~> 0.10'
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracinho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,88 +16,88 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '10.4'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '10.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.35'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.35'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '3.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '3.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '0.10'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '0.10'
97
97
  description: |-
98
- This gem converts words with dash in the version without it and
99
- vice-versa. It also gets the verb name from a word and gives the full grammar classification of
100
- the verb.
98
+ This gem converts words with dash in the version without it and vice-versa.
99
+ It also gets the verb name from a word and gives the full grammar
100
+ classification of the verb.
101
101
  email:
102
102
  - oterosantos@gmail.com
103
103
  executables: []
@@ -107,8 +107,6 @@ files:
107
107
  - ".gitignore"
108
108
  - ".rspec"
109
109
  - ".rubocop.yml"
110
- - ".ruby-gemset"
111
- - ".ruby-version"
112
110
  - ".travis.yml"
113
111
  - Gemfile
114
112
  - Gemfile.lock
@@ -145,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
143
  version: '0'
146
144
  requirements: []
147
145
  rubyforge_project:
148
- rubygems_version: 2.4.5
146
+ rubygems_version: 2.4.5.1
149
147
  signing_key:
150
148
  specification_version: 4
151
149
  summary: Tracinho.com gem.
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- tracinho
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.2