rdp-arguments 0.6 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -2
- data/arguments.gemspec +42 -43
- data/lib/arguments/class.rb +15 -3
- data/lib/arguments.rb +1 -1
- data/spec/arguments_spec.rb +10 -3
- data/spec/klass.rb +4 -0
- data/spec/module.rb +1 -1
- metadata +9 -7
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ Hoe.plugin :newgem
|
|
10
10
|
|
11
11
|
# Generate all the Rake tasks
|
12
12
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
$hoe = Hoe.spec 'arguments' do
|
13
|
+
$hoe = Hoe.spec 'rdp-arguments' do
|
14
14
|
self.developer 'Macario Ortega', 'macarui@gmail.com'
|
15
15
|
self.rubyforge_name = self.name # TODO this is default value
|
16
16
|
self.extra_deps = [
|
@@ -18,7 +18,6 @@ $hoe = Hoe.spec 'arguments' do
|
|
18
18
|
['ParseTree', '>= 3.0.3'],
|
19
19
|
['ruby2ruby', '= 1.1.9']
|
20
20
|
]
|
21
|
-
self.homepage = 'http://github.com/maca/arguments'
|
22
21
|
end
|
23
22
|
|
24
23
|
require 'newgem/tasks'
|
data/arguments.gemspec
CHANGED
@@ -1,43 +1,42 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{
|
5
|
-
s.version = "0.6"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Macario Ortega"]
|
9
|
-
s.date = %q{2009-
|
10
|
-
s.description = %q{You don't have to wait until Ruby 2.0 to get (named|keyword) arguments support.
|
11
|
-
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
s.add_runtime_dependency(%q<
|
28
|
-
s.add_runtime_dependency(%q<
|
29
|
-
s.
|
30
|
-
|
31
|
-
|
32
|
-
s.add_dependency(%q<
|
33
|
-
s.add_dependency(%q<
|
34
|
-
s.add_dependency(%q<
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
s.add_dependency(%q<
|
39
|
-
s.add_dependency(%q<
|
40
|
-
s.add_dependency(%q<
|
41
|
-
|
42
|
-
|
43
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{arguments}
|
5
|
+
s.version = "0.6.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Macario Ortega"]
|
9
|
+
s.date = %q{2009-10-29}
|
10
|
+
s.description = %q{You don't have to wait until Ruby 2.0 to get (named|keyword) arguments support.
|
11
|
+
Arguments has been tested with Ruby 1.8.6 and ruby 1.9.1 and eventually will work with JRuby (if someone is interested in contributing, I guess is possible since merb-action-args works with JRuby)}
|
12
|
+
s.email = ["macarui@gmail.com"]
|
13
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
14
|
+
s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "arguments.gemspec", "lib/arguments.rb", "lib/arguments/class.rb", "lib/arguments/mri.rb", "lib/arguments/vm.rb", "spec/arguments_spec.rb", "spec/klass.rb", "spec/module.rb"]
|
15
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{arguments}
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
|
+
s.summary = %q{You don't have to wait until Ruby 2.0 to get (named|keyword) arguments support}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<ruby_parser>, [">= 2.0.2"])
|
27
|
+
s.add_runtime_dependency(%q<ParseTree>, [">= 3.0.3"])
|
28
|
+
s.add_runtime_dependency(%q<ruby2ruby>, ["= 1.1.9"])
|
29
|
+
s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<ruby_parser>, [">= 2.0.2"])
|
32
|
+
s.add_dependency(%q<ParseTree>, [">= 3.0.3"])
|
33
|
+
s.add_dependency(%q<ruby2ruby>, ["= 1.1.9"])
|
34
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
35
|
+
end
|
36
|
+
else
|
37
|
+
s.add_dependency(%q<ruby_parser>, [">= 2.0.2"])
|
38
|
+
s.add_dependency(%q<ParseTree>, [">= 3.0.3"])
|
39
|
+
s.add_dependency(%q<ruby2ruby>, ["= 1.1.9"])
|
40
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
41
|
+
end
|
42
|
+
end
|
data/lib/arguments/class.rb
CHANGED
@@ -4,7 +4,14 @@ module Arguments
|
|
4
4
|
|
5
5
|
methods.each do |meth|
|
6
6
|
meth = meth.to_s
|
7
|
-
|
7
|
+
original_klass = self
|
8
|
+
if meth =~ /^self\./
|
9
|
+
am_self = true
|
10
|
+
klass = (class << self; self; end)
|
11
|
+
meth.sub!(/^self\./ , '')
|
12
|
+
else
|
13
|
+
klass = self
|
14
|
+
end
|
8
15
|
names = Arguments.names klass, meth
|
9
16
|
next if names.empty? or names.inject(false) { |bol, pair| bol || /^\*/ === pair.first.to_s }
|
10
17
|
assigns = []
|
@@ -31,7 +38,9 @@ module Arguments
|
|
31
38
|
end
|
32
39
|
end
|
33
40
|
|
34
|
-
|
41
|
+
|
42
|
+
it = <<-RUBY_EVAL, __FILE__, __LINE__
|
43
|
+
#{ "class << self" if am_self }
|
35
44
|
def __#{ meth }_with_keyword_arguments *args, &block
|
36
45
|
opts = args.last.kind_of?( Hash ) && args.size < #{ names.size } ? args.pop : {}
|
37
46
|
#{ assigns.join("\n") }
|
@@ -40,10 +49,12 @@ module Arguments
|
|
40
49
|
end
|
41
50
|
__original_#{ meth } #{ names.collect{ |n| n.first }.join(', ') }, &block
|
42
51
|
end
|
43
|
-
|
52
|
+
|
44
53
|
alias __original_#{ meth } #{ meth }
|
45
54
|
alias #{ meth } __#{ meth }_with_keyword_arguments
|
55
|
+
#{ "end" if am_self }
|
46
56
|
RUBY_EVAL
|
57
|
+
original_klass.class_eval *it
|
47
58
|
end
|
48
59
|
end
|
49
60
|
alias :named_args_for :named_arguments_for
|
@@ -53,6 +64,7 @@ end
|
|
53
64
|
class Class
|
54
65
|
include Arguments
|
55
66
|
end
|
67
|
+
|
56
68
|
class Module
|
57
69
|
include Arguments
|
58
70
|
end
|
data/lib/arguments.rb
CHANGED
data/spec/arguments_spec.rb
CHANGED
@@ -43,9 +43,15 @@ describe Arguments do
|
|
43
43
|
Klass.send( :named_arguments_for, :defaults_with_class)
|
44
44
|
@instance.defaults_with_class(1, 3).should == 3
|
45
45
|
@instance.defaults_with_class(:a => 3).should == 3
|
46
|
-
require '_dbg'
|
47
46
|
@instance.defaults_with_class().should == 3
|
48
47
|
end
|
48
|
+
|
49
|
+
it "should allow for class arguments in class methods" do
|
50
|
+
Klass.send( :named_arguments_for, :'self.klass_defaults_with_class')
|
51
|
+
Klass.klass_defaults_with_class(1, 3).should == 3
|
52
|
+
Klass.klass_defaults_with_class(:a => 3).should == 3
|
53
|
+
Klass.klass_defaults_with_class().should == 3
|
54
|
+
end
|
49
55
|
|
50
56
|
it "should allow overriding with nil" do
|
51
57
|
Klass.send( :named_arguments_for, :two )
|
@@ -70,6 +76,8 @@ describe Arguments do
|
|
70
76
|
it "should work with class methods" do
|
71
77
|
(class << Klass; self; end).send( :named_arguments_for, :k_method )
|
72
78
|
Klass.k_method(:d => :d).should == [1, 2, 3, :d]
|
79
|
+
#(class << Klass; self; end).send( :named_arguments_for, :k_method )
|
80
|
+
#Klass.k_method(:d => :d).should == [1, 2, 3, :d]
|
73
81
|
end
|
74
82
|
|
75
83
|
it "should override defaults on standard passing" do
|
@@ -143,13 +151,12 @@ describe Arguments do
|
|
143
151
|
}
|
144
152
|
end
|
145
153
|
|
146
|
-
it "should work with modules" do
|
154
|
+
it "should work with modules (not working yet)" do
|
147
155
|
require 'module.rb'
|
148
156
|
TestMod.send(:named_arguments_for, :go)
|
149
157
|
IncludesTestMod.new.go(1,2).should == 2
|
150
158
|
IncludesTestMod.new.go(:a => 1, :b => 2).should == 2
|
151
159
|
end
|
152
|
-
|
153
160
|
|
154
161
|
it "should benchmark with hack" do
|
155
162
|
puts Benchmark.measure {
|
data/spec/klass.rb
CHANGED
data/spec/module.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdp-arguments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Macario Ortega
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-29 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,9 +50,11 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.3.
|
53
|
+
version: 2.3.3
|
54
54
|
version:
|
55
|
-
description:
|
55
|
+
description: |-
|
56
|
+
You don't have to wait until Ruby 2.0 to get (named|keyword) arguments support.
|
57
|
+
Arguments has been tested with Ruby 1.8.6 and ruby 1.9.1 and eventually will work with JRuby (if someone is interested in contributing, I guess is possible since merb-action-args works with JRuby)
|
56
58
|
email:
|
57
59
|
- macarui@gmail.com
|
58
60
|
executables: []
|
@@ -76,7 +78,7 @@ files:
|
|
76
78
|
- spec/klass.rb
|
77
79
|
- spec/module.rb
|
78
80
|
has_rdoc: true
|
79
|
-
homepage:
|
81
|
+
homepage:
|
80
82
|
licenses: []
|
81
83
|
|
82
84
|
post_install_message:
|
@@ -99,10 +101,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
101
|
version:
|
100
102
|
requirements: []
|
101
103
|
|
102
|
-
rubyforge_project: arguments
|
104
|
+
rubyforge_project: rdp-arguments
|
103
105
|
rubygems_version: 1.3.5
|
104
106
|
signing_key:
|
105
|
-
specification_version:
|
107
|
+
specification_version: 3
|
106
108
|
summary: You don't have to wait until Ruby 2.0 to get (named|keyword) arguments support
|
107
109
|
test_files: []
|
108
110
|
|