merb_parts 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ == 0.9.14
2
+ * Fix multiple parameter bug for part() method [#192 status:resolved]
3
+ * Added /lib/merb_parts/version.rb
4
+ * Added CHANGELOG
data/Rakefile CHANGED
@@ -1,77 +1,55 @@
1
1
  require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require "extlib"
4
- require 'merb-core/tasks/merb_rake_helper'
5
- require "spec/rake/spectask"
6
- require "#{File.dirname(__FILE__)}" / ".." / "version"
7
-
8
- ##############################################################################
9
- # Package && release
10
- ##############################################################################
11
- RUBY_FORGE_PROJECT = "merb"
12
- PROJECT_URL = "http://merbivore.com"
13
- PROJECT_SUMMARY = "Merb plugin that provides Part Controllers."
14
- PROJECT_DESCRIPTION = PROJECT_SUMMARY
15
-
16
- GEM_AUTHOR = "Daniel Neighman"
17
- GEM_EMAIL = "has.sox@gmail.com"
18
-
19
- GEM_NAME = "merb_parts"
20
- PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
21
- GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.9") + PKG_BUILD
22
-
23
- RELEASE_NAME = "REL #{GEM_VERSION}"
24
-
25
- require "extlib/tasks/release"
26
-
27
- spec = Gem::Specification.new do |s|
28
- s.rubyforge_project = RUBY_FORGE_PROJECT
29
- s.name = GEM_NAME
30
- s.version = GEM_VERSION
31
- s.platform = Gem::Platform::RUBY
32
- s.has_rdoc = true
33
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
34
- s.summary = PROJECT_SUMMARY
35
- s.description = PROJECT_DESCRIPTION
36
- s.author = GEM_AUTHOR
37
- s.email = GEM_EMAIL
38
- s.homepage = PROJECT_URL
39
- s.add_dependency('merb-core', '>= 0.9.9')
40
- s.require_path = 'lib'
41
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib}/**/*")
42
- end
2
+ require 'rake'
43
3
 
44
- Rake::GemPackageTask.new(spec) do |pkg|
45
- pkg.gem_spec = spec
46
- end
4
+ # Assume a typical dev checkout to fetch the current merb-core version
5
+ require File.expand_path('../../merb/merb-core/lib/merb-core/version', __FILE__)
47
6
 
48
- desc "Install the gem"
49
- task :install do
50
- Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
51
- end
7
+ # Load this library's version information
8
+ require File.expand_path('../lib/merb_parts/version', __FILE__)
52
9
 
53
- desc "Uninstall the gem"
54
- task :uninstall do
55
- Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
56
- end
10
+ begin
11
+
12
+ require 'jeweler'
13
+
14
+ Jeweler::Tasks.new do |gemspec|
15
+
16
+ gemspec.version = Merb::Parts::VERSION
17
+
18
+ gemspec.name = "merb_parts"
19
+ gemspec.description = "Merb plugin that provides Part Controllers."
20
+ gemspec.summary = "Merb plugin that provides Part Controllers."
21
+
22
+ gemspec.authors = [ "Daniel Neighman" ]
23
+ gemspec.email = "has.sox@gmail.com"
24
+ gemspec.homepage = "http://github.com/merb/merb_parts"
25
+
26
+ gemspec.files = %w(CHANGELOG LICENSE Rakefile README TODO) + Dir['{lib,spec}/**/*']
27
+
28
+ # Runtime dependencies
29
+ gemspec.add_dependency 'merb-core', ">= 0.9.9"
30
+
31
+ # Development dependencies
32
+ gemspec.add_development_dependency 'rspec', '>= 1.2.9'
57
33
 
58
- desc "Create a gemspec file"
59
- task :gemspec do
60
- File.open("#{GEM_NAME}.gemspec", "w") do |file|
61
- file.puts spec.to_ruby
62
34
  end
35
+
36
+ Jeweler::GemcutterTasks.new
37
+
38
+ rescue LoadError
39
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
63
40
  end
64
41
 
