public
Description: All the extra stuff you could want for the Mack Framework.
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack-more.git
Got all the tests passing for renaming use_distributed_routes to share_routes 
[#79]
markbates (author)
Wed Aug 06 12:33:09 -0700 2008
commit  c8e93fc4ae67fa03c5a444fb0395ac3ff6d2569e
tree    1f70d6b01349c8b6322920ca522b562f394dd1df
parent  fa64e5f6e217a9b8a4a33cfb09a5a41f846c32b4
...
1
2
3
4
5
6
7
8
9
 
 
 
 
 
 
 
 
 
10
11
12
...
1
2
 
 
 
 
 
 
 
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1,12 +1,14 @@
0
 base = File.join(File.dirname(__FILE__), "mack-distributed")
0
 
0
-config = {}
0
-config["mack::share_routes"] = false if app_config.mack.share_routes.nil?
0
-config["mack::share_objects"] = false if app_config.mack.share_objects.nil?
0
-config["mack::distributed_app_name"] = String.randomize(10) if app_config.mack.distributed_app_name.nil?
0
-config["mack::distributed_site_domain"] = "http://localhost:3000" if app_config.mack.distributed_site_domain.nil?
0
-config["mack::drb_timeout"] = 0 if app_config.mack.drb_timeout.nil?
0
-app_config.load_hash(config, "mack-distributed")
0
+config = {
0
+  "mack::share_routes" => false,
0
+  "mack::share_objects" => false,
0
+  "mack::distributed_app_name" => nil,
0
+  "mack::distributed_site_domain" => "http://localhost:3000",
0
+  "mack::drb_timeout" => 0
0
+}
0
+app_config.load_hash(config.merge(app_config.final_configuration_settings), "mack-distributed")
0
+# app_config.reload
0
 
0
 # load *.rb files
0
 Dir.glob(File.join(base, "**", "*.rb")).each do |f|
...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
...
65
66
67
68
69
70
71
72
73
74
75
76
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
79
80
...
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
46
47
48
...
53
54
55
 
 
 
 
 
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
0
@@ -43,18 +43,6 @@ module Mack
0
       def droute_url(app_name, route_name, options = {})
0
         if app_config.mack.share_routes
0
           d_urls = Mack::Distributed::Routes::Urls.get(app_name)
0
-          # return d_urls.send(route_name, options)
0
-          # ivar_cache("droute_url_hash") do
0
-          #   {}
0
-          # end
0
-          # d_urls = @droute_url_hash[app_name.to_sym]
0
-          # if d_urls.nil?
0
-          #   d_urls = Mack::Distributed::Routes::UrlCache.get(app_name.to_sym)
0
-          #   @droute_url_hash[app_name.to_sym] = d_urls
0
-          #   if d_urls.nil?
0
-          #     raise Mack::Distributed::Errors::UnknownApplication.new(app_name)
0
-          #   end
0
-          # end
0
           route_name = route_name.to_s
0
           if route_name.match(/_url$/)
0
             unless route_name.match(/_distributed_url$/)
0
@@ -65,16 +53,29 @@ module Mack
0
           end
0
           raise Mack::Distributed::Errors::UnknownRouteName.new(app_name, route_name) unless d_urls.respond_to?(route_name)
0
           return d_urls.run(route_name, options)
0
-          # if d_urls.run.respond_to?(route_name)
0
-          #   return d_urls.run.send(route_name, options)
0
-          # else
0
-          #   raise Mack::Distributed::Errors::UnknownRouteName.new(app_name, route_name)
0
-          # end
0
         else
0
           return nil
0
         end
0
       end # droute_url
0
     end # Urls
0
+    
0
+    class RouteMap
0
+      alias_method :normal_connect_with_named_route, :connect_with_named_route
0
+      
0
+      def connect_with_named_route(n_route, pattern, options = {})
0
+        n_route = n_route.methodize
0
+        normal_connect_with_named_route(n_route, pattern, options)
0
+        if app_config.mack.share_routes
0
+          Mack::Routes::Urls.class_eval %{
0
+            def #{n_route}_distributed_url(options = {})
0
+              (@dsd || app_config.mack.distributed_site_domain) + #{n_route}_url(options)
0
+            end
0
+          }
0
+        end
0
+      end # connect_with_named_route
0
+      
0
+    end # RouteMap
0
+    
0
   end # Routes
0
   
0
 end # Mack

Comments