coupler 0.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. data/.document +5 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +1 -0
  4. data/.vimrc +40 -0
  5. data/Gemfile +27 -0
  6. data/Gemfile.lock +71 -0
  7. data/LICENSE +20 -0
  8. data/NOTES +6 -0
  9. data/README.rdoc +18 -0
  10. data/Rakefile +42 -0
  11. data/TODO +11 -0
  12. data/VERSION +1 -0
  13. data/bin/coupler +7 -0
  14. data/db/.gitignore +6 -0
  15. data/db/migrate/001_initial_schema.rb +166 -0
  16. data/db/migrate/002_stub.rb +4 -0
  17. data/db/migrate/003_stub.rb +4 -0
  18. data/db/migrate/004_create_comparisons.rb +28 -0
  19. data/db/migrate/005_move_database_name.rb +19 -0
  20. data/db/migrate/006_upgrade_comparisons.rb +34 -0
  21. data/db/migrate/007_add_which_to_comparisons.rb +23 -0
  22. data/db/migrate/008_add_result_field_to_transformations.rb +33 -0
  23. data/db/migrate/009_add_generated_flag_to_fields.rb +13 -0
  24. data/db/migrate/010_create_imports.rb +24 -0
  25. data/db/migrate/011_add_primary_key_type.rb +13 -0
  26. data/db/migrate/012_add_transformed_with_to_resources.rb +13 -0
  27. data/db/migrate/013_add_run_count_to_scenarios.rb +13 -0
  28. data/db/migrate/014_add_last_accessed_at_to_some_tables.rb +13 -0
  29. data/db/migrate/015_add_run_number_to_results.rb +15 -0
  30. data/db/migrate/016_fix_scenario_run_count.rb +27 -0
  31. data/db/migrate/017_rename_comparison_columns.rb +14 -0
  32. data/db/migrate/018_fix_scenario_linkage_type.rb +8 -0
  33. data/db/migrate/019_add_columns_to_imports.rb +24 -0
  34. data/db/migrate/020_rename_import_columns.rb +12 -0
  35. data/db/migrate/021_add_fields_to_connections.rb +15 -0
  36. data/db/migrate/022_remove_database_name_from_resources.rb +11 -0
  37. data/features/connections.feature +28 -0
  38. data/features/matchers.feature +35 -0
  39. data/features/projects.feature +11 -0
  40. data/features/resources.feature +62 -0
  41. data/features/scenarios.feature +45 -0
  42. data/features/step_definitions/coupler_steps.rb +145 -0
  43. data/features/step_definitions/matchers_steps.rb +26 -0
  44. data/features/step_definitions/resources_steps.rb +12 -0
  45. data/features/step_definitions/scenarios_steps.rb +7 -0
  46. data/features/step_definitions/transformations_steps.rb +3 -0
  47. data/features/support/env.rb +128 -0
  48. data/features/transformations.feature +22 -0
  49. data/features/wizard.feature +10 -0
  50. data/gfx/coupler-header.svg +213 -0
  51. data/gfx/coupler-sidebar.svg +656 -0
  52. data/gfx/coupler.svg +184 -0
  53. data/gfx/icon.svg +75 -0
  54. data/lib/coupler/base.rb +63 -0
  55. data/lib/coupler/config.rb +128 -0
  56. data/lib/coupler/data_uploader.rb +20 -0
  57. data/lib/coupler/database.rb +31 -0
  58. data/lib/coupler/extensions/connections.rb +57 -0
  59. data/lib/coupler/extensions/exceptions.rb +58 -0
  60. data/lib/coupler/extensions/imports.rb +43 -0
  61. data/lib/coupler/extensions/jobs.rb +21 -0
  62. data/lib/coupler/extensions/matchers.rb +64 -0
  63. data/lib/coupler/extensions/projects.rb +62 -0
  64. data/lib/coupler/extensions/resources.rb +89 -0
  65. data/lib/coupler/extensions/results.rb +100 -0
  66. data/lib/coupler/extensions/scenarios.rb +50 -0
  67. data/lib/coupler/extensions/transformations.rb +70 -0
  68. data/lib/coupler/extensions/transformers.rb +58 -0
  69. data/lib/coupler/extensions.rb +16 -0
  70. data/lib/coupler/helpers.rb +121 -0
  71. data/lib/coupler/import_buffer.rb +48 -0
  72. data/lib/coupler/logger.rb +16 -0
  73. data/lib/coupler/models/common_model.rb +104 -0
  74. data/lib/coupler/models/comparison.rb +166 -0
  75. data/lib/coupler/models/connection.rb +59 -0
  76. data/lib/coupler/models/field.rb +55 -0
  77. data/lib/coupler/models/import.rb +238 -0
  78. data/lib/coupler/models/job.rb +42 -0
  79. data/lib/coupler/models/jobify.rb +17 -0
  80. data/lib/coupler/models/matcher.rb +36 -0
  81. data/lib/coupler/models/project.rb +40 -0
  82. data/lib/coupler/models/resource.rb +287 -0
  83. data/lib/coupler/models/result.rb +92 -0
  84. data/lib/coupler/models/scenario/runner.rb +357 -0
  85. data/lib/coupler/models/scenario.rb +115 -0
  86. data/lib/coupler/models/transformation.rb +117 -0
  87. data/lib/coupler/models/transformer/runner.rb +28 -0
  88. data/lib/coupler/models/transformer.rb +110 -0
  89. data/lib/coupler/models.rb +30 -0
  90. data/lib/coupler/runner.rb +76 -0
  91. data/lib/coupler/scheduler.rb +56 -0
  92. data/lib/coupler.rb +34 -0
  93. data/log/.gitignore +1 -0
  94. data/misc/README +5 -0
  95. data/misc/jruby-json.license +57 -0
  96. data/misc/rack-flash.license +22 -0
  97. data/script/dbconsole.rb +5 -0
  98. data/src/edu/vanderbilt/coupler/Main.java +116 -0
  99. data/src/edu/vanderbilt/coupler/jruby.properties +1 -0
  100. data/tasks/annotations.rake +84 -0
  101. data/tasks/db.rake +120 -0
  102. data/tasks/environment.rake +12 -0
  103. data/tasks/jeweler.rake +43 -0
  104. data/tasks/package.rake +58 -0
  105. data/tasks/rdoc.rake +13 -0
  106. data/tasks/test.rake +63 -0
  107. data/tasks/vendor.rake +43 -0
  108. data/test/README.txt +6 -0
  109. data/test/config.yml +9 -0
  110. data/test/coupler/models/test_import.rb +221 -0
  111. data/test/factories.rb +91 -0
  112. data/test/fixtures/duplicate-keys.csv +5 -0
  113. data/test/fixtures/no-headers.csv +50 -0
  114. data/test/fixtures/people.csv +51 -0
  115. data/test/fixtures/varying-row-size.csv +4 -0
  116. data/test/helper.rb +156 -0
  117. data/test/integration/extensions/test_connections.rb +80 -0
  118. data/test/integration/extensions/test_imports.rb +94 -0
  119. data/test/integration/extensions/test_jobs.rb +52 -0
  120. data/test/integration/extensions/test_matchers.rb +134 -0
  121. data/test/integration/extensions/test_projects.rb +82 -0
  122. data/test/integration/extensions/test_resources.rb +150 -0
  123. data/test/integration/extensions/test_results.rb +89 -0
  124. data/test/integration/extensions/test_scenarios.rb +88 -0
  125. data/test/integration/extensions/test_transformations.rb +113 -0
  126. data/test/integration/extensions/test_transformers.rb +80 -0
  127. data/test/integration/test_field.rb +45 -0
  128. data/test/integration/test_import.rb +78 -0
  129. data/test/integration/test_running_scenarios.rb +379 -0
  130. data/test/integration/test_transformation.rb +56 -0
  131. data/test/integration/test_transforming.rb +154 -0
  132. data/test/table_sets.rb +76 -0
  133. data/test/unit/models/test_common_model.rb +130 -0
  134. data/test/unit/models/test_comparison.rb +619 -0
  135. data/test/unit/models/test_connection.rb +115 -0
  136. data/test/unit/models/test_field.rb +99 -0
  137. data/test/unit/models/test_import.rb +130 -0
  138. data/test/unit/models/test_job.rb +115 -0
  139. data/test/unit/models/test_matcher.rb +82 -0
  140. data/test/unit/models/test_project.rb +102 -0
  141. data/test/unit/models/test_resource.rb +564 -0
  142. data/test/unit/models/test_result.rb +90 -0
  143. data/test/unit/models/test_scenario.rb +199 -0
  144. data/test/unit/models/test_transformation.rb +193 -0
  145. data/test/unit/models/test_transformer.rb +188 -0
  146. data/test/unit/test_base.rb +60 -0
  147. data/test/unit/test_data_uploader.rb +27 -0
  148. data/test/unit/test_database.rb +23 -0
  149. data/test/unit/test_helpers.rb +58 -0
  150. data/test/unit/test_logger.rb +10 -0
  151. data/test/unit/test_models.rb +12 -0
  152. data/test/unit/test_runner.rb +76 -0
  153. data/test/unit/test_scheduler.rb +66 -0
  154. data/uploads/.gitignore +2 -0
  155. data/vendor/java/.gitignore +5 -0
  156. data/webroot/public/css/960.css +1 -0
  157. data/webroot/public/css/dataTables.css +1057 -0
  158. data/webroot/public/css/jquery-ui.css +572 -0
  159. data/webroot/public/css/jquery.treeview.css +68 -0
  160. data/webroot/public/css/reset.css +1 -0
  161. data/webroot/public/css/style.css +504 -0
  162. data/webroot/public/css/text.css +1 -0
  163. data/webroot/public/favicon.ico +0 -0
  164. data/webroot/public/images/12_col.gif +0 -0
  165. data/webroot/public/images/16_col.gif +0 -0
  166. data/webroot/public/images/add.png +0 -0
  167. data/webroot/public/images/ajax-loader.gif +0 -0
  168. data/webroot/public/images/cog.png +0 -0
  169. data/webroot/public/images/coupler.png +0 -0
  170. data/webroot/public/images/foo.png +0 -0
  171. data/webroot/public/images/hammer.png +0 -0
  172. data/webroot/public/images/header.png +0 -0
  173. data/webroot/public/images/home.gif +0 -0
  174. data/webroot/public/images/jobs.gif +0 -0
  175. data/webroot/public/images/sidebar-bottom.png +0 -0
  176. data/webroot/public/images/sidebar.png +0 -0
  177. data/webroot/public/images/treeview-default-line.gif +0 -0
  178. data/webroot/public/images/treeview-default.gif +0 -0
  179. data/webroot/public/images/ui-anim_basic_16x16.gif +0 -0
  180. data/webroot/public/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  181. data/webroot/public/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  182. data/webroot/public/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  183. data/webroot/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  184. data/webroot/public/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  185. data/webroot/public/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  186. data/webroot/public/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  187. data/webroot/public/images/ui-bg_highlight-hard_30_565356_1x100.png +0 -0
  188. data/webroot/public/images/ui-bg_highlight-hard_75_888588_1x100.png +0 -0
  189. data/webroot/public/images/ui-bg_highlight-soft_30_6e3b3a_1x100.png +0 -0
  190. data/webroot/public/images/ui-bg_highlight-soft_35_8e8b8e_1x100.png +0 -0
  191. data/webroot/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  192. data/webroot/public/images/ui-icons_222222_256x240.png +0 -0
  193. data/webroot/public/images/ui-icons_2e83ff_256x240.png +0 -0
  194. data/webroot/public/images/ui-icons_454545_256x240.png +0 -0
  195. data/webroot/public/images/ui-icons_888888_256x240.png +0 -0
  196. data/webroot/public/images/ui-icons_cd0a0a_256x240.png +0 -0
  197. data/webroot/public/images/ui-icons_ffffff_256x240.png +0 -0
  198. data/webroot/public/js/ajaxupload.js +673 -0
  199. data/webroot/public/js/application.js +40 -0
  200. data/webroot/public/js/jquery-ui.combobox.js +98 -0
  201. data/webroot/public/js/jquery-ui.js +9867 -0
  202. data/webroot/public/js/jquery-ui.min.js +559 -0
  203. data/webroot/public/js/jquery.dataTables.min.js +587 -0
  204. data/webroot/public/js/jquery.min.js +154 -0
  205. data/webroot/public/js/jquery.timeago.js +140 -0
  206. data/webroot/public/js/jquery.tooltip.min.js +19 -0
  207. data/webroot/public/js/jquery.treeview.min.js +15 -0
  208. data/webroot/public/js/resource.js +11 -0
  209. data/webroot/public/js/results.js +56 -0
  210. data/webroot/public/js/transformations.js +95 -0
  211. data/webroot/views/connections/index.erb +5 -0
  212. data/webroot/views/connections/list.erb +34 -0
  213. data/webroot/views/connections/new.erb +55 -0
  214. data/webroot/views/connections/show.erb +36 -0
  215. data/webroot/views/imports/edit.erb +60 -0
  216. data/webroot/views/imports/form.erb +81 -0
  217. data/webroot/views/imports/new.erb +89 -0
  218. data/webroot/views/index.erb +12 -0
  219. data/webroot/views/jobs/index.erb +7 -0
  220. data/webroot/views/jobs/list.erb +24 -0
  221. data/webroot/views/layout.erb +38 -0
  222. data/webroot/views/matchers/form.erb +250 -0
  223. data/webroot/views/matchers/list.erb +32 -0
  224. data/webroot/views/projects/form.erb +14 -0
  225. data/webroot/views/projects/index.erb +96 -0
  226. data/webroot/views/projects/show.erb +24 -0
  227. data/webroot/views/resources/edit.erb +88 -0
  228. data/webroot/views/resources/index.erb +5 -0
  229. data/webroot/views/resources/list.erb +27 -0
  230. data/webroot/views/resources/new.erb +121 -0
  231. data/webroot/views/resources/show.erb +86 -0
  232. data/webroot/views/resources/transform.erb +2 -0
  233. data/webroot/views/results/csv.erb +12 -0
  234. data/webroot/views/results/details.erb +15 -0
  235. data/webroot/views/results/index.erb +2 -0
  236. data/webroot/views/results/list.erb +22 -0
  237. data/webroot/views/results/record.erb +24 -0
  238. data/webroot/views/results/show.erb +68 -0
  239. data/webroot/views/scenarios/index.erb +5 -0
  240. data/webroot/views/scenarios/list.erb +20 -0
  241. data/webroot/views/scenarios/new.erb +99 -0
  242. data/webroot/views/scenarios/run.erb +2 -0
  243. data/webroot/views/scenarios/show.erb +50 -0
  244. data/webroot/views/sidebar.erb +106 -0
  245. data/webroot/views/transformations/create.erb +115 -0
  246. data/webroot/views/transformations/for.erb +16 -0
  247. data/webroot/views/transformations/index.erb +2 -0
  248. data/webroot/views/transformations/list.erb +29 -0
  249. data/webroot/views/transformations/new.erb +126 -0
  250. data/webroot/views/transformations/preview.erb +46 -0
  251. data/webroot/views/transformers/edit.erb +6 -0
  252. data/webroot/views/transformers/form.erb +58 -0
  253. data/webroot/views/transformers/index.erb +2 -0
  254. data/webroot/views/transformers/list.erb +25 -0
  255. data/webroot/views/transformers/new.erb +5 -0
  256. data/webroot/views/transformers/preview.erb +23 -0
  257. data/webroot/views/transformers/show.erb +0 -0
  258. metadata +558 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "pages"]
2
+ path = pages
3
+ url = git@github.com:coupler/coupler.github.com.git
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm jruby
data/.vimrc ADDED
@@ -0,0 +1,40 @@
1
+ function! s:AlternateFile()
2
+ let fn = substitute(expand('%'), "^".getcwd()."/", "", "")
3
+ let head = fnamemodify(fn, ':h')
4
+ let tail = fnamemodify(fn, ':t')
5
+
6
+ if match(head, '^lib/coupler/extensions') >= 0
7
+ return substitute(head, '^lib/coupler', 'test/integration', '').'/test_'.tail
8
+ elseif match(head, '^lib') >= 0
9
+ return substitute(head, '^lib/coupler', 'test/unit', '').'/test_'.tail
10
+ elseif match(head, '^test/integration/extensions') >= 0
11
+ return substitute(head, '^test/integration', 'lib/coupler', '').'/'.substitute(tail, '^test_', '', '')
12
+ elseif match(head, '^test') >= 0
13
+ return substitute(head, '^test/unit', 'lib/coupler', '').'/'.substitute(tail, '^test_', '', '')
14
+ endif
15
+ return ''
16
+ endfunction
17
+
18
+ function! s:Alternate(cmd)
19
+ let file = s:AlternateFile()
20
+ "if file != '' && filereadable(file)
21
+ if a:cmd == 'T'
22
+ let cmd = 'tabe'
23
+ elseif a:cmd == 'S'
24
+ let cmd = 'sp'
25
+ else
26
+ let cmd = 'e'
27
+ endif
28
+ exe ':'.cmd.' '.file
29
+ "else
30
+ "echomsg 'No alternate file is defined: '.file
31
+ "endif
32
+ endfunction
33
+
34
+ command! A :call s:Alternate('')
35
+ command! AE :call s:Alternate('E')
36
+ command! AS :call s:Alternate('S')
37
+ command! AV :call s:Alternate('V')
38
+ command! AT :call s:Alternate('T')
39
+
40
+ let @a='OHv/def
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ source "http://rubygems.org"
2
+ gem 'sinatra'
3
+ gem 'sequel'
4
+ gem 'rack-flash'
5
+ gem 'json'
6
+ gem 'fastercsv'
7
+ gem 'carrierwave'
8
+ gem 'mongrel'
9
+ gem 'jdbc-mysql'
10
+ #gem 'mvn:com.h2database:h2'
11
+
12
+ group :development do
13
+ gem 'rake'
14
+ gem 'jeweler'
15
+ gem 'forgery', :require => false
16
+ gem 'test-unit', '2.2.0', :require => 'test/unit'
17
+ gem 'mocha'
18
+ gem 'rack-test', :require => 'rack/test'
19
+ gem 'nokogiri'
20
+ gem 'timecop'
21
+ gem 'factory_girl'
22
+ gem 'git'
23
+ gem 'thor'
24
+ gem 'rake'
25
+ gem 'table_maker'
26
+ gem 'ruby-debug'
27
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.0.7)
5
+ carrierwave (0.5.3)
6
+ activesupport (~> 3.0)
7
+ columnize (0.3.2)
8
+ factory_girl (1.3.3)
9
+ fastercsv (1.5.4)
10
+ forgery (0.3.8)
11
+ nokogiri (~> 1.4)
12
+ gem_plugin (0.2.3)
13
+ git (1.2.5)
14
+ jdbc-mysql (5.1.13)
15
+ jeweler (1.6.0)
16
+ bundler (~> 1.0.0)
17
+ git (>= 1.2.5)
18
+ rake
19
+ json (1.5.1-java)
20
+ mocha (0.9.12)
21
+ mongrel (1.1.5-java)
22
+ gem_plugin (>= 0.2.3)
23
+ nokogiri (1.4.4.2-java)
24
+ weakling (>= 0.0.3)
25
+ rack (1.2.2)
26
+ rack-flash (0.1.1)
27
+ rack
28
+ rack-test (0.6.0)
29
+ rack (>= 1.0)
30
+ rake (0.8.7)
31
+ ruby-debug (0.10.4)
32
+ columnize (>= 0.1)
33
+ ruby-debug-base (~> 0.10.4.0)
34
+ ruby-debug-base (0.10.4-java)
35
+ sequel (3.23.0)
36
+ sinatra (1.2.6)
37
+ rack (~> 1.1)
38
+ tilt (>= 1.2.2, < 2.0)
39
+ table_maker (0.0.2)
40
+ sequel
41
+ test-unit (2.2.0)
42
+ thor (0.14.6)
43
+ tilt (1.3)
44
+ timecop (0.3.5)
45
+ weakling (0.0.4-java)
46
+
47
+ PLATFORMS
48
+ java
49
+
50
+ DEPENDENCIES
51
+ carrierwave
52
+ factory_girl
53
+ fastercsv
54
+ forgery
55
+ git
56
+ jdbc-mysql
57
+ jeweler
58
+ json
59
+ mocha
60
+ mongrel
61
+ nokogiri
62
+ rack-flash
63
+ rack-test
64
+ rake
65
+ ruby-debug
66
+ sequel
67
+ sinatra
68
+ table_maker
69
+ test-unit (= 2.2.0)
70
+ thor
71
+ timecop
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009, 2010, 2011 Vanderbilt University
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/NOTES ADDED
@@ -0,0 +1,6 @@
1
+ How to run IRB with JDBC/MySQL
2
+ ------------------------------
3
+
4
+ GEM_HOME=/opt/jruby/lib/ruby/gems/1.8 java -cp \
5
+ vendor/java/mysql-connector-java-5.1.13/mysql-connector-java-5.1.13-bin.jar:vendor/java/jruby-complete.jar \
6
+ org.jruby.Main -S irb
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = coupler
2
+
3
+ Coupler is a Sinatra application for linking databases together.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009-2011 Vanderbilt University. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ if RUBY_PLATFORM != 'java'
2
+ puts "ERROR: JRuby is required to run Coupler."
3
+ exit
4
+ end
5
+
6
+ require 'open-uri'
7
+ require 'tempfile'
8
+ require 'fileutils'
9
+ require 'rubygems'
10
+ require 'bundler'
11
+ begin
12
+ Bundler.setup(:default, :development)
13
+ rescue Bundler::BundlerError => e
14
+ $stderr.puts e.message
15
+ $stderr.puts "Run `bundle install` to install missing gems"
16
+ exit e.status_code
17
+ end
18
+ require 'rake'
19
+
20
+ def confirm(prompt)
21
+ answer = nil
22
+ while answer != "y" && answer != "n"
23
+ print "#{prompt} Are you sure? [yn] "
24
+ $stdout.flush
25
+ answer = $stdin.gets.chomp.downcase
26
+ end
27
+ exit if answer == "n"
28
+ end
29
+
30
+ alias :original_ruby :ruby
31
+ def ruby(*args, &block)
32
+ # turn on objectspace (for nokogiri)
33
+ unless String === args[0]
34
+ args = [""] + args
35
+ end
36
+ args[0] = "-X+O #{args[0]}"
37
+ original_ruby(args, &block)
38
+ end
39
+
40
+ Dir['tasks/*.rake'].sort.each { |f| import f }
41
+
42
+ task :default => :test
data/TODO ADDED
@@ -0,0 +1,11 @@
1
+ Major features/bugs:
2
+ - Job management: canceling, etc.
3
+ - Chain matchers
4
+ - package:dist changes bundler config; fix this!
5
+
6
+ Other ideas:
7
+ - Do authorization on projects
8
+ - Allow user to enter resource password whenever needed; don't store it
9
+ - Better migrations based on commit hashes
10
+ - Use classes in a previous state
11
+ - Run migrations before upgrading code, or vice versa
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/coupler ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env jruby
2
+ require 'rubygems'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
+ require 'coupler'
6
+
7
+ Coupler::Runner.new
data/db/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ test
2
+ production
3
+ development
4
+ bin
5
+ data
6
+ share
@@ -0,0 +1,166 @@
1
+ class InitialSchema < Sequel::Migration
2
+ def up
3
+ create_table(:connections) do
4
+ primary_key :id
5
+ String :name
6
+ String :slug
7
+ String :adapter
8
+ String :host
9
+ Integer :port
10
+ String :username
11
+ String :password
12
+ String :database_name
13
+ Time :created_at
14
+ Time :updated_at
15
+ end
16
+
17
+ [:projects, :projects_versions].each do |name|
18
+ create_table(name) do
19
+ primary_key :id
20
+ String :name
21
+ String :slug
22
+ String :description
23
+ Integer :version, :default => 0
24
+ Integer :current_id if name.to_s =~ /_versions$/
25
+ Time :created_at
26
+ Time :updated_at
27
+ end
28
+ end
29
+
30
+ [:resources, :resources_versions].each do |name|
31
+ create_table(name) do
32
+ primary_key :id
33
+ String :name
34
+ String :slug
35
+ String :table_name
36
+ String :primary_key_name, :default => "id"
37
+ Integer :connection_id
38
+ Integer :project_id
39
+ Integer :version, :default => 0
40
+ Integer :current_id if name.to_s =~ /_versions$/
41
+ Time :transformed_at
42
+ Time :created_at
43
+ Time :updated_at
44
+ end
45
+ end
46
+
47
+ [:fields, :fields_versions].each do |name|
48
+ create_table(name) do
49
+ primary_key :id
50
+ String :name
51
+ String :type
52
+ String :db_type
53
+ String :local_type
54
+ String :local_db_type
55
+ Boolean :is_primary_key, :default => false
56
+ Boolean :is_selected, :default => true
57
+ Integer :resource_id
58
+ Integer :version, :default => 0
59
+ Integer :current_id if name.to_s =~ /_versions$/
60
+ Time :created_at
61
+ Time :updated_at
62
+ end
63
+ end
64
+
65
+ [:transformers, :transformers_versions].each do |name|
66
+ create_table(name) do
67
+ primary_key :id
68
+ String :name
69
+ Text :code
70
+ String :allowed_types
71
+ String :result_type
72
+ Integer :version, :default => 0
73
+ Integer :current_id if name.to_s =~ /_versions$/
74
+ Time :created_at
75
+ Time :updated_at
76
+ end
77
+ end
78
+
79
+ [:transformations, :transformations_versions].each do |name|
80
+ create_table(name) do
81
+ primary_key :id
82
+ Integer :transformer_id
83
+ Integer :field_id
84
+ Integer :resource_id
85
+ Integer :version, :default => 0
86
+ Integer :current_id if name.to_s =~ /_versions$/
87
+ Time :created_at
88
+ Time :updated_at
89
+ end
90
+ end
91
+
92
+ [:scenarios, :scenarios_versions].each do |name|
93
+ create_table(name) do
94
+ primary_key :id
95
+ String :name
96
+ String :slug
97
+ String :description
98
+ Integer :project_id
99
+ Integer :resource_1_id
100
+ Integer :resource_2_id
101
+ String :linkage_type
102
+ Integer :score_set_id
103
+ Integer :version, :default => 0
104
+ Integer :current_id if name.to_s =~ /_versions$/
105
+ Time :last_run_at
106
+ Time :created_at
107
+ Time :updated_at
108
+ end
109
+ end
110
+
111
+ [:matchers, :matchers_versions].each do |name|
112
+ create_table(name) do
113
+ primary_key :id
114
+ String :comparator_name
115
+ Text :comparator_options
116
+ Integer :scenario_id
117
+ Integer :version, :default => 0
118
+ Integer :current_id if name.to_s =~ /_versions$/
119
+ Time :created_at
120
+ Time :updated_at
121
+ end
122
+ end
123
+
124
+ create_table :jobs do
125
+ primary_key :id
126
+ String :name
127
+ String :status
128
+ Integer :resource_id
129
+ Integer :scenario_id
130
+ Integer :total, :default => 0
131
+ Integer :completed, :default => 0
132
+ Time :created_at
133
+ Time :updated_at
134
+ Time :started_at
135
+ Time :completed_at
136
+ end
137
+
138
+ create_table :results do
139
+ primary_key :id
140
+ Integer :scenario_id
141
+ Integer :scenario_version
142
+ Integer :score_set_id
143
+ Time :created_at
144
+ Time :updated_at
145
+ end
146
+ end
147
+
148
+ def down
149
+ drop_table(
150
+ :projects,
151
+ :projects_versions,
152
+ :resources,
153
+ :resources_versions,
154
+ :transformers,
155
+ :transformers_versions,
156
+ :transformations,
157
+ :transformations_versions,
158
+ :scenarios,
159
+ :scenarios_versions,
160
+ :matchers,
161
+ :matchers_versions,
162
+ :jobs,
163
+ :results
164
+ )
165
+ end
166
+ end
@@ -0,0 +1,4 @@
1
+ Sequel.migration do
2
+ up { }
3
+ down { }
4
+ end
@@ -0,0 +1,4 @@
1
+ Sequel.migration do
2
+ up { }
3
+ down { }
4
+ end
@@ -0,0 +1,28 @@
1
+ class CreateComparisons < Sequel::Migration
2
+ def up
3
+ create_table :comparisons do
4
+ primary_key :id
5
+ Integer :matcher_id
6
+ Integer :matcher_version
7
+ Integer :field_1_id
8
+ Integer :field_2_id
9
+ Time :created_at
10
+ Time :updated_at
11
+ end
12
+
13
+ [:matchers, :matchers_versions].each do |name|
14
+ alter_table(name) do
15
+ drop_column :comparator_options
16
+ end
17
+ end
18
+ end
19
+
20
+ def down
21
+ [:matchers, :matchers_versions].each do |name|
22
+ alter_table(name) do
23
+ add_column :comparator_options, :text
24
+ end
25
+ end
26
+ drop_table :comparisons
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ class MoveDatabaseName < Sequel::Migration
2
+ def up
3
+ [:resources, :resources_versions].each do |name|
4
+ alter_table(name) { add_column(:database_name, String) }
5
+ end
6
+
7
+ self[:connections].each do |connection|
8
+ [:resources, :resources_versions].each do |name|
9
+ self[name].filter(:connection_id => connection[:id]).update(:database_name => connection[:database_name])
10
+ end
11
+ end
12
+
13
+ alter_table(:connections) { drop_column(:database_name) }
14
+ end
15
+
16
+ def down
17
+ raise "This migration is not reversible."
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ class UpgradeComparisons < Sequel::Migration
2
+ def marshal(v)
3
+ [Marshal.dump(v)].pack('m')
4
+ end
5
+
6
+ def up
7
+ alter_table(:comparisons) do
8
+ add_column :lhs_type, String
9
+ add_column :lhs_value, String
10
+ add_column :operator, String
11
+ add_column :rhs_type, String
12
+ add_column :rhs_value, String
13
+ end
14
+ dataset = self[:comparisons]
15
+ dataset.each do |comparison|
16
+ dataset.filter(:id => comparison[:id]).update({
17
+ :lhs_type => "field", :lhs_value => marshal(comparison[:field_1_id]),
18
+ :rhs_type => "field", :rhs_value => marshal(comparison[:field_2_id]),
19
+ :operator => "equals"
20
+ })
21
+ end
22
+ alter_table(:comparisons) do
23
+ drop_column :field_1_id
24
+ drop_column :field_2_id
25
+ end
26
+
27
+ alter_table(:matchers) { drop_column(:comparator_name) }
28
+ alter_table(:matchers_versions) { drop_column(:comparator_name) }
29
+ end
30
+
31
+ def down
32
+ raise "This migration is not reversible."
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ Sequel.migration do
2
+ up do
3
+ alter_table :comparisons do
4
+ add_column :lhs_which, Integer
5
+ add_column :rhs_which, Integer
6
+ end
7
+ ds = self[:comparisons].
8
+ select(:comparisons__id).
9
+ join(:matchers, :matchers__id => :comparisons__matcher_id).
10
+ join(:scenarios, :scenarios__id => :matchers__scenario_id).
11
+ filter(:scenarios__resource_2_id => nil)
12
+ ids = ds.all.collect { |x| x[:id] }
13
+ self[:comparisons].filter(:id => ids, :lhs_type => 'field').update(:lhs_which => 1)
14
+ self[:comparisons].filter(:id => ids, :rhs_type => 'field').update(:rhs_which => 2)
15
+ end
16
+
17
+ down do
18
+ alter_table :comparisons do
19
+ drop_column :lhs_which
20
+ drop_column :rhs_which
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ Sequel.migration do
2
+ up do
3
+ [:transformations, :transformations_versions].each do |name|
4
+ alter_table(name) do
5
+ rename_column(:field_id, :source_field_id)
6
+ add_column(:result_field_id, Integer)
7
+ add_column(:position, Integer)
8
+ end
9
+ self[name].update(:result_field_id => :source_field_id)
10
+
11
+ position = nil
12
+ last_resource_id = nil
13
+ self[name].order(:id).each do |record|
14
+ if record[:resource_id] != last_resource_id
15
+ position = 0
16
+ last_resource_id = record[:resource_id]
17
+ end
18
+ position += 1
19
+ self[name].filter(:id => record[:id]).update(:position => position)
20
+ end
21
+ end
22
+ end
23
+
24
+ down do
25
+ [:transformations, :transformations_versions].each do |name|
26
+ alter_table(name) do
27
+ rename_column(:source_field_id, :field_id)
28
+ drop_column(:result_field_id)
29
+ drop_column(:position)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,13 @@
1
+ Sequel.migration do
2
+ up do
3
+ [:fields, :fields_versions].each do |name|
4
+ alter_table(name) { add_column(:is_generated, :boolean, :default => false) }
5
+ self[name].update(:is_generated => false)
6
+ end
7
+ end
8
+
9
+ down do
10
+ alter_table(:fields) { drop_column(:is_generated) }
11
+ alter_table(:fields_versions) { drop_column(:is_generated) }
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ Sequel.migration do
2
+ up do
3
+ create_table :imports do
4
+ primary_key :id
5
+ String :name
6
+ String :data
7
+ String :type, :default => "csv"
8
+ Text :fields
9
+ Integer :project_id
10
+ Time :created_at
11
+ Time :updated_at
12
+ end
13
+ [:resources, :resources_versions].each do |name|
14
+ alter_table(name) { add_column :import_id, Integer }
15
+ end
16
+ end
17
+
18
+ down do
19
+ [:resources, :resources_versions].each do |name|
20
+ alter_table(name) { drop_column :import_id }
21
+ end
22
+ drop_table :imports
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ Sequel.migration do
2
+ up do
3
+ [:resources, :resources_versions].each do |name|
4
+ alter_table(name) { add_column(:primary_key_type, String) }
5
+ self[name].update(:primary_key_type => 'integer')
6
+ end
7
+ end
8
+
9
+ down do
10
+ alter_table(:resources) { drop_column(:primary_key_type) }
11
+ alter_table(:resources_versions) { drop_column(:primary_key_type) }
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ Sequel.migration do
2
+ up do
3
+ [:resources, :resources_versions].each do |name|
4
+ alter_table(name) { add_column(:transformed_with, String) }
5
+ end
6
+ end
7
+
8
+ down do
9
+ [:resources, :resources_versions].each do |name|
10
+ alter_table(name) { drop_column(:transformed_with) }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ Sequel.migration do
2
+ up do
3
+ [:scenarios, :scenarios_versions].each do |name|
4
+ alter_table(name) { add_column(:run_count, Integer, :default => 0) }
5
+ end
6
+ end
7
+
8
+ down do
9
+ [:scenarios, :scenarios_versions].each do |name|
10
+ alter_table(name) { drop_column(:run_count) }
11
+ end
12
+ end
13
+ end