footing 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
@@ -73,6 +73,7 @@ Footing::String.escape "foo", "o" # => "f\\o\\o"
73
73
  1. `git clone git://github.com/hopsoft/footing.git`
74
74
  1. `cd /path/to/footing`
75
75
  1. `bundle`
76
+ 1. `./test`
76
77
  1. `./console`
77
78
  1. `Footing.patch! String, Footing::String`
78
79
 
@@ -1,11 +1,25 @@
1
1
  module Footing
2
2
  module String
3
3
 
4
- ## Generates a random string (upcase alpha-numeric)
5
- ## Returns a string with the length provided, defaulting to 12 chars
6
- def random_key(length=12)
7
- @chars ||= [(0..9).to_a, ('A'..'Z').to_a].flatten
8
- (1..length).map{ |i| @chars.sample }.join
4
+ # Generates a random string.
5
+ #
6
+ # @example
7
+ # Footing.util! Footing::String
8
+ # Footing::String.random_key(100, :reject => ["1", "I", "l", "0", "O"])
9
+ #
10
+ # @param [Integer] length The length of the key to generate. Defaults to 12.
11
+ # @param [Hash] opts
12
+ # @option opts [Array] :reject A list of characters to omit from the key.
13
+ # @option opts [Boolean] :upcase Indicates that only use uppercase characters should be used.
14
+ # @return [String]
15
+ def random_key(length=12, opts={})
16
+ @chars ||= [(0..9).to_a, ('a'..'z').to_a, ('A'..'Z').to_a].flatten.map { |c| c.to_s }
17
+ chars = @chars.reject do |c|
18
+ c =~ /[a-z]/ if opts[:upcase]
19
+ end
20
+ opts[:reject] ||= []
21
+ opts[:reject] = opts[:reject].map { |c| c.to_s }
22
+ (1..length).map{ |i| (chars - opts[:reject]).sample }.join
9
23
  end
10
24
 
11
25
  # Escapes a series of chars in the current string.
data/lib/footing.rb CHANGED
@@ -59,7 +59,13 @@ module Footing
59
59
 
60
60
  mod.instance_methods(false).each do |method|
61
61
  eigen.send :define_method, method do |*args|
62
- proxy_eigen.instance_method(method).bind(args.first || proxy).call(*args)
62
+ o = args.first || proxy
63
+ m = proxy_eigen.instance_method(method)
64
+ if m.parameters.empty?
65
+ m.bind(o).call
66
+ else
67
+ m.bind(o).call(*args)
68
+ end
63
69
  end
64
70
  end
65
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: footing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: