configurable 0.6.0 → 0.7.0
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/History +8 -0
- data/MIT-LICENSE +1 -1
- data/lib/config_parser.rb +6 -0
- data/lib/configurable/utils.rb +1 -1
- data/lib/configurable/validation.rb +17 -8
- data/lib/configurable/version.rb +1 -1
- metadata +24 -13
data/History
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 0.7.0 / 2010-05-02
|
2
|
+
|
3
|
+
* Utils#load_file now properly raises error for non-existant files
|
4
|
+
* Improved/added support for JRuby, Rubinius, MRI 1.9.1
|
5
|
+
* Added guess method to Validations
|
6
|
+
* Added warn_ignored_args to ConfigParser
|
7
|
+
* Patched security hole via string evals
|
8
|
+
|
1
9
|
== 0.6.0 / 2009-12-05
|
2
10
|
|
3
11
|
* minor bug fixes in interface
|
data/MIT-LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Copyright (c) 2008-2009, Regents of the University of Colorado.
|
2
2
|
|
3
|
-
Copyright (c) 2009, Simon Chiang.
|
3
|
+
Copyright (c) 2009-2010, Simon Chiang.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/config_parser.rb
CHANGED
@@ -501,6 +501,12 @@ class ConfigParser
|
|
501
501
|
argv
|
502
502
|
end
|
503
503
|
|
504
|
+
def warn_ignored_args(args)
|
505
|
+
if args && !args.empty?
|
506
|
+
warn "ignoring args: #{args.inspect}"
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
504
510
|
# Converts the options and separators in self into a help string suitable for
|
505
511
|
# display on the command line.
|
506
512
|
def to_s
|
data/lib/configurable/utils.rb
CHANGED
@@ -132,7 +132,7 @@ module Configurable
|
|
132
132
|
# values in the hash loaded from the path.
|
133
133
|
def load_file(path, recurse=false, &block)
|
134
134
|
return load_file(path, recurse, &DEFAULT_LOAD) if recurse && !block_given?
|
135
|
-
base = File.
|
135
|
+
base = File.directory?(path) ? {} : (YAML.load_file(path) || {})
|
136
136
|
|
137
137
|
if recurse
|
138
138
|
# determine the files/dirs to load recursively
|
@@ -158,6 +158,21 @@ module Configurable
|
|
158
158
|
lambda {|input| validate(input, validations) }
|
159
159
|
end
|
160
160
|
|
161
|
+
# Guesses and returns a block for the example value.
|
162
|
+
def guess(value)
|
163
|
+
case value
|
164
|
+
when true then switch
|
165
|
+
when false then flag
|
166
|
+
when Numeric then numeric
|
167
|
+
when Array then list
|
168
|
+
when String then string
|
169
|
+
when Time then time
|
170
|
+
when Range then range
|
171
|
+
when Regexp then regexp
|
172
|
+
else yaml
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
161
176
|
# Returns a block that calls validate_api using the block input
|
162
177
|
# and methods.
|
163
178
|
def api(*methods)
|
@@ -188,21 +203,15 @@ module Configurable
|
|
188
203
|
end
|
189
204
|
|
190
205
|
# Returns a block that checks the input is a string.
|
191
|
-
# Moreover, strings are re-evaluated as string
|
192
|
-
# literals using %Q.
|
193
206
|
#
|
194
207
|
# string.class # => Proc
|
195
208
|
# string.call('str') # => 'str'
|
196
|
-
# string.call('\n') # => "\n"
|
197
|
-
# string.call("\n") # => "\n"
|
198
|
-
# string.call("%s") # => "%s"
|
199
209
|
# string.call(nil) # => ValidationError
|
200
210
|
# string.call(:sym) # => ValidationError
|
201
211
|
#
|
202
212
|
def string(); STRING; end
|
203
213
|
string_validation_block = lambda do |input|
|
204
|
-
|
205
|
-
eval %Q{"#{input}"}
|
214
|
+
validate(input, [String])
|
206
215
|
end
|
207
216
|
|
208
217
|
# default attributes {:type => :string, :example => "string"}
|
@@ -222,7 +231,7 @@ module Configurable
|
|
222
231
|
input = validate(input, [String, nil])
|
223
232
|
case input
|
224
233
|
when nil, '~' then nil
|
225
|
-
else
|
234
|
+
else input
|
226
235
|
end
|
227
236
|
end
|
228
237
|
|
data/lib/configurable/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configurable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 7
|
8
|
+
- 0
|
9
|
+
version: 0.7.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Simon Chiang
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-05-02 00:00:00 -06:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: lazydoc
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
- 0
|
23
31
|
version: 1.0.0
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
description:
|
26
35
|
email: simon.a.chiang@gmail.com
|
27
36
|
executables: []
|
@@ -60,30 +69,32 @@ licenses: []
|
|
60
69
|
|
61
70
|
post_install_message:
|
62
71
|
rdoc_options:
|
63
|
-
- --title
|
64
|
-
- Configurable
|
65
72
|
- --main
|
66
73
|
- README
|
67
|
-
-
|
68
|
-
-
|
74
|
+
- -S
|
75
|
+
- -N
|
76
|
+
- --title
|
77
|
+
- Configurable
|
69
78
|
require_paths:
|
70
79
|
- lib
|
71
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
81
|
requirements:
|
73
82
|
- - ">="
|
74
83
|
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
75
86
|
version: "0"
|
76
|
-
version:
|
77
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
88
|
requirements:
|
79
89
|
- - ">="
|
80
90
|
- !ruby/object:Gem::Version
|
91
|
+
segments:
|
92
|
+
- 0
|
81
93
|
version: "0"
|
82
|
-
version:
|
83
94
|
requirements: []
|
84
95
|
|
85
96
|
rubyforge_project: tap
|
86
|
-
rubygems_version: 1.3.
|
97
|
+
rubygems_version: 1.3.6
|
87
98
|
signing_key:
|
88
99
|
specification_version: 3
|
89
100
|
summary: configurable
|