From 8655c0decb32d4159161863dc96d882c6bc33f75 Mon Sep 17 00:00:00 2001 From: Ben Burkert Date: Fri, 30 May 2008 15:18:48 -0500 Subject: [PATCH] started Quick-E-Mart example. --- app/controllers/main.rb | 7 - app/controllers/products.rb | 8 + app/models/product.rb | 6 +- app/models/upload.rb | 3 +- app/models/upload/image.rb | 3 +- app/models/upload/image/product_image.rb | 3 +- app/views/main/index.html.erb | 1 - app/views/products/_preview.html.haml | 9 + app/views/products/index.html.haml | 4 + examples/quick-E-mart/Rakefile | 76 ++++++++ .../quick-E-mart/app/controllers/application.rb | 2 + .../quick-E-mart/app/controllers/exceptions.rb | 13 ++ .../quick-E-mart/app/helpers/global_helpers.rb | 5 + .../exceptions/internal_server_error.html.erb | 216 +++++++++++++++++++++ .../app/views/exceptions/not_acceptable.html.erb | 63 ++++++ .../app/views/exceptions/not_found.html.erb | 47 +++++ .../app/views/layout/application.html.erb | 11 ++ examples/quick-E-mart/autotest/discover.rb | 1 + examples/quick-E-mart/autotest/merb.rb | 149 ++++++++++++++ examples/quick-E-mart/autotest/merb_rspec.rb | 166 ++++++++++++++++ examples/quick-E-mart/config/database.yml.sample | 36 ++++ .../config/environments/development.rb | 20 ++ .../quick-E-mart/config/environments/production.rb | 7 + examples/quick-E-mart/config/environments/rake.rb | 7 + examples/quick-E-mart/config/environments/test.rb | 6 + examples/quick-E-mart/config/init.rb | 9 + examples/quick-E-mart/config/rack.rb | 12 ++ examples/quick-E-mart/config/router.rb | 25 +++ examples/quick-E-mart/public/images/merb.jpg | Bin 0 -> 5815 bytes examples/quick-E-mart/public/merb.fcgi | 22 +++ .../slices/merb-E-mart/javascripts/master.js | 0 .../slices/merb-E-mart/stylesheets/master.css | 2 + .../quick-E-mart/public/stylesheets/master.css | 119 ++++++++++++ examples/quick-E-mart/spec/spec.opts | 0 examples/quick-E-mart/spec/spec_helper.rb | 11 ++ lib/merb-E-mart.rb | 10 +- spec/spec_helper.rb | 18 -- 37 files changed, 1061 insertions(+), 36 deletions(-) delete mode 100644 app/controllers/main.rb create mode 100644 app/controllers/products.rb delete mode 100644 app/views/main/index.html.erb create mode 100644 app/views/products/_preview.html.haml create mode 100644 app/views/products/index.html.haml create mode 100644 examples/quick-E-mart/Rakefile create mode 100644 examples/quick-E-mart/app/controllers/application.rb create mode 100644 examples/quick-E-mart/app/controllers/exceptions.rb create mode 100644 examples/quick-E-mart/app/helpers/global_helpers.rb create mode 100644 examples/quick-E-mart/app/views/exceptions/internal_server_error.html.erb create mode 100644 examples/quick-E-mart/app/views/exceptions/not_acceptable.html.erb create mode 100644 examples/quick-E-mart/app/views/exceptions/not_found.html.erb create mode 100644 examples/quick-E-mart/app/views/layout/application.html.erb create mode 100644 examples/quick-E-mart/autotest/discover.rb create mode 100644 examples/quick-E-mart/autotest/merb.rb create mode 100644 examples/quick-E-mart/autotest/merb_rspec.rb create mode 100644 examples/quick-E-mart/config/database.yml.sample create mode 100644 examples/quick-E-mart/config/environments/development.rb create mode 100644 examples/quick-E-mart/config/environments/production.rb create mode 100644 examples/quick-E-mart/config/environments/rake.rb create mode 100644 examples/quick-E-mart/config/environments/test.rb create mode 100644 examples/quick-E-mart/config/init.rb create mode 100644 examples/quick-E-mart/config/rack.rb create mode 100644 examples/quick-E-mart/config/router.rb create mode 100644 examples/quick-E-mart/public/images/merb.jpg create mode 100644 examples/quick-E-mart/public/merb.fcgi create mode 100644 examples/quick-E-mart/public/slices/merb-E-mart/javascripts/master.js create mode 100644 examples/quick-E-mart/public/slices/merb-E-mart/stylesheets/master.css create mode 100644 examples/quick-E-mart/public/stylesheets/master.css create mode 100644 examples/quick-E-mart/spec/spec.opts create mode 100644 examples/quick-E-mart/spec/spec_helper.rb diff --git a/app/controllers/main.rb b/app/controllers/main.rb deleted file mode 100644 index e34767a..0000000 --- a/app/controllers/main.rb +++ /dev/null @@ -1,7 +0,0 @@ -class MerbEMart::Main < MerbEMart::Application - - def index - render - end - -end \ No newline at end of file diff --git a/app/controllers/products.rb b/app/controllers/products.rb new file mode 100644 index 0000000..7f5e3a1 --- /dev/null +++ b/app/controllers/products.rb @@ -0,0 +1,8 @@ +class MerbEMart::Products < MerbEMart::Application + + def index + @products = Product.all + + display @products + end +end \ No newline at end of file diff --git a/app/models/product.rb b/app/models/product.rb index 62a35fb..d1a86ea 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -9,11 +9,7 @@ class Product property :price, BigDecimal, :default => 0.0, :nullable => false property :date_available, DateTime, :nullable => false property :quantity, Integer, :default => 0, :nullable => false - property :size_width, Float, :default => 0.0, :nullable => false - property :size_height, Float, :default => 0.0, :nullable => false - property :size_depth, Float, :default => 0.0, :nullable => false - property :weight, Float, :default => 0.0, :nullable => false - property :is_discontinued, Boolean, :default => false, :nullable => false + property :is_discontinued, Boolean has n, :items has n, :variations diff --git a/app/models/upload.rb b/app/models/upload.rb index fadb561..f36f331 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -1,10 +1,11 @@ class Upload include DataMapper::Resource - include Merb::Slices::config[:merb_E_mart][:upload_processor_mixin] property :id, Integer, :serial => true property :type, Class # single-table inheritance property :location, DM::URI, :nullable => false before :save, :process + + def process; end end \ No newline at end of file diff --git a/app/models/upload/image.rb b/app/models/upload/image.rb index c0b48c2..db866a9 100644 --- a/app/models/upload/image.rb +++ b/app/models/upload/image.rb @@ -1,5 +1,4 @@ class Image < Upload - include Merb::Slices::config[:merb_E_mart][:image_resize_mixin] IMAGE_EXTENSIONS = ['gif', 'jpg', 'jpeg', 'png', 'bmp'] @@ -9,4 +8,6 @@ class Image < Upload validates_present :width, :height after :process, :resize + + def resize; end end \ No newline at end of file diff --git a/app/models/upload/image/product_image.rb b/app/models/upload/image/product_image.rb index 2dea497..aab7442 100644 --- a/app/models/upload/image/product_image.rb +++ b/app/models/upload/image/product_image.rb @@ -1,5 +1,4 @@ class ProductImage < Image - include Merb::Slices::config[:merb_E_mart][:thumbnail_mixin] property :product_id, Integer # foreign-key @@ -8,4 +7,6 @@ class ProductImage < Image after :resize, :generate_thumbnail validates_present :product + + def generate_thumbnail; end end \ No newline at end of file diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb deleted file mode 100644 index 755c73d..0000000 --- a/app/views/main/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= slice.description %> (v. <%= slice.version %>) \ No newline at end of file diff --git a/app/views/products/_preview.html.haml b/app/views/products/_preview.html.haml new file mode 100644 index 0000000..cc86f06 --- /dev/null +++ b/app/views/products/_preview.html.haml @@ -0,0 +1,9 @@ +%li.product + %h4=product.name + .code + Product Code: + %strong=product.code + .price + Price: + =product.price + .description=product.description \ No newline at end of file diff --git a/app/views/products/index.html.haml b/app/views/products/index.html.haml new file mode 100644 index 0000000..c3f6eb8 --- /dev/null +++ b/app/views/products/index.html.haml @@ -0,0 +1,4 @@ +%h3 Products +%ul.products + -@products.each do |product| + =partial :preview, :product => product \ No newline at end of file diff --git a/examples/quick-E-mart/Rakefile b/examples/quick-E-mart/Rakefile new file mode 100644 index 0000000..37fc9ff --- /dev/null +++ b/examples/quick-E-mart/Rakefile @@ -0,0 +1,76 @@ +require 'rubygems' +Gem.clear_paths +Gem.path.unshift(File.join(File.dirname(__FILE__), "gems")) + +require 'rake' +require 'rake/rdoctask' +require 'rake/testtask' +require 'spec/rake/spectask' +require 'fileutils' + +## +# requires frozen merb-core (from /framework) +# adds the other components to the load path +def require_frozen_framework + framework = File.join(File.dirname(__FILE__), "framework") + if File.directory?(framework) + puts "Running from frozen framework" + core = File.join(framework,"merb-core") + if File.directory?(core) + puts "using merb-core from #{core}" + $:.unshift File.join(core,"lib") + require 'merb-core' + end + more = File.join(framework,"merb-more") + if File.directory?(more) + Dir.new(more).select {|d| d =~ /merb-/}.each do |d| + $:.unshift File.join(more,d,'lib') + end + end + plugins = File.join(framework,"merb-plugins") + if File.directory?(plugins) + Dir.new(plugins).select {|d| d =~ /merb_/}.each do |d| + $:.unshift File.join(plugins,d,'lib') + end + end + require "merb-core/core_ext/kernel" + require "merb-core/core_ext/rubygems" + else + p "merb doesn't seem to be frozen in /framework" + require 'merb-core' + end +end + +if ENV['FROZEN'] + require_frozen_stuff +else + require 'merb-core' +end + +require 'rubigen' +require 'merb-core/tasks/merb' +include FileUtils + +# Load the basic runtime dependencies; this will include +# any plugins and therefore plugin rake tasks. +init_env = ENV['MERB_ENV'] || 'rake' +Merb.load_dependencies(:environment => init_env) + +# Get Merb plugins and dependencies +Merb::Plugins.rakefiles.each { |r| require r } + +# Load any app level custom rakefile extensions from lib/tasks +tasks_path = File.join(File.dirname(__FILE__), "lib", "tasks") +rake_files = Dir["#{tasks_path}/*.rb"] +rake_files.each{|rake_file| load rake_file } + + +desc "start runner environment" +task :merb_env do + Merb.start_environment(:environment => init_env, :adapter => 'runner') +end + +############################################################################## +# ADD YOUR CUSTOM TASKS IN /lib/tasks +# NAME YOUR RAKE FILES file_name.rake +############################################################################## diff --git a/examples/quick-E-mart/app/controllers/application.rb b/examples/quick-E-mart/app/controllers/application.rb new file mode 100644 index 0000000..5ce39a0 --- /dev/null +++ b/examples/quick-E-mart/app/controllers/application.rb @@ -0,0 +1,2 @@ +class Application < Merb::Controller +end \ No newline at end of file diff --git a/examples/quick-E-mart/app/controllers/exceptions.rb b/examples/quick-E-mart/app/controllers/exceptions.rb new file mode 100644 index 0000000..8f462b1 --- /dev/null +++ b/examples/quick-E-mart/app/controllers/exceptions.rb @@ -0,0 +1,13 @@ +class Exceptions < Application + + # handle NotFound exceptions (404) + def not_found + render :format => :html + end + + # handle NotAcceptable exceptions (406) + def not_acceptable + render :format => :html + end + +end \ No newline at end of file diff --git a/examples/quick-E-mart/app/helpers/global_helpers.rb b/examples/quick-E-mart/app/helpers/global_helpers.rb new file mode 100644 index 0000000..9c9e5aa --- /dev/null +++ b/examples/quick-E-mart/app/helpers/global_helpers.rb @@ -0,0 +1,5 @@ +module Merb + module GlobalHelpers + # helpers defined here available to all views. + end +end diff --git a/examples/quick-E-mart/app/views/exceptions/internal_server_error.html.erb b/examples/quick-E-mart/app/views/exceptions/internal_server_error.html.erb new file mode 100644 index 0000000..aadbfad --- /dev/null +++ b/examples/quick-E-mart/app/views/exceptions/internal_server_error.html.erb @@ -0,0 +1,216 @@ + + + + <%= @exception_name %> + + + +
+ +
+

