coupler 0.0.4-java → 0.0.6-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/Gemfile +7 -8
  2. data/Gemfile.lock +43 -24
  3. data/VERSION +1 -1
  4. data/coupler.gemspec +27 -31
  5. data/features/wizard.feature +2 -1
  6. data/lib/coupler.rb +2 -2
  7. data/lib/coupler/base.rb +4 -0
  8. data/lib/coupler/extensions/connections.rb +2 -12
  9. data/lib/coupler/extensions/jobs.rb +4 -2
  10. data/lib/coupler/extensions/projects.rb +1 -1
  11. data/lib/coupler/helpers.rb +9 -1
  12. data/lib/coupler/models.rb +8 -0
  13. data/lib/coupler/models/comparison.rb +5 -4
  14. data/lib/coupler/models/connection.rb +10 -1
  15. data/lib/coupler/models/import.rb +3 -7
  16. data/lib/coupler/models/transformer.rb +1 -1
  17. data/lib/coupler/runner.rb +1 -1
  18. data/lib/coupler/scheduler.rb +1 -1
  19. data/tasks/test.rake +8 -0
  20. data/test/functional/test_base.rb +17 -0
  21. data/test/functional/test_connections.rb +81 -0
  22. data/test/functional/test_imports.rb +76 -0
  23. data/test/{integration/extensions → functional}/test_jobs.rb +21 -12
  24. data/test/functional/test_matchers.rb +108 -0
  25. data/test/functional/test_projects.rb +67 -0
  26. data/test/functional/test_resources.rb +126 -0
  27. data/test/{integration/extensions → functional}/test_results.rb +20 -29
  28. data/test/functional/test_scenarios.rb +92 -0
  29. data/test/functional/test_transformations.rb +106 -0
  30. data/test/functional/test_transformers.rb +68 -0
  31. data/test/helper.rb +30 -20
  32. data/test/integration/test_transformation.rb +6 -1
  33. data/test/unit/models/test_common_model.rb +2 -2
  34. data/test/unit/models/test_comparison.rb +8 -8
  35. data/test/unit/models/test_connection.rb +2 -2
  36. data/test/unit/models/test_field.rb +2 -2
  37. data/test/unit/models/test_import.rb +9 -4
  38. data/test/unit/models/test_job.rb +2 -2
  39. data/test/unit/models/test_matcher.rb +2 -2
  40. data/test/unit/models/test_project.rb +2 -2
  41. data/test/unit/models/test_resource.rb +2 -2
  42. data/test/unit/models/test_result.rb +2 -2
  43. data/test/unit/models/test_scenario.rb +2 -2
  44. data/test/unit/models/test_transformation.rb +2 -2
  45. data/test/unit/models/test_transformer.rb +12 -2
  46. data/test/unit/test_base.rb +1 -14
  47. data/test/unit/test_data_uploader.rb +1 -1
  48. data/test/unit/test_database.rb +1 -1
  49. data/test/unit/test_helpers.rb +2 -2
  50. data/test/unit/test_import_buffer.rb +40 -38
  51. data/test/unit/test_logger.rb +1 -1
  52. data/test/unit/test_models.rb +1 -1
  53. data/test/unit/test_runner.rb +1 -1
  54. data/test/unit/test_scheduler.rb +1 -1
  55. data/webroot/public/css/style.css +7 -5
  56. data/webroot/public/js/jquery.dataTables.min.js +130 -574
  57. data/webroot/views/connections/new.erb +41 -3
  58. data/webroot/views/imports/new.erb +2 -0
  59. data/webroot/views/jobs/list.erb +25 -21
  60. data/webroot/views/projects/index.erb +23 -15
  61. data/webroot/views/resources/list.erb +1 -2
  62. data/webroot/views/resources/new.erb +2 -2
  63. data/webroot/views/resources/show.erb +5 -2
  64. data/webroot/views/scenarios/new.erb +1 -1
  65. data/webroot/views/transformations/new.erb +1 -1
  66. metadata +30 -44
  67. data/lib/coupler/config.rb +0 -128
  68. data/test/coupler/models/test_import.rb +0 -221
  69. data/test/factories.rb +0 -91
  70. data/test/integration/extensions/test_connections.rb +0 -80
  71. data/test/integration/extensions/test_imports.rb +0 -94
  72. data/test/integration/extensions/test_matchers.rb +0 -134
  73. data/test/integration/extensions/test_projects.rb +0 -82
  74. data/test/integration/extensions/test_resources.rb +0 -150
  75. data/test/integration/extensions/test_scenarios.rb +0 -88
  76. data/test/integration/extensions/test_transformations.rb +0 -113
  77. data/test/integration/extensions/test_transformers.rb +0 -80
  78. data/vendor/h2-1.3.154.jar +0 -0
@@ -1,6 +1,6 @@
1
1
  <% @breadcrumbs = [@connection] %>
2
2
  <%= error_messages_for @connection %>
3
- <form method="post" action="/connections">
3
+ <form method="post" action="/connections" class="connection-form">
4
4
  <table class="form">
5
5
  <tr>
6
6
  <td class="left"><label for="name">Name</label></td>
@@ -12,8 +12,8 @@
12
12
  <td class="left"><label for="adapter">Type</label></td>
13
13
  <td>
14
14
  <select id="adapter" name="connection[adapter]">
15
- <% Coupler::Models::Connection::ADAPTERS.each do |(value, label)| %>
16
- <option value="<%= value %>"<%= ' selected="selected"' if @connection.adapter == value %>><%= label %></option>
15
+ <% Coupler::Models::Connection::ADAPTERS.each do |options| %>
16
+ <option value="<%= options[:name] %>"<%= ' selected="selected"' if @connection.adapter == options[:name] %>><%= options[:label] %></option>
17
17
  <% end %>
18
18
  </select>
19
19
  </td>
@@ -48,8 +48,46 @@
48
48
  <input id="database_name" name="connection[database_name]" type="text" value="<%= @connection.database_name %>" />
49
49
  </td>
50
50
  </tr>
51
+ <tr>
52
+ <td class="left"><label for="path">Path</label></td>
53
+ <td>
54
+ <input id="path" name="connection[path]" type="text" value="<%= @connection.path %>" />
55
+ </td>
56
+ </tr>
51
57
  </table>
52
58
  <p>
53
59
  <input type="submit" value="Submit" /> or <a href="/connections">Cancel</a>
54
60
  </p>
55
61
  </form>
62
+ <script type="text/javascript">
63
+ var ignoredAttribs = <%= Coupler::Models::Connection::ADAPTERS.inject({}) { |m, o| m[o[:name]] = o[:ignored_attributes]; m }.to_json %>
64
+ function adapterSelected(fade) {
65
+ var ignored = ignoredAttribs[$(this).val()];
66
+ var enable = $([]);
67
+ var disable = $([]);
68
+ $("[name^=connection\\[]").each(function() {
69
+ var obj = $(this);
70
+ var row = obj.closest('tr');
71
+ if ($.inArray(obj.attr('id'), ignored) == -1) {
72
+ enable = enable.add(row);
73
+ } else {
74
+ disable = disable.add(row);
75
+ }
76
+ });
77
+ if (typeof(fade) == 'undefined' || fade) {
78
+ disable.fadeOut(function() {
79
+ disable.find('input, select, textarea').attr('disabled', true);
80
+ enable.find('input, select, textarea').attr('disabled', false);
81
+ enable.fadeIn();
82
+ });
83
+ } else {
84
+ disable.hide().find('input, select, textarea').attr('disabled', true);
85
+ enable.find('input, select, textarea').attr('disabled', false).show();
86
+ }
87
+ }
88
+
89
+ $(function() {
90
+ var a = $('#adapter').change(adapterSelected);
91
+ adapterSelected.call(a[0], false);
92
+ });
93
+ </script>
@@ -2,6 +2,8 @@
2
2
  <%- add_javascript('jquery.dataTables.min.js') -%>
3
3
  <%- add_stylesheet('dataTables.css') -%>
4
4
 
5
+ <%= error_messages_for @import %>
6
+ <%= error_messages_for @resource %>
5
7
  <form action="/projects/<%= @project.id %>/imports" method="post">
6
8
  <input type="hidden" name="import[data_cache]" value="<%= @import.data_cache %>" />
7
9
  <p>
@@ -1,24 +1,28 @@
1
1
  <table class="list">
2
- <tr>
3
- <th>Type</th>
4
- <th>Status</th>
5
- <% if show_target %><th>Target</th><% end %>
6
- <th>Created</th>
7
- </tr>
8
- <% jobs.each_with_index do |job, i| %>
9
- <tr<%= cycle("", " class='alt'") %>>
10
- <td><%= job.name %></td>
11
- <td><%= job.status %></td>
12
- <%- if show_target -%>
13
- <%- if job.resource -%>
14
- <td><a href="/projects/<%= job.resource.project.id %>/resources/<%= job.resource.id %>"><%= job.resource.name %></a></td>
15
- <%- elsif job.scenario -%>
16
- <td><a href="/projects/<%= job.scenario.project.id %>/scenarios/<%= job.scenario.id %>"><%= job.scenario.name %></a></td>
17
- <%- else -%>
18
- <td>N/A</td>
2
+ <thead>
3
+ <tr>
4
+ <th>Type</th>
5
+ <th>Status</th>
6
+ <% if show_target %><th>Target</th><% end %>
7
+ <th>Created</th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% jobs.each_with_index do |job, i| %>
12
+ <tr<%= cycle("", " class='alt'") %>>
13
+ <td><%= job.name %></td>
14
+ <td><%= job.status %></td>
15
+ <%- if show_target -%>
16
+ <%- if job.resource -%>
17
+ <td><a href="/projects/<%= job.resource.project.id %>/resources/<%= job.resource.id %>"><%= job.resource.name %></a></td>
18
+ <%- elsif job.scenario -%>
19
+ <td><a href="/projects/<%= job.scenario.project.id %>/scenarios/<%= job.scenario.id %>"><%= job.scenario.name %></a></td>
20
+ <%- else -%>
21
+ <td>N/A</td>
22
+ <%- end -%>
19
23
  <%- end -%>
20
- <%- end -%>
21
- <td><%= timeago(job.created_at) %></td>
22
- </tr>
23
- <% end %>
24
+ <td><%= timeago(job.created_at) %></td>
25
+ </tr>
26
+ <% end %>
27
+ </tbody>
24
28
  </table>
@@ -55,24 +55,32 @@
55
55
  $(function() {
56
56
  $('#delete-project-dialog').dialog({
57
57
  autoOpen: false,
58
- buttons: {
59
- "Yes": function() {
60
- if ($('#confirm-1').is(':visible')) {
61
- $('#nuke-choice').toggle($('#nuke').is(':checked'));
62
- $('#confirm-1').hide();
63
- $('#confirm-2').show();
64
- }
65
- else {
66
- $('#delete-form').submit();
58
+ buttons: [
59
+ {
60
+ id: "yes-button",
61
+ text: "Yes",
62
+ click: function() {
63
+ if ($('#confirm-1').is(':visible')) {
64
+ $('#nuke-choice').toggle($('#nuke').is(':checked'));
65
+ $('#confirm-1').hide();
66
+ $('#confirm-2').show();
67
+ }
68
+ else {
69
+ $('#delete-form').submit();
70
+ }
67
71
  }
68
72
  },
69
- "No": function() {
70
- $('#delete-project-dialog').dialog('close');
71
- $('#nuke').attr('checked', false)
72
- $('#confirm-1').show();
73
- $('#confirm-2').hide();
73
+ {
74
+ id: "no-button",
75
+ text: "No",
76
+ click: function() {
77
+ $('#delete-project-dialog').dialog('close');
78
+ $('#nuke').attr('checked', false)
79
+ $('#confirm-1').show();
80
+ $('#confirm-2').hide();
81
+ },
74
82
  }
75
- },
83
+ ],
76
84
  modal: true
77
85
  });
78
86
  $('button.edit-project').button({icons: { primary: 'ui-icon-pencil' }});
@@ -6,14 +6,13 @@
6
6
  <tr>
7
7
  <th>Name</th>
8
8
  <% unless @hide_connection %><th>Connection</th><% end %>
9
- <th>Database</th>
10
9
  <th>Table</th>
11
10
  </tr>
12
11
  </thead>
13
12
  <tbody>
14
13
  <% @resources.each_with_index do |resource, i| %>
15
14
  <tr<%= ' class="alt"' if i % 2 == 1 %>>
16
- <td><a href="/projects/<%= @project.id %>/resources/<%= resource.id %>"><%= resource.name %></a></td>
15
+ <td><a href="/projects/<%= resource.project_id %>/resources/<%= resource.id %>"><%= resource.name %></a></td>
17
16
  <%- if resource.import_id -%>
18
17
  <td colspan="3" class='centered'>(imported)</td>
19
18
  <%- else -%>
@@ -23,8 +23,8 @@
23
23
  <td class="left"><label for="adapter" class="strong">Type</label></td>
24
24
  <td>
25
25
  <select id="adapter" name="resource[connection_attributes][adapter]">
26
- <%- Coupler::Models::Connection::ADAPTERS.each do |(value, label)| -%>
27
- <option value="<%= value %>"<%= ' selected="selected"' if @resource.connection.adapter == value %>><%= label %></option>
26
+ <%- Coupler::Models::Connection::ADAPTERS.each do |options| -%>
27
+ <option value="<%= options[:name] %>"<%= ' selected="selected"' if @resource.connection.adapter == options[:name] %>><%= options[:label] %></option>
28
28
  <%- end -%>
29
29
  </select>
30
30
  </td>
@@ -13,7 +13,7 @@
13
13
  <%- @fields.each do |field| -%>
14
14
  <tr>
15
15
  <td<%= ' class="altered-field"' if field.is_generated %>><%= field.name %></td>
16
- <td<%= ' class="altered-field"' if field.local_db_type %>><%= field.final_db_type %></td>
16
+ <td<%= ' class="altered-field"' if field.local_type %>><%= field_type(@resource, field) %></td>
17
17
  </tr>
18
18
  <%- end -%>
19
19
  </tbody>
@@ -66,7 +66,10 @@
66
66
  <script type="text/javascript">
67
67
  var intervalId;
68
68
  $(function() {
69
- $('#fields').dataTable({bJQueryUI: true, aaSorting: [], aoColumns: [null, null] });
69
+ $('#fields').dataTable({
70
+ bJQueryUI: true, aaSorting: [],
71
+ bAutoWidth: false, aoColumns: [{sWidth: "50%"}, {sWidth: "50%"}]
72
+ });
70
73
  <%- if @job && @job.status == 'running' -%>
71
74
  $('#progressbar').progressbar({value: <%= @job.percent_completed %>});
72
75
  setInterval(function() {
@@ -35,7 +35,7 @@
35
35
  <tr class="alt">
36
36
  <td class="left"><label for="description">Description</label></td>
37
37
  <td>
38
- <input id="name" name="scenario[description]" type="text" value="<%= @scenario.description %>" />
38
+ <input id="description" name="scenario[description]" type="text" value="<%= @scenario.description %>" />
39
39
  </td>
40
40
  </tr>
41
41
  </table>
@@ -27,7 +27,7 @@
27
27
  </tr>
28
28
  <tr id="field-info" class="hidden">
29
29
  <td class="col1">Current Type:</td>
30
- <td><span id='field-type'></span> (<span id='field-db-type'></span>)</td>
30
+ <td><span id='field-type'></span><%= " (<span id='field-db-type'></span>)" if !@resource.import_id %></td>
31
31
  </tr>
32
32
  </table>
33
33
  </div>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: coupler
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.6
6
6
  platform: java
7
7
  authors:
8
8
  - Jeremy Stephens
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-16 00:00:00 -05:00
13
+ date: 2011-07-12 00:00:00 -05:00
14
14
  default_executable: coupler
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -69,7 +69,7 @@ dependencies:
69
69
  prerelease: false
70
70
  type: :runtime
71
71
  - !ruby/object:Gem::Dependency
72
- name: carrierwave
72
+ name: carrierwave-sequel
73
73
  version_requirements: &id006 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
@@ -102,7 +102,7 @@ dependencies:
102
102
  prerelease: false
103
103
  type: :runtime
104
104
  - !ruby/object:Gem::Dependency
105
- name: rake
105
+ name: jdbc-h2
106
106
  version_requirements: &id009 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
@@ -111,9 +111,9 @@ dependencies:
111
111
  version: "0"
112
112
  requirement: *id009
113
113
  prerelease: false
114
- type: :development
114
+ type: :runtime
115
115
  - !ruby/object:Gem::Dependency
116
- name: jeweler
116
+ name: rake
117
117
  version_requirements: &id010 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
@@ -124,7 +124,7 @@ dependencies:
124
124
  prerelease: false
125
125
  type: :development
126
126
  - !ruby/object:Gem::Dependency
127
- name: forgery
127
+ name: jeweler
128
128
  version_requirements: &id011 !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
@@ -135,29 +135,29 @@ dependencies:
135
135
  prerelease: false
136
136
  type: :development
137
137
  - !ruby/object:Gem::Dependency
138
- name: test-unit
138
+ name: forgery
139
139
  version_requirements: &id012 !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
142
- - - "="
142
+ - - ">="
143
143
  - !ruby/object:Gem::Version
144
- version: 2.2.0
144
+ version: "0"
145
145
  requirement: *id012
146
146
  prerelease: false
147
147
  type: :development
148
148
  - !ruby/object:Gem::Dependency
149
- name: mocha
149
+ name: test-unit
150
150
  version_requirements: &id013 !ruby/object:Gem::Requirement
151
151
  none: false
152
152
  requirements:
153
- - - ">="
153
+ - - "="
154
154
  - !ruby/object:Gem::Version
155
- version: "0"
155
+ version: 2.2.0
156
156
  requirement: *id013
157
157
  prerelease: false
158
158
  type: :development
159
159
  - !ruby/object:Gem::Dependency
160
- name: rack-test
160
+ name: mocha
161
161
  version_requirements: &id014 !ruby/object:Gem::Requirement
162
162
  none: false
163
163
  requirements:
@@ -190,7 +190,7 @@ dependencies:
190
190
  prerelease: false
191
191
  type: :development
192
192
  - !ruby/object:Gem::Dependency
193
- name: factory_girl
193
+ name: git
194
194
  version_requirements: &id017 !ruby/object:Gem::Requirement
195
195
  none: false
196
196
  requirements:
@@ -201,7 +201,7 @@ dependencies:
201
201
  prerelease: false
202
202
  type: :development
203
203
  - !ruby/object:Gem::Dependency
204
- name: git
204
+ name: thor
205
205
  version_requirements: &id018 !ruby/object:Gem::Requirement
206
206
  none: false
207
207
  requirements:
@@ -212,7 +212,7 @@ dependencies:
212
212
  prerelease: false
213
213
  type: :development
214
214
  - !ruby/object:Gem::Dependency
215
- name: thor
215
+ name: table_maker
216
216
  version_requirements: &id019 !ruby/object:Gem::Requirement
217
217
  none: false
218
218
  requirements:
@@ -223,7 +223,7 @@ dependencies:
223
223
  prerelease: false
224
224
  type: :development
225
225
  - !ruby/object:Gem::Dependency
226
- name: rake
226
+ name: capybara
227
227
  version_requirements: &id020 !ruby/object:Gem::Requirement
228
228
  none: false
229
229
  requirements:
@@ -234,7 +234,7 @@ dependencies:
234
234
  prerelease: false
235
235
  type: :development
236
236
  - !ruby/object:Gem::Dependency
237
- name: table_maker
237
+ name: jruby-openssl
238
238
  version_requirements: &id021 !ruby/object:Gem::Requirement
239
239
  none: false
240
240
  requirements:
@@ -244,17 +244,6 @@ dependencies:
244
244
  requirement: *id021
245
245
  prerelease: false
246
246
  type: :development
247
- - !ruby/object:Gem::Dependency
248
- name: ruby-debug
249
- version_requirements: &id022 !ruby/object:Gem::Requirement
250
- none: false
251
- requirements:
252
- - - ">="
253
- - !ruby/object:Gem::Version
254
- version: "0"
255
- requirement: *id022
256
- prerelease: false
257
- type: :development
258
247
  description: Coupler is a (JRuby) desktop application designed to link datasets together
259
248
  email: jeremy.f.stephens@vanderbilt.edu
260
249
  executables:
@@ -323,7 +312,6 @@ files:
323
312
  - gfx/icon.svg
324
313
  - lib/coupler.rb
325
314
  - lib/coupler/base.rb
326
- - lib/coupler/config.rb
327
315
  - lib/coupler/data_uploader.rb
328
316
  - lib/coupler/database.rb
329
317
  - lib/coupler/extensions.rb
@@ -375,23 +363,22 @@ files:
375
363
  - tasks/vendor.rake
376
364
  - test/README.txt
377
365
  - test/config.yml
378
- - test/coupler/models/test_import.rb
379
- - test/factories.rb
380
366
  - test/fixtures/duplicate-keys.csv
381
367
  - test/fixtures/no-headers.csv
382
368
  - test/fixtures/people.csv
383
369
  - test/fixtures/varying-row-size.csv
370
+ - test/functional/test_base.rb
371
+ - test/functional/test_connections.rb
372
+ - test/functional/test_imports.rb
373
+ - test/functional/test_jobs.rb
374
+ - test/functional/test_matchers.rb
375
+ - test/functional/test_projects.rb
376
+ - test/functional/test_resources.rb
377
+ - test/functional/test_results.rb
378
+ - test/functional/test_scenarios.rb
379
+ - test/functional/test_transformations.rb
380
+ - test/functional/test_transformers.rb
384
381
  - test/helper.rb
385
- - test/integration/extensions/test_connections.rb
386
- - test/integration/extensions/test_imports.rb
387
- - test/integration/extensions/test_jobs.rb
388
- - test/integration/extensions/test_matchers.rb
389
- - test/integration/extensions/test_projects.rb
390
- - test/integration/extensions/test_resources.rb
391
- - test/integration/extensions/test_results.rb
392
- - test/integration/extensions/test_scenarios.rb
393
- - test/integration/extensions/test_transformations.rb
394
- - test/integration/extensions/test_transformers.rb
395
382
  - test/integration/test_field.rb
396
383
  - test/integration/test_import.rb
397
384
  - test/integration/test_running_scenarios.rb
@@ -421,7 +408,6 @@ files:
421
408
  - test/unit/test_runner.rb
422
409
  - test/unit/test_scheduler.rb
423
410
  - uploads/.gitignore
424
- - vendor/h2-1.3.154.jar
425
411
  - webroot/public/css/960.css
426
412
  - webroot/public/css/dataTables.css
427
413
  - webroot/public/css/jquery-ui.css
@@ -1,128 +0,0 @@
1
- module Coupler
2
- module Config
3
- DEFAULT_CONFIG = {
4
- :database => {
5
- :port => 12345,
6
- :user => 'coupler',
7
- :password => 'cupla',
8
- :max_connections => '100',
9
- :max_allowed_packet => '1M',
10
- :connection_string => 'jdbc:mysql://localhost:%d/%s?user=%s&password=%s',
11
- }
12
- }
13
-
14
- VENDOR_LIBS = {
15
- 'jruby' => {
16
- :type => 'java',
17
- :filetype => 'jar',
18
- :version => '1.6.0',
19
- :url => "http://jruby.org.s3.amazonaws.com/downloads/%1$s/jruby-complete-%1$s.jar",
20
- :uncompress => false,
21
- :filename => "jruby-complete-%s.jar",
22
- :symlink => "jruby-complete.jar"
23
- },
24
- 'mysql-connector-mxj' => {
25
- :type => 'java',
26
- :filetype => "tarball",
27
- :version => '5-0-11',
28
- :dir => "mysql-connector-mxj-gpl-%s",
29
- :url => "http://mysql.mirrors.hoobly.com/Downloads/Connector-MXJ/mysql-connector-mxj-gpl-%s.tar.gz",
30
- :libs => [
31
- "mysql-connector-mxj-gpl-%s.jar",
32
- "mysql-connector-mxj-gpl-%s-db-files.jar"
33
- ]
34
- },
35
- 'mysql-connector-java' => {
36
- :type => 'java',
37
- :filetype => "tarball",
38
- :version => '5.1.13',
39
- :dir => "mysql-connector-java-%s",
40
- :url => "http://mysql.mirrors.hoobly.com/Downloads/Connector-J/mysql-connector-java-%s.tar.gz",
41
- :libs => [
42
- "mysql-connector-java-%s-bin.jar",
43
- ]
44
- }
45
- }
46
-
47
- def self.each_vendor_lib
48
- VENDOR_LIBS.each_key do |name|
49
- yield(name, vendor_lib_info(name))
50
- end
51
- end
52
-
53
- def self.vendor_lib_info(name)
54
- info = VENDOR_LIBS[name]
55
- info = info.merge({:url => info[:url] % info[:version]})
56
- info[:dir] %= info[:version] if info[:dir]
57
- info[:filename] %= info[:version] if info[:filename]
58
- info
59
- end
60
-
61
- def self.vendor_lib_paths(name)
62
- info = VENDOR_LIBS[name]
63
- version = info[:version]
64
- path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'vendor', info[:type], info[:dir] % version))
65
- info[:libs].collect { |lib| File.join(path, lib % version) }
66
- end
67
-
68
- def self.require_vendor_libs(name)
69
- vendor_lib_paths(name).each { |path| require(path) }
70
- end
71
-
72
- @@config = nil
73
- def self.get(*keys)
74
- if @@config.nil?
75
- @@config = DEFAULT_CONFIG
76
- end
77
-
78
- if keys == [:data_path]
79
- if !@@config.has_key?(keys[0])
80
- # FIXME: this is a little naive
81
- dir = File.join(File.dirname(__FILE__), "..", "..")
82
- if ENV['APPDATA']
83
- # Windows
84
- dir = File.join(ENV['APPDATA'], "coupler")
85
- elsif !File.writable?(dir)
86
- if ENV['HOME']
87
- dir = File.join(ENV['HOME'], ".coupler")
88
- else
89
- raise "don't know where to put data!"
90
- end
91
- end
92
- @@config[:data_path] = File.expand_path(dir)
93
- end
94
- Dir.mkdir(@@config[:data_path]) if !File.exist?(@@config[:data_path])
95
- elsif keys == [:upload_path]
96
- if !@@config.has_key?(keys[0])
97
- @@config[:upload_path] = path = File.join(get(:data_path), "uploads")
98
- end
99
- Dir.mkdir(@@config[:upload_path]) if !File.exist?(@@config[:upload_path])
100
- end
101
-
102
- keys.inject(@@config) { |hash, key| hash[key] }
103
- end
104
-
105
- def self.set(*args)
106
- if @@config.nil?
107
- @@config = DEFAULT_CONFIG
108
- end
109
-
110
- value = args.pop
111
- keys = args
112
-
113
- hash = keys[0..-2].inject(@@config) { |h, k| h[k] }
114
- hash[keys[-1]] = value
115
- end
116
-
117
- def self.connection_string(database, options = {})
118
- retval = self.get(:database, :connection_string) % [self.get(:database, :port), database, self.get(:database, :user), self.get(:database, :password)]
119
- retval += "&createDatabaseIfNotExist=true" if options[:create_database]
120
- case options[:zero_date_time_behavior]
121
- when :convert_to_null
122
- retval += "&zeroDateTimeBehavior=convertToNull"
123
- end
124
- retval += "&autoReconnect=true" if options[:auto_reconnect]
125
- retval
126
- end
127
- end
128
- end