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
Just a few more tests to go with renaming use_distributed_routes to 
share_routes. [#79]
markbates (author)
Wed Aug 06 11:56:11 -0700 2008
commit  fa64e5f6e217a9b8a4a33cfb09a5a41f846c32b4
tree    65266ae3ef137064408a5b85d2377de691751ed8
parent  d1f8d3cc46fe4d472431b6d44ff0779149985cc2
...
1
2
3
4
5
6
7
8
9
10
 
 
 
 
 
 
11
12
13
14
15
16
...
1
2
 
 
 
 
 
 
 
 
3
4
5
6
7
8
9
 
 
10
11
12
0
@@ -1,16 +1,12 @@
0
 base = File.join(File.dirname(__FILE__), "mack-distributed")
0
 
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
-
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
-app_config.load_hash(app_config.final_configuration_settings, "original settings")
0
-# app_config.reload
0
 
0
 # load *.rb files
0
 Dir.glob(File.join(base, "**", "*.rb")).each do |f|
...
32
33
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
36
37
...
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
0
@@ -32,6 +32,51 @@ module Mack
0
       
0
     end # Routes
0
   end # Distributed
0
+  
0
+  module Routes # :nodoc:
0
+    module Urls
0
+      # Retrieves a distributed route from a DRb server.
0
+      # 
0
+      # Example:
0
+      #   droute_url(:app_1, :home_page_url)
0
+      #   droute_url(:registration_app, :signup_url, {:from => :google})
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
+              route_name.gsub!("_url", "_distributed_url")
0
+            end
0
+          else
0
+            route_name << "_distributed_url"
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
+  end # Routes
0
+  
0
 end # Mack
0
 
0
 Mack::Routes.after_class_method(:build) do

Comments