65
- desc "Run all examples (or a specific spec with TASK=xxxx)"
66
- Spec::Rake::SpecTask.new('spec') do |t|
67
- t.spec_opts = ["-cfs"]
68
- t.spec_files = begin
69
- if ENV["TASK"]
70
- ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
71
- else
72
- FileList['spec/**/*_spec.rb']
73
- end
74
- end
42
+ require 'spec/rake/spectask'
43
+ Spec::Rake::SpecTask.new(:spec) do |spec|
44
+ spec.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
45
+ spec.libs << 'lib' << 'spec'
46
+ spec.spec_files = FileList['spec/**/*_spec.rb']
47
+ end
48
+
49
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
50
+ spec.libs << 'lib' << 'spec'
51
+ spec.pattern = 'spec/**/*_spec.rb'
52
+ spec.rcov = true
75
53
  end
76
54
 
77
55
  desc 'Default: run spec examples'
@@ -30,7 +30,7 @@ module Merb
30
30
  k.respond_to?(:ancestors) && k.ancestors.include?(Merb::PartController)
31
31
  end
32
32
 
33
- opts = opts.empty? ? {} : Hash[*(opts.first)]
33
+ opts = opts.inject({}) {|h,v| h[v.first] = v.last; h}
34
34
 
35
35
  res = klasses.inject([]) do |memo,(klass,action)|
36
36
  memo << klass.new(self, opts)._dispatch(action)
@@ -39,4 +39,4 @@ module Merb
39
39
  end
40
40
 
41
41
  end
