merb-action-args 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -5
- data/lib/merb-action-args/abstract_controller.rb +1 -1
- data/lib/merb-action-args/get_args.rb +11 -2
- data/spec/action_args_spec.rb +33 -0
- data/spec/controllers/action-args.rb +35 -0
- data/spec/spec_helper.rb +14 -0
- metadata +16 -3
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
|
|
3
3
|
|
4
4
|
PLUGIN = "merb-action-args"
|
5
5
|
NAME = "merb-action-args"
|
6
|
-
VERSION = "0.9.
|
6
|
+
VERSION = "0.9.3"
|
7
7
|
AUTHOR = "Yehuda Katz"
|
8
8
|
EMAIL = "ykatz@engineyard.com"
|
9
9
|
HOMEPAGE = "http://merb-plugins.rubyforge.org/merb-haml/"
|
@@ -20,25 +20,28 @@ spec = Gem::Specification.new do |s|
|
|
20
20
|
s.author = AUTHOR
|
21
21
|
s.email = EMAIL
|
22
22
|
s.homepage = HOMEPAGE
|
23
|
-
s.add_dependency('merb-core', '>= 0.9.
|
23
|
+
s.add_dependency('merb-core', '>= 0.9.3')
|
24
|
+
s.add_dependency('ruby2ruby', '>= 1.1.8')
|
24
25
|
s.require_path = 'lib'
|
25
26
|
s.autorequire = PLUGIN
|
26
|
-
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,
|
27
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
27
28
|
end
|
28
29
|
|
29
30
|
Rake::GemPackageTask.new(spec) do |pkg|
|
30
31
|
pkg.gem_spec = spec
|
31
32
|
end
|
32
33
|
|
34
|
+
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
|
35
|
+
|
33
36
|
task :install => [:package] do
|
34
|
-
sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
|
37
|
+
sh %{sudo gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
|
35
38
|
end
|
36
39
|
|
37
40
|
namespace :jruby do
|
38
41
|
|
39
42
|
desc "Run :package and install the resulting .gem with jruby"
|
40
43
|
task :install => :package do
|
41
|
-
sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
|
44
|
+
sh %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
|
42
45
|
end
|
43
46
|
|
44
47
|
end
|
@@ -2,9 +2,18 @@ require 'ruby2ruby'
|
|
2
2
|
|
3
3
|
class ParseTreeArray < Array #:nodoc:
|
4
4
|
def self.translate(*args)
|
5
|
-
|
5
|
+
sexp = ParseTree.translate(*args)
|
6
|
+
# ParseTree.translate returns [nil] if called on an inherited method, so walk
|
7
|
+
# up the inheritance chain to find the class that the method was defined in
|
8
|
+
unless sexp.first
|
9
|
+
klass = args.first.ancestors.detect do |klass|
|
10
|
+
klass.public_instance_methods(false).include?(args.last.to_s)
|
11
|
+
end
|
12
|
+
sexp = ParseTree.translate(klass, args.last) if klass
|
13
|
+
end
|
14
|
+
self.new(sexp)
|
6
15
|
end
|
7
|
-
|
16
|
+
|
8
17
|
def deep_array_node(type = nil)
|
9
18
|
each do |node|
|
10
19
|
return ParseTreeArray.new(node) if node.is_a?(Array) && (!type || node[0] == type)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Merb::AbstractController do
|
4
|
+
|
5
|
+
it "should be able to accept Action Arguments" do
|
6
|
+
dispatch_to(ActionArgs, :index, :foo => "bar").body.should == "bar"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be able to accept multiple Action Arguments" do
|
10
|
+
dispatch_to(ActionArgs, :multi, :foo => "bar", :bar => "baz").body.should == "bar baz"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be able to handle defaults in Action Arguments" do
|
14
|
+
dispatch_to(ActionArgs, :defaults, :foo => "bar").body.should == "bar bar"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be able to handle out of order defaults" do
|
18
|
+
dispatch_to(ActionArgs, :defaults_mixed, :foo => "bar", :baz => "bar").body.should == "bar bar bar"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should throw a BadRequest if the arguments are not provided" do
|
22
|
+
lambda { dispatch_to(ActionArgs, :index) }.should raise_error(Merb::ControllerExceptions::BadRequest)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should treat define_method actions as equal" do
|
26
|
+
dispatch_to(ActionArgs, :dynamic_define_method).body.should == "mos def"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to inherit actions for use with Action Arguments" do
|
30
|
+
dispatch_to(ActionArgs, :funky_inherited_method, :foo => "bar", :bar => "baz").body.should == "bar baz"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ExtraActions
|
2
|
+
def self.included(base)
|
3
|
+
base.show_action(:funky_inherited_method)
|
4
|
+
end
|
5
|
+
|
6
|
+
def funky_inherited_method(foo, bar)
|
7
|
+
"#{foo} #{bar}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
class ActionArgs < Merb::Controller
|
13
|
+
include ExtraActions
|
14
|
+
|
15
|
+
def index(foo)
|
16
|
+
foo
|
17
|
+
end
|
18
|
+
|
19
|
+
def multi(foo, bar)
|
20
|
+
"#{foo} #{bar}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def defaults(foo, bar = "bar")
|
24
|
+
"#{foo} #{bar}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def defaults_mixed(foo, bar ="bar", baz = "baz")
|
28
|
+
"#{foo} #{bar} #{baz}"
|
29
|
+
end
|
30
|
+
|
31
|
+
define_method :dynamic_define_method do
|
32
|
+
"mos def"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$TESTING=true
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
require "merb-core"
|
6
|
+
require "merb-action-args"
|
7
|
+
require File.dirname(__FILE__) / "controllers" / "action-args"
|
8
|
+
require "spec"
|
9
|
+
|
10
|
+
Merb.start :environment => 'test'
|
11
|
+
|
12
|
+
Spec::Runner.configure do |config|
|
13
|
+
config.include Merb::Test::RequestHelper
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -9,7 +9,7 @@ autorequire: merb-action-args
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-05-04 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,7 +19,16 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.9.
|
22
|
+
version: 0.9.3
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: ruby2ruby
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.1.8
|
23
32
|
version:
|
24
33
|
description: Merb plugin that provides support for ActionArgs
|
25
34
|
email: ykatz@engineyard.com
|
@@ -40,6 +49,10 @@ files:
|
|
40
49
|
- lib/merb-action-args/abstract_controller.rb
|
41
50
|
- lib/merb-action-args/get_args.rb
|
42
51
|
- lib/merb-action-args.rb
|
52
|
+
- spec/action_args_spec.rb
|
53
|
+
- spec/controllers
|
54
|
+
- spec/controllers/action-args.rb
|
55
|
+
- spec/spec_helper.rb
|
43
56
|
has_rdoc: true
|
44
57
|
homepage: http://merb-plugins.rubyforge.org/merb-haml/
|
45
58
|
post_install_message:
|