mack-distributed 0.7.1.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -18,11 +18,10 @@ Distributed objects are an easy way to share functionality across many different
18
18
 
19
19
  Let's configure our 'server' application. This is where pretty much all the 'heavy lifting' is done. First we need setup our configuration file:
20
20
 
21
- config/app_config/default.yml:
21
+ config/configatron/default.rb:
22
22
  # All distributed applications need to have a unique name so they can easily be identified for lookup.
23
- mack::distributed_app_name: my_cool_app
24
- # Turn object sharing on
25
- mack::share_objects: true
23
+ configatron.mack.distributed.app_name = 'my_cool_app'
24
+ configatron.mack.distributed.share_objects = true
26
25
 
27
26
  Let's assume that we have a simple User DataMapper model that looks something like this:
28
27
 
@@ -71,12 +70,11 @@ When you include Mack::Distributable into a class it registers a proxy of that c
71
70
  With distributed views, you can easily share views and layouts among different Mack Applications.
72
71
 
73
72
  == Application #1 (Server)
74
- config/app_config/default.yml:
75
- mack::distributed_site_domain: http://localhost:3001
76
- mack::distributed_app_name: my_cool_app
77
- # Turn view sharing on
78
- mack::share_views: true
79
- # and all the model sharing settings...
73
+ config/configatron/default.rb:
74
+
75
+ configatron.mack.distributed.site_domain = 'http://localhost:3001'
76
+ configatron.mack.distributed.share_views = true
77
+ configatron.mack.app_name = 'my_cool_app'
80
78
 
81
79
  That's it. When the server is started, the distributed view module will register a proxy with rinda ready for use by the client.
82
80
 
@@ -1,7 +1,7 @@
1
1
  module Mack # :nodoc:
2
2
  # Include this module into any class it will instantly register that class with
3
3
  # the mack_ring_server. The class will be registered with the name of the class
4
- # and the mack.distributed_app_name configured in your config/app_config/*.yml file.
4
+ # and the mack.distributed_app_name configured in your config/configatron/*.rb file.
5
5
  # If the mack.distributed_app_name configuration parameter is nil it will raise
6
6
  # an Mack::Distributed::Errors::ApplicationNameUndefined exception.
7
7
  #
@@ -17,7 +17,7 @@ module Mack # :nodoc:
17
17
  module Distributable
18
18
 
19
19
  def self.included(base) # :nodoc:
20
- if app_config.mack.share_objects
20
+ if configatron.mack.distributed.share_objects
21
21
  base.class_eval do
22
22
  include ::DRbUndumped
23
23
  end
@@ -43,8 +43,8 @@ module Mack # :nodoc:
43
43
  # end
44
44
  end
45
45
  }