<%= @exception_name %> <%= @exception.class::STATUS %>

+ <% if show_details = ::Merb::Config[:exception_details] -%> +

<%= @exception.message %>

+ <% else -%> +

Sorry about that...

+ <% end -%> +

Parameters

+
    + <% params[:original_params].each do |param, value| %> +
  • <%= param %>: <%= value.inspect %>
  • + <% end %> + <%= "
  • None
  • " if params[:original_params].empty? %> +
+ +

Session

+
    + <% params[:original_session].each do |param, value| %> +
  • <%= param %>: <%= value.inspect %>
  • + <% end %> + <%= "
  • None
  • " if params[:original_session].empty? %> +
+ +

Cookies

+
    + <% params[:original_cookies].each do |param, value| %> +
  • <%= param %>: <%= value.inspect %>
  • + <% end %> + <%= "
  • None
  • " if params[:original_cookies].empty? %> +
+
+ + <% if show_details %> + + <% @exception.backtrace.each_with_index do |line, index| %> + + + + + + + + + + + + <% end %> +
+ + <%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %> + <% unless line.match(/\.erb:/) %> + in "<%= line.match(/:in `(.+)'$/)[1] rescue '?' %>" + <% else %> + (ERB Template) + <% end %> + + <%=lineno%>  +
+ <% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %> +<%= llineno %><%='' if llineno==lineno.to_i %><%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'......' : CGI.escapeHTML(lcode) %><%='' if llineno==lineno.to_i %> +<% end %> + +
+ + <% end %> + +
+ + \ No newline at end of file diff --git a/examples/quick-E-mart/app/views/exceptions/not_acceptable.html.erb b/examples/quick-E-mart/app/views/exceptions/not_acceptable.html.erb new file mode 100644 index 0000000..f632712 --- /dev/null +++ b/examples/quick-E-mart/app/views/exceptions/not_acceptable.html.erb @@ -0,0 +1,63 @@ +
+
+ + +

