public
Description: Some utility scripts (the stuff I keep in ~/bin)
Clone URL: git://github.com/foca/utility_scripts.git
Search Repo:
Cleaned up old dependencies in passgen
foca (author)
Mon Mar 24 14:58:17 -0700 2008
commit  898b31fd7d662efefcaaccf806dec05dc63ed0d5
tree    5004c5aac7be23b7f6512f04723d7a265df1dafc
parent  9cbd966a1703b9c7c6fde512676303ce47be23ad
...
1
 
2
3
 
4
5
6
7
8
9
10
11
12
 
13
14
15
16
...
34
35
36
37
 
38
39
40
41
42
 
43
44
45
...
 
1
2
 
3
4
 
 
 
 
 
 
5
 
6
7
8
9
10
...
28
29
30
 
31
32
33
34
35
 
36
37
38
39
0
@@ -1,15 +1,9 @@
0
-#!/opt/local/bin/ruby
0
+#!/usr/bin/env ruby
0
 
0
-%w( rubygems active_support optparse ostruct ).each {|l| require l}
0
+%w( rubygems optparse ).each &method(:require)
0
 
0
-module Enumerable
0
- def shuffle
0
- sort_by { rand }
0
- end
0
-end
0
-
0
 class PassGrid
0
- ALPHANUMERIC = ('A'..'Z').to_a + (0..9).to_a.map(&:to_s)
0
+ ALPHANUMERIC = ('A'..'Z').to_a + (0..9).to_a.map {|i| i.to_s }
0
   EXTENDED = ALPHANUMERIC + %w( + - = _ ! / < > @ # $ % ^ & * \ ; : . , )
0
 
0
   def initialize(width, height, extended_charset = false, label = nil)
0
0
@@ -34,12 +28,12 @@
0
     def populate
0
       @height.times do
0
         @rows << []
0
- @width.times { @rows.last << characters.shuffle.last.gsub(/\s+/, "") }
0
+ @width.times { @rows.last << characters.sort_by { rand }.last.gsub(/\s+/, "") }
0
       end
0
     end
0
     def characters=(charset)
0
       @charset = ALPHANUMERIC
0
- return if charset.blank?
0
+ return if charset.nil? || charset.empty?
0
 
0
       @charset += case charset
0
         when String then charset.split("").uniq

Comments

    No one has commented yet.