rantly 1.2.0 → 3.0.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.
@@ -1,7 +1,7 @@
1
1
  # Integer : shrink to zero
2
2
  class Integer
3
3
  def shrink
4
- shrunk = if self > 8
4
+ if self > 8
5
5
  self / 2
6
6
  elsif self > 0
7
7
  self - 1
@@ -12,7 +12,6 @@ class Integer
12
12
  else
13
13
  0
14
14
  end
15
- return shrunk
16
15
  end
17
16
 
18
17
  def retry?
@@ -27,12 +26,12 @@ end
27
26
  # String : shrink to ""
28
27
  class String
29
28
  def shrink
30
- shrunk = self.dup
31
- if self.size > 0
32
- idx = Random::rand(self.size)
33
- shrunk[idx] = ""
29
+ shrunk = dup
30
+ unless empty?
31
+ idx = Random.rand(size)
32
+ shrunk[idx] = ''
34
33
  end
35
- return shrunk
34
+ shrunk
36
35
  end
37
36
 
38
37
  def retry?
@@ -40,7 +39,7 @@ class String
40
39
  end
41
40
 
42
41
  def shrinkable?
43
- self != ""
42
+ self != ''
44
43
  end
45
44
  end
46
45
 
@@ -64,39 +63,36 @@ class Tuple
64
63
  end
65
64
 
66
65
  def size
67
- self.length
66
+ length
68
67
  end
69
68
 
70
69
  def to_s
71
- @array.to_s.insert(1, "T ")
70
+ @array.to_s.insert(1, 'T ')
72
71
  end
73
72
 
74
73
  def inspect
75
- self.to_s
74
+ to_s
76
75
  end
77
76
 
78
77
  def each(&block)
79
78
  @array.each(&block)
80
79
  end
81
80
 
82
- def array
83
- return @array
84
- end
81
+ attr_reader :array
85
82
 
86
83
  def shrink
87
84
  shrunk = @array.dup
88
85
  while @position >= 0
89
86
  e = @array.at(@position)
90
- if e.respond_to?(:shrinkable?) && e.shrinkable?
91
- break
92
- end
87
+ break if e.respond_to?(:shrinkable?) && e.shrinkable?
88
+
93
89
  @position -= 1
94
90
  end
95
91
  if @position >= 0
96
92
  shrunk[@position] = e.shrink
97
93
  @position -= 1
98
94
  end
99
- return Tuple.new(shrunk)
95
+ Tuple.new(shrunk)
100
96
  end
101
97
 
102
98
  def retry?
@@ -104,7 +100,7 @@ class Tuple
104
100
  end
105
101
 
106
102
  def shrinkable?
107
- @array.any? {|e| e.respond_to?(:shrinkable?) && e.shrinkable? }
103
+ @array.any? { |e| e.respond_to?(:shrinkable?) && e.shrinkable? }
108
104
  end
109
105
  end
110
106
 
@@ -128,24 +124,22 @@ class Deflating
128
124
  end
129
125
 
130
126
  def size
131
- self.length
127
+ length
132
128
  end
133
129
 
134
130
  def to_s
135
- @array.to_s.insert(1, "D ")
131
+ @array.to_s.insert(1, 'D ')
136
132
  end
137
133
 
138
134
  def inspect
139
- self.to_s
135
+ to_s
140
136
  end
141
137
 
142
138
  def each(&block)
143
139
  @array.each(&block)
144
140
  end
145
141
 
146
- def array
147
- return @array
148
- end
142
+ attr_reader :array
149
143
 
150
144
  def shrink
151
145
  shrunk = @array.dup
@@ -158,7 +152,7 @@ class Deflating
158
152
  end
159
153
  @position -= 1
160
154
  end
161
- return Deflating.new(shrunk)
155
+ Deflating.new(shrunk)
162
156
  end
163
157
 
164
158
  def retry?
@@ -172,24 +166,24 @@ end
172
166
 
173
167
  class Hash
174
168
  def shrink
175
- if self.any?{|_,v| v.respond_to?(:shrinkable?) && v.shrinkable? }
176
- key,_ = self.detect{|_,v| v.respond_to?(:shrinkable?) && v.shrinkable? }
177
- clone = self.dup
169
+ if any? { |_, v| v.respond_to?(:shrinkable?) && v.shrinkable? }
170
+ key, = detect { |_, v| v.respond_to?(:shrinkable?) && v.shrinkable? }
171
+ clone = dup
178
172
  clone[key] = clone[key].shrink
179
- return clone
180
- elsif !self.empty?
181
- key = self.keys.first
182
- h2 = self.dup
173
+ clone
174
+ elsif !empty?
175
+ key = keys.first
176
+ h2 = dup
183
177
  h2.delete(key)
184
- return h2
178
+ h2
185
179
  else
186
- return self
180
+ self
187
181
  end
188
182
  end
189
183
 
190
184
  def shrinkable?
191
- self.any?{|_,v| v.respond_to?(:shrinkable?) && v.shrinkable? } ||
192
- !self.empty?
185
+ any? { |_, v| v.respond_to?(:shrinkable?) && v.shrinkable? } ||
186
+ !empty?
193
187
  end
194
188
 
195
189
  def retry?
data/lib/rantly/silly.rb CHANGED
@@ -8,18 +8,17 @@ module Rantly::Silly
8
8
  end
9
9
 
10
10
  module Rantly::Silly::Love
11
+ def letter(n = 3)
12
+ body = array(n) { paragraph }.join "\n\n"
13
+ <<~EOS
14
+ #{address}:
11
15
 
12
- def letter(n=3)
13
- body = array(n){paragraph}.join "\n\n"
14
- <<-EOS
15
- #{address}:
16
+ #{body}
16
17
 
17
- #{body}
18
+ #{sign}
18
19
 
19
- #{sign}
20
-
21
- #{post_script}
22
- EOS
20
+ #{post_script}
21
+ EOS
23
22
  end
24
23
 
25
24
  def address
@@ -27,31 +26,34 @@ EOS
27
26
  end
28
27
 
29
28
  def extremifier
30
- choose "most","ultimate","unbelievable","incredible","burning"
29
+ choose 'most', 'ultimate', 'unbelievable', 'incredible', 'burning'
31
30
  end
32
31
 
33
32
  def pedestal_label
34
- choose "beloved","desire","dove","virgin goddess","existential solution","lighthouse","beacon","holy mother","queen","mistress"
33
+ choose 'beloved', 'desire', 'dove', 'virgin goddess', 'existential solution', 'lighthouse', 'beacon', 'holy mother', 'queen', 'mistress'
35
34
  end
36
35
 
37
36
  def double_plus_good
38
- choose "holy","shiny","glittering","joyous","delicious"
37
+ choose 'holy', 'shiny', 'glittering', 'joyous', 'delicious'
39
38
  end
40
39
 
41
40
  def how_i_feel
42
- choose "my heart aches","my spine pines","my spirit wanders and wonders","my soul is awed","my loin burns"
41
+ choose 'my heart aches', 'my spine pines', 'my spirit wanders and wonders', 'my soul is awed', 'my loin burns'
43
42
  end
44
43
 
45
44
  def paragraph
46
- array(range(2,4)){ sentence}.join " "
45
+ array(range(2, 4)) { sentence }.join ' '
47
46
  end
48
47
 
49
48
  def sentence
50
49
  freq \
51
- Proc.new { "when #{how_i_feel}, my #{pedestal_label}, i feel the need to #{stalk_action}, but this is not because #{how_i_feel}, but rather a symptom of my being your #{whoami}." },
52
- Proc.new { "because you are my #{pedestal_label}, and i am your #{whoami}, no, rather your #{whoami}, #{fragment}."},
53
- Proc.new { "do not think that saying '#{how_i_feel}' suffices to show the depth of how #{how_i_feel}, because more than that, #{fantasy}"},
54
- Proc.new { "as a #{whoami}, that #{how_i_feel} is never quite enough for you, my #{double_plus_good} #{pedestal_label}."}
50
+ proc {
51
+ "when #{how_i_feel}, my #{pedestal_label}, i feel the need to #{stalk_action},"\
52
+ "but this is not because #{how_i_feel}, but rather a symptom of my being your #{whoami}."
53
+ },
54
+ proc { "because you are my #{pedestal_label}, and i am your #{whoami}, no, rather your #{whoami}, #{fragment}." },
55
+ proc { "do not think that saying '#{how_i_feel}' suffices to show the depth of how #{how_i_feel}, because more than that, #{fantasy}" },
56
+ proc { "as a #{whoami}, that #{how_i_feel} is never quite enough for you, my #{double_plus_good} #{pedestal_label}." }
55
57
  end
