rantly 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :major: 0
3
- :minor: 1
4
2
  :build:
3
+ :major: 0
4
+ :minor: 2
5
5
  :patch: 0
@@ -1,7 +1,7 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
- class Rant
4
+ class Rantly
5
5
  end
6
6
 
7
- require 'rant/generator'
7
+ require 'rantly/generator'
@@ -1,4 +1,4 @@
1
- module Rant::Data
1
+ module Rantly::Data
2
2
  def email
3
3
  "#{string(:alnum)}@#{string(:alnum)}.#{sized(3){string(:alpha)}}".downcase
4
4
  end
@@ -8,6 +8,6 @@ module Rant::Data
8
8
  end
9
9
  end
10
10
 
11
- class Rant
12
- include Rant::Data
11
+ class Rantly
12
+ include Rantly::Data
13
13
  end
@@ -1,9 +1,9 @@
1
- class Rant
1
+ class Rantly
2
2
 
3
3
  class << self
4
4
  attr_writer :default_size
5
5
  def singleton
6
- @singleton ||= Rant.new
6
+ @singleton ||= Rantly.new
7
7
  @singleton
8
8
  end
9
9
 
@@ -11,6 +11,18 @@ class Rant
11
11
  @default_size || 6
12
12
  end
13
13
 
14
+ def each(n,limit=10,&block)
15
+ gen.each(n,limit,&block)
16
+ end
17
+
18
+ def map(n,limit=10,&block)
19
+ gen.map(n,limit,&block)
20
+ end
21
+
22
+ def value(limit=10,&block)
23
+ gen.value(limit,&block)
24
+ end
25
+
14
26
  def gen
15
27
  self.singleton
16
28
  end
@@ -93,7 +105,7 @@ class Rant
93
105
  end
94
106
 
95
107
  def size
96
- @size || Rant.default_size
108
+ @size || Rantly.default_size
97
109
  end
98
110
 
99
111
  def sized(n,&block)
@@ -259,5 +271,3 @@ class Rant
259
271
  str
260
272
  end
261
273
  end
262
-
263
-
@@ -1,8 +1,8 @@
1
- require 'rant'
1
+ require 'rantly'
2
2
  require 'test/unit'
3
3
  require 'pp'
4
4
 
5
- class Rant::Property
5
+ class Rantly::Property
6
6
 
7
7
  def initialize(property)
8
8
  @property = property
@@ -12,7 +12,7 @@ class Rant::Property
12
12
  i = 0
13
13
  test_data = nil
14
14
  begin
15
- Rant.singleton.generate(n,limit,@property) do |val|
15
+ Rantly.singleton.generate(n,limit,@property) do |val|
16
16
  test_data = val
17
17
  assertion.call(val) if assertion
18
18
  puts "" if i % 100 == 0
@@ -21,7 +21,7 @@ class Rant::Property
21
21
  end
22
22
  puts
23
23
  puts "success: #{i} tests"
24
- rescue Rant::TooManyTries => e
24
+ rescue Rantly::TooManyTries => e
25
25
  puts
26
26
  puts "too many tries: #{e.tries}"
27
27
  raise e
@@ -44,7 +44,7 @@ end
44
44
 
45
45
  module Test::Unit::Assertions
46
46
  def property_of(&block)
47
- Rant::Property.new(block)
47
+ Rantly::Property.new(block)
48
48
  end
49
49
  end
50
50
 
@@ -1,13 +1,13 @@
1
- require 'rant'
2
- module Rant::Silly
1
+ require 'rantly'
2
+ module Rantly::Silly
3
3
  class << self
4
4
  def love_letter(n)
5
- Rant.new.extend(Rant::Silly::Love).value { letter(n) }
5
+ Rantly.new.extend(Rantly::Silly::Love).value { letter(n) }
6
6
  end
7
7
  end
8
8
  end
9
9
 
10
- module Rant::Silly::Love
10
+ module Rantly::Silly::Love
11
11
 
12
12
  def letter(n=3)
13
13
  body = sized(n) { array(:paragraph) }.join "\n\n"
