literate_randomizer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -50,6 +50,16 @@ Advanced example:
50
50
  lr.paragraph :sentances => 5, :words => 3..8, :first_word => "A", :punctuation => "!!!"
51
51
  # => "A dense mob of our. Gods on that Challenger. Invariably to safety though. Weaponless but it my! Some bandy-legged lurching creature!!!"
52
52
 
53
+ If you just want to use a single, global instance, you can initialize and access it this way:
54
+
55
+ # initialize on first call
56
+ # use the same options as .create
57
+ LiterateRandomizer::global(options={})
58
+
59
+ # after the first call, options are ignored and the existing randomizer is returned
60
+ LiterateRandomizer::global.sentance
61
+ # => "Muscular arms round opening of sorts while Lord John Roxton."
62
+
53
63
  ## Contributing
54
64
 
55
65
  1. Fork it
@@ -7,4 +7,9 @@ module LiterateRandomizer
7
7
  def LiterateRandomizer::create(options={})
8
8
  MarkovChain.new options
9
9
  end
10
+
11
+ def LiterateRandomizer::global(options={})
12
+ MarkovChain.global options
13
+ end
14
+
10
15
  end
@@ -97,6 +97,12 @@ class MarkovChain
97
97
  populate
98
98
  end
99
99
 
100
+ class << self
101
+ def global(options={})
102
+ @global_randomizer = MarkovChain.new options
103
+ end
104
+ end
105
+
100
106
  def inspect
101
107
  "#<#{self.class}: #{@words.length} words, #{@markov_words.length} word-chains, #{@first_words.length} first_words>"
102
108
  end
@@ -1,3 +1,3 @@
1
1
  module LiterateRandomizer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -67,4 +67,8 @@ describe LiterateRandomizer do
67
67
  it "punctuation should work" do
68
68
  new_lr.paragraph(:punctuation => "!!!",:sentances => 5, :words=>3).should == "Bad job for? Discreetly vague way. Melee in the. Gleam of a. Puffing as a!!!"
69
69
  end
70
+
71
+ it "global_randomizer_should work" do
72
+ LiterateRandomizer::global.class.should == LiterateRandomizer::MarkovChain
73
+ end
70
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: literate_randomizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: