offroad 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/LICENSE +674 -674
  2. data/README.rdoc +29 -29
  3. data/Rakefile +75 -75
  4. data/TODO +42 -42
  5. data/lib/app/models/offroad/group_state.rb +85 -85
  6. data/lib/app/models/offroad/mirror_info.rb +53 -53
  7. data/lib/app/models/offroad/model_state.rb +36 -36
  8. data/lib/app/models/offroad/received_record_state.rb +115 -115
  9. data/lib/app/models/offroad/sendable_record_state.rb +91 -91
  10. data/lib/app/models/offroad/system_state.rb +33 -33
  11. data/lib/cargo_streamer.rb +222 -222
  12. data/lib/controller_extensions.rb +74 -74
  13. data/lib/exceptions.rb +16 -16
  14. data/lib/migrate/20100512164608_create_offroad_tables.rb +72 -72
  15. data/lib/mirror_data.rb +376 -376
  16. data/lib/model_extensions.rb +378 -377
  17. data/lib/module_funcs.rb +94 -94
  18. data/lib/offroad.rb +41 -41
  19. data/lib/version.rb +3 -3
  20. data/lib/view_helper.rb +7 -7
  21. data/templates/offline.rb +36 -36
  22. data/templates/offline_database.yml +7 -7
  23. data/templates/offroad.yml +6 -6
  24. data/test/app_root/app/controllers/application_controller.rb +2 -2
  25. data/test/app_root/app/controllers/group_controller.rb +28 -28
  26. data/test/app_root/app/models/global_record.rb +10 -10
  27. data/test/app_root/app/models/group.rb +12 -12
  28. data/test/app_root/app/models/group_owned_record.rb +68 -68
  29. data/test/app_root/app/models/guest.rb +7 -7
  30. data/test/app_root/app/models/subrecord.rb +12 -12
  31. data/test/app_root/app/models/unmirrored_record.rb +4 -4
  32. data/test/app_root/app/views/group/download_down_mirror.html.erb +3 -3
  33. data/test/app_root/app/views/group/download_initial_down_mirror.html.erb +3 -3
  34. data/test/app_root/app/views/group/download_up_mirror.html.erb +5 -5
  35. data/test/app_root/app/views/layouts/mirror.html.erb +8 -8
  36. data/test/app_root/config/boot.rb +115 -115
  37. data/test/app_root/config/database-pg.yml +8 -8
  38. data/test/app_root/config/database.yml +5 -5
  39. data/test/app_root/config/environment.rb +24 -24
  40. data/test/app_root/config/environments/test.rb +17 -17
  41. data/test/app_root/config/offroad.yml +6 -6
  42. data/test/app_root/config/routes.rb +4 -4
  43. data/test/app_root/db/migrate/20100529235049_create_tables.rb +64 -64
  44. data/test/app_root/lib/common_hobo.rb +15 -15
  45. data/test/app_root/vendor/plugins/offroad/init.rb +2 -2
  46. data/test/functional/mirror_operations_test.rb +148 -148
  47. data/test/test_helper.rb +453 -453
  48. data/test/unit/app_state_tracking_test.rb +275 -275
  49. data/test/unit/cargo_streamer_test.rb +332 -332
  50. data/test/unit/global_data_test.rb +102 -102
  51. data/test/unit/group_controller_test.rb +152 -152
  52. data/test/unit/group_data_test.rb +442 -435
  53. data/test/unit/group_single_test.rb +136 -136
  54. data/test/unit/hobo_permissions_test.rb +57 -57
  55. data/test/unit/mirror_data_test.rb +1283 -1283
  56. data/test/unit/mirror_info_test.rb +31 -31
  57. data/test/unit/module_funcs_test.rb +37 -37
  58. data/test/unit/pathological_model_test.rb +62 -62
  59. data/test/unit/test_framework_test.rb +86 -86
  60. data/test/unit/unmirrored_data_test.rb +14 -14
  61. metadata +6 -8
@@ -1,10 +1,10 @@
1
- class GlobalRecord < ActiveRecord::Base
2
- include CommonHobo if HOBO_TEST_MODE
3
- acts_as_offroadable :global
4
- validates_presence_of :title
5
- belongs_to :unmirrored_record
6
- belongs_to :some_group, :class_name => "Group"
7
- belongs_to :friend, :class_name => "GlobalRecord"
8
- validates_numericality_of :should_be_odd, :odd => true
9
- attr_protected :protected_integer
10
- end
1
+ class GlobalRecord < ActiveRecord::Base
2
+ include CommonHobo if HOBO_TEST_MODE
3
+ acts_as_offroadable :global
4
+ validates_presence_of :title
5
+ belongs_to :unmirrored_record
6
+ belongs_to :some_group, :class_name => "Group"
7
+ belongs_to :friend, :class_name => "GlobalRecord"
8
+ validates_numericality_of :should_be_odd, :odd => true
9
+ attr_protected :protected_integer
10
+ end
@@ -1,12 +1,12 @@
1
- class Group < ActiveRecord::Base
2
- include CommonHobo if HOBO_TEST_MODE
3
- acts_as_offroadable :group_base
4
- validates_presence_of :name
5
- has_many :group_owned_records, :dependent => :destroy
6
- belongs_to :favorite, :class_name => "GroupOwnedRecord"
7
- belongs_to :unmirrored_record
8
- belongs_to :global_record
9
- def to_s
10
- name
11
- end
12
- end
1
+ class Group < ActiveRecord::Base
2
+ include CommonHobo if HOBO_TEST_MODE
3
+ acts_as_offroadable :group_base
4
+ validates_presence_of :name
5
+ has_many :group_owned_records, :dependent => :destroy
6
+ belongs_to :favorite, :class_name => "GroupOwnedRecord"
7
+ belongs_to :unmirrored_record
8
+ belongs_to :global_record
9
+ def to_s
10
+ name
11
+ end
12
+ end
@@ -1,68 +1,68 @@
1
- class GroupOwnedRecord < ActiveRecord::Base
2
- include CommonHobo if HOBO_TEST_MODE
3
- belongs_to :group
4
- acts_as_offroadable :group_owned, :parent => :group
5
-
6
- belongs_to :parent, :class_name => "GroupOwnedRecord"
7
- belongs_to :unmirrored_record
8
- belongs_to :global_record
9
- has_many :children, :foreign_key => "parent_id", :class_name => "GroupOwnedRecord"
10
- has_many :subrecords
11
- validates_presence_of :description, :group
12
- validates_numericality_of :should_be_even, :even => true
13
- attr_protected :protected_integer
14
-
15
- def to_s
16
- description
17
- end
18
-
19
- def before_save
20
- @@callback_called = true
21
- end
22
-
23
- def after_save
24
- @@callback_called = true
25
- end
26
-
27
- def before_destroy
28
- @@callback_called = true
29
- end
30
-
31
- def after_destroy
32
- @@callback_called = true
33
- end
34
-
35
- def self.reset_callback_called
36
- @@callback_called = false
37
- end
38
-
39
- def self.callback_called
40
- @@callback_called
41
- end
42
-
43
- def after_offroad_upload
44
- @@after_upload_count ||= 0
45
- @@after_upload_count += 1
46
- end
47
-
48
- def self.reset_after_upload_count
49
- @@after_upload_count = 0
50
- end
51
-
52
- def self.after_upload_count
53
- @@after_upload_count
54
- end
55
-
56
- def after_offroad_destroy
57
- @@after_destroy_count ||= 0
58
- @@after_destroy_count += 1
59
- end
60
-
61
- def self.reset_after_destroy_count
62
- @@after_destroy_count = 0
63
- end
64
-
65
- def self.after_destroy_count
66
- @@after_destroy_count
67
- end
68
- end
1
+ class GroupOwnedRecord < ActiveRecord::Base
2
+ include CommonHobo if HOBO_TEST_MODE
3
+ belongs_to :group
4
+ acts_as_offroadable :group_owned, :parent => :group
5
+
6
+ belongs_to :parent, :class_name => "GroupOwnedRecord"
7
+ belongs_to :unmirrored_record
8
+ belongs_to :global_record
9
+ has_many :children, :foreign_key => "parent_id", :class_name => "GroupOwnedRecord"
10
+ has_many :subrecords
11
+ validates_presence_of :description, :group
12
+ validates_numericality_of :should_be_even, :even => true
13
+ attr_protected :protected_integer
14
+
15
+ def to_s
16
+ description
17
+ end
18
+
19
+ def before_save
20
+ @@callback_called = true
21
+ end
22
+
23
+ def after_save
24
+ @@callback_called = true
25
+ end
26
+
27
+ def before_destroy
28
+ @@callback_called = true
29
+ end
30
+
31
+ def after_destroy
32
+ @@callback_called = true
33
+ end
34
+
35
+ def self.reset_callback_called
36
+ @@callback_called = false
37
+ end
38
+
39
+ def self.callback_called
40
+ @@callback_called
41
+ end
42
+
43
+ def after_offroad_upload
44
+ @@after_upload_count ||= 0
45
+ @@after_upload_count += 1
46
+ end
47
+
48
+ def self.reset_after_upload_count
49
+ @@after_upload_count = 0
50
+ end
51
+
52
+ def self.after_upload_count
53
+ @@after_upload_count
54
+ end
55
+
56
+ def after_offroad_destroy
57
+ @@after_destroy_count ||= 0
58
+ @@after_destroy_count += 1
59
+ end
60
+
61
+ def self.reset_after_destroy_count
62
+ @@after_destroy_count = 0
63
+ end
64
+
65
+ def self.after_destroy_count
66
+ @@after_destroy_count
67
+ end
68
+ end
@@ -1,7 +1,7 @@
1
- if HOBO_TEST_MODE
2
- class Guest < Hobo::Guest
3
- def administrator?
4
- false
5
- end
6
- end
7
- end
1
+ if HOBO_TEST_MODE
2
+ class Guest < Hobo::Guest
3
+ def administrator?
4
+ false
5
+ end
6
+ end
7
+ end
@@ -1,12 +1,12 @@
1
- class SubRecord < ActiveRecord::Base
2
- include CommonHobo if HOBO_TEST_MODE
3
- belongs_to :group_owned_record
4
- acts_as_offroadable :group_owned, :parent => :group_owned_record
5
-
6
- belongs_to :buddy, :class_name => "SubRecord"
7
- belongs_to :unmirrored_record
8
-
9
- def to_s
10
- description
11
- end
12
- end
1
+ class SubRecord < ActiveRecord::Base
2
+ include CommonHobo if HOBO_TEST_MODE
3
+ belongs_to :group_owned_record
4
+ acts_as_offroadable :group_owned, :parent => :group_owned_record
5
+
6
+ belongs_to :buddy, :class_name => "SubRecord"
7
+ belongs_to :unmirrored_record
8
+
9
+ def to_s
10
+ description
11
+ end
12
+ end
@@ -1,4 +1,4 @@
1
- class UnmirroredRecord < ActiveRecord::Base
2
- include CommonHobo if HOBO_TEST_MODE
3
- validates_presence_of :content
4
- end
1
+ class UnmirroredRecord < ActiveRecord::Base
2
+ include CommonHobo if HOBO_TEST_MODE
3
+ validates_presence_of :content
4
+ end
@@ -1,4 +1,4 @@
1
- <% content_for :title do %>Test App Downloaded Data<% end %>
2
-
3
- This file contains information downloaded from the Test App online system.<br/>
1
+ <% content_for :title do %>Test App Downloaded Data<% end %>
2
+
3
+ This file contains information downloaded from the Test App online system.<br/>
4
4
  Please take it to your offline Test App system and load it there.
@@ -1,4 +1,4 @@
1
- <% content_for :title do %>Test App Downloaded Data<% end %>
2
-
3
- This file contains information downloaded from the Test App online system.<br/>
1
+ <% content_for :title do %>Test App Downloaded Data<% end %>
2
+
3
+ This file contains information downloaded from the Test App online system.<br/>
4
4
  Please take it to your offline Test App system and load it there.
@@ -1,6 +1,6 @@
1
- <% content_for :title do %>Test App Data For Upload<% end %>
2
-
3
- This file contains your data that is to be sent to the Test App online system.<br/>
4
- Take this file to a computer with Internet access, then go to this website:<br/><br/>
5
-
1
+ <% content_for :title do %>Test App Data For Upload<% end %>
2
+
3
+ This file contains your data that is to be sent to the Test App online system.<br/>
4
+ Take this file to a computer with Internet access, then go to this website:<br/><br/>
5
+
6
6
  <%= link_to_online_app %>
@@ -1,9 +1,9 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <title><%= yield :title %></title>
5
- </head>
6
- <body>
7
- <%= yield %>
8
- </body>
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title><%= yield :title %></title>
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
9
  </html>
@@ -1,115 +1,115 @@
1
- # Allow customization of the rails framework path
2
- RAILS_FRAMEWORK_ROOT = (ENV['RAILS_FRAMEWORK_ROOT'] || "#{File.dirname(__FILE__)}/../../../../../../vendor/rails") unless defined?(RAILS_FRAMEWORK_ROOT)
3
-
4
- # Don't change this file!
5
- # Configure your app in config/environment.rb and config/environments/*.rb
6
-
7
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
8
-
9
- module Rails
10
- class << self
11
- def boot!
12
- unless booted?
13
- preinitialize
14
- pick_boot.run
15
- end
16
- end
17
-
18
- def booted?
19
- defined? Rails::Initializer
20
- end
21
-
22
- def pick_boot
23
- (vendor_rails? ? VendorBoot : GemBoot).new
24
- end
25
-
26
- def vendor_rails?
27
- File.exist?(RAILS_FRAMEWORK_ROOT)
28
- end
29
-
30
- def preinitialize
31
- load(preinitializer_path) if File.exist?(preinitializer_path)
32
- end
33
-
34
- def preinitializer_path
35
- "#{RAILS_ROOT}/config/preinitializer.rb"
36
- end
37
- end
38
-
39
- class Boot
40
- def run
41
- load_initializer
42
- Rails::Initializer.run(:set_load_path)
43
- end
44
- end
45
-
46
- class VendorBoot < Boot
47
- def load_initializer
48
- require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/initializer"
49
- Rails::Initializer.run(:install_gem_spec_stubs)
50
- Rails::GemDependency.add_frozen_gem_path
51
- end
52
- end
53
-
54
- class GemBoot < Boot
55
- def load_initializer
56
- self.class.load_rubygems
57
- load_rails_gem
58
- require 'initializer'
59
- end
60
-
61
- def load_rails_gem
62
- if version = self.class.gem_version
63
- gem 'rails', version
64
- else
65
- gem 'rails'
66
- end
67
- rescue Gem::LoadError => load_error
68
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
69
- exit 1
70
- end
71
-
72
- class << self
73
- def rubygems_version
74
- Gem::RubyGemsVersion rescue nil
75
- end
76
-
77
- def gem_version
78
- if defined? RAILS_GEM_VERSION
79
- RAILS_GEM_VERSION
80
- elsif ENV.include?('RAILS_GEM_VERSION')
81
- ENV['RAILS_GEM_VERSION']
82
- else
83
- parse_gem_version(read_environment_rb)
84
- end
85
- end
86
-
87
- def load_rubygems
88
- require 'rubygems'
89
- min_version = '1.3.1'
90
- unless rubygems_version >= min_version
91
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
92
- exit 1
93
- end
94
-
95
- rescue LoadError
96
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
97
- exit 1
98
- end
99
-
100
- def parse_gem_version(text)
101
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
102
- end
103
-
104
- private
105
- def read_environment_rb
106
- environment_rb = "#{RAILS_ROOT}/config/environment.rb"
107
- environment_rb = "#{HELPER_RAILS_ROOT}/config/environment.rb" unless File.exists?(environment_rb)
108
- File.read(environment_rb)
109
- end
110
- end
111
- end
112
- end
113
-
114
- # All that for this:
115
- Rails.boot!
1
+ # Allow customization of the rails framework path
2
+ RAILS_FRAMEWORK_ROOT = (ENV['RAILS_FRAMEWORK_ROOT'] || "#{File.dirname(__FILE__)}/../../../../../../vendor/rails") unless defined?(RAILS_FRAMEWORK_ROOT)
3
+
4
+ # Don't change this file!
5
+ # Configure your app in config/environment.rb and config/environments/*.rb
6
+
7
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
8
+
9
+ module Rails
10
+ class << self
11
+ def boot!
12
+ unless booted?
13
+ preinitialize
14
+ pick_boot.run
15
+ end
16
+ end
17
+
18
+ def booted?
19
+ defined? Rails::Initializer
20
+ end
21
+
22
+ def pick_boot
23
+ (vendor_rails? ? VendorBoot : GemBoot).new
24
+ end
25
+
26
+ def vendor_rails?
27
+ File.exist?(RAILS_FRAMEWORK_ROOT)
28
+ end
29
+
30
+ def preinitialize
31
+ load(preinitializer_path) if File.exist?(preinitializer_path)
32
+ end
33
+
34
+ def preinitializer_path
35
+ "#{RAILS_ROOT}/config/preinitializer.rb"
36
+ end
37
+ end
38
+
39
+ class Boot
40
+ def run
41
+ load_initializer
42
+ Rails::Initializer.run(:set_load_path)
43
+ end
44
+ end
45
+
46
+ class VendorBoot < Boot
47
+ def load_initializer
48
+ require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/initializer"
49
+ Rails::Initializer.run(:install_gem_spec_stubs)
50
+ Rails::GemDependency.add_frozen_gem_path
51
+ end
52
+ end
53
+
54
+ class GemBoot < Boot
55
+ def load_initializer
56
+ self.class.load_rubygems
57
+ load_rails_gem
58
+ require 'initializer'
59
+ end
60
+
61
+ def load_rails_gem
62
+ if version = self.class.gem_version
63
+ gem 'rails', version
64
+ else
65
+ gem 'rails'
66
+ end
67
+ rescue Gem::LoadError => load_error
68
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
69
+ exit 1
70
+ end
71
+
72
+ class << self
73
+ def rubygems_version
74
+ Gem::RubyGemsVersion rescue nil
75
+ end
76
+
77
+ def gem_version
78
+ if defined? RAILS_GEM_VERSION
79
+ RAILS_GEM_VERSION
80
+ elsif ENV.include?('RAILS_GEM_VERSION')
81
+ ENV['RAILS_GEM_VERSION']
82
+ else
83
+ parse_gem_version(read_environment_rb)
84
+ end
85
+ end
86
+
87
+ def load_rubygems
88
+ require 'rubygems'
89
+ min_version = '1.3.1'
90
+ unless rubygems_version >= min_version
91
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
92
+ exit 1
93
+ end
94
+
95
+ rescue LoadError
96
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
97
+ exit 1
98
+ end
99
+
100
+ def parse_gem_version(text)
101
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
102
+ end
103
+
104
+ private
105
+ def read_environment_rb
106
+ environment_rb = "#{RAILS_ROOT}/config/environment.rb"
107
+ environment_rb = "#{HELPER_RAILS_ROOT}/config/environment.rb" unless File.exists?(environment_rb)
108
+ File.read(environment_rb)
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ # All that for this:
115
+ Rails.boot!