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 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 = "ykatz@engineyard.com"
9
- HOMEPAGE = "http://merb-plugins.rubyforge.org/merb-haml/"
10
- SUMMARY = "Merb plugin that provides support for ActionArgs"
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.name = NAME
14
- s.version = VERSION
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 = SUMMARY
19
- s.description = s.summary
33
+ s.summary = PROJECT_SUMMARY
34
+ s.description = PROJECT_DESCRIPTION
20
35
  s.author = AUTHOR
21
36
  s.email = EMAIL
22
- s.homepage = HOMEPAGE
23
- s.add_dependency('merb-core', '>= 0.9.3')
24
- s.add_dependency('ruby2ruby', '>= 1.1.8')
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
- install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
35
-
49
+ desc "Install the gem"
36
50
  task :install => [:package] do
37
- sh %{sudo gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
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 %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
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
- args = self.class.action_argument_list[action].map do |arg, default|
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 || default
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 #:nodoc:
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 #:nodoc:
87
+ class UnboundMethod
88
88
  include GetArgs
89
89
  end
90
90
 
91
- class Method #:nodoc:
91
+ class Method
92
92
  include GetArgs
93
93
  end
@@ -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
@@ -32,4 +32,8 @@ class ActionArgs < Merb::Controller
32
32
  "mos def"
33
33
  end
34
34
 
35
+ def with_default_nil(foo, bar = nil)
36
+ "#{foo} #{bar}"
37
+ end
38
+
35
39
  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.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
8
- autorequire: merb-action-args
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-04 00:00:00 -05:00
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.3
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.8
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://merb-plugins.rubyforge.org/merb-haml/
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.1
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