rubyrep 1.0.0

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 (140) hide show
  1. data/History.txt +4 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +137 -0
  4. data/README.txt +37 -0
  5. data/Rakefile +30 -0
  6. data/bin/rubyrep +8 -0
  7. data/config/hoe.rb +72 -0
  8. data/config/mysql_config.rb +25 -0
  9. data/config/postgres_config.rb +21 -0
  10. data/config/proxied_test_config.rb +14 -0
  11. data/config/redmine_config.rb +17 -0
  12. data/config/rep_config.rb +20 -0
  13. data/config/requirements.rb +32 -0
  14. data/config/test_config.rb +20 -0
  15. data/lib/rubyrep/base_runner.rb +195 -0
  16. data/lib/rubyrep/command_runner.rb +144 -0
  17. data/lib/rubyrep/committers/buffered_committer.rb +140 -0
  18. data/lib/rubyrep/committers/committers.rb +146 -0
  19. data/lib/rubyrep/configuration.rb +240 -0
  20. data/lib/rubyrep/connection_extenders/connection_extenders.rb +133 -0
  21. data/lib/rubyrep/connection_extenders/jdbc_extender.rb +284 -0
  22. data/lib/rubyrep/connection_extenders/mysql_extender.rb +168 -0
  23. data/lib/rubyrep/connection_extenders/postgresql_extender.rb +261 -0
  24. data/lib/rubyrep/database_proxy.rb +52 -0
  25. data/lib/rubyrep/direct_table_scan.rb +75 -0
  26. data/lib/rubyrep/generate_runner.rb +105 -0
  27. data/lib/rubyrep/initializer.rb +39 -0
  28. data/lib/rubyrep/logged_change.rb +326 -0
  29. data/lib/rubyrep/proxied_table_scan.rb +171 -0
  30. data/lib/rubyrep/proxy_block_cursor.rb +145 -0
  31. data/lib/rubyrep/proxy_connection.rb +318 -0
  32. data/lib/rubyrep/proxy_cursor.rb +44 -0
  33. data/lib/rubyrep/proxy_row_cursor.rb +43 -0
  34. data/lib/rubyrep/proxy_runner.rb +89 -0
  35. data/lib/rubyrep/replication_difference.rb +91 -0
  36. data/lib/rubyrep/replication_extenders/mysql_replication.rb +271 -0
  37. data/lib/rubyrep/replication_extenders/postgresql_replication.rb +204 -0
  38. data/lib/rubyrep/replication_extenders/replication_extenders.rb +26 -0
  39. data/lib/rubyrep/replication_helper.rb +104 -0
  40. data/lib/rubyrep/replication_initializer.rb +307 -0
  41. data/lib/rubyrep/replication_run.rb +48 -0
  42. data/lib/rubyrep/replication_runner.rb +138 -0
  43. data/lib/rubyrep/replicators/replicators.rb +37 -0
  44. data/lib/rubyrep/replicators/two_way_replicator.rb +334 -0
  45. data/lib/rubyrep/scan_progress_printers/progress_bar.rb +65 -0
  46. data/lib/rubyrep/scan_progress_printers/scan_progress_printers.rb +65 -0
  47. data/lib/rubyrep/scan_report_printers/scan_detail_reporter.rb +111 -0
  48. data/lib/rubyrep/scan_report_printers/scan_report_printers.rb +67 -0
  49. data/lib/rubyrep/scan_report_printers/scan_summary_reporter.rb +75 -0
  50. data/lib/rubyrep/scan_runner.rb +25 -0
  51. data/lib/rubyrep/session.rb +177 -0
  52. data/lib/rubyrep/sync_helper.rb +111 -0
  53. data/lib/rubyrep/sync_runner.rb +31 -0
  54. data/lib/rubyrep/syncers/syncers.rb +112 -0
  55. data/lib/rubyrep/syncers/two_way_syncer.rb +174 -0
  56. data/lib/rubyrep/table_scan.rb +54 -0
  57. data/lib/rubyrep/table_scan_helper.rb +38 -0
  58. data/lib/rubyrep/table_sorter.rb +70 -0
  59. data/lib/rubyrep/table_spec_resolver.rb +136 -0
  60. data/lib/rubyrep/table_sync.rb +68 -0
  61. data/lib/rubyrep/trigger_mode_switcher.rb +63 -0
  62. data/lib/rubyrep/type_casting_cursor.rb +31 -0
  63. data/lib/rubyrep/uninstall_runner.rb +92 -0
  64. data/lib/rubyrep/version.rb +9 -0
  65. data/lib/rubyrep.rb +68 -0
  66. data/script/destroy +14 -0
  67. data/script/generate +14 -0
  68. data/script/txt2html +74 -0
  69. data/setup.rb +1585 -0
  70. data/sims/performance/big_rep_spec.rb +100 -0
  71. data/sims/performance/big_scan_spec.rb +57 -0
  72. data/sims/performance/big_sync_spec.rb +141 -0
  73. data/sims/performance/performance.rake +228 -0
  74. data/sims/sim_helper.rb +24 -0
  75. data/spec/base_runner_spec.rb +218 -0
  76. data/spec/buffered_committer_spec.rb +271 -0
  77. data/spec/command_runner_spec.rb +145 -0
  78. data/spec/committers_spec.rb +174 -0
  79. data/spec/configuration_spec.rb +198 -0
  80. data/spec/connection_extender_interface_spec.rb +138 -0
  81. data/spec/connection_extenders_registration_spec.rb +129 -0
  82. data/spec/database_proxy_spec.rb +48 -0
  83. data/spec/database_rake_spec.rb +40 -0
  84. data/spec/db_specific_connection_extenders_spec.rb +34 -0
  85. data/spec/db_specific_replication_extenders_spec.rb +38 -0
  86. data/spec/direct_table_scan_spec.rb +61 -0
  87. data/spec/generate_runner_spec.rb +84 -0
  88. data/spec/initializer_spec.rb +46 -0
  89. data/spec/logged_change_spec.rb +480 -0
  90. data/spec/postgresql_replication_spec.rb +48 -0
  91. data/spec/postgresql_support_spec.rb +57 -0
  92. data/spec/progress_bar_spec.rb +77 -0
  93. data/spec/proxied_table_scan_spec.rb +151 -0
  94. data/spec/proxy_block_cursor_spec.rb +197 -0
  95. data/spec/proxy_connection_spec.rb +399 -0
  96. data/spec/proxy_cursor_spec.rb +56 -0
  97. data/spec/proxy_row_cursor_spec.rb +66 -0
  98. data/spec/proxy_runner_spec.rb +70 -0
  99. data/spec/replication_difference_spec.rb +160 -0
  100. data/spec/replication_extender_interface_spec.rb +365 -0
  101. data/spec/replication_extenders_spec.rb +32 -0
  102. data/spec/replication_helper_spec.rb +121 -0
  103. data/spec/replication_initializer_spec.rb +477 -0
  104. data/spec/replication_run_spec.rb +166 -0
  105. data/spec/replication_runner_spec.rb +213 -0
  106. data/spec/replicators_spec.rb +31 -0
  107. data/spec/rubyrep_spec.rb +8 -0
  108. data/spec/scan_detail_reporter_spec.rb +119 -0
  109. data/spec/scan_progress_printers_spec.rb +68 -0
  110. data/spec/scan_report_printers_spec.rb +67 -0
  111. data/spec/scan_runner_spec.rb +50 -0
  112. data/spec/scan_summary_reporter_spec.rb +61 -0
  113. data/spec/session_spec.rb +212 -0
  114. data/spec/spec.opts +1 -0
  115. data/spec/spec_helper.rb +295 -0
  116. data/spec/sync_helper_spec.rb +157 -0
  117. data/spec/sync_runner_spec.rb +78 -0
  118. data/spec/syncers_spec.rb +171 -0
  119. data/spec/table_scan_helper_spec.rb +29 -0
  120. data/spec/table_scan_spec.rb +49 -0
  121. data/spec/table_sorter_spec.rb +31 -0
  122. data/spec/table_spec_resolver_spec.rb +102 -0
  123. data/spec/table_sync_spec.rb +84 -0
  124. data/spec/trigger_mode_switcher_spec.rb +83 -0
  125. data/spec/two_way_replicator_spec.rb +551 -0
  126. data/spec/two_way_syncer_spec.rb +256 -0
  127. data/spec/type_casting_cursor_spec.rb +50 -0
  128. data/spec/uninstall_runner_spec.rb +86 -0
  129. data/tasks/database.rake +439 -0
  130. data/tasks/deployment.rake +29 -0
  131. data/tasks/environment.rake +9 -0
  132. data/tasks/java.rake +37 -0
  133. data/tasks/redmine_test.rake +47 -0
  134. data/tasks/rspec.rake +68 -0
  135. data/tasks/rubyrep.tailor +18 -0
  136. data/tasks/stats.rake +19 -0
  137. data/tasks/task_helper.rb +20 -0
  138. data.tar.gz.sig +0 -0
  139. metadata +243 -0
  140. metadata.gz.sig +0 -0
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 1.0.0 2009-03-07
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Arndt Lehmann
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,137 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/rubyrep
7
+ config/hoe.rb
8
+ config/mysql_config.rb
9
+ config/postgres_config.rb
10
+ config/proxied_test_config.rb
11
+ config/redmine_config.rb
12
+ config/rep_config.rb
13
+ config/requirements.rb
14
+ config/test_config.rb
15
+ lib/rubyrep.rb
16
+ lib/rubyrep/base_runner.rb
17
+ lib/rubyrep/command_runner.rb
18
+ lib/rubyrep/committers/buffered_committer.rb
19
+ lib/rubyrep/committers/committers.rb
20
+ lib/rubyrep/configuration.rb
21
+ lib/rubyrep/connection_extenders/connection_extenders.rb
22
+ lib/rubyrep/connection_extenders/jdbc_extender.rb
23
+ lib/rubyrep/connection_extenders/mysql_extender.rb
24
+ lib/rubyrep/connection_extenders/postgresql_extender.rb
25
+ lib/rubyrep/database_proxy.rb
26
+ lib/rubyrep/direct_table_scan.rb
27
+ lib/rubyrep/generate_runner.rb
28
+ lib/rubyrep/initializer.rb
29
+ lib/rubyrep/logged_change.rb
30
+ lib/rubyrep/proxied_table_scan.rb
31
+ lib/rubyrep/proxy_block_cursor.rb
32
+ lib/rubyrep/proxy_connection.rb
33
+ lib/rubyrep/proxy_cursor.rb
34
+ lib/rubyrep/proxy_row_cursor.rb
35
+ lib/rubyrep/proxy_runner.rb
36
+ lib/rubyrep/replication_difference.rb
37
+ lib/rubyrep/replication_extenders/mysql_replication.rb
38
+ lib/rubyrep/replication_extenders/postgresql_replication.rb
39
+ lib/rubyrep/replication_extenders/replication_extenders.rb
40
+ lib/rubyrep/replication_helper.rb
41
+ lib/rubyrep/replication_initializer.rb
42
+ lib/rubyrep/replication_run.rb
43
+ lib/rubyrep/replication_runner.rb
44
+ lib/rubyrep/replicators/replicators.rb
45
+ lib/rubyrep/replicators/two_way_replicator.rb
46
+ lib/rubyrep/scan_progress_printers/progress_bar.rb
47
+ lib/rubyrep/scan_progress_printers/scan_progress_printers.rb
48
+ lib/rubyrep/scan_report_printers/scan_detail_reporter.rb
49
+ lib/rubyrep/scan_report_printers/scan_report_printers.rb
50
+ lib/rubyrep/scan_report_printers/scan_summary_reporter.rb
51
+ lib/rubyrep/scan_runner.rb
52
+ lib/rubyrep/session.rb
53
+ lib/rubyrep/sync_helper.rb
54
+ lib/rubyrep/sync_runner.rb
55
+ lib/rubyrep/syncers/syncers.rb
56
+ lib/rubyrep/syncers/two_way_syncer.rb
57
+ lib/rubyrep/table_scan.rb
58
+ lib/rubyrep/table_scan_helper.rb
59
+ lib/rubyrep/table_sorter.rb
60
+ lib/rubyrep/table_spec_resolver.rb
61
+ lib/rubyrep/table_sync.rb
62
+ lib/rubyrep/trigger_mode_switcher.rb
63
+ lib/rubyrep/type_casting_cursor.rb
64
+ lib/rubyrep/uninstall_runner.rb
65
+ lib/rubyrep/version.rb
66
+ script/destroy
67
+ script/generate
68
+ script/txt2html
69
+ setup.rb
70
+ sims/performance/big_rep_spec.rb
71
+ sims/performance/big_scan_spec.rb
72
+ sims/performance/big_sync_spec.rb
73
+ sims/performance/performance.rake
74
+ sims/sim_helper.rb
75
+ spec/base_runner_spec.rb
76
+ spec/buffered_committer_spec.rb
77
+ spec/command_runner_spec.rb
78
+ spec/committers_spec.rb
79
+ spec/configuration_spec.rb
80
+ spec/connection_extender_interface_spec.rb
81
+ spec/connection_extenders_registration_spec.rb
82
+ spec/database_proxy_spec.rb
83
+ spec/database_rake_spec.rb
84
+ spec/db_specific_connection_extenders_spec.rb
85
+ spec/db_specific_replication_extenders_spec.rb
86
+ spec/direct_table_scan_spec.rb
87
+ spec/generate_runner_spec.rb
88
+ spec/initializer_spec.rb
89
+ spec/logged_change_spec.rb
90
+ spec/postgresql_replication_spec.rb
91
+ spec/postgresql_support_spec.rb
92
+ spec/progress_bar_spec.rb
93
+ spec/proxied_table_scan_spec.rb
94
+ spec/proxy_block_cursor_spec.rb
95
+ spec/proxy_connection_spec.rb
96
+ spec/proxy_cursor_spec.rb
97
+ spec/proxy_row_cursor_spec.rb
98
+ spec/proxy_runner_spec.rb
99
+ spec/replication_difference_spec.rb
100
+ spec/replication_extender_interface_spec.rb
101
+ spec/replication_extenders_spec.rb
102
+ spec/replication_helper_spec.rb
103
+ spec/replication_initializer_spec.rb
104
+ spec/replication_run_spec.rb
105
+ spec/replication_runner_spec.rb
106
+ spec/replicators_spec.rb
107
+ spec/rubyrep_spec.rb
108
+ spec/scan_detail_reporter_spec.rb
109
+ spec/scan_progress_printers_spec.rb
110
+ spec/scan_report_printers_spec.rb
111
+ spec/scan_runner_spec.rb
112
+ spec/scan_summary_reporter_spec.rb
113
+ spec/session_spec.rb
114
+ spec/spec.opts
115
+ spec/spec_helper.rb
116
+ spec/sync_helper_spec.rb
117
+ spec/sync_runner_spec.rb
118
+ spec/syncers_spec.rb
119
+ spec/table_scan_helper_spec.rb
120
+ spec/table_scan_spec.rb
121
+ spec/table_sorter_spec.rb
122
+ spec/table_spec_resolver_spec.rb
123
+ spec/table_sync_spec.rb
124
+ spec/trigger_mode_switcher_spec.rb
125
+ spec/two_way_replicator_spec.rb
126
+ spec/two_way_syncer_spec.rb
127
+ spec/type_casting_cursor_spec.rb
128
+ spec/uninstall_runner_spec.rb
129
+ tasks/database.rake
130
+ tasks/deployment.rake
131
+ tasks/environment.rake
132
+ tasks/java.rake
133
+ tasks/redmine_test.rake
134
+ tasks/rspec.rake
135
+ tasks/rubyrep.tailor
136
+ tasks/stats.rake
137
+ tasks/task_helper.rb
data/README.txt ADDED
@@ -0,0 +1,37 @@
1
+ = rubyrep
2
+
3
+ == MISSION:
4
+
5
+ Development of an open-source solution for asynchronous, master-master replication of relational databases that is
6
+ * ridiculously easy to use
7
+ * database independent
8
+
9
+
10
+ == MORE INFORMATION:
11
+
12
+ Refer to the project website at http://rubyrep.github.com
13
+
14
+ == LICENSE:
15
+
16
+ (The MIT License)
17
+
18
+ Copyright (c) 2009 Arndt Lehmann
19
+
20
+ Permission is hereby granted, free of charge, to any person obtaining
21
+ a copy of this software and associated documentation files (the
22
+ 'Software'), to deal in the Software without restriction, including
23
+ without limitation the rights to use, copy, modify, merge, publish,
24
+ distribute, sublicense, and/or sell copies of the Software, and to
25
+ permit persons to whom the Software is furnished to do so, subject to
26
+ the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be
29
+ included in all copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
32
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
35
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
36
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
37
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' if Object.const_defined? 'Hoe' # setup Hoe + all gem configuration
3
+
4
+ require 'lib/rubyrep'
5
+ require 'tasks/task_helper'
6
+
7
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
8
+ load 'sims/performance/performance.rake'
9
+
10
+ desc "Creates the repository commit statistics"
11
+ task :repostats do
12
+ # phase 0: create the repository tmp directory
13
+ system 'mkdir -p tmp'
14
+ # phase 1: migrate the hg repository to svn
15
+ tailor_path = '~/usr/tailor/tailor'
16
+ cmd = "#{tailor_path} --use-propset --configfile '#{File.dirname(__FILE__) + '/tasks/rubyrep.tailor'}'"
17
+ system cmd
18
+
19
+ # phase 2: create the repository statistics through the statsvn library
20
+ jar_path = '~/usr/statsvn/statsvn.jar'
21
+ log_path = File.dirname(__FILE__) + '/tmp/statsvn.log'
22
+ checkout_path = '/tmp/rubyrep_tailor/svn'
23
+ svnstats_dir = File.dirname(__FILE__) + '/statsvn'
24
+
25
+ system "cd #{checkout_path}; svn update"
26
+ cmd = "cd #{checkout_path}; svn log -v --xml >#{log_path}"
27
+ system cmd
28
+ cmd = "java -jar #{jar_path} -output-dir #{svnstats_dir} -exclude 'setup.rb:website/**' #{log_path} #{checkout_path}"
29
+ system cmd
30
+ end
data/bin/rubyrep ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
4
+
5
+ require 'rubyrep'
6
+
7
+ exit RR::CommandRunner.run(ARGV)
8
+
data/config/hoe.rb ADDED
@@ -0,0 +1,72 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/rubyrep'
2
+ #require 'rubyrep/version'
3
+
4
+ AUTHOR = 'Arndt Lehmann' # can also be an array of Authors
5
+ EMAIL = "mail@arndtlehman.com"
6
+ DESCRIPTION = "Asynchronous master-master replication of relational databases."
7
+ GEM_NAME = 'rubyrep' # what ppl will type to install your gem
8
+ RUBYFORGE_PROJECT = 'rubyrep' # The unix name for your project
9
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
10
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
11
+
12
+ @config_file = "~/.rubyforge/user-config.yml"
13
+ @config = nil
14
+ RUBYFORGE_USERNAME = "alehmann"
15
+ def rubyforge_username
16
+ unless @config
17
+ begin
18
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
19
+ rescue
20
+ puts <<-EOS
21
+ ERROR: No rubyforge config file found: #{@config_file}
22
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
23
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
24
+ EOS
25
+ exit
26
+ end
27
+ end
28
+ RUBYFORGE_USERNAME.replace @config["username"]
29
+ end
30
+
31
+
32
+ REV = nil
33
+ # UNCOMMENT IF REQUIRED:
34
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
35
+ VERS = RR::VERSION::STRING + (REV ? ".#{REV}" : "")
36
+
37
+ ENV['RDOCOPT'] = "-S -f html -T hanna"
38
+
39
+ class Hoe
40
+ def extra_deps
41
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
42
+ @extra_deps
43
+ end
44
+ end
45
+
46
+ # Generate all the Rake tasks
47
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
48
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
49
+ p.author = AUTHOR
50
+ p.description = DESCRIPTION
51
+ p.email = EMAIL
52
+ p.summary = DESCRIPTION
53
+ p.url = HOMEPATH
54
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
55
+ p.test_globs = ["test/**/test_*.rb"]
56
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
57
+
58
+ # == Optional
59
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
60
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
61
+ p.extra_deps = [
62
+ ['activesupport', '>= 2.2.2'],
63
+ ['activerecord' , '>= 2.2.2']
64
+ ]
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+
68
+ end
69
+
70
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
71
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
72
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''))
@@ -0,0 +1,25 @@
1
+ # Used as component of a rubyrep config file.
2
+ # Defines connection parameters to the mysql databases.
3
+
4
+ RR::Initializer::run do |config|
5
+ config.left = {
6
+ :adapter => 'mysql',
7
+ :database => 'rr_left',
8
+ :username => 'root',
9
+ :password => '',
10
+ :host => 'localhost',
11
+ :port => 3306,
12
+ :encoding => 'utf8'
13
+ }
14
+
15
+ config.right = {
16
+ :adapter => 'mysql',
17
+ :database => 'rr_right',
18
+ :username => 'root',
19
+ :password => '',
20
+ :host => 'localhost',
21
+ :port => 3306,
22
+ :encoding => 'utf8'
23
+ }
24
+
25
+ end
@@ -0,0 +1,21 @@
1
+ # Used as component of a rubyrep config file.
2
+ # Defines connection parameters to the postgresql databases.
3
+
4
+ RR::Initializer::run do |config|
5
+ config.left = {
6
+ :adapter => 'postgresql',
7
+ :database => 'rr_left',
8
+ :username => 'postgres',
9
+ :password => 'password',
10
+ :host => 'localhost'
11
+ }
12
+
13
+ config.right = {
14
+ :adapter => 'postgresql',
15
+ :database => 'rr_right',
16
+ :username => 'postgres',
17
+ :password => 'password',
18
+ :host => 'localhost'
19
+ }
20
+
21
+ end
@@ -0,0 +1,14 @@
1
+ # Rubyrep configuration file.
2
+ # "Proxyfies" test_config.rb.
3
+
4
+ load File.dirname(__FILE__) + '/test_config.rb'
5
+
6
+ # $start_proxy_as_external_process = true
7
+
8
+ RR::Initializer::run do |config|
9
+ config.left.merge!({
10
+ :proxy_host => 'localhost',
11
+ :proxy_port => '9876',
12
+ })
13
+
14
+ end
@@ -0,0 +1,17 @@
1
+ # Test configuration file for replication between two Redmine issue tracking
2
+ # systems
3
+
4
+ database = ENV['RR_TEST_DB'] ? ENV['RR_TEST_DB'] : :postgres
5
+
6
+ load File.dirname(__FILE__) + "/#{database}_config.rb"
7
+
8
+ RR::Initializer::run do |config|
9
+ config.left[:database] = 'leftmine'
10
+ config.right[:database] = 'rightmine'
11
+
12
+ config.include_tables(/./)
13
+ config.exclude_tables 'schema_migrations'
14
+ config.exclude_tables 'plugin_schema_infos'
15
+
16
+ config.options[:auto_key_limit] = 2
17
+ end
@@ -0,0 +1,20 @@
1
+ # Simple rubyrep configuration file.
2
+ # Intendet to be used for manual tests of the rubyrep commands.
3
+ #
4
+ # IMPORTANT:
5
+ # After completion of manual tests, use the 'db:test:rebuild' command to
6
+ # recreate the test databases.
7
+ # Otherwise the rspec tests will fail.
8
+
9
+ database = ENV['RR_TEST_DB'] ? ENV['RR_TEST_DB'] : :postgres
10
+ # $start_proxy_as_external_process = true
11
+
12
+ load File.dirname(__FILE__) + "/#{database}_config.rb"
13
+
14
+ RR::Initializer::run do |config|
15
+ config.options = {
16
+ }
17
+ config.include_tables 'scanner_left_records_only'
18
+ config.include_tables 'table_with_manual_key', :key => 'id'
19
+ config.include_tables 'extender_combined_key'
20
+ end
@@ -0,0 +1,32 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+
6
+ # Load essential gems. Exit if not available.
7
+ %w[rake activerecord].each do |req_gem|
8
+ begin
9
+ require req_gem
10
+ rescue LoadError
11
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
12
+ puts "Installation: gem install #{req_gem} -y"
13
+ exit
14
+ end
15
+ end
16
+
17
+ # Load gem builder / ruby-forge integration gems. Complain but continue if not available.
18
+ %w[hoe].each do |req_gem|
19
+ begin
20
+ require req_gem
21
+ rescue LoadError
22
+ # The jruby platform is probably only used for testing.
23
+ # So if on jruby, do not even complain.
24
+ if not RUBY_PLATFORM =~ /java/
25
+ puts "Without #{req_gem} rake tasks to build the gem / integrate the RubyForge will not be available."
26
+ end
27
+ end
28
+ end
29
+
30
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
31
+
32
+ require 'rubyrep'
@@ -0,0 +1,20 @@
1
+ # Simple rubyrep configuration file for use by rspec tests.
2
+ # Can be tweaked to either use mysql or postgresql.
3
+ #
4
+ # IMPORTANT:
5
+ # Due to configuration of committer :default will NOT work for manual running
6
+ # of rubyrep commands!
7
+
8
+ database = ENV['RR_TEST_DB'] ? ENV['RR_TEST_DB'] : :postgres
9
+ # $start_proxy_as_external_process = true
10
+
11
+ load File.dirname(__FILE__) + "/#{database}_config.rb"
12
+
13
+ RR::Initializer::run do |config|
14
+ config.options = {
15
+ :committer => :default,
16
+ :sync_conflict_handling => :left_wins
17
+ }
18
+ config.include_tables 'scanner_left_records_only'
19
+ config.include_tables 'table_with_manual_key', :key => 'id'
20
+ end
@@ -0,0 +1,195 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
2
+
3
+ require 'optparse'
4
+
5
+ module RR
6
+ # This class implements the base functionality for runners that process table
7
+ # specs.
8
+ class BaseRunner
9
+
10
+ # Default options if not overriden in command line
11
+ DEFAULT_OPTIONS = {
12
+ :table_specs => []
13
+ }
14
+
15
+ # Provided options. Possible values:
16
+ # * +:config_file+: path to config file
17
+ # * +:table_specs+: array of table specification strings
18
+ attr_accessor :options
19
+
20
+ # The class for the selected report printer
21
+ attr_accessor :report_printer_class
22
+
23
+ # The specified option parameter for the report printer
24
+ attr_accessor :report_printer_arg
25
+
26
+ # Returns the active ScanReportPrinters instance (as selected through the
27
+ # command line options OR if none was selected, the default one).
28
+ def report_printer
29
+ unless @report_printer
30
+ printer_class = report_printer_class || ScanReportPrinters::ScanSummaryReporter
31
+ @report_printer ||= printer_class.new(session, report_printer_arg)
32
+ end
33
+ @report_printer
34
+ end
35
+
36
+ # Returns the command line selected ScanProgressPrinters class
37
+ attr_accessor :selected_progress_printer
38
+
39
+ # Returns the active ScanProgressPrinter class (as selected through the
40
+ # command line options OR if none was selected, the default one).
41
+ def progress_printer
42
+ if selected_progress_printer
43
+ selected_progress_printer
44
+ else
45
+ printer_key = session.configuration.options[:scan_progress_printer]
46
+ ScanProgressPrinters.printers[printer_key][:printer_class]
47
+ end
48
+ end
49
+
50
+ # Returns the default command summary description (nothing).
51
+ # Should be overwritten by child classes.
52
+ def summary_description; ""; end
53
+
54
+ # Parses the given command line parameter array.
55
+ # Returns the status (as per UNIX conventions: 1 if parameters were invalid,
56
+ # 0 otherwise)
57
+ def process_options(args)
58
+ status = 0
59
+ self.options = DEFAULT_OPTIONS.clone
60
+
61
+ parser = OptionParser.new do |opts|
62
+ opts.banner = <<EOS
63
+ Usage: #{$0} #{self.class.name.sub(/^.*::(.*)Runner$/, '\\1').downcase} [options] [table_spec] [table_spec] ...
64
+
65
+ #{summary_description}
66
+
67
+ table_spec can be either:
68
+ * a specific table name (e. g. 'users') or
69
+ * a pair of (specific) table names (e. g.: 'users,users_backup')
70
+ (In this case the first table in the 'left' database is compared
71
+ with the second table in the 'right' database.)
72
+ * a regular expression (e. g. '/^user/') [case insensitive match]
73
+ If no table_specs are provided via command line, the ones from the
74
+ configuration file are used.
75
+ EOS
76
+ opts.separator ""
77
+ opts.separator " Specific options:"
78
+
79
+ ScanReportPrinters.on_printer_selection(opts) do |printer_class, arg|
80
+ self.report_printer_class = printer_class
81
+ self.report_printer_arg = arg
82
+ end
83
+
84
+ ScanProgressPrinters.on_printer_selection(opts) do |printer|
85
+ self.selected_progress_printer = printer
86
+ end
87
+
88
+ opts.on("-c", "--config", "=CONFIG_FILE",
89
+ "Mandatory. Path to configuration file.") do |arg|
90
+ options[:config_file] = arg
91
+ end
92
+
93
+ add_specific_options(opts)
94
+
95
+ opts.on_tail("--help", "Show this message") do
96
+ $stderr.puts opts
97
+ self.options = nil
98
+ end
99
+ end
100
+
101
+ begin
102
+ unprocessed_args = parser.parse!(args)
103
+ if options # this will be +nil+ if the --help option is specified
104
+ options[:table_specs] = unprocessed_args
105
+ raise("Please specify configuration file") unless options.include?(:config_file)
106
+ end
107
+ rescue Exception => e
108
+ $stderr.puts "Command line parsing failed: #{e}"
109
+ $stderr.puts parser.help
110
+ self.options = nil
111
+ status = 1
112
+ end
113
+
114
+ return status
115
+ end
116
+
117
+ # Signals scan completion to the (active) scan report printer if it supports
118
+ # that method.
119
+ def signal_scanning_completion
120
+ if report_printer.respond_to? :scanning_finished
121
+ report_printer.scanning_finished
122
+ end
123
+ end
124
+
125
+ # Creates a processor that does something with the given table.
126
+ # A processor needs to implement a +run+ method that yields for progress
127
+ # reporting purposes pairs of diff_type and row as defined under
128
+ # DirectTableScan#run.
129
+ def create_processor(left_table, right_table)
130
+ # not implemented in the base class
131
+ end
132
+
133
+ # Intended to be overwritten by derived classes that need to add additional
134
+ # options to the provided +OptionParser+ object.
135
+ def add_specific_options(opts)
136
+ end
137
+
138
+ # Intended to be overwritten by derived classes that need to modify the
139
+ # table_pairs.
140
+ # * table_pairs: array of table pairs as returned by TableSpecResolver#resolve
141
+ # Returns the new table pairs array.
142
+ def prepare_table_pairs(table_pairs)
143
+ table_pairs
144
+ end
145
+
146
+ # Returns the active +Session+.
147
+ # Loads config file and creates session if necessary.
148
+ def session
149
+ unless @session
150
+ load options[:config_file]
151
+ @session = Session.new Initializer.configuration
152
+ end
153
+ @session
154
+ end
155
+
156
+ attr_writer :session
157
+
158
+ # Returns the table pairs that should be processed.
159
+ # Refer to TableSpecRsolver#resolve for format of return value.
160
+ def table_pairs
161
+ prepare_table_pairs(session.configured_table_pairs(options[:table_specs]))
162
+ end
163
+
164
+ # Executes a run based on the established options.
165
+ def execute
166
+ session.configuration.exclude_rubyrep_tables
167
+ table_pairs.each do |table_pair|
168
+ report_printer.scan table_pair[:left], table_pair[:right] do
169
+ processor = create_processor \
170
+ table_pair[:left], table_pair[:right]
171
+ processor.progress_printer = progress_printer
172
+ processor.run do |diff_type, row|
173
+ report_printer.report_difference diff_type, row
174
+ end
175
+ end
176
+ end
177
+ signal_scanning_completion
178
+ end
179
+
180
+ # Entry points for executing a processing run.
181
+ # args: the array of command line options that were provided by the user.
182
+ def self.run(args)
183
+ runner = new
184
+
185
+ status = runner.process_options(args)
186
+ if runner.options
187
+ runner.execute
188
+ end
189
+ status
190
+ end
191
+
192
+ end
193
+ end
194
+
195
+