GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
Renamed default helper to "built-in" to deal with bug #75. Also added 
support for regexp parameters in mappings. Plus miscellaneous bug fixes.
dyoder (author)
Sun Aug 10 18:56:34 -0700 2008
commit  92a4430a2b19309afcc9f39dc9c2312cbfee1507
tree    dc0b6022c7ddde813c2d1ef11b7e4f19d6965baf
parent  840f9bd3a39ddabe10d370f3dc415191626cb174
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ gem = Gem::Specification.new do |gem|
0
   gem.platform = Gem::Platform::RUBY
0
   gem.required_ruby_version = '>= 1.8.6'
0
   %w( mongrel rack markaby erubis haml RedCloth metaid filebase
0
- extensions live_console choice daemons rakegen).each do |dep|
0
+ extensions live_console choice daemons rakegen functor ).each do |dep|
0
     gem.add_dependency dep
0
   end
0
   gem.add_dependency('sequel', '>= 2.0.0')
...
19
20
21
22
23
24
 
 
 
25
26
27
...
19
20
21
 
 
 
22
23
24
25
26
27
0
@@ -19,9 +19,9 @@ module Waves
0
       # Treat content as Textile.
0
       def textile( content )
0
         return if content.nil? or content.empty?
0
- ( ::RedCloth::TEXTILE_TAGS << [ 96.chr, '&8216;'] ).each do |pat,ent|
0
- content.gsub!( pat, ent.gsub('&','&#') )
0
- end
0
+ #( ::RedCloth::TEXTILE_TAGS << [ 96.chr, '&8216;'] ).each do |pat,ent|
0
+ # content.gsub!( pat, ent.gsub('&','&#') )
0
+ #end
0
         self << ::RedCloth.new( content ).to_html
0
       end
0
 
...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
49
50
51
 
 
 
 
 
 
 
 
52
53
54
...
8
9
10
 
 
 
 
 
 
 
 
11
12
13
...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
0
@@ -8,14 +8,6 @@ module Waves
0
 
0
       def self.included( app )
0
         
0
- app.auto_create_module( :Helpers ) do
0
- include AutoCode
0
- auto_create_module( :Default ) { include Waves::Helpers::Default }
0
- auto_load :Default, :directories => [ :helpers ]
0
- auto_create_module( true ) { include app::Helpers::Default }
0
- auto_load true, :directories => [ :helpers ]
0
- end
0
-
0
         app.auto_create_module( :Models ) do
0
           include AutoCode
0
           auto_create_class :Default
0
@@ -49,6 +41,14 @@ module Waves
0
           auto_load true, :directories => [ :controllers ]
0
         end
0
 
0
+ app.auto_create_module( :Helpers ) do
0
+ include AutoCode
0
+ auto_create_module( :Default ) { include Waves::Helpers::BuiltIn }
0
+ auto_load :Default, :directories => [ :helpers ]
0
+ auto_create_module( true ) { include app::Helpers::Default }
0
+ auto_load true, :directories => [ :helpers ]
0
+ end
0
+
0
         app.auto_eval :Resources do
0
           auto_create_class :Default, Waves::Resources::Base
0
           auto_load :Default, :directories => [ :resources ]
...
15
16
17
 
18
 
19
 
20
21
22
23
24
25
26
 
 
 
 
 
 
 
 
 
 
 
27
28
 
29
30
31
32
 
33
34
 
35
36
37
 
 
 
 
 
38
39
40
41
42
43
 
 
 
 
 
 
 
 
 
44
45
46
...
15
16
17
18
19
20
21
22
23
 
 
 
 
 
 
24
25
26
27
28
29
30
31
32
33
34
35
 
36
37
38
39
 
40
41
 
42
43
 
 
44
45
46
47
48
49
50
 
 
 
 
51
52
53
54
55
56
57
58
59
60
61
62
0
@@ -15,32 +15,48 @@ module Waves
0
       functor( :match, nil, String ) { |pattern, path| {} }
0
       # an empty pattern array matches root, i.e. "/"
0
       functor( :match, [], '/' ) { | pattern, path | {} }
0
+ # otherwise break the path down into an array and match arrays
0
       functor( :match, Array, String ) { | pattern, path | match( pattern, path.split('/')[1..-1] ) }