@@ -0,0 +1,10 @@
1
+ require 'rantly'
2
+ module Rantly::Check
3
+ def check(n=100,&block)
4
+ Rantly.gen.each(n,&block)
5
+ end
6
+
7
+ def sample(n=100,&block)
8
+ Rantly.gen.map(n,&block)
9
+ end
10
+ end
data/rantly.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rantly}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Howard Yeh"]
12
- s.date = %q{2009-11-30}
12
+ s.date = %q{2010-01-04}
13
13
  s.email = %q{hayeah@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -21,16 +21,15 @@ Gem::Specification.new do |s|
21
21
  "LICENSE",
22
22
  "README.textile",
23
23
  "Rakefile",
24
- "Rant.gemspec",
25
24
  "VERSION.yml",
26
- "lib/rant.rb",
27
- "lib/rant/data.rb",
28
- "lib/rant/generator.rb",
29
- "lib/rant/property.rb",
30
- "lib/rant/silly.rb",
31
- "lib/rant/spec.rb",
25
+ "lib/rantly.rb",
26
+ "lib/rantly/data.rb",
27
+ "lib/rantly/generator.rb",
28
+ "lib/rantly/property.rb",
29
+ "lib/rantly/silly.rb",
30
+ "lib/rantly/spec.rb",
32
31
  "rantly.gemspec",
33
- "test/rant_test.rb",
32
+ "test/rantly_test.rb",
34
33
  "test/test_helper.rb"
35
34
  ]
