dunmanifestin 1.0.1 → 1.1.2

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
  SHA256:
3
- metadata.gz: 55d7067a0c40ad1e14de97d12e9b8a3244e07d0852823b242227686fa37279d6
4
- data.tar.gz: 3207afa67b6f493fcd4feefb934acba148a347428b1d67b10c142c559172e99a
3
+ metadata.gz: 934eb3422c194a6dd594aeabeb0463c06f79d8d1df3900ddbaf5ff891369abd4
4
+ data.tar.gz: ffb693990eead59ae574e5b90520aaad3fb3893b931e2d69733cf61dfe5f39f4
5
5
  SHA512:
6
- metadata.gz: c0d1c2fe81d1bb8d4c71a48cb7e788cc2718217f0f5cc63552d6908b98235b51d0c2df61427561abc00ce648eff9ec598f5fe1beed891cca318f0843cb48902f
7
- data.tar.gz: f68a590e1ad6848f0ded1a08c7a4c34e80d26d5e44b2fdf402acadeee97e5f372caabc82e34b0edb4c9aa4f0a028fa2f771acd46a7437aeb1bbce7a58b4adf01
6
+ metadata.gz: e23c747b18b8de4e6315ec97beb2a3c179bc1c72144344c23c5bda325e58457353e77f67b1023a142cdc4df701fecb4709b97eb05f6c1952538f40e757f7229e
7
+ data.tar.gz: 7189eed17e6daf22aa608293243ded14113ea1ce26d2156af8d8f2b974ba278c8801ecaa453a2a45e6536ee9fd3e6699da8652bb30f5821d4f46269dd3a405e1
@@ -12,8 +12,8 @@ user_demands = Optimist::options do
12
12
  opt :phrase, "Specify a phrase or list, e.g. 'The [animal] sat on the [article]' or '[weapon]'", type: :string, short: '-p'
13
13
  opt :chomp, "remove the trailing newline from the output", short: '-o'
14
14
  opt :file, "Read a file as the phrase", type: :string, short: '-f'
15
- opt :coarse_seed, "Stick to one region", type: :integer, short: "-s"
16
- opt :fine_seed, "Lock all randomness", type: :integer, short: "-e"
15
+ opt :coarse_seed, "Set this number to encourage phrases to resolve somewhat predictably", type: :integer, short: "-s"
16
+ opt :fine_seed, "Set this number (alongside -s) to lock phrases into resolving completely predictably", type: :integer, short: "-e"
17
17
  end
18
18
 
19
19
  begin
@@ -1,13 +1,26 @@
1
- NUM_DEFAULT_REGIONS = 100000
2
- RECCURENCES = 5
3
- COARSE_SEED ||= rand(NUM_DEFAULT_REGIONS)
4
- FINE_SEED ||= nil
5
-
6
- META_RANDOM = FINE_SEED ? Random.new(FINE_SEED) : Random.new
7
- RANDOMS = RECCURENCES.times.map { Random.new(COARSE_SEED) }
1
+ require_relative 'integer'
8
2
 
9
3
  class Array
10
- def constrained_sample(randoms: RANDOMS, meta_random: META_RANDOM)
4
+ RECCURENCES = 500
5
+
6
+ class << self
7
+ attr_accessor :coarse_seed, :fine_seed, :diversity
8
+
9
+ def meta_random
10
+ @meta_random ||= @fine_seed ? Random.new(@fine_seed) : Random.new
11
+ end
12
+
13
+ def randoms
14
+ @coarse_seed ||= meta_random.rand(Integer::MAX)
15
+ @randoms ||= RECCURENCES.times.map do |i|
16
+ Random.new(@coarse_seed + i % @diversity)
17
+ end
18
+ end
19
+ end
20
+
21
+ def constrained_sample(randoms: Array.randoms, meta_random: Array.meta_random)
22
+ # $count ||= 1
23
+ # p $count += 1
11
24
  self.sample(
12
25
  1,
13
26
  random: randoms.sample(1, random: meta_random).pop
@@ -0,0 +1,6 @@
1
+ class Integer
2
+ N_BYTES = [42].pack('i').size
3
+ N_BITS = N_BYTES * 16
4
+ MAX = 2 ** (N_BITS - 2) - 1
5
+ MIN = -MAX - 1
6
+ end
@@ -136,7 +136,10 @@ class Phrase
136
136
 
137
137
  delegates = @inflection_delegates[inflection]
138
138
  delegates.each { |delegate| variables[delegate].inflect inflection }
139
-
139
+ self
140
+ rescue NoMethodError
141
+ puts "==> Failed to inflect: .#{inflection}?"
142
+ puts "==> Valid inflections are: plural, possessive, article, capitalize, titleize"
140
143
  self
141
144
  end
142
145
 
@@ -9,9 +9,9 @@ class Terminator
9
9
  end
10
10
 
11
11
  def address demands
12
- $coarse_seed = demands[:coarse_seed] || $coarse_seed
13
- $fine_seed = demands[:fine_seed] || $fine_seed
14
-
12
+ Array.coarse_seed = demands[:coarse_seed]
13
+ Array.fine_seed = demands[:fine_seed]
14
+ Array.diversity = 5
15
15
  phrase_string = phrasing(demands[:phrase], demands[:file])
16
16
  root_phrase_class = Class.new(Phrase) { list phrase_string, !!demands[:file] }
17
17
  list_loader.load demands[:genre]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dunmanifestin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - quavmo
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-04-01 00:00:00.000000000 Z
13
+ date: 2019-04-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -100,6 +100,7 @@ files:
100
100
  - lib/dunmanifestin/array.rb
101
101
  - lib/dunmanifestin/custom_inflections.rb
102
102
  - lib/dunmanifestin/generator.rb
103
+ - lib/dunmanifestin/integer.rb
103
104
  - lib/dunmanifestin/list.rb
104
105
  - lib/dunmanifestin/list_loader.rb
105
106
  - lib/dunmanifestin/manifestation.rb