syllabize 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,3 +2,5 @@
2
2
  exceptions:
3
3
  really: 2
4
4
  cooperate: 4
5
+ Waynes: 1
6
+ basement: 2
@@ -1,4 +1,3 @@
1
- require 'syllabize/version'
2
1
  require 'yaml'
3
2
 
4
3
  module Syllabize
@@ -7,7 +6,7 @@ module Syllabize
7
6
  attr_accessor :word, :exceptions_file
8
7
 
9
8
  def initialize(word)
10
- @word = word
9
+ @word = strip_apostrophes(word)
11
10
  handle_non_string_input
12
11
  load_exceptions
13
12
  end
@@ -34,6 +33,10 @@ module Syllabize
34
33
  File.dirname(__FILE__)
35
34
  end unless respond_to?(:__dir__, true)
36
35
 
36
+ def strip_apostrophes(string)
37
+ string.gsub("'",'')
38
+ end
39
+
37
40
  def handle_non_string_input
38
41
  if !(word.is_a?(String))
39
42
  raise ArgumentError.new "#{word} must be a string"
@@ -69,7 +72,7 @@ module Syllabize
69
72
  end
70
73
 
71
74
  def ends_in_silent_e?
72
- word.downcase.each_char.to_a[-1] == 'e'
75
+ word.downcase.each_char.to_a.last == 'e'
73
76
  end
74
77
 
75
78
  def contains_le_vowel_sound?
@@ -1,3 +1,3 @@
1
1
  module Syllabize
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -98,7 +98,8 @@ describe Syllabize::Counter do
98
98
  describe '#count_syllables' do
99
99
  context 'given a string' do
100
100
  it 'counts the syllables in a word' do
101
- { 'blizzard' => 2,
101
+ {
102
+ 'blizzard' => 2,
102
103
  'why' => 1,
103
104
  'plain' => 1,
104
105
  'sticky' => 2,
@@ -111,9 +112,12 @@ describe Syllabize::Counter do
111
112
  'realize' => 3,
112
113
  'really' => 2,
113
114
  'cooperate' => 4,
114
- 'ways' => 1
115
- }.each do |word, syllable_count|
116
- expect(Syllabize::Counter.new(word).count_syllables).to eq(syllable_count), "#{word} was not the correct number of syllables"
115
+ 'ways' => 1,
116
+ "Wayne's" => 1,
117
+ 'basement' => 2
118
+ }.each do |word, actual|
119
+ count = Syllabize::Counter.new(word).count_syllables
120
+ expect(count).to eq(actual), "#{word} was not the correct number of syllables; expected #{actual}, was #{count}"
117
121
  end
118
122
  end
119
123
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syllabize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: