random_fu 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Random_fu
2
2
  =========
3
3
 
4
- A Ruby gem to add random capability. Currently, only for Strings. Tested with
4
+ A Ruby gem to add random capability. Currently, only for Strings and Hashes. Tested with
5
5
  ruby 1.9.2 and RSpec 2.10
6
6
 
7
7
  DO NOT USE for generating any data related to security!!!
@@ -18,6 +18,8 @@ Random_fu will soon be distributed as a ruby gem (not yet published, in dev). S
18
18
 
19
19
  ## Usage
20
20
 
21
+ ## Strings
22
+ ----------
21
23
  ## String#random_order
22
24
 
23
25
  Returns a random string created from the characters in the string. Characters in the string are used only once, and the result
@@ -59,6 +61,19 @@ To produce a 20 character random string from the alphabet:
59
61
  "abcdefghijklmnopqrstuvwxyz".random(20)
60
62
  # => "ijvrvddrwgucdsyzybfq"
61
63
 
64
+ ## Hashs
65
+ --------------
66
+ ## Hash#random
67
+ Returns the value from a random key. If called on an empty hash, returns nil.
68
+
69
+ ### Examples:
70
+
71
+ hash = { first_base: 'fred', second_base: 'tom', pitcher: 'jen' }
72
+ hash.random
73
+ # => "jen"
74
+
75
+ {}.random
76
+ # => nil
62
77
 
63
78
  License
64
79
  =======
data/lib/random_fu.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require_relative 'random_fu/version'
2
2
  require_relative 'random_fu/string'
3
+ require_relative 'random_fu/hash'
3
4
 
4
5
  String.send :include, RandomFu::StringInstanceMethods
6
+ Hash.send :include, RandomFu::HashInstanceMethods
@@ -1,3 +1,3 @@
1
1
  module RandomFu
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -58,61 +58,3 @@ describe "random_fu's String#random" do
58
58
  end
59
59
 
60
60
  end
61
-
62
-
63
-
64
-
65
- #
66
- #
67
- #
68
- #
69
- #
70
- # it "should return a random string of the same length" do
71
- # rand = string.random
72
- # rand.length.should == string.length
73
- # rand.should_not == string
74
- # rand.chars.each do |char|
75
- # string.should include(char)
76
- # end
77
- # end
78
- #
79
- # it "should not use an index greater than its length" do
80
- # string = "ab"
81
- # 1.upto(99) do
82
- # string.random.length.should == string.length
83
- # # nil returned from String#[index to high] would not increase
84
- # # the length of the result string after foo.join. Thus, if
85
- # # random went out of bounds on index, the result string
86
- # # would be less in size.
87
- # end
88
- # end
89
- #
90
- # end
91
- #
92
- # describe "with argument of 0" do
93
- #
94
- # it "should return a blank string" do
95
- # rand = string.random(0)
96
- # rand.should == ""
97
- # end
98
- #
99
- # end
100
- #
101
- # describe "with invalid arguments" do
102
- #
103
- # it "should raise an exception when count is too high" do
104
- # lambda { rand = string.random(string.length+1) }.should raise_exception
105
- # end
106
- #
107
- # it "should raise an exception if it's negative" do
108
- # lambda { rand = string.random(-1) }.should raise_exception
109
- # end
110
- #
111
- # it "should raise an exception if not an Integer class" do
112
- # lambda { rand = string.random("foo") }.should raise_exception
113
- # lambda { rand = string.random(0.1) }.should raise_exception
114
- # end
115
- #
116
- # end
117
- #
118
-
data/spec/version_spec.rb CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe "random_fu's version" do
4
4
  it "should be current" do
5
- RandomFu::VERSION.should == '0.0.4'
5
+ RandomFu::VERSION.should == '0.0.5'
6
6
  end
7
7
  end
8
8
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: random_fu
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brian Ledsworth of Ledsworth Consluting LLC
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-06-20 00:00:00 Z
13
+ date: 2012-06-21 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: Incorprate random helpers into your app
@@ -66,3 +66,4 @@ test_files:
66
66
  - spec/string_random_order_spec.rb
67
67
  - spec/string_random_spec.rb
68
68
  - spec/version_spec.rb
69
+ has_rdoc: