merb-action-args 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +32 -20
- data/lib/merb-action-args/abstract_controller.rb +4 -3
- data/lib/merb-action-args/get_args.rb +7 -7
- data/spec/action_args_spec.rb +4 -0
- data/spec/controllers/action-args.rb +4 -0
- metadata +20 -8
data/Rakefile
CHANGED
@@ -1,29 +1,44 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake/gempackagetask'
|
3
|
+
require "extlib"
|
4
|
+
require 'merb-core/tasks/merb_rake_helper'
|
5
|
+
|
6
|
+
##############################################################################
|
7
|
+
# Package && release
|
8
|
+
##############################################################################
|
9
|
+
RUBY_FORGE_PROJECT = "merb"
|
10
|
+
PROJECT_URL = "http://merbivore.com"
|
11
|
+
PROJECT_SUMMARY = "Merb plugin that provides support for ActionArgs"
|
12
|
+
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
3
13
|
|
4
|
-
PLUGIN = "merb-action-args"
|
5
|
-
NAME = "merb-action-args"
|
6
|
-
VERSION = "0.9.3"
|
7
14
|
AUTHOR = "Yehuda Katz"
|
8
|
-
EMAIL
|
9
|
-
|
10
|
-
|
15
|
+
EMAIL = "ykatz@engineyard.com"
|
16
|
+
|
17
|
+
GEM_NAME = "merb-action-args"
|
18
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
19
|
+
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.4") + PKG_BUILD
|
20
|
+
|
21
|
+
RELEASE_NAME = "REL #{GEM_VERSION}"
|
22
|
+
|
23
|
+
require "extlib/tasks/release"
|
24
|
+
|
11
25
|
|
12
26
|
spec = Gem::Specification.new do |s|
|
13
|
-
s.
|
14
|
-
s.
|
27
|
+
s.rubyforge_project = RUBY_FORGE_PROJECT
|
28
|
+
s.name = GEM_NAME
|
29
|
+
s.version = GEM_VERSION
|
15
30
|
s.platform = Gem::Platform::RUBY
|
16
31
|
s.has_rdoc = true
|
17
32
|
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
18
|
-
s.summary =
|
19
|
-
s.description =
|
33
|
+
s.summary = PROJECT_SUMMARY
|
34
|
+
s.description = PROJECT_DESCRIPTION
|
20
35
|
s.author = AUTHOR
|
21
36
|
s.email = EMAIL
|
22
|
-
s.homepage =
|
23
|
-
s.add_dependency('merb-core', '>= 0.9.
|
24
|
-
s.add_dependency('ruby2ruby', '>= 1.1.
|
37
|
+
s.homepage = PROJECT_URL
|
38
|
+
s.add_dependency('merb-core', '>= 0.9.4')
|
39
|
+
s.add_dependency('ruby2ruby', '>= 1.1.9')
|
40
|
+
s.add_dependency('ParseTree', '>= 2.2')
|
25
41
|
s.require_path = 'lib'
|
26
|
-
s.autorequire = PLUGIN
|
27
42
|
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
28
43
|
end
|
29
44
|
|
@@ -31,17 +46,14 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|
31
46
|
pkg.gem_spec = spec
|
32
47
|
end
|
33
48
|
|
34
|
-
|
35
|
-
|
49
|
+
desc "Install the gem"
|
36
50
|
task :install => [:package] do
|
37
|
-
sh %{sudo gem install #{install_home} pkg/#{
|
51
|
+
sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
|
38
52
|
end
|
39
53
|
|
40
54
|
namespace :jruby do
|
41
|
-
|
42
55
|
desc "Run :package and install the resulting .gem with jruby"
|
43
56
|
task :install => :package do
|
44
|
-
sh %{#{
|
57
|
+
sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
|
45
58
|
end
|
46
|
-
|
47
59
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Merb::AbstractController
|
2
2
|
|
3
3
|
class << self
|
4
|
-
attr_accessor :action_argument_list
|
4
|
+
attr_accessor :action_argument_list
|
5
5
|
alias_method :old_inherited, :inherited
|
6
6
|
|
7
7
|
# Stores the argument lists for all methods for this class.
|
@@ -25,10 +25,11 @@ class Merb::AbstractController
|
|
25
25
|
# ==== Raises
|
26
26
|
# BadRequest:: The params hash doesn't have a required parameter.
|
27
27
|
def _call_action(action)
|
28
|
-
|
28
|
+
arguments, defaults = self.class.action_argument_list[action]
|
29
|
+
args = arguments.map do |arg, default|
|
29
30
|
arg = arg
|
30
31
|
p = params.key?(arg.to_sym)
|
31
|
-
raise BadRequest unless p ||
|
32
|
+
raise BadRequest unless p || (defaults && defaults.include?(arg))
|
32
33
|
p ? params[arg.to_sym] : default
|
33
34
|
end
|
34
35
|
__send__(action, *args)
|
@@ -1,6 +1,7 @@
|
|
1
|
+
require 'parse_tree'
|
1
2
|
require 'ruby2ruby'
|
2
3
|
|
3
|
-
class ParseTreeArray < Array
|
4
|
+
class ParseTreeArray < Array
|
4
5
|
def self.translate(*args)
|
5
6
|
sexp = ParseTree.translate(*args)
|
6
7
|
# ParseTree.translate returns [nil] if called on an inherited method, so walk
|
@@ -35,20 +36,19 @@ class ParseTreeArray < Array #:nodoc:
|
|
35
36
|
# method defined with def keyword
|
36
37
|
args = arg_node.arg_nodes
|
37
38
|
default_node = arg_node.deep_array_node(:block)
|
38
|
-
return args unless default_node
|
39
|
+
return [args, []] unless default_node
|
39
40
|
else
|
40
41
|
# assuming method defined with Module#define_method
|
41
|
-
return []
|
42
|
+
return [[],[]]
|
42
43
|
end
|
43
44
|
|
44
45
|
# if it was defined with def, and we found the default_node,
|
45
46
|
# that should bring us back to regularly scheduled programming..
|
46
|
-
|
47
47
|
lasgns = default_node[1..-1]
|
48
48
|
lasgns.each do |asgn|
|
49
49
|
args.assoc(asgn[1]) << eval(RubyToRuby.new.process(asgn[2]))
|
50
50
|
end
|
51
|
-
args
|
51
|
+
[args, (default_node[1..-1].map { |asgn| asgn[1] })]
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
@@ -84,10 +84,10 @@ module GetArgs
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
class UnboundMethod
|
87
|
+
class UnboundMethod
|
88
88
|
include GetArgs
|
89
89
|
end
|
90
90
|
|
91
|
-
class Method
|
91
|
+
class Method
|
92
92
|
include GetArgs
|
93
93
|
end
|
data/spec/action_args_spec.rb
CHANGED
@@ -30,4 +30,8 @@ describe Merb::AbstractController do
|
|
30
30
|
dispatch_to(ActionArgs, :funky_inherited_method, :foo => "bar", :bar => "baz").body.should == "bar baz"
|
31
31
|
end
|
32
32
|
|
33
|
+
it "should be able to handle nil defaults" do
|
34
|
+
dispatch_to(ActionArgs, :with_default_nil, :foo => "bar").body.should == "bar "
|
35
|
+
end
|
36
|
+
|
33
37
|
end
|
metadata
CHANGED
@@ -1,34 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-action-args
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-13 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: merb-core
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
20
21
|
- - ">="
|
21
22
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.9.
|
23
|
+
version: 0.9.4
|
23
24
|
version:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: ruby2ruby
|
27
|
+
type: :runtime
|
26
28
|
version_requirement:
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
29
31
|
- - ">="
|
30
32
|
- !ruby/object:Gem::Version
|
31
|
-
version: 1.1.
|
33
|
+
version: 1.1.9
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: ParseTree
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "2.2"
|
32
44
|
version:
|
33
45
|
description: Merb plugin that provides support for ActionArgs
|
34
46
|
email: ykatz@engineyard.com
|
@@ -54,7 +66,7 @@ files:
|
|
54
66
|
- spec/controllers/action-args.rb
|
55
67
|
- spec/spec_helper.rb
|
56
68
|
has_rdoc: true
|
57
|
-
homepage: http://
|
69
|
+
homepage: http://merbivore.com
|
58
70
|
post_install_message:
|
59
71
|
rdoc_options: []
|
60
72
|
|
@@ -74,8 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
86
|
version:
|
75
87
|
requirements: []
|
76
88
|
|
77
|
-
rubyforge_project:
|
78
|
-
rubygems_version: 1.0
|
89
|
+
rubyforge_project: merb
|
90
|
+
rubygems_version: 1.2.0
|
79
91
|
signing_key:
|
80
92
|
specification_version: 2
|
81
93
|
summary: Merb plugin that provides support for ActionArgs
|