merb-parts 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/Rakefile +25 -13
- data/lib/merb-parts/mixins/parts_mixin.rb +2 -2
- data/lib/merb-parts/mixins/web_controller.rb +2 -16
- data/lib/merb-parts/part_controller.rb +19 -0
- data/spec/fixtures/controllers/main.rb +4 -0
- data/spec/fixtures/parts/views/todo_part/part_with_params.html.erb +5 -1
- data/spec/merb-parts_spec.rb +5 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -3
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ GEM_EMAIL = "has.sox@gmail.com"
|
|
17
17
|
|
18
18
|
GEM_NAME = "merb-parts"
|
19
19
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
20
|
-
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.
|
20
|
+
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.8") + PKG_BUILD
|
21
21
|
|
22
22
|
RELEASE_NAME = "REL #{GEM_VERSION}"
|
23
23
|
|
@@ -35,7 +35,7 @@ spec = Gem::Specification.new do |s|
|
|
35
35
|
s.author = GEM_AUTHOR
|
36
36
|
s.email = GEM_EMAIL
|
37
37
|
s.homepage = PROJECT_URL
|
38
|
-
s.add_dependency('merb-core', '>= 0.9.
|
38
|
+
s.add_dependency('merb-core', '>= 0.9.8')
|
39
39
|
s.require_path = 'lib'
|
40
40
|
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec,merb_generators}/**/*")
|
41
41
|
end
|
@@ -45,21 +45,33 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|
45
45
|
end
|
46
46
|
|
47
47
|
desc "Install the gem"
|
48
|
-
task :install
|
49
|
-
|
48
|
+
task :install do
|
49
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
desc "Uninstall the gem"
|
53
|
+
task :uninstall do
|
54
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
55
|
+
end
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
desc "Create a gemspec file"
|
58
|
+
task :gemspec do
|
59
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
60
|
+
file.puts spec.to_ruby
|
57
61
|
end
|
58
|
-
|
59
62
|
end
|
60
63
|
|
61
|
-
desc "Run all
|
62
|
-
Spec::Rake::SpecTask.new(
|
63
|
-
t.spec_opts
|
64
|
-
t.spec_files =
|
64
|
+
desc "Run all examples (or a specific spec with TASK=xxxx)"
|
65
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
66
|
+
t.spec_opts = ["-cfs"]
|
67
|
+
t.spec_files = begin
|
68
|
+
if ENV["TASK"]
|
69
|
+
ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
|
70
|
+
else
|
71
|
+
FileList['spec/**/*_spec.rb']
|
72
|
+
end
|
73
|
+
end
|
65
74
|
end
|
75
|
+
|
76
|
+
desc 'Default: run spec examples'
|
77
|
+
task :default => 'spec'
|
@@ -29,8 +29,8 @@ module Merb
|
|
29
29
|
klasses, opts = opts.partition do |k,v|
|
30
30
|
k.respond_to?(:ancestors) && k.ancestors.include?(Merb::PartController)
|
31
31
|
end
|
32
|
-
|
33
|
-
opts = Hash[*(opts.
|
32
|
+
|
33
|
+
opts = opts.empty? ? {} : Hash[*(opts.first)]
|
34
34
|
|
35
35
|
res = klasses.inject([]) do |memo,(klass,action)|
|
36
36
|
memo << klass.new(self, opts)._dispatch(action)
|
@@ -36,22 +36,8 @@ module Merb
|
|
36
36
|
request.route
|
37
37
|
end
|
38
38
|
|
39
|
-
def url(name,
|
40
|
-
|
41
|
-
{ :controller => @web_controller.controller_name,
|
42
|
-
:action => @web_controller.action_name,
|
43
|
-
:format => params[:format]
|
44
|
-
}
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
# This method is here to overwrite the one in the general_controller mixin
|
50
|
-
# The method ensures that when a url is generated with a hash, it contains a controller
|
51
|
-
def get_controller_for_url_generation(opts)
|
52
|
-
controller = opts[:controller] || @web_controller.params[:controller]
|
53
|
-
raise "No Controller Specified for url()" unless controller
|
54
|
-
controller
|
39
|
+
def url(name, *args)
|
40
|
+
@web_controller.url(name, *args)
|
55
41
|
end
|
56
42
|
|
57
43
|
end
|
@@ -72,6 +72,25 @@ module Merb
|
|
72
72
|
super
|
73
73
|
@content_type = @web_controller.content_type
|
74
74
|
end
|
75
|
+
|
76
|
+
# ==== Parameters
|
77
|
+
# name<~to_sym, Hash>:: The name of the URL to generate.
|
78
|
+
# rparams<Hash>:: Parameters for the route generation.
|
79
|
+
#
|
80
|
+
# ==== Returns
|
81
|
+
# String:: The generated URL.
|
82
|
+
#
|
83
|
+
# ==== Alternatives
|
84
|
+
# If a hash is used as the first argument, a default route will be
|
85
|
+
# generated based on it and rparams.
|
86
|
+
# ====
|
87
|
+
# TODO: Update this documentation
|
88
|
+
def url(name, *args)
|
89
|
+
args << params
|
90
|
+
Merb::Router.url(name, *args)
|
91
|
+
end
|
92
|
+
|
93
|
+
alias_method :relative_url, :url
|
75
94
|
|
76
95
|
# ==== Parameters
|
77
96
|
# action<~to_s>:: An action to dispatch to. Defaults to :to_s.
|
@@ -22,6 +22,10 @@ class Main < Merb::Controller
|
|
22
22
|
part(TodoPart => :part_with_params, :my_param => "my_value")
|
23
23
|
end
|
24
24
|
|
25
|
+
def part_with_arrays_in_params
|
26
|
+
part(TodoPart => :part_with_params, :my_param => ['my_first_value', 'my_second_value'])
|
27
|
+
end
|
28
|
+
|
25
29
|
def part_within_view
|
26
30
|
render
|
27
31
|
end
|
data/spec/merb-parts_spec.rb
CHANGED
@@ -46,6 +46,11 @@ describe "A Merb PartController" do
|
|
46
46
|
controller = dispatch_to(Main, :part_with_params)
|
47
47
|
controller.body.should match( /my_param = my_value/)
|
48
48
|
end
|
49
|
+
|
50
|
+
it "should provide arrays from params when calling a part" do
|
51
|
+
controller = dispatch_to(Main, :part_with_arrays_in_params)
|
52
|
+
controller.body.should match(/my_param = my_first_value, my_second_value/)
|
53
|
+
end
|
49
54
|
|
50
55
|
it "should render from inside a view" do
|
51
56
|
controller = dispatch_to(Main, :part_within_view)
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require File.join( File.dirname(__FILE__), "..", "lib", "merb-parts" )
|
|
5
5
|
# Require the fixtures
|
6
6
|
Dir[File.join(File.dirname(__FILE__), "fixtures", "*/**.rb")].each{|f| require f }
|
7
7
|
|
8
|
-
Merb.start :environment => 'test'
|
8
|
+
Merb.start :environment => 'test', :adapter => 'runner'
|
9
9
|
|
10
10
|
Spec::Runner.configure do |config|
|
11
11
|
config.include Merb::Test::RequestHelper
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-parts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Neighman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-06 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.8
|
24
24
|
version:
|
25
25
|
description: Merb plugin that provides Part Controllers.
|
26
26
|
email: has.sox@gmail.com
|