46
- raise Mack::Distributed::Errors::ApplicationNameUndefined.new if app_config.mack.distributed_app_name.nil?
47
- Mack::Distributed::Utils::Rinda.register_or_renew(:space => app_config.mack.distributed_app_name.to_sym,
46
+ raise Mack::Distributed::Errors::ApplicationNameUndefined.new if configatron.mack.distributed.app_name.nil?
47
+ Mack::Distributed::Utils::Rinda.register_or_renew(:space => configatron.mack.distributed.app_name.to_sym,
48
48
  :klass_def => "#{base}".to_sym,
49
49
  :object => "Mack::Distributed::#{base}Proxy".constantize.instance)
50
50
  end
@@ -56,10 +56,10 @@ end # Mack
56
56
  module DRb # :nodoc:
57
57
  class DRbObject # :nodoc:
58
58
 
59
- alias_method :original_inspect, :inspect
59
+ alias_instance_method :inspect
60
60
 
61
61
  def inspect
62
- "#{original_inspect}|#{method_missing(:inspect)}"
62
+ "#{_original_inspect}|#{method_missing(:inspect)}"
63
63
  end
64
64
 
65
65
  undef :id
@@ -1,25 +1,20 @@
1
1
  module Mack
2
2
  module Routes # :nodoc:
3
3
  class RouteMap # :nodoc:
4
-
5
- # let's make sure we only do the alias_method once.
6
- unless self.private_instance_methods.include?("normal_connect_with_named_route")
7
-
8
- alias_method :normal_connect_with_named_route, :connect_with_named_route
9
-
10
- def connect_with_named_route(n_route, pattern, options = {}) # :nodoc:
11
- n_route = n_route.methodize
12
- normal_connect_with_named_route(n_route, pattern, options)
13
- if app_config.mack.share_routes
14
- Mack::Routes::Urls.class_eval %{
15
- def #{n_route}_distributed_url(options = {})
16
- (@dsd || app_config.mack.distributed_site_domain) + #{n_route}_url(options)
17
- end
18
- }
19
- end
20
- end # connect_with_named_route
21
-
22
- end
4
+
5
+ alias_instance_method :connect_with_name
6
+
7
+ def connect_with_name(name, path, options = {}, &block) # :nodoc:
8
+ n_route = name.methodize
9
+ _original_connect_with_name(n_route, path, options, &block)
10
+ if configatron.mack.distributed.share_routes
11
+ Mack::Routes::Urls.class_eval %{
12
+ def #{n_route}_distributed_url(options = {})
13
+ (@dsd || configatron.mack.distributed.site_domain) + #{n_route}_url(options)
14
+ end
15
+ }
16
+ end
17
+ end # connect_with_name
23
18
 
24
19
  end # RouteMap
25
20
  end # Routes
@@ -1,8 +1,7 @@
1
1
  module Mack # :nodoc:
2
2
  module Routes # :nodoc:
3
3
  module Urls
4
-
5
- alias_deprecated_method :droute_url, :distributed_url, '0.7.0', '>=0.8.0'
4
+
6
5
  # Retrieves a distributed route from a DRb server.
7
6
  #
8
7
  # Example:
@@ -18,7 +17,7 @@ module Mack # :nodoc:
18
17
  route_name << "_distributed_url"
19
18
  end
20
19
 
21
- if !app_config.mack.distributed_app_name.nil? && app_name.to_sym == app_config.mack.distributed_app_name.to_sym
20
+ if !configatron.mack.distributed.app_name.nil? && app_name.to_sym == configatron.mack.distributed.app_name.to_sym
22
21
  # if it's local let's just use it and not go out to Rinda
23
22
  return self.send(route_name, options)
24
23
  end
@@ -11,7 +11,7 @@ module Mack
11
11
  end
12
12
 
13
13
  def put
14
- Mack::Distributed::Utils::Rinda.register_or_renew(:space => app_config.mack.distributed_app_name.to_sym,
14
+ Mack::Distributed::Utils::Rinda.register_or_renew(:space => configatron.mack.distributed.app_name.to_sym,
15
15
  :klass_def => :distributed_routes,
16
16
  :object => self, :timeout => 0)
17
17
  end
@@ -36,10 +36,10 @@ module Mack
36
36
  end # Mack
37
37
 
38
38
  Mack::Routes.after_class_method(:build) do
39
- if app_config.mack.share_routes
40
- raise Mack::Distributed::Errors::ApplicationNameUndefined.new if app_config.mack.distributed_app_name.nil?
39
+ if configatron.mack.distributed.share_routes
40
+ raise Mack::Distributed::Errors::ApplicationNameUndefined.new if configatron.mack.distributed.app_name.nil?
41
41
 
42
- d_urls = Mack::Distributed::Routes::Urls.new(app_config.mack.distributed_site_domain)
42
+ d_urls = Mack::Distributed::Routes::Urls.new(configatron.mack.distributed.site_domain)
43
43
  d_urls.put
44
44
  Mack::Routes::Urls.include_safely_into(Mack::Distributed::Routes::Urls)
45
45
  Mack::Distributed::Routes::Urls.protected_instance_methods.each do |m|
@@ -23,8 +23,8 @@ module Mack
23
23
  end
24
24
 
25
25
  def self.ring_server
26
- if app_config.mack.distributed_acl
27
- acl = ACL.new(app_config.mack.distributed_acl)
26
+ if configatron.mack.distributed.retrieve(:acl, nil)
27
+ acl = ACL.new(configatron.mack.distributed.acl)
28
28
  DRb.install_acl(acl)
29
29
  end
30
30
  ::DRb.start_service
@@ -39,7 +39,7 @@ module Mack
39
39
 
40
40
  private
41
41
  def self.handle_options(options = {})
42
- {:space => nil, :klass_def => nil, :object => nil, :description => nil, :timeout => app_config.mack.drb_timeout}.merge(options)
42
+ {:space => nil, :klass_def => nil, :object => nil, :description => nil, :timeout => configatron.mack.distributed.timeout}.merge(options)
43
43
  end
44
44
 
45
45
  end
@@ -2,15 +2,13 @@ module Mack
2
2
  module Rendering # :nodoc:
3
3
  module Type # :nodoc:
4
4
  class Layout
5
-
6
- unless public_instance_methods.include?("old_render")
7
- alias_method :old_render, :render
8
- end
5
+
6
+ alias_instance_method :render
9
7
 
10
8
  def render
11
9
  if !self.options[:layout].starts_with?("distributed")
12
10
  # this is the regular layout, so call the local_render method
13
- old_render
11
+ _original_render
14
12
  else
15
13
  uri = Addressable::URI.parse(self.options[:layout])
16
14
  raise InvalidAddressableURIFormat.new("#{self.options[:layout]}") if uri.host.nil? or uri.path.nil?
@@ -34,13 +32,11 @@ module Mack
34
32
  old_render_value = self.view_template.render_value.dup
35
33
  self.view_template.render_value = raw
36
34
  Mack::Rendering::Type::Inline.new(self.view_template).render
37
- # self.view_template.render_value = old_render_value
38
35
  end
39
36
  end
40
- end
37
+ end # render
41
38
 
42
- end
43
- end
44
- end
45
- end
46
-
39
+ end # Layout
40
+ end # Type
41
+ end # Rendering
42
+ end # Mack
@@ -13,11 +13,11 @@ module Mack
13
13
 
14
14
  class << self
15
15
  def register
16
- if app_config.mack.share_views
17
- raise Mack::Distributed::Errors::ApplicationNameUndefined.new if app_config.mack.distributed_app_name.nil?
16
+ if configatron.mack.distributed.share_views
17
+ raise Mack::Distributed::Errors::ApplicationNameUndefined.new if configatron.mack.distributed.app_name.nil?
18
18
  # Mack.logger.info "Registering Mack::Distributed::View for '#{app_config.mack.distributed_app_name}' with Rinda"
19
19
 
20
- Mack::Distributed::Utils::Rinda.register_or_renew(:space => app_config.mack.distributed_app_name.to_sym,
20
+ Mack::Distributed::Utils::Rinda.register_or_renew(:space => configatron.mack.distributed.app_name.to_sym,
21
21
  :klass_def => :distributed_views,
22
22
  :object => Mack::Distributed::View.instance)
23
23
  end
@@ -1,18 +1,16 @@
1
1
  require 'drb/acl'
2
2
  require 'addressable/uri'
3
3
  require 'ruby-debug'
4
+ require 'mack-caching'
4
5
 
5
6
  base = File.join(File.dirname(__FILE__), "mack-distributed")
6
7
 
7
- config = {
8
- "mack::share_routes" => false,
9
- "mack::share_objects" => false,
10
- "mack::share_views" => false,
11
- "mack::distributed_app_name" => nil,
12
- "mack::distributed_site_domain" => "http://localhost:3000",
13
- "mack::drb_timeout" => 0
14
- }
15
- app_config.load_hash(config.merge(app_config.final_configuration_settings), "mack-distributed")
8
+ configatron.mack.distributed.set_default(:share_routes, false)
9
+ configatron.mack.distributed.set_default(:share_objects, false)
10
+ configatron.mack.distributed.set_default(:share_views, false)
11
+ configatron.mack.distributed.set_default(:app_name, nil)
12
+ configatron.mack.distributed.set_default(:site_domain, 'http://localhost:3000')
13
+ configatron.mack.distributed.set_default(:timeout, 0)
16
14
 
17
15
  # load *.rb files
18
16
  Dir.glob(File.join(base, "**", "*.rb")).each do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mack-distributed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-14 00:00:00 -04:00
12
+ date: 2008-10-06 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.0.4
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: mack-caching
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.0
34
+ version:
25
35
  description: Distributed Application Support for Mack Framework
26
36
  email: mark@mackframework.com
27
37
  executables:
@@ -70,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
80
  requirements: []
71
81
 
72
82
  rubyforge_project: magrathea
73
- rubygems_version: 1.2.0
83
+ rubygems_version: 1.3.0
74
84
  signing_key:
75
85
  specification_version: 2
76
86
  summary: Distributed Application