rahoulb-rujitsu 0.1.6 → 0.1.7

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.
data/CHANGELOG CHANGED
@@ -1,6 +1,10 @@
1
+ = Version 0.1.7 (2008-12-08)
2
+
3
+ Added the limiter to Range#random_numbers
4
+
1
5
  = Version 0.1.6 (2008-12-08)
2
6
 
3
- Added a limiter to random_numbers
7
+ Added a limiter to Fixnum#random_numbers
4
8
 
5
9
  = Version 0.1.5 (2008-12-03)
6
10
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('rujitsu', '0.1.6') do | config |
5
+ Echoe.new('rujitsu', '0.1.7') do | config |
6
6
  config.description = 'Various helper methods to smooth over Ruby development'
7
7
  config.url = 'http://github.com/rahoub/rujitsu'
8
8
  config.author = 'Brightbox Systems Ltd'
data/lib/rujitsu/range.rb CHANGED
@@ -12,8 +12,8 @@ class Range
12
12
 
13
13
  # create a string of random numbers whose length is one of the values in your range
14
14
  # (3..4).random_numbers # => returns a string or 3 or 4 random numbers
15
- def random_numbers
16
- self.to_random_i.random_numbers
15
+ def random_numbers opts = {}
16
+ self.to_random_i.random_numbers opts
17
17
  end
18
18
 
19
19
  # create a string of random characters whose length is one of the values in your range
data/rujitsu.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rujitsu}
5
- s.version = "0.1.6"
5
+ s.version = "0.1.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Brightbox Systems Ltd"]
data/spec/range_spec.rb CHANGED
@@ -8,16 +8,18 @@ describe Range do
8
8
  end
9
9
 
10
10
  it "should return a random number from the range" do
11
+ setup_range
12
+
11
13
  # First check with an absolute
12
- result = (3..3).to_random_i
14
+ result = @range.to_random_i
13
15
  result.should be_a_kind_of(Fixnum)
14
- result.should == 3
16
+ result.should == 4
15
17
 
16
18
  # And then one that is random
17
19
  res = (3..5).to_random_i
18
20
  res.should be_a_kind_of(Fixnum)
19
21
  [3,4,5].should include(res)
20
- end
22
+ end
21
23
  end
22
24
 
23
25
  describe "random_letters" do
@@ -48,6 +50,49 @@ describe Range do
48
50
  str.length.should == 4
49
51
  str.should match( /^[0-9]+$/ )
50
52
  end
53
+
54
+ it "should contain only the number 5 upwards" do
55
+ setup_range
56
+
57
+ str = @range.random_numbers :from => 5
58
+ str.should be_a_kind_of(String)
59
+
60
+ string_to_integers(str).each do |i|
61
+ i.should be_a_kind_of(Integer)
62
+ i.should >= 5
63
+ end
64
+ end
65
+
66
+ it "should contain only the number 5 downwards" do
67
+ setup_range
68
+
69
+ str = @range.random_numbers :to => 5
70
+ str.should be_a_kind_of(String)
71
+
72
+ string_to_integers(str).each do |i|
73
+ i.should be_a_kind_of(Integer)
74
+ i.should <= 5
75
+ end
76
+ end
77
+
78
+ it "should contain only numbers between 4 and 6" do
79
+ setup_range
80
+
81
+ str = @range.random_numbers :from => 4, :to => 6
82
+ str.should be_a_kind_of(String)
83
+
84
+ string_to_integers(str).each do |i|
85
+ i.should be_a_kind_of(Integer)
86
+ i.should >= 4
87
+ i.should <= 6
88
+ end
89
+ end
90
+
91
+ private
92
+
93
+ def string_to_integers(str)
94
+ str.split("").map {|x| x.to_i }
95
+ end
51
96
  end
52
97
 
53
98
  describe "random_letters" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rahoulb-rujitsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brightbox Systems Ltd