56
58
 
57
59
  def fragment
@@ -59,8 +61,7 @@ EOS
59
61
  choose "i hope to god #{fun}", "i believe #{fun}", "i will that #{fun}"
60
62
  end
61
63
 
62
- def caused_by
63
- end
64
+ def caused_by; end
64
65
 
65
66
  def whoami
66
67
  "#{extremifier} #{humbleizer} #{groveler}"
@@ -71,11 +72,11 @@ EOS
71
72
  end
72
73
 
73
74
  def humbleizer
74
- choose "undeserving","insignificant","unremarkable","fearful","menial"
75
+ choose 'undeserving', 'insignificant', 'unremarkable', 'fearful', 'menial'
75
76
  end
76
77
 
77
78
  def groveler
78
- choose "slave","servant","captive","lapdog"
79
+ choose 'slave', 'servant', 'captive', 'lapdog'
79
80
  end
80
81
 
81
82
  def post_script
@@ -88,27 +89,28 @@ EOS
88
89
 
89
90
  def fantasy
90
91
  freq \
91
- Proc.new {
92
- make = choose "raise","nurture","bring into the world"
93
- babies = choose "brood of babies","#{double_plus_good} angels"
94
- good = double_plus_good
95
- effect = choose "the world becomes all the more #{good}",
96
- "we may at the end of our lives rest in #{good} peace.",
97
- "you, my #{pedestal_label}, would continue to live."
98
- "we would #{make} #{babies}, so #{effect}."
99
- },
100
- Proc.new {
101
- do_thing = choose "kiss","hug","read poetry to each other","massage","whisper empty nothings into each others' ears","be with each other, and oblivious to the entire world"
102
- affect = choose "joy", "mindfulness", "calm", "sanctity"
103
- "we would #{do_thing} with #{double_plus_good} #{affect}"
104
- }
92
+ proc {
93
+ make = choose 'raise', 'nurture', 'bring into the world'
94
+ babies = choose 'brood of babies', "#{double_plus_good} angels"
95
+ good = double_plus_good
96
+ effect = choose "the world becomes all the more #{good}",
97
+ "we may at the end of our lives rest in #{good} peace.",
98
+ "you, my #{pedestal_label}, would continue to live."
99
+ "we would #{make} #{babies}, so #{effect}."
100
+ },
101
+ proc {
102
+ do_thing = choose('kiss', 'hug', 'read poetry to each other', 'massage', "whisper empty nothings into each others' ears",
103
+ 'be with each other, and oblivious to the entire world')
104
+ affect = choose 'joy', 'mindfulness', 'calm', 'sanctity'
105
+ "we would #{do_thing} with #{double_plus_good} #{affect}"
106
+ }
105
107
  end
106
108
 
107
109
  def stalk_action
108
- choose "think of you","dream of us together","look at your picture and sigh"
110
+ choose 'think of you', 'dream of us together', 'look at your picture and sigh'
109
111
  end
110
112
 
111
113
  def time_duration
112
- choose "once in a while","night","day","hour","minute"
114
+ choose 'once in a while', 'night', 'day', 'hour', 'minute'
113
115
  end
114
116
  end
data/lib/rantly/spec.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'rantly'
2
2
  module Rantly::Check
3
- def check(n=100,&block)
4
- Rantly.gen.each(n,&block)
3
+ def check(n = 100, &block)
4
+ Rantly.gen.each(n, &block)
5
5
  end
6
6
 
7
- def sample(n=100,&block)
8
- Rantly.gen.map(n,&block)
7
+ def sample(n = 100, &block)
8
+ Rantly.gen.map(n, &block)
9
9
  end
10
10
  end
data/lib/rantly.rb CHANGED
@@ -1,14 +1,14 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__)) unless
2
+ $LOAD_PATH.include?(File.dirname(__FILE__)) || $LOAD_PATH.include?(__dir__)
3
3
 
4
4
  class Rantly
5
5
  end
6
6
 
7
7
  require 'rantly/generator'
8
8
 