36
35
  s.homepage = %q{http://github.com/hayeah/rantly}
@@ -39,7 +38,7 @@ Gem::Specification.new do |s|
39
38
  s.rubygems_version = %q{1.3.5}
40
39
  s.summary = %q{Ruby Imperative Random Data Generator and Quickcheck}
41
40
  s.test_files = [
42
- "test/rant_test.rb",
41
+ "test/rantly_test.rb",
43
42
  "test/test_helper.rb"
44
43
  ]
45
44
 
@@ -1,18 +1,18 @@
1
- require 'test_helper'
2
- require 'rant/check'
1
+ require 'test/test_helper'
2
+ require 'rantly/property'
3
3
 
4
- module RantTest
4
+ module RantlyTest
5
5
  end
6
6
 
7
7
  # check we generate the right kind of data.
8
8
  ## doesn't check for distribution
9
- class RantTest::Generator < Test::Unit::TestCase
9
+ class RantlyTest::Generator < Test::Unit::TestCase
10
10
  def setup
11
- Rant.gen.reset
11
+ Rantly.gen.reset
12
12
  end
13
13
 
14
14
  should "fail test generation" do
15
- assert_raises(Rant::TooManyTries) {
15
+ assert_raises(Rantly::TooManyTries) {
16
16
  property_of { guard range(0,1) < 0 }.check
17
17
  }
18
18
  end
@@ -59,7 +59,7 @@ class RantTest::Generator < Test::Unit::TestCase
59
59
  end
60
60
 
61
61
  should "generate Boolean" do
62
- property_of { bool }.check { |t|
62
+ property_of { boolean }.check { |t|
63
63
  assert t == true || t == false
64
64
  }
65
65
  end
@@ -73,14 +73,14 @@ class RantTest::Generator < Test::Unit::TestCase
73
73
  end
74
74
 
75
75
  should "generate strings with the right regexp char classes" do
76
- char_classes = Rant::Chars::CLASSES.keys
76
+ char_classes = Rantly::Chars::CLASSES.keys
77
77
  property_of {
78
78
  char_class = choose(*char_classes)
79
79
  len = range(0,10)
80
80
  sized(len) { [len,char_class,string(char_class)]}
81
81
  }.check { |(len,char_class,str)|
82
82
  t = true
83
- chars = Rant::Chars::CLASSES[char_class]
83
+ chars = Rantly::Chars::CLASSES[char_class]
84
84
  str.each_byte { |c|
85
85
  unless chars.include?(c)
86
86
  t = false
@@ -117,7 +117,7 @@ class RantTest::Generator < Test::Unit::TestCase
117
117
 
118
118
  should "call Array by calling first element as method, the rest as args" do
119
119
  assert_raise(RuntimeError) {
120
- Rant.gen.value {
120
+ Rantly.gen.value {
121
121
  call []
122
122
  }
123
123
  }
@@ -150,13 +150,13 @@ class RantTest::Generator < Test::Unit::TestCase
150
150
 
151
151
  should "raise if calling on any other value" do
152
152
  assert_raise(RuntimeError) {
153
- Rant.gen.call 0
153
+ Rantly.gen.call 0
154
154
  }
155
155
  end
156
156
 
157
157
  # branch
158
158
 
159
- should "branch by Rant#calling one of the args" do
159
+ should "branch by Rantly#calling one of the args" do
160
160
  property_of {
161
161
  branch :integer, :integer, :integer
162
162
  }.check { |o|
@@ -219,7 +219,7 @@ class RantTest::Generator < Test::Unit::TestCase
219
219
 
220
220
  should "handle degenerate freq pairs" do
221
221
  assert_raise(RuntimeError) {
222
- Rant.gen.value {
222
+ Rantly.gen.value {
223
223
  freq
224
224
  }
225
225
  }
@@ -268,17 +268,17 @@ class RantTest::Generator < Test::Unit::TestCase
268
268
  }
269
269
  end
270
270
 
271
- should "raise if generating an array without size" do
272
- assert_raise(RuntimeError) {
273
- Rant.gen.value { array(:integer) }
274
- }
275
- end
271
+ # should "raise if generating an array without size" do
272
+ # assert_raise(RuntimeError) {
273
+ # Rantly.gen.value { array(:integer) }
274
+ # }
275
+ # end
276
276
 
277
277
  end
278
278
 
279
279
 
280
280
 
281
281
  # TODO: check that distributions of different methods look roughly correct.
282
- class RantTest::Distribution
282
+ class RantlyTest::Distribution
283
283
 
284
284
  end
data/test/test_helper.rb CHANGED
@@ -4,7 +4,8 @@ require 'shoulda'
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'rant'
7
+
8
+ require 'rantly'
8
9
 
9
10
  class Test::Unit::TestCase
10
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rantly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Howard Yeh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-30 00:00:00 -08:00
12
+ date: 2010-01-04 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -28,16 +28,15 @@ files:
28
28
  - LICENSE
29
29
  - README.textile
30
30
  - Rakefile
31
- - Rant.gemspec
32
31
  - VERSION.yml
33
- - lib/rant.rb
34
- - lib/rant/data.rb
35
- - lib/rant/generator.rb
36
- - lib/rant/property.rb
37
- - lib/rant/silly.rb
38
- - lib/rant/spec.rb
32
+ - lib/rantly.rb
33
+ - lib/rantly/data.rb
34
+ - lib/rantly/generator.rb
35
+ - lib/rantly/property.rb
36
+ - lib/rantly/silly.rb
37
+ - lib/rantly/spec.rb
39
38
  - rantly.gemspec
40
- - test/rant_test.rb
39
+ - test/rantly_test.rb
41
40
  - test/test_helper.rb
42
41
  has_rdoc: true
43
42
  homepage: http://github.com/hayeah/rantly
@@ -68,5 +67,5 @@ signing_key:
68
67
  specification_version: 3
69
68
  summary: Ruby Imperative Random Data Generator and Quickcheck
70
69
  test_files:
71
- - test/rant_test.rb
70
+ - test/rantly_test.rb
72
71
  - test/test_helper.rb
data/Rant.gemspec DELETED
@@ -1,54 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{Rant}
8
- s.version = "0.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Howard Yeh"]
12
- s.date = %q{2009-10-01}
13
- s.email = %q{hayeah@gmail.com}
14
- s.extra_rdoc_files = [
15
- "LICENSE",
16
- "README.textile"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".gitignore",
21
- "LICENSE",
22
- "README.textile",
23
- "Rakefile",
24
- "Rant.gemspec",
25
- "VERSION.yml",
26
- "lib/rant.rb",
27
- "lib/rant/check.rb",
28
- "lib/rant/data.rb",
29
- "lib/rant/generator.rb",
30
- "lib/rant/silly.rb",
31
- "test/rant_test.rb",
32
- "test/test_helper.rb"
33
- ]
34
- s.has_rdoc = true
35
- s.homepage = %q{http://github.com/hayeah/rant}
36
- s.rdoc_options = ["--charset=UTF-8"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.1}
39
- s.summary = %q{Ruby Imperative Random Data Generator and Quickcheck}
40
- s.test_files = [
41
- "test/rant_test.rb",
42
- "test/test_helper.rb"
43
- ]
44
-
45
- if s.respond_to? :specification_version then
46
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
- s.specification_version = 2
48
-
49
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
- else
51
- end
52
- else
53
- end
54
- end
data/lib/rant/spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'rant'
2
- module Rant::Check
3
- def check(n=100,&block)
4
- Rant.gen.each(n,&block)
5
- end
6
-
7
- def sample(n=100,&block)
8
- Rant.gen.map(n,&block)
9
- end
10
- end