42
- end
42
+ end
@@ -0,0 +1,5 @@
1
+ module Merb
2
+ module Parts
3
+ VERSION = '0.9.14'.freeze
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ class Main < Merb::Controller
2
+ self._template_root = File.dirname(__FILE__) / ".." / "views"
3
+
4
+ def index
5
+ part TodoPart => :list
6
+ end
7
+
8
+ def index2
9
+ part TodoPart => :one
10
+ end
11
+
12
+ def index3
13
+ part(TodoPart => :one) + part(TodoPart => :list)
14
+ end
15
+
16
+ def index4
17
+ provides :xml, :js
18
+ part(TodoPart => :formatted_output)
19
+ end
20
+
21
+ def part_with_params
22
+ part(TodoPart => :part_with_params, :my_param => "my_value", :my_second_param => "my_value")
23
+ end
24
+
25
+ def part_with_arrays_in_params
26
+ part(TodoPart => :part_with_params, :my_param => ['my_first_value', 'my_second_value'], :my_second_param => "my_value")
27
+ end
28
+
29
+ def part_within_view
30
+ render
31
+ end
32
+
33
+ def parth_with_absolute_template
34
+ part(TodoPart => :parth_with_absolute_template)
35
+ end
36
+
37
+ end
@@ -0,0 +1,4 @@
1
+ require File.dirname(__FILE__) / 'todo_part'
2
+
3
+ class DonePart < TodoPart
4
+ end
@@ -0,0 +1,30 @@
1
+ class TodoPart < Merb::PartController
2
+ self._template_root = File.expand_path(File.join(File.dirname(__FILE__), "views"))
3
+
4
+ before :load_todos
5
+
6
+ def list
7
+ render
8
+ end
9
+
10
+ def one
11
+ render :list, :layout => false
12
+ end
13
+
14
+ def load_todos
15
+ @todos = ["Do this", "Do that", 'Do the other thing']
16
+ end
17
+
18
+ def formatted_output
19
+ render
20
+ end
21
+
22
+ def part_with_params
23
+ render
24
+ end
25
+
26
+ def parth_with_absolute_template
27
+ render :template => File.expand_path(self._template_root) / 'todo_part' / 'formatted_output'
28
+ end
29
+
30
+ end
@@ -0,0 +1,3 @@
1
+ TODOLAYOUT
2
+ <%= catch_content :for_layout %>
3
+ TODOLAYOUT
@@ -0,0 +1,3 @@
1
+ <todolayout>
2
+ <%= catch_content :for_layout %>
3
+ </todolayout>
@@ -0,0 +1,3 @@
1
+ TODOPART
2
+ <%= @todos.join('|') %>
3
+ TODOPART
@@ -0,0 +1,7 @@
1
+ <% params.each do |param, value| %>
2
+ <% if value.is_a? Array %>
3
+ <%= param %> = <%= value.join(", ") %>
4
+ <% else %>
5
+ <%= param %> = <%= value %>
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= part TodoPart => :one %>
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ describe "A Merb PartController" do
4
+
5
+ before(:each) do
6
+ Merb::Router.prepare do
7
+ default_routes
8
+ end
9
+ end
10
+
11
+ it "should render a part template with no layout" do
12
+ controller = dispatch_to(Main, :index2)
13
+ controller.body.should ==
14
+ "TODOPART\nDo this|Do that|Do the other thing\nTODOPART"
15
+ end
16
+
17
+ it "should render a part template with it's own layout" do
18
+ controller = dispatch_to(Main, :index)
19
+ controller.body.should ==
20
+ "TODOLAYOUT\nTODOPART\nDo this|Do that|Do the other thing\nTODOPART\nTODOLAYOUT"
21
+ end
22
+
23
+ it "should render multiple parts if more then one part is passed in" do
24
+ controller = dispatch_to(Main, :index3)
25
+ controller.body.should ==
26
+ "TODOPART\nDo this|Do that|Do the other thing\nTODOPART" +
27
+ "TODOLAYOUT\nTODOPART\nDo this|Do that|Do the other thing\nTODOPART\nTODOLAYOUT"
28
+ end
29
+
30
+ it "should render the html format by default to the controller that set it" do
31
+ controller = dispatch_to(Main, :index4)
32
+ controller.body.should match(/part_html_format/m)
33
+ end
34
+
35
+ it "should render the xml format according to the controller" do
36
+ controller = dispatch_to(Main, :index4, {:format => 'xml'} )
37
+ controller.body.should match(/part_xml_format/m)
38
+ end
39
+
40
+ it "should render the js format according to the controller" do
41
+ controller = dispatch_to(Main, :index4, :format => 'js')
42
+ controller.body.should match(/part_js_format/m)
43
+ end
44
+
45
+ it "should provide params when calling a part" do
46
+ controller = dispatch_to(Main, :part_with_params)
47
+ controller.body.should match( /my_param = my_value/)
48
+ controller.body.should match( /my_second_param = my_value/)
49
+ end
50
+
51
+ it "should provide arrays from params when calling a part" do
52
+ controller = dispatch_to(Main, :part_with_arrays_in_params)
53
+ controller.body.should match(/my_param = my_first_value, my_second_value/)
54
+ controller.body.should match( /my_second_param = my_value/)
55
+ end
56
+
57
+ it "should render from inside a view" do
58
+ controller = dispatch_to(Main, :part_within_view)
59
+ controller.body.should match( /Do this/)
60
+ end
61
+
62
+ it "should render a template from an absolute path" do
63
+ controller = dispatch_to(Main, :parth_with_absolute_template)
64
+ controller.body.should match(/part_html_format/m)
65
+ end
66
+
67
+ end
68
+
69
+ describe "A Merb Part Controller with urls" do
70
+
71
+ def new_url_controller(route, params = {:action => 'show', :controller => 'Test'})
72
+ @controller = dispatch_to(Main, :index)
73
+ TodoPart.new(@controller)
74
+ end
75
+
76
+ it "should use the web_controllers type if no controller is specified" do
77
+ c = new_url_controller(@default_route, :controller => "my_controller")
78
+ the_url = c.url(:action => "bar")
79
+ the_url.should == "/main/bar"
80
+ end
81
+
82
+ end
83
+
84
+ describe "A Merb Part Controller inheriting from another Part Controller" do
85
+
86
+ it "should inherit the _template_root" do
87
+ TodoPart._template_root.should == File.expand_path(File.dirname(__FILE__) / 'fixtures' / 'parts' / 'views')
88
+ TodoPart._template_root.should == DonePart._template_root
89
+ end
90
+
91
+ end
@@ -0,0 +1,2 @@
1
+ --format specdoc
2
+ --colour
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+
3
+ # Use current merb-core sources if running from a typical dev checkout.
4
+ lib = File.expand_path('../../../merb/merb-core/lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
6
+ require "merb-core"
7
+
8
+ # The lib under test
9
+ require 'merb_parts'
10
+
11
+ # Require the fixtures
12
+ Dir[File.join(File.dirname(__FILE__), "fixtures", "*/**.rb")].each{|f| require f }
13
+
14
+ Merb.start(
15
+ :environment => 'test',
16
+ :adapter => 'runner',
17
+ :log_level => :error,
18
+ :disabled_components => [:json]
19
+ )
20
+
21
+ Spec::Runner.configure do |config|
22
+ config.include Merb::Test::RequestHelper
23
+ end
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.13
4
+ version: 0.9.14
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-11-03 00:00:00 -08:00
12
+ date: 2009-11-07 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.9.9
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.9
34
+ version:
25
35
  description: Merb plugin that provides Part Controllers.
26
36
  email: has.sox@gmail.com
27
37
  executables: []
@@ -29,26 +39,41 @@ executables: []
29
39
  extensions: []
30
40
 
31
41
  extra_rdoc_files:
32
- - README
33
42
  - LICENSE
34
- - TODO
43
+ - README
35
44
  files:
45
+ - CHANGELOG
36
46
  - LICENSE
37
47
  - README
38
48
  - Rakefile
39
49
  - TODO
40
- - lib/merb_parts
50
+ - lib/merb_parts.rb
41
51
  - lib/merb_parts/merbtasks.rb
42
- - lib/merb_parts/mixins
43
52
  - lib/merb_parts/mixins/parts_mixin.rb
44
53
  - lib/merb_parts/mixins/web_controller.rb
45
54
  - lib/merb_parts/part_controller.rb
46
- - lib/merb_parts.rb
55
+ - lib/merb_parts/version.rb
56
+ - spec/fixtures/controllers/main.rb
57
+ - spec/fixtures/parts/done_part.rb
58
+ - spec/fixtures/parts/todo_part.rb
59
+ - spec/fixtures/parts/views/layout/todo_part.html.erb
60
+ - spec/fixtures/parts/views/layout/todo_part.xml.erb
61
+ - spec/fixtures/parts/views/todo_part/formatted_output.html.erb
62
+ - spec/fixtures/parts/views/todo_part/formatted_output.js.erb
63
+ - spec/fixtures/parts/views/todo_part/formatted_output.xml.erb
64
+ - spec/fixtures/parts/views/todo_part/list.html.erb
65
+ - spec/fixtures/parts/views/todo_part/part_with_params.html.erb
66
+ - spec/fixtures/views/main/part_within_view.html.erb
67
+ - spec/merb-parts_spec.rb
68
+ - spec/spec.opts
69
+ - spec/spec_helper.rb
47
70
  has_rdoc: true
48
- homepage: http://merbivore.com
49
- post_install_message:
50
- rdoc_options: []
71
+ homepage: http://github.com/merb/merb_parts
72
+ licenses: []
51
73
 
74
+ post_install_message:
75
+ rdoc_options:
76
+ - --charset=UTF-8
52
77
  require_paths:
53
78
  - lib
54
79
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -65,10 +90,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
90
  version:
66
91
  requirements: []
67
92
 
68
- rubyforge_project: merb
69
- rubygems_version: 1.3.1
93
+ rubyforge_project:
94
+ rubygems_version: 1.3.5
70
95
  signing_key:
71
- specification_version: 2
96
+ specification_version: 3
72
97
  summary: Merb plugin that provides Part Controllers.
73
- test_files: []
74
-
98
+ test_files:
99
+ - spec/fixtures/controllers/main.rb
100
+ - spec/fixtures/parts/done_part.rb
101
+ - spec/fixtures/parts/todo_part.rb
102
+ - spec/merb-parts_spec.rb
103
+ - spec/spec_helper.rb