9
- def Rantly(n=1,&block)
9
+ def Rantly(n = 1, &block)
10
10
  if n > 1
11
- Rantly.map(n,&block)
11
+ Rantly.map(n, &block)
12
12
  else
13
13
  Rantly.value(&block)
14
14
  end
data/rantly.gemspec CHANGED
@@ -1,47 +1,42 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = "rantly"
3
- s.summary = "Ruby Imperative Random Data Generator and Quickcheck"
4
- s.homepage = "https://github.com/rantly-rb/rantly"
5
- s.version = "1.2.0"
6
- s.license = "MIT"
7
- s.require_paths = ["lib"]
8
- s.authors = ["Ana María Martínez Gómez", "Howard Yeh", "Anthony Bargnesi", "Eric Bischoff"]
9
- s.email = ["anamma06@gmail.com", "hayeah@gmail.com", "abargnesi@gmail.com", "ebischoff@nerim.net"]
2
+ s.name = 'rantly'
3
+ s.summary = 'Ruby Imperative Random Data Generator and Quickcheck'
4
+ s.homepage = 'https://github.com/rantly-rb/rantly'
5
+ s.version = '3.0.0'
6
+ s.license = 'MIT'
7
+ s.require_paths = ['lib']
8
+ s.authors = ['Ana María Martínez Gómez', 'Howard Yeh', 'Anthony Bargnesi', 'Eric Bischoff']
9
+ s.email = ['anamma06@gmail.com', 'hayeah@gmail.com', 'abargnesi@gmail.com', 'ebischoff@nerim.net']
10
10
  s.extra_rdoc_files = [
11
- "LICENSE",
12
- "README.md",
13
- "CHANGELOG.md"
11
+ 'LICENSE',
12
+ 'README.md',
13
+ 'CHANGELOG.md'
14
14
  ]
15
- s.files = [
16
- ".document",
17
- ".travis.yml",
18
- "Gemfile",
19
- "LICENSE",
20
- "README.md",
21
- "CHANGELOG.md",
22
- "Rakefile",
23
- "VERSION.yml",
24
- "lib/rantly.rb",
25
- "lib/rantly/data.rb",
26
- "lib/rantly/generator.rb",
27
- "lib/rantly/minitest.rb",
28
- "lib/rantly/minitest_extensions.rb",
29
- "lib/rantly/property.rb",
30
- "lib/rantly/rspec.rb",
31
- "lib/rantly/rspec_extensions.rb",
32
- "lib/rantly/shrinks.rb",
33
- "lib/rantly/silly.rb",
34
- "lib/rantly/spec.rb",
35
- "lib/rantly/testunit_extensions.rb",
36
- "rantly.gemspec",
37
- "test/rantly_test.rb",
38
- "test/shrinks_test.rb",
39
- "test/test_helper.rb"
15
+ s.files = [
16
+ '.document',
17
+ '.travis.yml',
18
+ 'Gemfile',
19
+ 'LICENSE',
20
+ 'README.md',
21
+ 'CHANGELOG.md',
22
+ 'Rakefile',
23
+ 'VERSION.yml',
24
+ 'lib/rantly.rb',
25
+ 'lib/rantly/data.rb',
26
+ 'lib/rantly/generator.rb',
27
+ 'lib/rantly/minitest.rb',
28
+ 'lib/rantly/minitest_extensions.rb',
29
+ 'lib/rantly/property.rb',
30
+ 'lib/rantly/rspec.rb',
31
+ 'lib/rantly/rspec_extensions.rb',
32
+ 'lib/rantly/shrinks.rb',
33
+ 'lib/rantly/silly.rb',
34
+ 'lib/rantly/spec.rb',
35
+ 'lib/rantly/testunit_extensions.rb',
36
+ 'rantly.gemspec',
37
+ 'test/rantly_test.rb',
38
+ 'test/shrinks_test.rb',
39
+ 'test/test_helper.rb'
40
40
  ]
41
-
42
- s.add_development_dependency('rake', '~> 12.0.0')
43
- s.add_development_dependency('minitest', '~> 5.10.0')
44
- s.add_development_dependency('simplecov', '>= 0')
45
- s.add_development_dependency('coveralls', '>= 0')
41
+ s.required_ruby_version = '>= 3.3.0'
46
42
  end
47
-