syllabize 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/syllabize.rb +14 -2
- data/lib/syllabize/version.rb +1 -1
- data/spec/lib/syllabize_spec.rb +23 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b244e59fc134e14178deb39734180a351af0b7b
|
4
|
+
data.tar.gz: 7653f1f76b9953150897b2c6f697d54646882db5
|
5
5
|
!binary "U0hBNTEy":
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eec995cdb480749467a962f03ef4a12b838ddc2e310b6772368b8d628477755c418e4db1249a3eff5d31d81745bf626d7432fe27d1eb815c5792b33c992ecdd3
|
7
|
+
data.tar.gz: e61dd7a06a97402657b82ff1d91e107ffb1b11d77cb4f4f9c7ae97601c5b799f5291865d9f0feb7f18e9abc511bf566facace12b6b70f636a4f6449508600382
|
data/lib/syllabize.rb
CHANGED
@@ -4,10 +4,12 @@ require 'yaml'
|
|
4
4
|
module Syllabize
|
5
5
|
|
6
6
|
class Counter
|
7
|
-
attr_accessor :word
|
7
|
+
attr_accessor :word, :exceptions_file
|
8
8
|
|
9
9
|
def initialize(word)
|
10
10
|
@word = word
|
11
|
+
handle_non_string_input
|
12
|
+
load_exceptions
|
11
13
|
end
|
12
14
|
|
13
15
|
CONSONANTS = /[bcdfghjklmnpqrstvwxz]/i
|
@@ -27,8 +29,18 @@ module Syllabize
|
|
27
29
|
|
28
30
|
private
|
29
31
|
|
32
|
+
def handle_non_string_input
|
33
|
+
if !(word.is_a?(String))
|
34
|
+
raise ArgumentError.new "#{word} must be a string"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_exceptions
|
39
|
+
@exceptions_file = YAML::load_file(File.join(__dir__, 'exceptions.yml'))
|
40
|
+
end
|
41
|
+
|
30
42
|
def exceptions
|
31
|
-
|
43
|
+
@exceptions_file['exceptions']
|
32
44
|
end
|
33
45
|
|
34
46
|
def handle_exceptions
|
data/lib/syllabize/version.rb
CHANGED
data/spec/lib/syllabize_spec.rb
CHANGED
@@ -96,22 +96,29 @@ describe Syllabize::Counter do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
describe '#count_syllables' do
|
99
|
-
|
100
|
-
|
101
|
-
'
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
99
|
+
context 'given a string' do
|
100
|
+
it 'counts the syllables in a word' do
|
101
|
+
{ 'blizzard' => 2,
|
102
|
+
'why' => 1,
|
103
|
+
'plain' => 1,
|
104
|
+
'sticky' => 2,
|
105
|
+
'syzygy' => 3,
|
106
|
+
'yeses' => 2,
|
107
|
+
'communism' => 4,
|
108
|
+
'please' => 1,
|
109
|
+
'candle' => 2,
|
110
|
+
'handling' => 3,
|
111
|
+
'realize' => 3,
|
112
|
+
'really' => 2,
|
113
|
+
'cooperate' => 4,
|
114
|
+
}.each do |word, syllable_count|
|
115
|
+
expect(Syllabize::Counter.new(word).count_syllables).to eq(syllable_count), "#{word} was not the correct number of syllables"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
context 'other data' do
|
120
|
+
it 'raises an error' do
|
121
|
+
expect { Syllabize::Counter.new(7) }.to raise_error
|
115
122
|
end
|
116
123
|
end
|
117
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syllabize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thenickcox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|