data_fabric 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/CHANGELOG +4 -0
  2. data/Manifest +73 -0
  3. data/README.rdoc +1 -1
  4. data/Rakefile +34 -8
  5. data/data_fabric.gemspec +7 -7
  6. data/example/app/models/figment.rb +1 -1
  7. data/example/db/development.sqlite3 +0 -0
  8. data/example/db/s0_development.sqlite3 +0 -0
  9. data/example/db/s0_test.sqlite3 +0 -0
  10. data/example/db/s1_development.sqlite3 +0 -0
  11. data/example/db/s1_test.sqlite3 +0 -0
  12. data/example/db/test.sqlite3 +0 -0
  13. data/example/vendor/plugins/data_fabric/init.rb +1 -0
  14. data/example/vendor/plugins/data_fabric/lib/data_fabric.rb +106 -0
  15. data/example/vendor/plugins/data_fabric/lib/data_fabric/ar20.rb +135 -0
  16. data/example/vendor/plugins/data_fabric/lib/data_fabric/ar22.rb +172 -0
  17. data/example/vendor/plugins/data_fabric/lib/data_fabric/version.rb +5 -0
  18. data/example22/Rakefile +58 -0
  19. data/example22/app/controllers/accounts_controller.rb +22 -0
  20. data/example22/app/controllers/application.rb +39 -0
  21. data/example22/app/controllers/figments_controller.rb +8 -0
  22. data/example22/app/helpers/application_helper.rb +3 -0
  23. data/example22/app/models/account.rb +3 -0
  24. data/example22/app/models/figment.rb +4 -0
  25. data/example22/app/views/accounts/index.html.erb +47 -0
  26. data/example22/app/views/layouts/application.html.erb +8 -0
  27. data/example22/config/boot.rb +109 -0
  28. data/example22/config/database.yml +21 -0
  29. data/example22/config/environment.rb +76 -0
  30. data/example22/config/environments/development.rb +17 -0
  31. data/example22/config/environments/production.rb +24 -0
  32. data/example22/config/environments/test.rb +22 -0
  33. data/example22/config/initializers/inflections.rb +10 -0
  34. data/example22/config/initializers/mime_types.rb +5 -0
  35. data/example22/config/initializers/new_rails_defaults.rb +17 -0
  36. data/example22/config/locales/en.yml +5 -0
  37. data/example22/config/routes.rb +46 -0
  38. data/example22/db/migrate/20080702154628_create_accounts.rb +14 -0
  39. data/example22/db/migrate/20080702154820_create_figments.rb +14 -0
  40. data/example22/public/404.html +30 -0
  41. data/example22/public/422.html +30 -0
  42. data/example22/public/500.html +33 -0
  43. data/example22/public/dispatch.cgi +10 -0
  44. data/example22/public/dispatch.fcgi +24 -0
  45. data/example22/public/dispatch.rb +10 -0
  46. data/example22/public/favicon.ico +0 -0
  47. data/example22/public/images/rails.png +0 -0
  48. data/example22/public/index.html +274 -0
  49. data/example22/public/javascripts/application.js +2 -0
  50. data/example22/public/javascripts/controls.js +963 -0
  51. data/example22/public/javascripts/dragdrop.js +973 -0
  52. data/example22/public/javascripts/effects.js +1128 -0
  53. data/example22/public/javascripts/prototype.js +4320 -0
  54. data/example22/public/robots.txt +5 -0
  55. data/example22/script/about +4 -0
  56. data/example22/script/console +3 -0
  57. data/example22/script/dbconsole +3 -0
  58. data/example22/script/destroy +3 -0
  59. data/example22/script/generate +3 -0
  60. data/example22/script/performance/benchmarker +3 -0
  61. data/example22/script/performance/profiler +3 -0
  62. data/example22/script/performance/request +3 -0
  63. data/example22/script/plugin +3 -0
  64. data/example22/script/process/inspector +3 -0
  65. data/example22/script/process/reaper +3 -0
  66. data/example22/script/process/spawner +3 -0
  67. data/example22/script/runner +3 -0
  68. data/example22/script/server +3 -0
  69. data/example22/test/fixtures/accounts.yml +7 -0
  70. data/example22/test/functional/accounts_controller_test.rb +12 -0
  71. data/example22/test/integration/account_figments_test.rb +97 -0
  72. data/example22/test/performance/browsing_test.rb +9 -0
  73. data/example22/test/test_helper.rb +38 -0
  74. data/lib/data_fabric.rb +7 -132
  75. data/lib/data_fabric/ar20.rb +133 -0
  76. data/lib/data_fabric/ar22.rb +172 -0
  77. data/lib/data_fabric/version.rb +1 -1
  78. data/test/connection_test.rb +6 -2
  79. data/test/database_test.rb +26 -2
  80. data/test/test_helper.rb +34 -28
  81. data/test/thread_test.rb +19 -11
  82. data/test/vr_austin_master.db +0 -0
  83. data/test/vr_austin_slave.db +0 -0
  84. data/test/vr_dallas_master.db +0 -0
  85. data/test/vr_dallas_slave.db +0 -0
  86. metadata +79 -5