pocket rocket web framework

+
+
+ +
+

Exception:

+

<%= params[:exception] %>

+
+ +
+

Why am I seeing this page?

+

Merb couldn't find an appropriate content_type to return, + based on what you said was available via provides() and + what the client requested.

+ +

How to add a mime-type

+

+      Merb.add_mime_type :pdf, :to_pdf, %w[application/pdf], "Content-Encoding" => "gzip"
+    
+

What this means is:

+
    +
  • Add a mime-type for :pdf
  • +
  • Register the method for converting objects to PDF as #to_pdf.
  • +
  • Register the incoming mime-type "Accept" header as application/pdf.
  • +
  • Specify a new header for PDF types so it will set Content-Encoding to gzip.
  • +
+ +

You can then do:

+

+      class Foo < Application
+        provides :pdf
+      end
+    
+ +

Where can I find help?

+

If you have any questions or if you can't figure something out, please take a + look at our project page, + feel free to come chat at irc.freenode.net, channel #merb, + or post to merb mailing list + on Google Groups.

+ +

What if I've found a bug?

+

If you want to file a bug or make your own contribution to Merb, + feel free to register and create a ticket at our + project development page + on Lighthouse.

+ +

How do I edit this page?

+

You can change what people see when this happens by editing app/views/exceptions/not_acceptable.html.erb.

