hash_keyword_args 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -5
- data/hash_keyword_args.gemspec +1 -1
- data/lib/hash_keyword_args/version.rb +1 -1
- metadata +14 -14
data/README.rdoc
CHANGED
@@ -140,9 +140,12 @@ which will perform validity checking on element of the array. You can combine :
|
|
140
140
|
|
141
141
|
args = args.keyword_args(:winners => { :enumerable => true, :default => ["Huey", "Dewey"] }
|
142
142
|
|
143
|
-
===
|
143
|
+
=== But I like having my options in a Hash!
|
144
144
|
|
145
|
-
The returned object is actually a +Hash+ with the accessors
|
145
|
+
Not to worry. The returned object is actually a +Hash+ with the accessors
|
146
|
+
defined in its singleton class, so you can use hash operations on it if
|
147
|
+
needed. In particular you can pass it in turn to another method. For
|
148
|
+
example:
|
146
149
|
|
147
150
|
def my_wrapper(args={})
|
148
151
|
args = args.keyword_args(:name, :rank, :serial_number)
|
@@ -152,7 +155,8 @@ The returned object is actually a +Hash+ with the accessors defined in its singl
|
|
152
155
|
|
153
156
|
=== Suppress Argument Checking
|
154
157
|
|
155
|
-
If you want to suppress argument checking you can specify the magic keyword
|
158
|
+
If you want to suppress argument checking you can specify the magic keyword
|
159
|
+
+:OTHERS+ (with the intended meaning "and other keyword args that aren't listed here"):
|
156
160
|
|
157
161
|
def execute(operator, opts={})
|
158
162
|
opts = opts.keyword_args(:immediately, :OTHERS)
|
@@ -164,14 +168,17 @@ If you want to suppress argument checking you can specify the magic keyword :OTH
|
|
164
168
|
|
165
169
|
execute(operator, :yabba => 1, :dabba => 2, :doo => 3) # not an argument error
|
166
170
|
|
167
|
-
No accessor methods are defined for undeclared keywords, but the values
|
171
|
+
No accessor methods are defined for undeclared keywords, but the values
|
172
|
+
will be available in the hash. The properties to +:OTHERS+ are ignored, but
|
173
|
+
you can use <tt>:OTHERS => :optional</tt> to make it look nice at the end of a
|
174
|
+
list.
|
168
175
|
|
169
176
|
args = args.keyword_args(:name => String,
|
170
177
|
:OTHERS => :optional)
|
171
178
|
|
172
179
|
== Summary
|
173
180
|
|
174
|
-
=== Complete list of long form properties that can be specified
|
181
|
+
=== Complete list of long form properties that can be specified, individually or in combination:
|
175
182
|
|
176
183
|
:key => { :required => boolean }
|
177
184
|
:key => { :default => "your default value" }
|
data/hash_keyword_args.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["ronen@barzel.org"]
|
7
7
|
gem.description = %q{Makes it easier and more robust to use a hash for keyword args to a method. In particular, performs argument checking and default values.}
|
8
8
|
gem.summary = %q{Helper for using a hash for keyword args to a method. Performs argument checking, provides accessor methods for values, supports default values, required arguments, and argument value validation.}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "http://github.com/ronen/hash_keyword_args"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_keyword_args
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: enumerable_hashify
|
16
|
-
requirement: &
|
16
|
+
requirement: &70280648571600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70280648571600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70280648571160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70280648571160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70280648570680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70280648570680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: simplecov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70280648570220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70280648570220
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov-gem-adapter
|
60
|
-
requirement: &
|
60
|
+
requirement: &70280648569800 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70280648569800
|
69
69
|
description: Makes it easier and more robust to use a hash for keyword args to a method.
|
70
70
|
In particular, performs argument checking and default values.
|
71
71
|
email:
|
@@ -85,7 +85,7 @@ files:
|
|
85
85
|
- lib/hash_keyword_args/version.rb
|
86
86
|
- spec/keyword_args_spec.rb
|
87
87
|
- spec/spec_helper.rb
|
88
|
-
homepage:
|
88
|
+
homepage: http://github.com/ronen/hash_keyword_args
|
89
89
|
licenses: []
|
90
90
|
post_install_message:
|
91
91
|
rdoc_options: []
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 1.8.
|
108
|
+
rubygems_version: 1.8.12
|
109
109
|
signing_key:
|
110
110
|
specification_version: 3
|
111
111
|
summary: Helper for using a hash for keyword args to a method. Performs argument checking,
|