markovite 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: b6fee92d46759244fd174b5292ae9d7f5b418f25f9268922b9e1c9bc0d4d08fc
4
- data.tar.gz: 12601a0899b487e1fae3415ad3cb12b7107d5961cf06f9d32dda38bd6968cb13
3
+ metadata.gz: 9228ae1173249e835b7a51bff00e748a4cda2a134592a3bf630bbc55320fcbe1
4
+ data.tar.gz: 51d7fca721c7598b77185ad7729176b1c60957889d53a8be70d6d1865b670b5c
5
5
  SHA512:
6
- metadata.gz: 15f2a32d7a25bae0bcb2b085ab548bc156fdc49cb50d9b196e731bd9d9b214e216f9ffd2f0c6570516e966907f1eb06172879b5d718661ab9b7605c25354803f
7
- data.tar.gz: 6f39d34312712dbc3dee5070be285adfef7f98bc181def7ffc6d46b408864077d69e159cef2cd54638de61de3419193e6487d88c4d5bb9abbf0ed5e61406ecfb
6
+ metadata.gz: b83bc1f1b4995779073a53ec19a542c80e6aac02a3995b44f51d16e875fbe12137fb540aabdfc7c4b03e65ff79e3322a3fc8fff60f6b4937bf1e6c7899b22e3f
7
+ data.tar.gz: 55826f34f74b4c2cf8cf7cdd9a07310b7466927424d478da49e2ddf2b09455469d128f1e1513561f58261471e8cb67a626d58720bf7d4b820fbefdd36ef217ce
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markovite (0.2.2)
4
+ markovite (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -5,6 +5,8 @@ module Markovite
5
5
  class Chain
6
6
  attr_accessor :dictionary, :chainer, :split
7
7
  attr_reader :depth
8
+ MIN_DEPTH = 1
9
+ MAX_DEPTH = 4
8
10
  DEFAULT_DEPTH = 2
9
11
  MAX_FILENAME_LENGTH = 255
10
12
 
@@ -13,6 +15,7 @@ module Markovite
13
15
  end
14
16
 
15
17
  def parse_string(text, dict_depth=DEFAULT_DEPTH)
18
+ depth_check(dict_depth)
16
19
  if chainer
17
20
  add_from_text(text)
18
21
  else
@@ -58,6 +61,18 @@ module Markovite
58
61
 
59
62
  private
60
63
 
64
+ def depth_check(dict_depth)
65
+ if chainer
66
+ raise "Chain depth conflict" if dict_depth != depth
67
+ elsif !is_valid_depth?(dict_depth)
68
+ raise "Chain depth must be between #{MIN_DEPTH} and #{MAX_DEPTH}"
69
+ end
70
+ end
71
+
72
+ def is_valid_depth?(dict_depth)
73
+ dict_depth >= MIN_DEPTH && dict_depth <= MAX_DEPTH
74
+ end
75
+
61
76
  def split_words(str)
62
77
  str.split(" ")
63
78
  end
@@ -1,3 +1,3 @@
1
1
  module Markovite
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markovite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandra Wright
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-31 00:00:00.000000000 Z
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,6 +92,7 @@ files:
92
92
  - lib/markovite/splitter.rb
93
93
  - lib/markovite/version.rb
94
94
  - markovite.gemspec
95
+ - pkg/markovite-0.2.2.gem
95
96
  homepage: https://github.com/f3mshep/ruby_markovify
96
97
  licenses:
97
98
  - MIT