+ +
+ + +
diff --git a/examples/quick-E-mart/app/views/exceptions/not_found.html.erb b/examples/quick-E-mart/app/views/exceptions/not_found.html.erb new file mode 100644 index 0000000..388c72c --- /dev/null +++ b/examples/quick-E-mart/app/views/exceptions/not_found.html.erb @@ -0,0 +1,47 @@ +
+
+ + +

pocket rocket web framework

+
+
+ +
+

Exception:

+

<%= params[:exception] %>

+
+ +
+

Welcome to Merb!

+

Merb is a light-weight MVC framework written in Ruby. We hope you enjoy it.

+ +

Where can I find help?

+

If you have any questions or if you can't figure something out, please take a + look at our project page, + feel free to come chat at irc.freenode.net, channel #merb, + or post to merb mailing list + on Google Groups.

+ +

What if I've found a bug?

+

If you want to file a bug or make your own contribution to Merb, + feel free to register and create a ticket at our + project development page + on Lighthouse.

+ +

How do I edit this page?

+

You're seeing this page because you need to edit the following files: +

    +
  • config/router.rb (recommended)
  • +
  • app/views/exceptions/not_found.html.erb (recommended)
  • +
  • app/views/layout/application.html.erb (change this layout)
  • +
+

+
+ + +
diff --git a/examples/quick-E-mart/app/views/layout/application.html.erb b/examples/quick-E-mart/app/views/layout/application.html.erb new file mode 100644 index 0000000..96e5859 --- /dev/null +++ b/examples/quick-E-mart/app/views/layout/application.html.erb @@ -0,0 +1,11 @@ + + + + Fresh Merb App + + + + + <%= catch_content :for_layout %> + + \ No newline at end of file diff --git a/examples/quick-E-mart/autotest/discover.rb b/examples/quick-E-mart/autotest/discover.rb new file mode 100644 index 0000000..fddd126 --- /dev/null +++ b/examples/quick-E-mart/autotest/discover.rb @@ -0,0 +1 @@ +Autotest.add_discovery { "merb" } \ No newline at end of file diff --git a/examples/quick-E-mart/autotest/merb.rb b/examples/quick-E-mart/autotest/merb.rb new file mode 100644 index 0000000..b5d8ccb --- /dev/null +++ b/examples/quick-E-mart/autotest/merb.rb @@ -0,0 +1,149 @@ +# Adapted from Autotest::Rails +require 'autotest' + +class Autotest::Merb < Autotest + + # +model_tests_dir+:: the directory to find model-centric tests + # +controller_tests_dir+:: the directory to find controller-centric tests + # +view_tests_dir+:: the directory to find view-centric tests + # +fixtures_dir+:: the directory to find fixtures in + attr_accessor :model_tests_dir, :controller_tests_dir, :view_tests_dir, :fixtures_dir + + def initialize + super + + initialize_test_layout + + # Ignore any happenings in these directories + add_exception %r%^\./(?:doc|log|public|tmp)% + + # Ignore any mappings that Autotest may have already set up + clear_mappings + + # Any changes to a file in the root of the 'lib' directory will run any + # model test with a corresponding name. + add_mapping %r%^lib\/.*\.rb% do |filename, _| + files_matching Regexp.new(["^#{model_test_for(filename)}$"]) + end + + # Any changes to a fixture will run corresponding view, controller and + # model tests + add_mapping %r%^#{fixtures_dir}/(.*)s.yml% do |_, m| + [ + model_test_for(m[1]), + controller_test_for(m[1]), + view_test_for(m[1]) + ] + end + + # Any change to a test or test will cause it to be run + add_mapping %r%^test/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _| + filename + end + + # Any change to a model will cause it's corresponding test to be run + add_mapping %r%^app/models/(.*)\.rb$% do |_, m| + model_test_for(m[1]) + end + + # Any change to the global helper will result in all view and controller + # tests being run + add_mapping %r%^app/helpers/global_helpers.rb% do + files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$% + end + + # Any change to a helper will run it's corresponding view and controller + # tests, unless the helper is the global helper. Changes to the global + # helper run all view and controller tests. + add_mapping %r%^app/helpers/(.*)_helper(s)?.rb% do |_, m| + if m[1] == "global" then + files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$% + else + [ + view_test_for(m[1]), + controller_test_for(m[1]) + ] + end + end + + # Changes to views result in their corresponding view and controller test + # being run + add_mapping %r%^app/views/(.*)/% do |_, m| + [ + view_test_for(m[1]), + controller_test_for(m[1]) + ] + end + + # Changes to a controller result in its corresponding test being run. If + # the controller is the exception or application controller, all + # controller tests are run. + add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m| + if ["application", "exception"].include?(m[1]) + files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$% + else + controller_test_for(m[1]) + end + end + + # If a change is made to the router, run all controller and view tests + add_mapping %r%^config/router.rb$% do # FIX + files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$% + end + + # If any of the major files governing the environment are altered, run + # everything + add_mapping %r%^test/test_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX + files_matching %r%^test/(unit|models|controllers|views|functional)/.*_test\.rb$% + end + end + +private + + # Determines the paths we can expect tests or specs to reside, as well as + # corresponding fixtures. + def initialize_test_layout + self.model_tests_dir = "test/unit" + self.controller_tests_dir = "test/functional" + self.view_tests_dir = "test/views" + self.fixtures_dir = "test/fixtures" + end + + # Given a filename and the test type, this method will return the + # corresponding test's or spec's name. + # + # ==== Arguments + # +filename+:: the file name of the model, view, or controller + # +kind_of_test+:: the type of test we that we should run + # + # ==== Returns + # String:: the name of the corresponding test or spec + # + # ==== Example + # + # > test_for("user", :model) + # => "user_test.rb" + # > test_for("login", :controller) + # => "login_controller_test.rb" + # > test_for("form", :view) + # => "form_view_spec.rb" # If you're running a RSpec-like suite + def test_for(filename, kind_of_test) + name = [filename] + name << kind_of_test.to_s if kind_of_test == :view + name << "test" + return name.join("_") + ".rb" + end + + def model_test_for(filename) + [model_tests_dir, test_for(filename, :model)].join("/") + end + + def controller_test_for(filename) + [controller_tests_dir, test_for(filename, :controller)].join("/") + end + + def view_test_for(filename) + [view_tests_dir, test_for(filename, :view)].join("/") + end + +end \ No newline at end of file diff --git a/examples/quick-E-mart/autotest/merb_rspec.rb b/examples/quick-E-mart/autotest/merb_rspec.rb new file mode 100644 index 0000000..6d158ef --- /dev/null +++ b/examples/quick-E-mart/autotest/merb_rspec.rb @@ -0,0 +1,166 @@ +# Adapted from Autotest::Rails, RSpec's autotest class, as well as merb-core's. +require 'autotest' + +class RspecCommandError < StandardError; end + +# This class maps your application's structure so Autotest can understand what +# specs to run when files change. +# +# Fixtures are _not_ covered by this class. If you change a fixture file, you +# will have to run your spec suite manually, or, better yet, provide your own +# Autotest map explaining how your fixtures are set up. +class Autotest::MerbRspec < Autotest + def initialize + super + + # Ignore any happenings in these directories + add_exception %r%^\./(?:doc|log|public|tmp)% + + # Ignore SCM directories and custom Autotest mappings + %w[.svn .hg .git .autotest].each { |exception| add_exception(exception) } + + # Ignore any mappings that Autotest may have already set up + clear_mappings + + # Anything in /lib could have a spec anywhere, if at all. So, look for + # files with roughly the same name as the file in /lib + add_mapping %r%^lib\/(.*)\.rb% do |_, m| + files_matching %r%^spec\/#{m[1]}% + end + + add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do + all_specs + end + + # Changing a spec will cause it to run itself + add_mapping %r%^spec/.*\.rb$% do |filename, _| + filename + end + + # Any change to a model will cause it's corresponding test to be run + add_mapping %r%^app/models/(.*)\.rb$% do |_, m| + spec_for(m[1], 'model') + end + + # Any change to global_helpers will result in all view and controller + # tests being run + add_mapping %r%^app/helpers/global_helpers\.rb% do + files_matching %r%^spec/(views|controllers|helpers)/.*_spec\.rb$% + end + + # Any change to a helper will cause its spec to be run + add_mapping %r%^app/helpers/(.*)_helper(s)?\.rb% do |_, m| + spec_for(m[1], 'helper') + end + + # Changes to a view cause its spec to be run + add_mapping %r%^app/views/(.*)/% do |_, m| + spec_for(m[1], 'view') + end + + # Changes to a controller result in its corresponding spec being run. If + # the controller is the exception or application controller, all + # controller specs are run. + add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m| + if ["application", "exception"].include?(m[1]) + files_matching %r%^spec/controllers/.*_spec\.rb$% + else + spec_for(m[1], 'controller') + end + end + + # If a change is made to the router, run controller, view and helper specs + add_mapping %r%^config/router.rb$% do + files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$% + end + + # If any of the major files governing the environment are altered, run + # everything + add_mapping %r%^config/(init|rack|environments/test).*\.rb|database\.yml% do + all_specs + end + end + + def failed_results(results) + results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m) + end + + def handle_results(results) + @failures = failed_results(results) + @files_to_test = consolidate_failures(@failures) + @files_to_test.empty? && !$TESTING ? hook(:green) : hook(:red) + @tainted = !@files_to_test.empty? + end + + def consolidate_failures(failed) + filters = Hash.new { |h,k| h[k] = [] } + failed.each do |spec, failed_trace| + if f = test_files_for(failed).find { |f| f =~ /spec\// } + filters[f] << spec + break + end + end + filters + end + + def make_test_cmd(specs_to_runs) + [ + ruby, + "-S", + spec_command, + add_options_if_present, + files_to_test.keys.flatten.join(' ') + ].join(' ') + end + + def add_options_if_present + File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : "" + end + + # Finds the proper spec command to use. Precendence is set in the + # lazily-evaluated method spec_commands. Alias + Override that in + # ~/.autotest to provide a different spec command then the default + # paths provided. + def spec_command(separator=File::ALT_SEPARATOR) + unless defined?(@spec_command) + @spec_command = spec_commands.find { |cmd| File.exists?(cmd) } + + raise RspecCommandError, "No spec command could be found" unless @spec_command + + @spec_command.gsub!(File::SEPARATOR, separator) if separator + end + @spec_command + end + + # Autotest will look for spec commands in the following + # locations, in this order: + # + # * default spec bin/loader installed in Rubygems + # * any spec command found in PATH + def spec_commands + [File.join(Config::CONFIG['bindir'], 'spec'), 'spec'] + end + +private + + # Runs +files_matching+ for all specs + def all_specs + files_matching %r%^spec/.*_spec\.rb$% + end + + # Generates a path to some spec given its kind and the match from a mapping + # + # ==== Arguments + # match:: the match from a mapping + # kind:: the kind of spec that the match represents + # + # ==== Returns + # String + # + # ==== Example + # > spec_for('post', :view') + # => "spec/views/post_spec.rb" + def spec_for(match, kind) + File.join("spec", kind + 's', "#{match}_spec.rb") + end +end diff --git a/examples/quick-E-mart/config/database.yml.sample b/examples/quick-E-mart/config/database.yml.sample new file mode 100644 index 0000000..7c0a4ad --- /dev/null +++ b/examples/quick-E-mart/config/database.yml.sample @@ -0,0 +1,36 @@ +--- +# This is a sample database file for the DataMapper ORM +development: &defaults + # These are the settings for repository :default + adapter: postgres + database: sample_development + username: the_user + password: secrets + host: localhost + + # Add more repositories + # repositories: + # repo1: + # adapter: postgresql + # database: sample_development + # username: the_user + # password: secrets + # host: localhost + # repo2: + # ... + +test: + <<: *defaults + database: sample_test + + # repositories: + # repo1: + # database: sample_development + +production: + <<: *defaults + database: sample_production + + # repositories: + # repo1: + # database: sample_development diff --git a/examples/quick-E-mart/config/environments/development.rb b/examples/quick-E-mart/config/environments/development.rb new file mode 100644 index 0000000..806ed1b --- /dev/null +++ b/examples/quick-E-mart/config/environments/development.rb @@ -0,0 +1,20 @@ +Merb.logger.info("Loaded DEVELOPMENT Environment...") +Merb::Config.use { |c| + c[:exception_details] = true + c[:reload_classes] = true + c[:reload_time] = 0.5 + c[:log_auto_flush ] = true +} + +DataMapper.setup(:default, 'sqlite3::memory:') + +class PopulateStore < Merb::BootLoader + + after AfterAppLoads + + def self.run + DataMapper.auto_migrate! + Product.create(:name => "Duff Beer", :code => "0x01", :is_discontinued => false, :date_available => Time.now) + end + +end diff --git a/examples/quick-E-mart/config/environments/production.rb b/examples/quick-E-mart/config/environments/production.rb new file mode 100644 index 0000000..e389e6f --- /dev/null +++ b/examples/quick-E-mart/config/environments/production.rb @@ -0,0 +1,7 @@ +Merb.logger.info("Loaded PRODUCTION Environment...") +Merb::Config.use { |c| + c[:exception_details] = false + c[:reload_classes] = false + c[:log_level] = :error + c[:log_file] = Merb.log_path + "/production.log" +} \ No newline at end of file diff --git a/examples/quick-E-mart/config/environments/rake.rb b/examples/quick-E-mart/config/environments/rake.rb new file mode 100644 index 0000000..a7970ef --- /dev/null +++ b/examples/quick-E-mart/config/environments/rake.rb @@ -0,0 +1,7 @@ +Merb.logger.info("Loaded RAKE Environment...") +Merb::Config.use { |c| + c[:exception_details] = true + c[:reload_classes] = false + c[:log_auto_flush ] = true + c[:log_file] = Merb.log_path / 'merb_rake.log' +} \ No newline at end of file diff --git a/examples/quick-E-mart/config/environments/test.rb b/examples/quick-E-mart/config/environments/test.rb new file mode 100644 index 0000000..6865fb4 --- /dev/null +++ b/examples/quick-E-mart/config/environments/test.rb @@ -0,0 +1,6 @@ +Merb.logger.info("Loaded TEST Environment...") +Merb::Config.use { |c| + c[:testing] = true + c[:exception_details] = true + c[:log_auto_flush ] = true +} \ No newline at end of file diff --git a/examples/quick-E-mart/config/init.rb b/examples/quick-E-mart/config/init.rb new file mode 100644 index 0000000..20e37ff --- /dev/null +++ b/examples/quick-E-mart/config/init.rb @@ -0,0 +1,9 @@ +$LOAD_PATH.unshift Merb.root / ".." / ".." +$LOAD_PATH.unshift Merb.root / ".." / ".." / "lib" +Gem.clear_paths +Gem.path.unshift(Merb.root / "gems") + +require 'merb-haml' + +require 'merb-slices' +require "merb-E-mart" \ No newline at end of file diff --git a/examples/quick-E-mart/config/rack.rb b/examples/quick-E-mart/config/rack.rb new file mode 100644 index 0000000..a8ec99d --- /dev/null +++ b/examples/quick-E-mart/config/rack.rb @@ -0,0 +1,12 @@ + +# use PathPrefix Middleware if :path_prefix is set in Merb::Config +if prefix = ::Merb::Config[:path_prefix] + use Merb::Rack::PathPrefix, prefix +end + +# comment this out if you are running merb behind a load balancer +# that serves static files +use Merb::Rack::Static, Merb.dir_for(:public) + +# this is our main merb application +run Merb::Rack::Application.new \ No newline at end of file diff --git a/examples/quick-E-mart/config/router.rb b/examples/quick-E-mart/config/router.rb new file mode 100644 index 0000000..e28fdf9 --- /dev/null +++ b/examples/quick-E-mart/config/router.rb @@ -0,0 +1,25 @@ +# Merb::Router is the request routing mapper for the merb framework. +# +# You can route a specific URL to a controller / action pair: +# +# r.match("/contact"). +# to(:controller => "info", :action => "contact") +# +# You can define placeholder parts of the url with the :symbol notation. These +# placeholders will be available in the params hash of your controllers. For example: +# +# r.match("/books/:book_id/:action"). +# to(:controller => "books") +# +# Or, use placeholders in the "to" results for more complicated routing, e.g.: +# +# r.match("/admin/:module/:controller/:action/:id"). +# to(:controller => ":module/:controller") +# +# You can also use regular expressions, deferred routes, and many other options. +# See merb/specs/merb/router.rb for a fairly complete usage sample. + +Merb.logger.info("Compiling routes...") +Merb::Router.prepare do |r| + r.add_slice(:MerbEMart, 'admin') +end \ No newline at end of file diff --git a/examples/quick-E-mart/public/images/merb.jpg b/examples/quick-E-mart/public/images/merb.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a19dcf404840b13bc42f60042ef61e69b97bffb0 GIT binary patch literal 5815 zcwT*21yodB*S^ER3^Bk^g9s=gAt^P4gou==3`mEdG=ijb$bdAcbd8jht>1kCPDm$AyUS4-i3!{saU9g%U%d5E2qnQW6r_e***tgNX=9lNJ?uqykxtEh-A-(bG`8&?*QfjmB_9{+SkhTX!4mr%VG0>98 zfF=WmA4|23ORj5PL)~uQ{Wi}TOHcRIl=kC8lCStaX9~%Sk?Z@4tS~PvIGH({sj@yv z*WOTmUl*KLAU2e0wADS@?N=#0)_vOGYyC6J)rLnW?zsYUsU=Q3by71kXa8G9%hFI` z>K&8gJ@w90qxxN0@$v!eR-2@r*`!3t`TMO3d)(Jq)+Mi0gWo0}o8)TtSAD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DJ%Gu~JP)NTgZ_M&4LtH7a4g;|3sFWi$1>=i_TO_)Tv0;| zHql=n^GchAH993IX&j6@zxJU|b9f2dOA#_${GFt~8R*^P;%M*M@8syJ0$DM88a7%N zYSs*GZgP~d3{x9`%xFRN*{uA4$Gi5B--m2czqnhj$W9AiNqBRhFqBIOlUA(siku9{ ztRbDs0p~nnfIEM#SsAgWSAZ;IRQ)<_DknYNZYPW#O&E?oiynGBQo#S{2-8>T%PuQB zh&d7S;eOpPC*!vd3RB%vYydD~>&vd-w=Eji|Cy?2zTW##KRRsKDC9q9Tr?%pCKlbK-lkMC{}^-$6!<2ITAIOp91A! zE;@&K&00tu$o1MPuBJC|5G~HA3Y@oFT&H{|(0$9;D@JHI=Mr$}NQhkB7CpO>VkmPU zbpi?Qm3z043C?3yAeZ~D#S6wM)t3?O!4T8Y7ICFV2`4+!f$C#yueT}fVLQLE*{9Jw zvH`@*%W5MORAD3T*#9V`@C*K@_$GS^6nyD4F|jw@uU>tCU9x_fNl7;dx9X#vXy_Zx zJms#XyzOT(KMh?#Ma&8QTGOR37+GPOEbZ8iS08Ja4fq8T&6=)_H+%v<3s{&SWtX-x zeyYRTp5AN>@_fUkJz7Eu^)UoGpz;U&8C`b$J}t*-B8Eueo!j|szeG7_7i+YtGzAXi zSESQvdSuK_BBae}q->6G2FQ-n($Jy4dRNL~5B)4fy!~o=L1+WTCD7Z@%fV#%_NJne z?}sKAk@i#e7RX+OFB4DlQQu}DmtS}+{o8pGg?(uQJ>&_+lfyaZuw!vQh4&%-ru81L z<9{3pdN&t(-j049p-i;|Yi>u^B>pmGpX3mH<~Y7nN_}x_CduQ;4Fdd#e|S_ka_sD) z67=t~1-}sJ6}K8X*Im6(<;D1)s8#*A1ir|_A_&;mT>ZaC^j-qE^WxP 'fcgi', + :merb_root => merb_root, + :log_file => merb_root /'log'/'merb.log') \ No newline at end of file diff --git a/examples/quick-E-mart/public/slices/merb-E-mart/javascripts/master.js b/examples/quick-E-mart/public/slices/merb-E-mart/javascripts/master.js new file mode 100644 index 0000000..e69de29 diff --git a/examples/quick-E-mart/public/slices/merb-E-mart/stylesheets/master.css b/examples/quick-E-mart/public/slices/merb-E-mart/stylesheets/master.css new file mode 100644 index 0000000..6b21d15 --- /dev/null +++ b/examples/quick-E-mart/public/slices/merb-E-mart/stylesheets/master.css @@ -0,0 +1,2 @@ +html, body { margin: 0; padding: 0; } +#container { width: 800px; margin: 4em auto; padding: 4em 4em 6em 4em; background: #DDDDDD; } \ No newline at end of file diff --git a/examples/quick-E-mart/public/stylesheets/master.css b/examples/quick-E-mart/public/stylesheets/master.css new file mode 100644 index 0000000..c4fa676 --- /dev/null +++ b/examples/quick-E-mart/public/stylesheets/master.css @@ -0,0 +1,119 @@ +body { + font-family: Arial, Verdana, sans-serif; + font-size: 12px; + background-color: #fff; +} +* { + margin: 0px; + padding: 0px; + text-decoration: none; +} +html { + height: 100%; + margin-bottom: 1px; +} +#container { + width: 80%; + text-align: left; + background-color: #fff; + margin-right: auto; + margin-left: auto; +} +#header-container { + width: 100%; + padding-top: 15px; +} +#header-container h1, #header-container h2 { + margin-left: 6px; + margin-bottom: 6px; +} +.spacer { + width: 100%; + height: 15px; +} +hr { + border: 0px; + color: #ccc; + background-color: #cdcdcd; + height: 1px; + width: 100%; + text-align: left; +} +h1 { + font-size: 28px; + color: #c55; + background-color: #fff; + font-family: Arial, Verdana, sans-serif; + font-weight: 300; +} +h2 { + font-size: 15px; + color: #999; + font-family: Arial, Verdana, sans-serif; + font-weight: 300; + background-color: #fff; +} +h3 { + color: #4d9b12; + font-size: 15px; + text-align: left; + font-weight: 300; + padding: 5px; + margin-top: 5px; +} + +#left-container { + float: left; + width: 250px; + background-color: #FFFFFF; + color: black; +} + +#left-container h3 { + color: #c55; +} + +#main-container { + margin: 5px 5px 5px 260px; + padding: 15px; + border-left: 1px solid silver; + min-height: 400px; +} +p { + color: #000; + background-color: #fff; + line-height: 20px; + padding: 5px; +} +a { + color: #4d9b12; + background-color: #fff; + text-decoration: none; +} +a:hover { + color: #4d9b12; + background-color: #fff; + text-decoration: underline; +} +#footer-container { + clear: both; + font-size: 12px; + font-family: Verdana, Arial, sans-serif; +} +.right { + float: right; + font-size: 100%; + margin-top: 5px; + color: #999; + background-color: #fff; +} +.left { + float: left; + font-size: 100%; + margin-top: 5px; + color: #999; + background-color: #fff; +} +#main-container ul { + margin-left: 3.0em; +} \ No newline at end of file diff --git a/examples/quick-E-mart/spec/spec.opts b/examples/quick-E-mart/spec/spec.opts new file mode 100644 index 0000000..e69de29 diff --git a/examples/quick-E-mart/spec/spec_helper.rb b/examples/quick-E-mart/spec/spec_helper.rb new file mode 100644 index 0000000..f83032e --- /dev/null +++ b/examples/quick-E-mart/spec/spec_helper.rb @@ -0,0 +1,11 @@ +require 'rubygems' +require 'merb-core' +require 'spec' # Satisfies Autotest and anyone else not using the Rake tasks + +Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test') + +Spec::Runner.configure do |config| + config.include(Merb::Test::ViewHelper) + config.include(Merb::Test::RouteHelper) + config.include(Merb::Test::ControllerHelper) +end diff --git a/lib/merb-E-mart.rb b/lib/merb-E-mart.rb index e33c170..5927b50 100644 --- a/lib/merb-E-mart.rb +++ b/lib/merb-E-mart.rb @@ -1,6 +1,7 @@ if defined?(Merb::Plugins) require 'merb-slices' + require 'merb-haml' require 'dm-validations' require 'dm-types' @@ -46,6 +47,11 @@ if defined?(Merb::Plugins) # router behaviour is a valid namespace, so you can attach # routes at any level of your router setup. def self.setup_router(scope) + scope.namespace(:admin) do |admin| + admin.to(:controller => 'products') do |products| + products.match('/products').to.name(:products) + end + end end end @@ -55,8 +61,8 @@ if defined?(Merb::Plugins) # Use MerbEMart.push_path and MerbEMart.push_app_path # 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_path(:application, MerbEMart.root) + 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/spec/spec_helper.rb b/spec/spec_helper.rb index 77ddfdf..47749f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,24 +13,6 @@ DataMapper.setup(:default, 'sqlite3::memory:') # - testing standalone, without being installed as a gem and no host application # - testing from within the host application; its root will be used -module MockUploadProcessor - def process; end -end - -module MockImageResize - def resize; end -end - -module MockThumbnailGenerator - def generate_thumbnail; end -end - -Merb::BootLoader.before_app_loads do - Merb::Slices::config[:merb_E_mart][:upload_processor_mixin] = MockUploadProcessor - Merb::Slices::config[:merb_E_mart][:image_resize_mixin] = MockImageResize - Merb::Slices::config[:merb_E_mart][:thumbnail_mixin] = MockThumbnailGenerator -end - Merb.start_environment( :testing => true, :adapter => 'runner', -- 2.11.4.GIT