haikuable 0.0.2 → 0.1.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.
data/README.md CHANGED
@@ -1,19 +1,27 @@
1
1
  # Haikuable
2
2
 
3
3
  > Garth: "Does anyone else find this weird? I mean, we're looking down on Wayne's basement. Only that's not Wayne's basement. Isn't that weird?"
4
+ >
4
5
  > Everyone: "That's weird…"
6
+ >
5
7
  > Wayne: "Garth, that was a haiku!"
6
8
 
7
- True to the simplicity and elegance of the Japanese poetic form, haikuable is a very simple gem. It has a single method. It takes a string, and returns a boolean based on whether or not that string is a haiku.
9
+ <cite>[Wayne's World](http://www.imdb.com/title/tt0105793/?ref_=nv_sr_1), 1992</cite>
10
+
11
+ True to the simplicity and elegance of the [Japanese poetic form](http://en.wikipedia.org/wiki/Haiku), haikuable is a very simple gem. It has a single method. It takes a string, and returns a boolean based on whether or not that string is a haiku.
12
+
13
+ Currently, `haikuable` only supports the traditional 5, 7, 5 haiku format. If you need configurability, feel free to [file an issue](https://github.com/thenickcox/haikuable).
8
14
 
9
15
  ## Usage
10
16
 
17
+ Require the gem, and call `is_haiku?` on a string.
18
+
11
19
  ```bash
12
20
  >> require 'haikuable'
13
21
  => true
14
22
  >> poem = 'at the age old pond a frog leaps into water a deep resonance'
15
23
  => "at the age old pond a frog leaps into water a deep resonance"
16
- >> Haikuable::Checker.new(poem).is_haiku?
24
+ >> poem.is_haiku?
17
25
  => true
18
26
  ```
19
27
 
@@ -9,6 +9,7 @@ module Haikuable
9
9
  def initialize(string)
10
10
  @string = string
11
11
  @line_counts = { line1: 0, line2: 0, line3: 0 }
12
+ raise ArgumentError.new('must be called on a string') unless string.is_a?(String)
12
13
  end
13
14
 
14
15
  def is_haiku?
@@ -43,3 +44,9 @@ module Haikuable
43
44
 
44
45
  end
45
46
  end
47
+
48
+ class String
49
+ def is_haiku?
50
+ Haikuable::Checker.new(self).is_haiku?
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Haikuable
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -4,6 +4,13 @@ describe Haikuable::Checker do
4
4
  describe '#is_haiku?' do
5
5
  subject { Haikuable::Checker.new(string).is_haiku? }
6
6
 
7
+ context 'not a string' do
8
+ let(:string) { 7 }
9
+ it 'raises an error' do
10
+ expect { subject }.to raise_error ArgumentError
11
+ end
12
+ end
13
+
7
14
  context 'not 17 syllables' do
8
15
  context 'too few' do
9
16
  let(:string) { 'I like cheese' }
@@ -31,4 +38,9 @@ describe Haikuable::Checker do
31
38
  it { should be_true }
32
39
  end
33
40
  end
41
+
42
+ context 'string method' do
43
+ subject { 'puppies and kittens'.is_haiku? }
44
+ it { should be_false }
45
+ end
34
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haikuable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-26 00:00:00.000000000 Z
12
+ date: 2014-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler