File tree Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -14,18 +14,21 @@ def type
14
14
15
15
def normalize ( value )
16
16
return nil unless value . kind_of? ( String )
17
- if value =~ /^rand:(.*)/
17
+ if ( value =~ /^file:(.*)/ )
18
+ path = $1
19
+ return false if not File . exists? ( path ) or File . directory? ( path )
20
+ return File . readlines ( path ) . map { |s | s . strip } . join ( " " )
21
+ elsif ( value =~ /^rand:(.*)/ )
18
22
count = $1. to_i
19
23
return false if count < 1
20
24
ret = ''
21
- count . times do
22
- ret << ' ' if not ret . empty?
23
- ret << [ rand ( 0x100000000 ) ] . pack ( 'N' ) . unpack ( 'C*' ) . map { |x | x . to_s } . join ( '.' )
24
- end
25
+ count . times {
26
+ ret << " " if not ret . empty?
27
+ ret << [ rand ( 0x100000000 ) ] . pack ( "N" ) . unpack ( "C*" ) . map { |x | x . to_s } . join ( "." )
28
+ }
25
29
return ret
26
30
end
27
-
28
- value
31
+ return value
29
32
end
30
33
31
34
def valid? ( value )
Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ def type
13
13
end
14
14
15
15
def normalize ( value )
16
+ if ( value =~ /^file:(.*)/ )
17
+ path = $1
18
+ begin
19
+ value = File . read ( path )
20
+ rescue ::Errno ::ENOENT , ::Errno ::EISDIR
21
+ value = nil
22
+ end
23
+ end
16
24
value
17
25
end
18
26
Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ def type
13
13
end
14
14
15
15
def normalize ( value )
16
+ if ( value =~ /^file:(.*)/ )
17
+ path = $1
18
+ begin
19
+ value = File . read ( path )
20
+ rescue ::Errno ::ENOENT , ::Errno ::EISDIR
21
+ value = nil
22
+ end
23
+ end
16
24
value
17
25
end
18
26
You can’t perform that action at this time.
0 commit comments