waves 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/waves +4 -3
- data/doc/VERSION +1 -1
- data/lib/waves.rb +52 -40
- data/lib/{caches → waves/caches}/file.rb +3 -1
- data/lib/waves/caches/memcached.rb +56 -0
- data/lib/{caches → waves/caches}/simple.rb +6 -7
- data/lib/{caches → waves/caches}/synchronized.rb +15 -1
- data/lib/{commands → waves/commands}/console.rb +4 -4
- data/lib/{commands → waves/commands}/generate.rb +6 -5
- data/lib/{commands → waves/commands}/help.rb +0 -0
- data/lib/{commands → waves/commands}/server.rb +1 -1
- data/lib/{dispatchers → waves/dispatchers}/base.rb +17 -31
- data/lib/waves/dispatchers/default.rb +19 -0
- data/lib/{ext → waves/ext}/float.rb +0 -0
- data/lib/{ext → waves/ext}/hash.rb +0 -0
- data/lib/{ext → waves/ext}/integer.rb +16 -1
- data/lib/{ext → waves/ext}/kernel.rb +3 -7
- data/lib/{ext → waves/ext}/module.rb +3 -3
- data/lib/{ext → waves/ext}/object.rb +2 -0
- data/lib/waves/ext/string.rb +73 -0
- data/lib/{ext → waves/ext}/symbol.rb +0 -1
- data/lib/{ext → waves/ext}/tempfile.rb +0 -0
- data/lib/waves/ext/time.rb +5 -0
- data/lib/{foundations → waves/foundations}/classic.rb +9 -21
- data/lib/{foundations → waves/foundations}/compact.rb +15 -20
- data/lib/waves/foundations/rest.rb +311 -0
- data/lib/waves/helpers/basic.rb +13 -0
- data/lib/{helpers → waves/helpers}/doc_type.rb +3 -0
- data/lib/waves/helpers/form.rb +94 -0
- data/lib/waves/helpers/formatting.rb +14 -0
- data/lib/waves/layers/mvc.rb +65 -0
- data/lib/{layers → waves/layers}/mvc/controllers.rb +0 -0
- data/lib/{layers → waves/layers}/mvc/extensions.rb +23 -11
- data/lib/{layers → waves/layers}/orm/migration.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/active_record.rb +2 -5
- data/lib/{layers → waves/layers}/orm/providers/active_record/migrations/empty.rb.erb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/generate.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/schema.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/data_mapper.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/filebase.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/sequel.rb +28 -29
- data/lib/{layers → waves/layers}/orm/providers/sequel/migrations/empty.rb.erb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/generate.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/schema.rb +2 -0
- data/lib/waves/layers/rack/rack_cache.rb +32 -0
- data/lib/waves/layers/renderers/erubis.rb +52 -0
- data/lib/waves/layers/renderers/haml.rb +67 -0
- data/lib/waves/layers/renderers/markaby.rb +41 -0
- data/lib/waves/layers/text/inflect/english.rb +42 -0
- data/lib/waves/matchers/accept.rb +47 -0
- data/lib/waves/matchers/ext.rb +27 -0
- data/lib/waves/matchers/path.rb +72 -0
- data/lib/waves/matchers/query.rb +43 -0
- data/lib/waves/matchers/request.rb +86 -0
- data/lib/waves/matchers/requested.rb +31 -0
- data/lib/{matchers → waves/matchers}/resource.rb +8 -1
- data/lib/waves/matchers/traits.rb +30 -0
- data/lib/waves/matchers/uri.rb +69 -0
- data/lib/waves/media/mime_types.rb +542 -0
- data/lib/waves/renderers/mixin.rb +9 -0
- data/lib/waves/request/accept.rb +92 -0
- data/lib/{runtime → waves/request}/request.rb +77 -61
- data/lib/waves/resources/file_mixin.rb +11 -0
- data/lib/{resources → waves/resources}/mixin.rb +42 -44
- data/lib/waves/resources/paths.rb +132 -0
- data/lib/waves/response/client_errors.rb +10 -0
- data/lib/waves/response/packaged.rb +19 -0
- data/lib/waves/response/redirects.rb +35 -0
- data/lib/{runtime → waves/response}/response.rb +29 -11
- data/lib/{runtime → waves/response}/response_mixin.rb +30 -17
- data/lib/waves/runtime/applications.rb +18 -0
- data/lib/{runtime → waves/runtime}/configuration.rb +31 -25
- data/lib/waves/runtime/console.rb +24 -0
- data/lib/{runtime → waves/runtime}/logger.rb +3 -3
- data/lib/{runtime → waves/runtime}/mocks.rb +2 -2
- data/lib/waves/runtime/rackup.rb +37 -0
- data/lib/waves/runtime/runtime.rb +48 -0
- data/lib/waves/runtime/server.rb +33 -0
- data/lib/{servers → waves/servers}/base.rb +0 -0
- data/lib/{servers → waves/servers}/mongrel.rb +0 -0
- data/lib/{servers → waves/servers}/webrick.rb +0 -0
- data/lib/{tasks → waves/tasks}/gem.rb +0 -0
- data/lib/{tasks → waves/tasks}/generate.rb +0 -0
- data/lib/waves/views/cassy.rb +173 -0
- data/lib/{views → waves/views}/errors.rb +8 -7
- data/lib/waves/views/mixin.rb +23 -0
- data/lib/waves/views/templated.rb +40 -0
- data/samples/basic/basic_startup.rb +70 -0
- data/samples/basic/config.ru +9 -0
- data/samples/blog/configurations/development.rb +17 -16
- data/samples/blog/configurations/production.rb +0 -11
- data/samples/blog/resources/entry.rb +3 -3
- data/samples/blog/resources/map.rb +10 -3
- data/samples/blog/startup.rb +4 -3
- data/templates/classic/Rakefile +28 -29
- data/templates/classic/configurations/default.rb.erb +8 -3
- data/templates/classic/configurations/development.rb.erb +1 -20
- data/templates/classic/configurations/production.rb.erb +2 -16
- data/templates/classic/public/images/favicon.ico +0 -0
- data/templates/classic/resources/server.rb.erb +9 -0
- data/templates/classic/startup.rb.erb +3 -3
- data/templates/classic/views/css.rb.erb +14 -0
- data/templates/classic/views/default.rb.erb +17 -0
- data/templates/classic/views/errors.rb.erb +10 -0
- data/templates/classic/views/pages.rb.erb +14 -0
- data/templates/compact/startup.rb.erb +8 -3
- data/test/ext/object.rb +55 -0
- data/test/ext/shortcuts.rb +73 -0
- data/test/helpers.rb +17 -0
- data/test/match/accept.rb +78 -0
- data/test/match/ext.rb +156 -0
- data/test/match/methods.rb +22 -0
- data/test/match/params.rb +33 -0
- data/test/match/path.rb +106 -0
- data/test/match/query.rb +60 -0
- data/test/match/request.rb +91 -0
- data/test/match/requested.rb +149 -0
- data/test/match/uri.rb +136 -0
- data/test/process/request.rb +75 -0
- data/test/process/resource.rb +53 -0
- data/test/resources/path.rb +166 -0
- data/test/runtime/configurations.rb +19 -0
- data/test/runtime/request.rb +63 -0
- data/test/runtime/response.rb +85 -0
- data/test/views/views.rb +40 -0
- metadata +243 -157
- data/lib/caches/memcached.rb +0 -40
- data/lib/dispatchers/default.rb +0 -25
- data/lib/ext/string.rb +0 -20
- data/lib/helpers/basic.rb +0 -11
- data/lib/helpers/extended.rb +0 -21
- data/lib/helpers/form.rb +0 -42
- data/lib/helpers/formatting.rb +0 -30
- data/lib/helpers/layouts.rb +0 -37
- data/lib/helpers/model.rb +0 -37
- data/lib/helpers/view.rb +0 -22
- data/lib/layers/inflect/english.rb +0 -67
- data/lib/layers/mvc.rb +0 -54
- data/lib/layers/renderers/erubis.rb +0 -60
- data/lib/layers/renderers/haml.rb +0 -47
- data/lib/layers/renderers/markaby.rb +0 -29
- data/lib/matchers/accept.rb +0 -21
- data/lib/matchers/base.rb +0 -30
- data/lib/matchers/content_type.rb +0 -17
- data/lib/matchers/path.rb +0 -67
- data/lib/matchers/query.rb +0 -21
- data/lib/matchers/request.rb +0 -27
- data/lib/matchers/traits.rb +0 -19
- data/lib/matchers/uri.rb +0 -20
- data/lib/renderers/mixin.rb +0 -36
- data/lib/resources/paths.rb +0 -34
- data/lib/runtime/console.rb +0 -23
- data/lib/runtime/mime_types.rb +0 -536
- data/lib/runtime/monitor.rb +0 -32
- data/lib/runtime/runtime.rb +0 -67
- data/lib/runtime/server.rb +0 -20
- data/lib/runtime/session.rb +0 -27
- data/lib/runtime/worker.rb +0 -86
- data/lib/views/mixin.rb +0 -62
- data/samples/blog/blog.db +0 -0
- data/samples/blog/log/waves.production +0 -3
- data/templates/classic/resources/map.rb.erb +0 -8
- data/templates/classic/templates/errors/not_found_404.mab +0 -7
- data/templates/classic/templates/errors/server_error_500.mab +0 -7
- data/templates/classic/templates/layouts/default.mab +0 -14
- data/templates/classic/tmp/sessions/.gitignore +0 -0
data/lib/caches/memcached.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'memcached'
|
|
2
|
-
module Waves
|
|
3
|
-
module Caches
|
|
4
|
-
class Memcached < Simple
|
|
5
|
-
|
|
6
|
-
def initialize( args )
|
|
7
|
-
raise ArgumentError, ":servers is nil" if args[ :servers ].nil?
|
|
8
|
-
@cache = ::Memcached.new( args[ :servers ], args[ :options ] || {} )
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def store( key,value, ttl = 0, marshal = true )
|
|
12
|
-
cache = @cache.clone; cache.add( key.to_s, value, ttl, marshal ); cache.destroy
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def fetch( key )
|
|
16
|
-
cache = @cache.clone; cache.get( key.to_s ); cache.destroy
|
|
17
|
-
rescue ::Memcached::NotFound => e
|
|
18
|
-
nil
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def delete( key )
|
|
22
|
-
cache = @cache.clone; cache.delete( key.to_s ); cache.destroy
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def clear
|
|
26
|
-
cache = @cache.clone; cache.flush; cache.destroy
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
class SynchronizedMemcached < Synchronized
|
|
32
|
-
|
|
33
|
-
def initialize( args )
|
|
34
|
-
super( Memcached.new( args ) )
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
end
|
data/lib/dispatchers/default.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Waves
|
|
2
|
-
|
|
3
|
-
module Dispatchers
|
|
4
|
-
|
|
5
|
-
class Default < Base
|
|
6
|
-
|
|
7
|
-
# Takes a Waves::Request and returns a Waves::Response
|
|
8
|
-
def safe( request )
|
|
9
|
-
# set a default content type -- this can be overridden by the resource
|
|
10
|
-
request.response.content_type = request.accept.default
|
|
11
|
-
resource = Waves.config.resource.new( request )
|
|
12
|
-
if request.response.body.empty?
|
|
13
|
-
request.response.body << resource.process.to_s
|
|
14
|
-
else
|
|
15
|
-
resource.process
|
|
16
|
-
end
|
|
17
|
-
# okay, we've handled the request, now write the response unless it was already done
|
|
18
|
-
request.response.finish
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
data/lib/ext/string.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Utility methods mixed into String.
|
|
2
|
-
|
|
3
|
-
class String
|
|
4
|
-
|
|
5
|
-
# Syntactic sugar for using File.join to concatenate the argument to the receiver.
|
|
6
|
-
#
|
|
7
|
-
# require "lib" / "utilities" / "string"
|
|
8
|
-
#
|
|
9
|
-
# The idea is not original, but we can't remember where we first saw it.
|
|
10
|
-
# Waves::Ext::Symbol defines the same method, allowing for :files / 'afilename.txt'
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
def / ( s ) ; File.join( self, s.to_s ); end
|
|
14
|
-
|
|
15
|
-
alias_method :lower_camel_case, :subcamelcase
|
|
16
|
-
alias_method :camel_case, :camelcase
|
|
17
|
-
alias_method :snake_case, :snakecase
|
|
18
|
-
alias_method :title_case, :titlecase
|
|
19
|
-
|
|
20
|
-
end
|
data/lib/helpers/basic.rb
DELETED
data/lib/helpers/extended.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'helpers/basic'
|
|
2
|
-
require 'helpers/doc_type'
|
|
3
|
-
require 'helpers/layouts'
|
|
4
|
-
require 'helpers/formatting'
|
|
5
|
-
require 'helpers/model'
|
|
6
|
-
require 'helpers/view'
|
|
7
|
-
require 'helpers/form'
|
|
8
|
-
|
|
9
|
-
module Waves
|
|
10
|
-
module Helpers
|
|
11
|
-
module Extended
|
|
12
|
-
include Waves::Helpers::Basic
|
|
13
|
-
include Waves::Helpers::DocType
|
|
14
|
-
include Waves::Helpers::Layouts
|
|
15
|
-
include Waves::Helpers::Formatting
|
|
16
|
-
include Waves::Helpers::Model
|
|
17
|
-
include Waves::Helpers::View
|
|
18
|
-
include Waves::Helpers::Form
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
data/lib/helpers/form.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module Waves
|
|
2
|
-
|
|
3
|
-
module Helpers
|
|
4
|
-
|
|
5
|
-
# Form helpers are used in generating forms. Since Markaby already provides Ruby
|
|
6
|
-
# methods for basic form generation, the focus of this helper is on providing templates
|
|
7
|
-
# to handle things that go beyond the basics. You must define a form template
|
|
8
|
-
# directory with templates for each type of form element you wish to use. The names
|
|
9
|
-
# of the template should match the +type+ option provided in the property method.
|
|
10
|
-
#
|
|
11
|
-
# For example, this code:
|
|
12
|
-
#
|
|
13
|
-
# property :name => 'blog.title', :type => :text, :value => @blog.title
|
|
14
|
-
#
|
|
15
|
-
# will invoke the +text+ form view (the template in +templates/form/text.mab+),
|
|
16
|
-
# passing in the name ('blog.title') and the value (@blog.title) as instance variables.
|
|
17
|
-
#
|
|
18
|
-
# These helpers work best with Markaby, but may work for other Renderers.
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
module Form
|
|
22
|
-
|
|
23
|
-
# This method really is a place-holder for common wrappers around groups of
|
|
24
|
-
# properties. You will usually want to override this. As is, it simply places
|
|
25
|
-
# a DIV element with class 'properties' around the block.
|
|
26
|
-
def properties(&block)
|
|
27
|
-
div.properties do
|
|
28
|
-
yield
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Invokes the form view for the +type+ given in the option.
|
|
33
|
-
def property( options )
|
|
34
|
-
self << view( :form, options[:type], options )
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
data/lib/helpers/formatting.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'redcloth'
|
|
2
|
-
module Waves
|
|
3
|
-
module Helpers
|
|
4
|
-
|
|
5
|
-
# Formatting helpers are used to convert specialized content, like Markaby or
|
|
6
|
-
# Textile, into valid HTML. It also provides common escaping functions.
|
|
7
|
-
module Formatting
|
|
8
|
-
|
|
9
|
-
# Escape a string as HTML content.
|
|
10
|
-
def escape_html(s); Rack::Utils.escape_html(s); end
|
|
11
|
-
|
|
12
|
-
# Escape a URI, converting quotes and spaces and so on.
|
|
13
|
-
def escape_uri(s); Rack::Utils.escape(s); end
|
|
14
|
-
|
|
15
|
-
# Treat content as Markaby and evaluate (only works within a Markaby template).
|
|
16
|
-
# Used to pull Markaby content from a file or database into a Markaby template.
|
|
17
|
-
def markaby( content ); self << eval( content ); end
|
|
18
|
-
|
|
19
|
-
# Treat content as Textile.
|
|
20
|
-
def textile( content )
|
|
21
|
-
return if content.nil? or content.empty?
|
|
22
|
-
#( ::RedCloth::TEXTILE_TAGS << [ 96.chr, '&8216;'] ).each do |pat,ent|
|
|
23
|
-
# content.gsub!( pat, ent.gsub('&','&#') )
|
|
24
|
-
#end
|
|
25
|
-
self << ::RedCloth.new( content ).to_html
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
data/lib/helpers/layouts.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module Waves
|
|
2
|
-
|
|
3
|
-
module Helpers
|
|
4
|
-
|
|
5
|
-
module Layouts
|
|
6
|
-
|
|
7
|
-
# Invokes a layout view (i.e., a view from the layouts template directory), using
|
|
8
|
-
# the assigns parameter to define instance variables for the view. The block is
|
|
9
|
-
# evaluated and also passed into the view as the +layout_content+ instance variable.
|
|
10
|
-
#
|
|
11
|
-
# You can define a layout just by creating a template and then calling the
|
|
12
|
-
# +layout_content+ accessor when you want to embed the caller's content.
|
|
13
|
-
#
|
|
14
|
-
# == Example
|
|
15
|
-
#
|
|
16
|
-
# doctype :html4_transitional
|
|
17
|
-
# html do
|
|
18
|
-
# title @title # passed as an assigns parameter
|
|
19
|
-
# end
|
|
20
|
-
# body do
|
|
21
|
-
# layout_content
|
|
22
|
-
# end
|
|
23
|
-
#
|
|
24
|
-
def layout( name, assigns = {}, &block )
|
|
25
|
-
assigns[ :layout_content ] = capture(&block)
|
|
26
|
-
self << Waves.main::Views[:layouts].process( request ) do
|
|
27
|
-
send( name, assigns )
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def layout_content
|
|
32
|
-
self << @layout_content
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
data/lib/helpers/model.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module Waves
|
|
2
|
-
module Helpers
|
|
3
|
-
|
|
4
|
-
# Model helpers allow you to directly access a model from within a view.
|
|
5
|
-
# This is useful when creating things like select boxes that need data
|
|
6
|
-
# from anther model. For example, a Markaby select box for authors might look like:
|
|
7
|
-
#
|
|
8
|
-
# select do
|
|
9
|
-
# all(:user).each do |user|
|
|
10
|
-
# option user.full_name, :value => user.id
|
|
11
|
-
# end
|
|
12
|
-
# end
|
|
13
|
-
#
|
|
14
|
-
# You could also use these within a view class to keep model-based logic out
|
|
15
|
-
# of the templates themselves. For example, in the view class you might define
|
|
16
|
-
# a method called +authors+ that returns an array of name / id pairs. This could
|
|
17
|
-
# then be called from the template instead of the model helper.
|
|
18
|
-
#
|
|
19
|
-
module Model
|
|
20
|
-
|
|
21
|
-
def model( name )
|
|
22
|
-
Waves.main::Models[ name ][ domain ]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Just like model.all. Returns all the instances of that model.
|
|
26
|
-
def all( model )
|
|
27
|
-
model( model ).all
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Finds a specific instance using the name field
|
|
31
|
-
def find( model, name )
|
|
32
|
-
model( model )[name ] rescue nil
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
data/lib/helpers/view.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Waves
|
|
2
|
-
module Helpers
|
|
3
|
-
|
|
4
|
-
# View helpers are intended to help reuse views from within other views.
|
|
5
|
-
# Both the +layout+ method in the common helpers and the +property+ method
|
|
6
|
-
# of the form helpers are specialized instance of this.
|
|
7
|
-
#
|
|
8
|
-
# The star of our show here is the +view+ method. This takes a model, view,
|
|
9
|
-
# and assigns hash (which are converted into instance variables in the target
|
|
10
|
-
# view) and returns the result of evaluating the view as content in the current
|
|
11
|
-
# template.
|
|
12
|
-
module View
|
|
13
|
-
|
|
14
|
-
# Invokes the view for the given model, passing the assigns as instance variables.
|
|
15
|
-
def view( model, view, assigns = {} )
|
|
16
|
-
self << Waves.main::Views[ model ].new( request ).send( view, assigns )
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
module Waves
|
|
2
|
-
module Layers
|
|
3
|
-
module Inflect
|
|
4
|
-
|
|
5
|
-
# Adds plural/singular methods for English to String
|
|
6
|
-
module English
|
|
7
|
-
|
|
8
|
-
def self.included(app)
|
|
9
|
-
|
|
10
|
-
require 'english/inflect'
|
|
11
|
-
|
|
12
|
-
Waves::Resources::Mixin::ClassMethods.module_eval do
|
|
13
|
-
def singular ; basename.snake_case.singular ; end
|
|
14
|
-
def plural ; basename.snake_case.plural ; end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
Waves::Resources::Mixin.module_eval do
|
|
18
|
-
def singular ; self.class.singular ; end
|
|
19
|
-
def plural ; self.class.plural ; end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
Waves::Resources::Paths.module_eval do
|
|
23
|
-
def resource ; self.class.resource.singular ; end
|
|
24
|
-
def resources ; self.class.resource.plural ; end
|
|
25
|
-
|
|
26
|
-
# TODO: be nice to DRY this up ... basically the same code
|
|
27
|
-
# as the mixin except with the singular / plural stuff
|
|
28
|
-
# mixed in ...
|
|
29
|
-
def generate( template, args )
|
|
30
|
-
return "/#{ args * '/' }" unless template.is_a?( Array ) and not template.empty?
|
|
31
|
-
path = []
|
|
32
|
-
( "/#{ path * '/' }" ) if template.all? do | want |
|
|
33
|
-
case want
|
|
34
|
-
when true then path += args
|
|
35
|
-
when String then path << want
|
|
36
|
-
when Symbol
|
|
37
|
-
case want
|
|
38
|
-
when :resource then path << resource
|
|
39
|
-
when :resources then path << resources
|
|
40
|
-
else path << args.shift
|
|
41
|
-
end
|
|
42
|
-
when Regexp then path << args.shift
|
|
43
|
-
when Hash
|
|
44
|
-
key, value = want.to_a.first
|
|
45
|
-
case key
|
|
46
|
-
when :resource then path << resource
|
|
47
|
-
when :resources then path << resources
|
|
48
|
-
else
|
|
49
|
-
case value
|
|
50
|
-
when true then path += args
|
|
51
|
-
when String, Symbol, RegExp then path << args.unshift
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
data/lib/layers/mvc.rb
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
module Waves
|
|
2
|
-
module Layers
|
|
3
|
-
module MVC
|
|
4
|
-
|
|
5
|
-
def self.included( app )
|
|
6
|
-
|
|
7
|
-
require 'layers/mvc/extensions'
|
|
8
|
-
require 'layers/mvc/controllers'
|
|
9
|
-
|
|
10
|
-
app.auto_create_module( :Models ) do
|
|
11
|
-
include AutoCode
|
|
12
|
-
auto_create_class :Default
|
|
13
|
-
auto_load :Default, :directories => [ :models ]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
app.auto_eval( :Models ) do
|
|
17
|
-
auto_create_class true, app::Models::Default
|
|
18
|
-
auto_load true, :directories => [ :models ]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
app.auto_create_module( :Views ) do
|
|
22
|
-
include AutoCode
|
|
23
|
-
auto_create_class :Default, Waves::Views::Base
|
|
24
|
-
auto_load :Default, :directories => [ :views ]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
app.auto_eval( :Views ) do
|
|
28
|
-
auto_create_class true, app::Views::Default
|
|
29
|
-
auto_load true, :directories => [ :views ]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
app.auto_create_module( :Controllers ) do
|
|
33
|
-
include AutoCode
|
|
34
|
-
auto_create_class :Default, Waves::Controllers::Base
|
|
35
|
-
auto_load :Default, :directories => [ :controllers ]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
app.auto_eval( :Controllers ) do
|
|
39
|
-
auto_create_class true, app::Controllers::Default
|
|
40
|
-
auto_load true, :directories => [ :controllers ]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
app.auto_create_module( :Helpers ) do
|
|
44
|
-
include AutoCode
|
|
45
|
-
auto_create_module( :Default ) { include Waves::Helpers::Extended }
|
|
46
|
-
auto_load :Default, :directories => [ :helpers ]
|
|
47
|
-
auto_create_module( true ) { include app::Helpers::Default }
|
|
48
|
-
auto_load true, :directories => [ :helpers ]
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
require 'erubis'
|
|
2
|
-
|
|
3
|
-
module Erubis # :nodoc:
|
|
4
|
-
|
|
5
|
-
# This is added to the Erubis Content class to allow the same helper methods
|
|
6
|
-
# to be used with both Markaby and Erubis.
|
|
7
|
-
class Context
|
|
8
|
-
|
|
9
|
-
def <<(s)
|
|
10
|
-
eval("_buf << '#{s}'", @binding)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def capture
|
|
14
|
-
eval("_context.push(_buf); _buf = ''", @binding) #ignore output from that eval, will be added via "<<"
|
|
15
|
-
result = Erubis::Eruby.new(yield).result @binding
|
|
16
|
-
eval("_buf = _context.pop", @binding)
|
|
17
|
-
result
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def to_s(eruby)
|
|
21
|
-
unless @binding
|
|
22
|
-
@binding = binding
|
|
23
|
-
eval("_buf = ''; _context = []", @binding)
|
|
24
|
-
end
|
|
25
|
-
eruby.result @binding
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
module Waves
|
|
33
|
-
|
|
34
|
-
module Renderers
|
|
35
|
-
|
|
36
|
-
module Erubis
|
|
37
|
-
|
|
38
|
-
Extension = :erb
|
|
39
|
-
|
|
40
|
-
extend Waves::Renderers::Mixin
|
|
41
|
-
|
|
42
|
-
def self.render( path, assigns )
|
|
43
|
-
eruby = ::Erubis::Eruby.new( template( path ) )
|
|
44
|
-
helper = helper( path )
|
|
45
|
-
context = ::Erubis::Context.new
|
|
46
|
-
context.meta_eval { include( helper ) ; }
|
|
47
|
-
context.instance_eval do
|
|
48
|
-
assigns.each do |key,val|
|
|
49
|
-
instance_variable_set("@#{key}",val)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
context.to_s(eruby)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
end
|