@@ -0,0 +1,21 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+
4
+ <% %w(development test production).each do |env| %>
5
+
6
+ <%= env %>:
7
+ adapter: sqlite3
8
+ database: <%= "db/#{env}.sqlite3" %>
9
+ timeout: 5000
10
+
11
+ <%= "shard_0_#{env}" %>:
12
+ adapter: sqlite3
13
+ database: <%= "db/s0_#{env}.sqlite3" %>
14
+ timeout: 5000
15
+
16
+ <%= "shard_1_#{env}" %>:
17
+ adapter: sqlite3
18
+ database: <%= "db/s1_#{env}.sqlite3" %>
19
+ timeout: 5000
20
+
21
+ <% end %>
@@ -0,0 +1,76 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Uncomment below to force Rails into production mode when
4
+ # you don't control web/app server and can't set it the proper way
5
+ # ENV['RAILS_ENV'] ||= 'production'
6
+
7
+ # Specifies gem version of Rails to use when vendor/rails is not present
8
+ RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
9
+
10
+ # Bootstrap the Rails environment, frameworks, and default configuration
11
+ require File.join(File.dirname(__FILE__), 'boot')
12
+
13
+ Rails::Initializer.run do |config|
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+ # See Rails::Configuration for more options.
18
+
19
+ # Skip frameworks you're not going to use. To use Rails without a database
20
+ # you must remove the Active Record framework.
21
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
22
+
23
+ # Specify gems that this application depends on.
24
+ # They can then be installed with "rake gems:install" on new installations.
25
+ # You have to specify the :lib option for libraries, where the Gem name (sqlite3-ruby) differs from the file itself (sqlite3)
26
+ # config.gem "bj"
27
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
28
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
29
+ # config.gem "aws-s3", :lib => "aws/s3"
30
+
31
+ # Only load the plugins named here, in the order given. By default, all plugins
32
+ # in vendor/plugins are loaded in alphabetical order.
33
+ # :all can be used as a placeholder for all plugins not explicitly named
34
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
35
+
36
+ # Add additional load paths for your own custom dirs
37
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
38
+
39
+ # Force all environments to use the same logger level
40
+ # (by default production uses :info, the others :debug)
41
+ # config.log_level = :debug
42
+
43
+ # Make Time.zone default to the specified zone, and make Active Record store time values
44
+ # in the database in UTC, and return them converted to the specified local zone.
45
+ # Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
46
+ config.time_zone = 'UTC'
47
+
48
+ # The internationalization framework can be changed to have another default locale (standard is :en) or more load paths.
49
+ # All files from config/locales/*.rb,yml are added automatically.
50
+ # config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')]
51
+ # config.i18n.default_locale = :de
52
+
53
+ # Your secret key for verifying cookie session data integrity.
54
+ # If you change this key, all old sessions will become invalid!
55
+ # Make sure the secret is at least 30 characters and all random,
56
+ # no regular words or you'll be exposed to dictionary attacks.
57
+ config.action_controller.session = {
58
+ :session_key => '_example22_session',
59
+ :secret => 'a726ae17b1f84e51e5ae5f8bc861a92dcffb188a7a1e9cb88c0c513ce9722b0983ee718c79741260669bfbc69b68044129fc11d8792b90fa912d719992cb9574'
60
+ }
61
+
62
+ # Use the database for sessions instead of the cookie-based default,
63
+ # which shouldn't be used to store highly confidential information
64
+ # (create the session table with "rake db:sessions:create")
65
+ # config.action_controller.session_store = :active_record_store
66
+
67
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
68
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
69
+ # like if you have constraints or database-specific column types
70
+ # config.active_record.schema_format = :sql
71
+
72
+ # Activate observers that should always be running
73
+ # Please note that observers generated using script/generate observer need to have an _observer suffix
74
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
75
+ config.threadsafe!
76
+ end
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,24 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Enable threaded mode
8
+ # config.threadsafe!
9
+
10
+ # Use a different logger for distributed setups
11
+ # config.logger = SyslogLogger.new
12
+
13
+ # Full error reports are disabled and caching is turned on
14
+ config.action_controller.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Use a different cache store in production
18
+ # config.cache_store = :mem_cache_store
19
+
20
+ # Enable serving of images, stylesheets, and javascripts from an asset server
21
+ # config.action_controller.asset_host = "http://assets.example.com"
22
+
23
+ # Disable delivery errors, bad email addresses will be ignored
24
+ # config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,22 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Disable request forgery protection in test environment
17
+ config.action_controller.allow_forgery_protection = false
18
+
19
+ # Tell Action Mailer not to deliver emails to the real world.
20
+ # The :test delivery method accumulates sent emails in the
21
+ # ActionMailer::Base.deliveries array.
22
+ config.action_mailer.delivery_method = :test
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,17 @@
1
+ # These settings change the behavior of Rails 2 apps and will be defaults
2
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
3
+
4
+ if defined?(ActiveRecord)
5
+ # Include Active Record class name as root for JSON serialized output.
6
+ ActiveRecord::Base.include_root_in_json = true
7
+
8
+ # Store the full class name (including module namespace) in STI type column.
9
+ ActiveRecord::Base.store_full_sti_class = true
10
+ end
11
+
12
+ # Use ISO 8601 format for JSON serialized times and dates.
13
+ ActiveSupport.use_standard_json_time_format = true
14
+
15
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
16
+ # if you're including raw json in an HTML page.
17
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,46 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.resources :figments
3
+ map.resources :accounts, :member => {:choose => :get}
4
+ map.root :controller => 'accounts'
5
+ # The priority is based upon order of creation: first created -> highest priority.
6
+
7
+ # Sample of regular route:
8
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
9
+ # Keep in mind you can assign values other than :controller and :action
10
+
11
+ # Sample of named route:
12
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
13
+ # This route can be invoked with purchase_url(:id => product.id)
14
+
15
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
16
+ # map.resources :products
17
+
18
+ # Sample resource route with options:
19
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
20
+
21
+ # Sample resource route with sub-resources:
22
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
23
+
24
+ # Sample resource route with more complex sub-resources
25
+ # map.resources :products do |products|
26
+ # products.resources :comments
27
+ # products.resources :sales, :collection => { :recent => :get }
28
+ # end
29
+
30
+ # Sample resource route within a namespace:
31
+ # map.namespace :admin do |admin|
32
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
33
+ # admin.resources :products
34
+ # end
35
+
36
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
37
+ # map.root :controller => "welcome"
38
+
39
+ # See how all your routes lay out with "rake routes"
40
+
41
+ # Install the default routes as the lowest priority.
42
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
43
+ # consider removing the them or commenting them out if you're using named routes and resources.
44
+ map.connect ':controller/:action/:id'
45
+ map.connect ':controller/:action/:id.:format'
46
+ end
@@ -0,0 +1,14 @@
1
+ class CreateAccounts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :accounts do |t|
4
+ t.string :name
5
+ t.string :shard
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :accounts
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreateFigments < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :figments do |t|
4
+ t.integer :account_id
5
+ t.integer :value
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :figments
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
+ <title>The page you were looking for doesn't exist (404)</title>
9
+ <style type="text/css">
10
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
+ div.dialog {
12
+ width: 25em;
13
+ padding: 0 4em;
14
+ margin: 4em auto 0 auto;
15
+ border: 1px solid #ccc;
16
+ border-right-color: #999;
17
+ border-bottom-color: #999;
18
+ }
19
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ <!-- This file lives in public/404.html -->
25
+ <div class="dialog">
26
+ <h1>The page you were looking for doesn't exist.</h1>
27
+ <p>You may have mistyped the address or the page may have moved.</p>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
+ <title>The change you wanted was rejected (422)</title>
9
+ <style type="text/css">
10
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
+ div.dialog {
12
+ width: 25em;
13
+ padding: 0 4em;
14
+ margin: 4em auto 0 auto;
15
+ border: 1px solid #ccc;
16
+ border-right-color: #999;
17
+ border-bottom-color: #999;
18
+ }
19
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ <!-- This file lives in public/422.html -->
25
+ <div class="dialog">
26
+ <h1>The change you wanted was rejected.</h1>
27
+ <p>Maybe you tried to change something you didn't have access to.</p>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,33 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
+ <title>We're sorry, but something went wrong (500)</title>
9
+ <style type="text/css">
10
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
+ div.dialog {
12
+ width: 25em;
13
+ padding: 0 4em;
14
+ margin: 4em auto 0 auto;
15
+ border: 1px solid #ccc;
16
+ border-right-color: #999;
17
+ border-bottom-color: #999;
18
+ }
19
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ <!-- This file lives in public/500.html -->
25
+ <div class="dialog">
26
+ <h1>We're sorry, but something went wrong.</h1>
27
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
28
+ <p><small>(If you're the administrator of this website, then please read
29
+ the log file "<%=h RAILS_ENV %>.log"
30
+ to find out what went wrong.)</small></p>
31
+ </div>
32
+ </body>
33
+ </html>
@@ -0,0 +1,10 @@
1
+ #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
+
5
+ # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
+ # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
+ require "dispatcher"
8
+
9
+ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
+ Dispatcher.dispatch
@@ -0,0 +1,24 @@
1
+ #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
2
+ #
3
+ # You may specify the path to the FastCGI crash log (a log of unhandled
4
+ # exceptions which forced the FastCGI instance to exit, great for debugging)
5
+ # and the number of requests to process before running garbage collection.
6
+ #
7
+ # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
8
+ # and the GC period is nil (turned off). A reasonable number of requests
9
+ # could range from 10-100 depending on the memory footprint of your app.
10
+ #
11
+ # Example:
12
+ # # Default log path, normal GC behavior.
13
+ # RailsFCGIHandler.process!
14
+ #
15
+ # # Default log path, 50 requests between GC.
16
+ # RailsFCGIHandler.process! nil, 50
17
+ #
18
+ # # Custom log path, normal GC behavior.
19
+ # RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
20
+ #
21
+ require File.dirname(__FILE__) + "/../config/environment"
22
+ require 'fcgi_handler'
23
+
24
+ RailsFCGIHandler.process!
@@ -0,0 +1,10 @@
1
+ #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
+
5
+ # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
+ # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
+ require "dispatcher"
8
+
9
+ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
+ Dispatcher.dispatch
File without changes