0
+ # this variation should never come up ... right?
0
       functor( :match, Array, nil ) { | pattern, path | nil }
0
+ # alright, now we are into the general case, matching two arrays ...
0
       functor( :match, Array, Array ) do | wants, gots |
0
- r = {}; matches = wants.all? do | want |
0
- if r[true] || want == true
0
- r[true] ||= []; r[true] << gots.shift
0
- else
0
- match( r, want, gots.shift )
0
- end
0
+ r = {}; if wants.length > gots.length
0
+ # pad gots with nils so they are the same length
0
+ gots = ( gots + ( [nil] * ( wants.length - gots.length ) ) )
0
+ elsif wants.length < gots.length
0
+ # true is a wildcard matcher ...
0
+ return false unless wants.last == true
0
+ # special case where true is the entire pattern
0
+ return { true => gots } if wants.size == 1
0
+ # collapse last n elements down to an array to match true
0
+ r[ true ] = gots[ wants.size-2..-1 ]
0
+ gots = gots[ 0..wants.size-2 ]
0
         end
0
- r if matches and gots.empty?
0
+ r if wants.zip( gots ).all? { |want, got| match( r, want, got ) }
0
       end
0
       functor( :match, Hash, String, String ) { | r, want, got | got if want == got }
0
       functor( :match, Hash, Regexp, String ) { | r, want, got | got if want === got }
0
- # placeholder Symbols use a default regex for matching
0
+ # a symbol matches pretty much anything and stores it as a param ...
0
       functor( :match, Hash, Symbol, String ) do | r, want, got |
0
- r[ want.to_s ] = got if match( r, /^([\w\_\-\#]+)$/, got )
0
+ r[ want.to_s ] = match( r, /^(\S+)$/, got )
0
       end
0
- functor( :match, Hash, Hash, String ) do | r, want, got |
0
- key = want.keys.first
0
+ # a hash is either a param with a custom regexp or a default value ...
0
+ functor( :match, Hash, Hash, Object ) do | r, want, got |
0
+ key, want = want.first ; match( r, key, want, got )
0
+ end
0
+ functor( :match, Hash, Symbol, String, String ) do | r, key, want, got |
0
         r[ key.to_s ] = got
0
       end
0
- # hashes represent optional values with a default
0
- functor( :match, Hash, Hash, nil ) { | r, want, got | r[ want.keys.first.to_s ] = want.values.first }
0
- # everything else is mandatory ...
0
- functor( :match, Hash, Object, nil ) { | r, want, got | false }
0
+ functor( :match, Hash, Symbol, String, nil ) do | r, key, want, got |
0
+ r[ key.to_s ] = want
0
+ end
0
+ functor( :match, Hash, Symbol, Regexp, String ) do | r, key, want, got |
0
+ r[ key.to_s ] = match( r, want, got )
0
+ end
0
+ functor( :match, Hash, Symbol, Regexp, nil ) do | r, key, want, got |
0
+ false
0
+ end
0
       
0
     end
0
 
...
8
9
10
 
11
12
13
...
24
25
26
 
27
28
29
...
74
75
76
77
 
78
79
80
...
8
9
10
11
12
13
14
...
25
26
27
28
29
30
31
...
76
77
78
 
79
80
81
82
0
@@ -8,6 +8,7 @@ require 'rack'
0
 require 'daemons'
0
 require 'live_console'
0
 
0
+gem 'dyoder-autocode'
0
 require 'autocode'
0
 require 'functor'
0
 
0
@@ -24,6 +25,7 @@ require 'benchmark'
0
 # require 'memcache'
0
 require 'base64'
0
 
0
+gem 'dyoder-filebase'
0
 require 'filebase'
0
 require 'filebase/model'
0
 
0
@@ -74,7 +76,7 @@ require 'helpers/form'
0
 require 'helpers/formatting'
0
 require 'helpers/model'
0
 require 'helpers/view'
0
-require 'helpers/default'
0
+require 'helpers/built_in'
0
 # require 'helpers/asset_helper'
0
 # require 'helpers/number_helper'
0
 require 'renderers/mixin'

Comments

    No one has commented yet.