named-parameters 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -4
- data/RELEASENOTES +13 -0
- data/VERSION +1 -1
- data/lib/named-parameters/module.rb +1 -1
- data/named-parameters.gemspec +16 -18
- data/spec/named-parameters_spec.rb +5 -5
- metadata +5 -6
- data/.gitignore +0 -21
data/README.md
CHANGED
@@ -142,8 +142,8 @@ in a class definition:
|
|
142
142
|
|
143
143
|
What Was Declared?
|
144
144
|
------------------
|
145
|
-
You can get a list of declared parameters
|
146
|
-
|
145
|
+
You can get a list of declared parameters via the `declared_parameters`
|
146
|
+
method:
|
147
147
|
|
148
148
|
class GoogleStorage
|
149
149
|
requires :'access-key', :'secret-key'
|
@@ -151,7 +151,7 @@ You can get a list of declared parameters for a method by invoking
|
|
151
151
|
|
152
152
|
def initialize options
|
153
153
|
# list the parameters declared
|
154
|
-
puts "#{
|
154
|
+
puts "#{declared_parameters.join(' ')}"
|
155
155
|
|
156
156
|
# ... now do the googly stuff ...
|
157
157
|
end
|
@@ -161,7 +161,8 @@ You can get a list of declared parameters for a method by invoking
|
|
161
161
|
# and print: [ access-key, secret-key, group-email, apps-domain ]
|
162
162
|
GoogleStorage.new :'access-key' => '...', :'secret-key' => '...'
|
163
163
|
|
164
|
-
`
|
164
|
+
`declared_parameters` is also available from the class methods of user defined
|
165
|
+
classes.
|
165
166
|
|
166
167
|
Permissive Mode
|
167
168
|
---------------
|
data/RELEASENOTES
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
0.0.10 [Nov 24, 2010]
|
2
|
+
- [BREAKING CHANGE] required_parameters to declared_parameters. So to get the
|
3
|
+
list of declared parameters for a method, do:
|
4
|
+
|
5
|
+
has_named_parameters :foobar,
|
6
|
+
:required => :a, :optional => [ :b, :c ]
|
7
|
+
def foobar
|
8
|
+
declared_parameters.inspect
|
9
|
+
end
|
10
|
+
|
11
|
+
foobar # => [ :a, :b, :c ]
|
12
|
+
- [INTERNAL] Parameter spec table is now retained.
|
13
|
+
|
1
14
|
0.0.9 [Nov 24, 2010]
|
2
15
|
- [FEATURE] You can now query what parameters have been declared for a method:
|
3
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
@@ -36,7 +36,7 @@ module NamedParameters
|
|
36
36
|
# @returns [Array] list of symbols representing the name of the declared
|
37
37
|
# parameters.
|
38
38
|
#
|
39
|
-
def
|
39
|
+
def declared_parameters
|
40
40
|
klazz = self.instance_of?(Class) ? self : self.class
|
41
41
|
specs = klazz.send :specs
|
42
42
|
|
data/named-parameters.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{named-parameters}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Juris Galang"]
|
@@ -19,29 +19,27 @@ Gem::Specification.new do |s|
|
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
"spec/spec_helper.rb"
|
22
|
+
"GPL-LICENSE",
|
23
|
+
"MIT-LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"RELEASENOTES",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/named-parameters.rb",
|
29
|
+
"lib/named-parameters/module.rb",
|
30
|
+
"lib/named-parameters/object.rb",
|
31
|
+
"named-parameters.gemspec",
|
32
|
+
"spec/named-parameters_spec.rb",
|
33
|
+
"spec/spec.opts",
|
34
|
+
"spec/spec_helper.rb"
|
36
35
|
]
|
37
36
|
s.homepage = %q{http://github.com/jurisgalang/named-parameters}
|
38
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
39
37
|
s.require_paths = ["lib"]
|
40
38
|
s.rubygems_version = %q{1.3.7}
|
41
39
|
s.summary = %q{Poor man's named-parameters in Ruby}
|
42
40
|
s.test_files = [
|
43
41
|
"spec/named-parameters_spec.rb",
|
44
|
-
|
42
|
+
"spec/spec_helper.rb"
|
45
43
|
]
|
46
44
|
|
47
45
|
if s.respond_to? :specification_version then
|
@@ -204,13 +204,13 @@ describe "NamedParameters" do
|
|
204
204
|
end
|
205
205
|
|
206
206
|
it "should be able to list of recognized parameters" do
|
207
|
-
class
|
207
|
+
class DeclaredParameters
|
208
208
|
requires :x, :y
|
209
209
|
recognizes :a, :b, :c
|
210
210
|
attr :parameters
|
211
211
|
|
212
212
|
def initialize opts = { }
|
213
|
-
@parameters =
|
213
|
+
@parameters = declared_parameters
|
214
214
|
end
|
215
215
|
|
216
216
|
has_named_parameters :'self.singleton',
|
@@ -218,12 +218,12 @@ describe "NamedParameters" do
|
|
218
218
|
:optional => [ :x, [ :y, 1 ], { :z => 1 } ],
|
219
219
|
:oneof => [ :a, :b, :c ]
|
220
220
|
def self.singleton opts = { }
|
221
|
-
|
221
|
+
declared_parameters
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
225
|
-
o =
|
225
|
+
o = DeclaredParameters.new(:x => :x, :y => :y)
|
226
226
|
o.parameters.should eql [ :a, :b, :c, :x, :y ]
|
227
|
-
|
227
|
+
DeclaredParameters.singleton(:w => :w, :a => :a).should eql [ :a, :b, :c, :w, :x, :y, :z ]
|
228
228
|
end
|
229
229
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: named-parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Juris Galang
|
@@ -58,7 +58,6 @@ extra_rdoc_files:
|
|
58
58
|
- README.md
|
59
59
|
files:
|
60
60
|
- .document
|
61
|
-
- .gitignore
|
62
61
|
- GPL-LICENSE
|
63
62
|
- MIT-LICENSE
|
64
63
|
- README.md
|
@@ -77,8 +76,8 @@ homepage: http://github.com/jurisgalang/named-parameters
|
|
77
76
|
licenses: []
|
78
77
|
|
79
78
|
post_install_message:
|
80
|
-
rdoc_options:
|
81
|
-
|
79
|
+
rdoc_options: []
|
80
|
+
|
82
81
|
require_paths:
|
83
82
|
- lib
|
84
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|