From 5177f42c71f69fdd85a944e873cf678598825ff9 Mon Sep 17 00:00:00 2001 From: Ben Burkert Date: Tue, 27 May 2008 11:33:30 -0500 Subject: [PATCH] finished move to merb-E-mart. --- README | 24 ++++++------- lib/{merb_e_mart.rb => merb-E-mart.rb} | 18 +++++++--- lib/{merb_e_mart => merb-E-mart}/merbtasks.rb | 0 spec/controllers/main_spec.rb | 41 ----------------------- spec/{merb_e_mart_spec.rb => merb-E-mart_spec.rb} | 12 +++---- spec/spec_helper.rb | 4 +-- 6 files changed, 34 insertions(+), 65 deletions(-) rename lib/{merb_e_mart.rb => merb-E-mart.rb} (66%) rename lib/{merb_e_mart => merb-E-mart}/merbtasks.rb (100%) delete mode 100644 spec/controllers/main_spec.rb rename spec/{merb_e_mart_spec.rb => merb-E-mart_spec.rb} (89%) diff --git a/README b/README index ad391c9..ec91eb6 100644 --- a/README +++ b/README @@ -11,7 +11,7 @@ file: config/init.rb # add the slice as a regular dependency -dependency 'merb_e_mart' +dependency 'merb-E-mart' # if needed, configure which slices to load and in which order @@ -21,13 +21,13 @@ Merb::Plugins.config[:merb_slices] = { :queue => ["MerbEMart", ...] } Merb::BootLoader.before_app_loads do - Merb::Slices::config[:merb_e_mart] = { ... } + Merb::Slices::config[:merb_E_mart] = { ... } end file: config/router.rb -# example: /merb_e_mart/:controller/:action/:id +# example: /merb-E-mart/:controller/:action/:id r.add_slice(:MerbEMart) @@ -45,32 +45,32 @@ r.slice(:MerbEMart) Normally you should also run the following rake task: -rake slices:merb_e_mart:install +rake slices:merb_E_mart:install ------------------------------------------------------------------------------ You can put your application-level overrides in: -host-app/slices/merb_e_mart/app - controllers, models, views ... +host-app/slices/merb-E-mart/app - controllers, models, views ... Templates are located in this order: -1. host-app/slices/merb_e_mart/app/views/* -2. gems/merb_e_mart/app/views/* +1. host-app/slices/merb-E-mart/app/views/* +2. gems/merb-E-mart/app/views/* 3. host-app/app/views/* You can use the host application's layout by configuring the -merb_e_mart slice in a before_app_loads block: +merb-E-mart slice in a before_app_loads block: -Merb::Slices.config[:merb_e_mart] = { :layout => :application } +Merb::Slices.config[:merb_E_mart] = { :layout => :application } -By default :merb_e_mart is used. If you need to override +By default :merb_E_mart is used. If you need to override stylesheets or javascripts, just specify your own files in your layout instead/in addition to the ones supplied (if any) in -host-app/public/slices/merb_e_mart. +host-app/public/slices/merb-E-mart. In any case don't edit those files directly as they may be clobbered any time -rake merb_e_mart:install is run. +rake merb_E_mart:install is run. ------------------------------------------------------------------------------ diff --git a/lib/merb_e_mart.rb b/lib/merb-E-mart.rb similarity index 66% rename from lib/merb_e_mart.rb rename to lib/merb-E-mart.rb index 9ec73ae..ec9db03 100644 --- a/lib/merb_e_mart.rb +++ b/lib/merb-E-mart.rb @@ -2,11 +2,21 @@ if defined?(Merb::Plugins) require 'merb-slices' require 'dm-validations' - Merb::Plugins.add_rakefiles "merb_e_mart/merbtasks" + Merb::Plugins.add_rakefiles "merb-E-mart/merbtasks" + # Register the Slice for the current host application Merb::Slices::register(__FILE__) - Merb::Slices::config[:merb_e_mart] = { :layout => :merb_e_mart } + # Slice configuration - set this in a before_app_loads callback. + # By default a Slice uses its own layout, so you can swicht to + # the main application layout or no layout at all if needed. + # + # Configuration options: + # :layout - the layout to use; defaults to :merb_E_mart + # :mirror - which path component types to use on copy operations; defaults to all + Merb::Slices::config[:merb_E_mart] = { :layout => :merb_E_mart } + + # All Slice code is expected to be namespaced inside a module module MerbEMart # Slice metadata @@ -40,10 +50,10 @@ if defined?(Merb::Plugins) # Setup the slice layout for MerbEMart # # Use MerbEMart.push_path and MerbEMart.push_app_path - # to set paths to merb_e_mart-level and app-level paths. Example: + # to set paths to merb-E-mart-level and app-level paths. Example: # # MerbEMart.push_path(:application, MerbEMart.root) - # MerbEMart.push_app_path(:application, Merb.root / 'slices' / 'merb_e_mart') + # MerbEMart.push_app_path(:application, Merb.root / 'slices' / 'merb-E-mart') # ... # # Any component path that hasn't been set will default to MerbEMart.root diff --git a/lib/merb_e_mart/merbtasks.rb b/lib/merb-E-mart/merbtasks.rb similarity index 100% rename from lib/merb_e_mart/merbtasks.rb rename to lib/merb-E-mart/merbtasks.rb diff --git a/spec/controllers/main_spec.rb b/spec/controllers/main_spec.rb deleted file mode 100644 index 4245877..0000000 --- a/spec/controllers/main_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' - -describe "MerbEMart::Main (controller)" do - - # Feel free to remove the specs below - - before :all do - Merb::Router.prepare { |r| r.add_slice(:MerbEMart) } if standalone? - end - - it "should have access to the slice module" do - controller = dispatch_to(MerbEMart::Main, :index) - controller.slice.should == MerbEMart - controller.slice.should == MerbEMart::Main.slice - end - - it "should have an index action" do - controller = dispatch_to(MerbEMart::Main, :index) - controller.status.should == 200 - controller.body.should contain('MerbEMart') - end - - it "should work with the default route" do - controller = get("/merb_e_mart/main/index") - controller.should be_kind_of(MerbEMart::Main) - controller.action_name.should == 'index' - end - - it "should have helper methods for dealing with public paths" do - controller = dispatch_to(MerbEMart::Main, :index) - controller.public_path_for(:image).should == "/slices/merb_e_mart/images" - controller.public_path_for(:javascript).should == "/slices/merb_e_mart/javascripts" - controller.public_path_for(:stylesheet).should == "/slices/merb_e_mart/stylesheets" - end - - it "should have a slice-specific _template_root" do - MerbEMart::Main._template_root.should == MerbEMart.dir_for(:view) - MerbEMart::Main._template_root.should == MerbEMart::Application._template_root - end - -end \ No newline at end of file diff --git a/spec/merb_e_mart_spec.rb b/spec/merb-E-mart_spec.rb similarity index 89% rename from spec/merb_e_mart_spec.rb rename to spec/merb-E-mart_spec.rb index dcbb07a..704e84b 100644 --- a/spec/merb_e_mart_spec.rb +++ b/spec/merb-E-mart_spec.rb @@ -11,11 +11,11 @@ describe "MerbEMart (module)" do end it "should have an :identifier property" do - MerbEMart.identifier.should == "merb_e_mart" + MerbEMart.identifier.should == "merb-E-mart" end it "should have an :identifier_sym property" do - MerbEMart.identifier_sym.should == :merb_e_mart + MerbEMart.identifier_sym.should == :merb_E_mart end it "should have a :root property" do @@ -34,7 +34,7 @@ describe "MerbEMart (module)" do end it "should have a :layout config option set" do - MerbEMart.config[:layout].should == :merb_e_mart + MerbEMart.config[:layout].should == :merb_E_mart end it "should have a dir_for method" do @@ -52,14 +52,14 @@ describe "MerbEMart (module)" do it "should have a app_dir_for method" do root_path = MerbEMart.app_dir_for(:root) - root_path.should == Merb.root / 'slices' / 'merb_e_mart' + root_path.should == Merb.root / 'slices' / 'merb-E-mart' app_path = MerbEMart.app_dir_for(:application) app_path.should == root_path / 'app' [:view, :model, :controller, :helper, :mailer, :part].each do |type| MerbEMart.app_dir_for(type).should == app_path / "#{type}s" end public_path = MerbEMart.app_dir_for(:public) - public_path.should == Merb.dir_for(:public) / 'slices' / 'merb_e_mart' + public_path.should == Merb.dir_for(:public) / 'slices' / 'merb-E-mart' [:stylesheet, :javascript, :image].each do |type| MerbEMart.app_dir_for(type).should == public_path / "#{type}s" end @@ -67,7 +67,7 @@ describe "MerbEMart (module)" do it "should have a public_dir_for method" do public_path = MerbEMart.public_dir_for(:public) - public_path.should == '/slices' / 'merb_e_mart' + public_path.should == '/slices' / 'merb-E-mart' [:stylesheet, :javascript, :image].each do |type| MerbEMart.public_dir_for(type).should == public_path / "#{type}s" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b10d89b..efafe43 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,7 +5,7 @@ require 'data_mapper' require 'can_has_fixtures' # Add the dependency in a before_app_loads hook -Merb::BootLoader.before_app_loads { require(File.join(File.dirname(__FILE__), '..', 'lib', 'merb_e_mart')) } +Merb::BootLoader.before_app_loads { require(File.join(File.dirname(__FILE__), '..', 'lib', 'merb-E-mart')) } DataMapper.setup(:default, 'sqlite3::memory:') DataMapper.auto_migrate! @@ -60,7 +60,7 @@ Address.fixture {{ Country.fixture {{ :code => 2.of {('a'..'z').random}.to_s, - :name => Random.word(:max => 100) + :name => Random.word(:max => 100, :unique => true) }} State.fixture {{ -- 2.11.4.GIT