loremarkov 0.1.0.1 → 0.2.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1b090a999f8b1b376bf4ca583921332ae438353
4
- data.tar.gz: c6d7d3a7a0eb6232485b0e19930038c84592c30f
3
+ metadata.gz: e78a7b3fb1d519f6c0224af1f9f1b7d474dc3d26
4
+ data.tar.gz: 69de89322707b1b4b6fe12e50e3c3210440d8288
5
5
  SHA512:
6
- metadata.gz: 2c1365ca9471260d02e26451a4dec7819910251c12610aac187dfc8c53f96db81e6fb7c7a6ae8bc32fdfc594a18efef3bd215d34ef8ff77e3dcdb1f4785fe560
7
- data.tar.gz: 92b2da3a553e8170383c377be1c288891921327dc964d47d7e05b2acad68119953fca975d57c6bb939059b3161e83369390fb0fdbb26a6cbde13f9feae26a86e
6
+ metadata.gz: 2777a1717bebf7649e6ba48ae38a0385bccf1d23247f00c5aca5b0ac64468058ec11a469cdbb84c94d6dc1d680109aece186e381afc54407c022d2b42b7c6382
7
+ data.tar.gz: 1d998f8216b82045bed198cdbaf5f6996ae17e1382505b540a80930605bed458c933068f17c690aeff7b6eb98ee2ad1736b06a3de7714d3702bd2c99a6957622
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ [![Build Status](https://travis-ci.org/rickhull/loremarkov.svg?branch=master)](https://travis-ci.org/rickhull/loremarkov)
2
+ [![Gem Version](https://badge.fury.io/rb/loremarkov.svg)](http://badge.fury.io/rb/loremarkov)
3
+ [![Code Climate](https://codeclimate.com/github/rickhull/loremarkov/badges/gpa.svg)](https://codeclimate.com/github/rickhull/loremarkov)
4
+ [![Dependency Status](https://gemnasium.com/rickhull/loremarkov.svg)](https://gemnasium.com/rickhull/loremarkov)
5
+ [![Security Status](https://hakiri.io/github/rickhull/loremarkov/master.svg)](https://hakiri.io/github/rickhull/loremarkov/master)
6
+
1
7
  Introduction
2
8
  ===
3
9
 
@@ -33,7 +39,7 @@ Examples
33
39
  $ destroy epigenetics
34
40
  $ destroy oslo_accords 3
35
41
  $ destroy ~/my_first_corpus.txt
36
- $ man ls | destroy 6
42
+ $ man ls | destroy 12
37
43
 
38
44
  Inspiration
39
45
  ===
data/Rakefile CHANGED
@@ -3,9 +3,10 @@ require 'buildar'
3
3
  Buildar.new do |b|
4
4
  b.gemspec_file = 'loremarkov.gemspec'
5
5
  b.version_file = 'VERSION'
6
+ b.use_git = true
6
7
  end
7
8
 
8
- # task default: %w[test bench]
9
+ task default: %w[test rocco] # bench]
9
10
 
10
11
  require 'rake/testtask'
11
12
  desc "Run tests"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0.1
1
+ 0.2.0.1
data/lib/loremarkov.rb CHANGED
@@ -93,6 +93,12 @@ class Loremarkov
93
93
  lex(text[0, 999 * num_prefix_words])[0, num_prefix_words]
94
94
  end
95
95
 
96
+ # Given `lorem_ipsum`, return the string from reading `text/lorem_ipsum`
97
+ def self.sample_text(name)
98
+ File.read File.join(__dir__, '..', 'text', name)
99
+ end
100
+
101
+ # Useful for testing at the very least
96
102
  attr_reader :markov
97
103
 
98
104
  # More prefix_words means tighter alignment to original text
@@ -102,7 +108,10 @@ class Loremarkov
102
108
  end
103
109
 
104
110
  # Generate Markov structure from text.
105
- # Text should have a definite end, not just a convenient buffer split
111
+ # Text should have a definite end, not just a convenient buffer split.
112
+ # This method may be called several times, but note that several EOFs
113
+ # will be present in the markov structure, any one of which will trigger
114
+ # a conclusion by #generate_all.
106
115
  def analyze(text)
107
116
  @markov.merge!(self.class.analyze(text, @num_prefix_words))
108
117
  end
data/loremarkov.gemspec CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  'text/lorem_ipsum',
16
16
  'text/epigenetics',
17
17
  'text/oslo_accords',
18
+ 'test/test_loremarkov.rb',
18
19
  ]
19
20
  s.executables = ['destroy']
20
21
  s.add_development_dependency "buildar", "~> 2"
@@ -0,0 +1,33 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'loremarkov'
4
+
5
+ NUM_PREFIX = 3
6
+ LOREM_IPSUM = Loremarkov.sample_text 'lorem_ipsum'
7
+ LOREM_LEX = Loremarkov.lex LOREM_IPSUM
8
+ LOREM_SENTENCE = LOREM_IPSUM[/[^.]*\./]
9
+ LOREM_SENTENCE_WORDS = %w{
10
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
11
+ tempor incididunt ut labore et dolore magna aliqua.
12
+ }
13
+
14
+ describe Loremarkov do
15
+ describe "Lorem ipsum" do
16
+ describe "sample text" do
17
+ it "must match test data" do
18
+ # this works because the first Lorem tokens are all spaces
19
+ LOREM_SENTENCE.must_equal LOREM_SENTENCE_WORDS.join(' ')
20
+ end
21
+ end
22
+
23
+ describe "lex" do
24
+ it "must provide expected prefixes" do
25
+ LOREM_LEX.each.with_index { |token, i|
26
+ break if i >= 36
27
+ # this too works because all tokens are spaces
28
+ token.must_equal (i % 2 == 0 ? LOREM_SENTENCE_WORDS[i/2] : ' ')
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loremarkov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.1
4
+ version: 0.2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Hull
@@ -65,6 +65,7 @@ files:
65
65
  - bin/destroy
66
66
  - lib/loremarkov.rb
67
67
  - loremarkov.gemspec
68
+ - test/test_loremarkov.rb
68
69
  - text/epigenetics
69
70
  - text/lorem_ipsum
70
71
  - text/oslo_accords