coupler 0.0.1-java → 0.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -7,7 +7,6 @@ gem 'fastercsv'
7
7
  gem 'carrierwave'
8
8
  gem 'mongrel'
9
9
  gem 'jdbc-mysql'
10
- #gem 'mvn:com.h2database:h2'
11
10
 
12
11
  group :development do
13
12
  gem 'rake'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bin/coupler CHANGED
@@ -4,4 +4,4 @@ require 'rubygems'
4
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
5
  require 'coupler'
6
6
 
7
- Coupler::Runner.new
7
+ Coupler::Runner.new(ARGV).join
data/coupler.gemspec ADDED
@@ -0,0 +1,364 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{coupler}
8
+ s.version = "0.0.1"
9
+ s.platform = %q{java}
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Jeremy Stephens"]
13
+ s.date = %q{2011-05-12}
14
+ s.default_executable = %q{coupler}
15
+ s.description = %q{Coupler is a (JRuby) desktop application designed to link datasets together}
16
+ s.email = %q{jeremy.f.stephens@vanderbilt.edu}
17
+ s.executables = ["coupler"]
18
+ s.extra_rdoc_files = [
19
+ "LICENSE",
20
+ "README.rdoc",
21
+ "TODO"
22
+ ]
23
+ s.files = [
24
+ ".document",
25
+ ".gitmodules",
26
+ ".rvmrc",
27
+ ".vimrc",
28
+ "Gemfile",
29
+ "Gemfile.lock",
30
+ "LICENSE",
31
+ "NOTES",
32
+ "README.rdoc",
33
+ "Rakefile",
34
+ "TODO",
35
+ "VERSION",
36
+ "bin/coupler",
37
+ "coupler.gemspec",
38
+ "db/.gitignore",
39
+ "db/migrate/001_initial_schema.rb",
40
+ "db/migrate/002_stub.rb",
41
+ "db/migrate/003_stub.rb",
42
+ "db/migrate/004_create_comparisons.rb",
43
+ "db/migrate/005_move_database_name.rb",
44
+ "db/migrate/006_upgrade_comparisons.rb",
45
+ "db/migrate/007_add_which_to_comparisons.rb",
46
+ "db/migrate/008_add_result_field_to_transformations.rb",
47
+ "db/migrate/009_add_generated_flag_to_fields.rb",
48
+ "db/migrate/010_create_imports.rb",
49
+ "db/migrate/011_add_primary_key_type.rb",
50
+ "db/migrate/012_add_transformed_with_to_resources.rb",
51
+ "db/migrate/013_add_run_count_to_scenarios.rb",
52
+ "db/migrate/014_add_last_accessed_at_to_some_tables.rb",
53
+ "db/migrate/015_add_run_number_to_results.rb",
54
+ "db/migrate/016_fix_scenario_run_count.rb",
55
+ "db/migrate/017_rename_comparison_columns.rb",
56
+ "db/migrate/018_fix_scenario_linkage_type.rb",
57
+ "db/migrate/019_add_columns_to_imports.rb",
58
+ "db/migrate/020_rename_import_columns.rb",
59
+ "db/migrate/021_add_fields_to_connections.rb",
60
+ "db/migrate/022_remove_database_name_from_resources.rb",
61
+ "features/connections.feature",
62
+ "features/matchers.feature",
63
+ "features/projects.feature",
64
+ "features/resources.feature",
65
+ "features/scenarios.feature",
66
+ "features/step_definitions/coupler_steps.rb",
67
+ "features/step_definitions/matchers_steps.rb",
68
+ "features/step_definitions/resources_steps.rb",
69
+ "features/step_definitions/scenarios_steps.rb",
70
+ "features/step_definitions/transformations_steps.rb",
71
+ "features/support/env.rb",
72
+ "features/transformations.feature",
73
+ "features/wizard.feature",
74
+ "gfx/coupler-header.svg",
75
+ "gfx/coupler-sidebar.svg",
76
+ "gfx/coupler.svg",
77
+ "gfx/icon.svg",
78
+ "lib/coupler.rb",
79
+ "lib/coupler/base.rb",
80
+ "lib/coupler/config.rb",
81
+ "lib/coupler/data_uploader.rb",
82
+ "lib/coupler/database.rb",
83
+ "lib/coupler/extensions.rb",
84
+ "lib/coupler/extensions/connections.rb",
85
+ "lib/coupler/extensions/exceptions.rb",
86
+ "lib/coupler/extensions/imports.rb",
87
+ "lib/coupler/extensions/jobs.rb",
88
+ "lib/coupler/extensions/matchers.rb",
89
+ "lib/coupler/extensions/projects.rb",
90
+ "lib/coupler/extensions/resources.rb",
91
+ "lib/coupler/extensions/results.rb",
92
+ "lib/coupler/extensions/scenarios.rb",
93
+ "lib/coupler/extensions/transformations.rb",
94
+ "lib/coupler/extensions/transformers.rb",
95
+ "lib/coupler/helpers.rb",
96
+ "lib/coupler/import_buffer.rb",
97
+ "lib/coupler/logger.rb",
98
+ "lib/coupler/models.rb",
99
+ "lib/coupler/models/common_model.rb",
100
+ "lib/coupler/models/comparison.rb",
101
+ "lib/coupler/models/connection.rb",
102
+ "lib/coupler/models/field.rb",
103
+ "lib/coupler/models/import.rb",
104
+ "lib/coupler/models/job.rb",
105
+ "lib/coupler/models/jobify.rb",
106
+ "lib/coupler/models/matcher.rb",
107
+ "lib/coupler/models/project.rb",
108
+ "lib/coupler/models/resource.rb",
109
+ "lib/coupler/models/result.rb",
110
+ "lib/coupler/models/scenario.rb",
111
+ "lib/coupler/models/scenario/runner.rb",
112
+ "lib/coupler/models/transformation.rb",
113
+ "lib/coupler/models/transformer.rb",
114
+ "lib/coupler/models/transformer/runner.rb",
115
+ "lib/coupler/runner.rb",
116
+ "lib/coupler/scheduler.rb",
117
+ "log/.gitignore",
118
+ "misc/README",
119
+ "misc/jruby-json.license",
120
+ "misc/rack-flash.license",
121
+ "script/dbconsole.rb",
122
+ "src/edu/vanderbilt/coupler/Main.java",
123
+ "src/edu/vanderbilt/coupler/jruby.properties",
124
+ "tasks/annotations.rake",
125
+ "tasks/db.rake",
126
+ "tasks/environment.rake",
127
+ "tasks/jeweler.rake",
128
+ "tasks/package.rake",
129
+ "tasks/rdoc.rake",
130
+ "tasks/test.rake",
131
+ "tasks/vendor.rake",
132
+ "test/README.txt",
133
+ "test/config.yml",
134
+ "test/coupler/models/test_import.rb",
135
+ "test/factories.rb",
136
+ "test/fixtures/duplicate-keys.csv",
137
+ "test/fixtures/no-headers.csv",
138
+ "test/fixtures/people.csv",
139
+ "test/fixtures/varying-row-size.csv",
140
+ "test/helper.rb",
141
+ "test/integration/extensions/test_connections.rb",
142
+ "test/integration/extensions/test_imports.rb",
143
+ "test/integration/extensions/test_jobs.rb",
144
+ "test/integration/extensions/test_matchers.rb",
145
+ "test/integration/extensions/test_projects.rb",
146
+ "test/integration/extensions/test_resources.rb",
147
+ "test/integration/extensions/test_results.rb",
148
+ "test/integration/extensions/test_scenarios.rb",
149
+ "test/integration/extensions/test_transformations.rb",
150
+ "test/integration/extensions/test_transformers.rb",
151
+ "test/integration/test_field.rb",
152
+ "test/integration/test_import.rb",
153
+ "test/integration/test_running_scenarios.rb",
154
+ "test/integration/test_transformation.rb",
155
+ "test/integration/test_transforming.rb",
156
+ "test/table_sets.rb",
157
+ "test/unit/models/test_common_model.rb",
158
+ "test/unit/models/test_comparison.rb",
159
+ "test/unit/models/test_connection.rb",
160
+ "test/unit/models/test_field.rb",
161
+ "test/unit/models/test_import.rb",
162
+ "test/unit/models/test_job.rb",
163
+ "test/unit/models/test_matcher.rb",
164
+ "test/unit/models/test_project.rb",
165
+ "test/unit/models/test_resource.rb",
166
+ "test/unit/models/test_result.rb",
167
+ "test/unit/models/test_scenario.rb",
168
+ "test/unit/models/test_transformation.rb",
169
+ "test/unit/models/test_transformer.rb",
170
+ "test/unit/test_base.rb",
171
+ "test/unit/test_data_uploader.rb",
172
+ "test/unit/test_database.rb",
173
+ "test/unit/test_helpers.rb",
174
+ "test/unit/test_logger.rb",
175
+ "test/unit/test_models.rb",
176
+ "test/unit/test_runner.rb",
177
+ "test/unit/test_scheduler.rb",
178
+ "uploads/.gitignore",
179
+ "vendor/h2-1.3.154.jar",
180
+ "webroot/public/css/960.css",
181
+ "webroot/public/css/dataTables.css",
182
+ "webroot/public/css/jquery-ui.css",
183
+ "webroot/public/css/jquery.treeview.css",
184
+ "webroot/public/css/reset.css",
185
+ "webroot/public/css/style.css",
186
+ "webroot/public/css/text.css",
187
+ "webroot/public/favicon.ico",
188
+ "webroot/public/images/12_col.gif",
189
+ "webroot/public/images/16_col.gif",
190
+ "webroot/public/images/add.png",
191
+ "webroot/public/images/ajax-loader.gif",
192
+ "webroot/public/images/cog.png",
193
+ "webroot/public/images/coupler.png",
194
+ "webroot/public/images/foo.png",
195
+ "webroot/public/images/hammer.png",
196
+ "webroot/public/images/header.png",
197
+ "webroot/public/images/home.gif",
198
+ "webroot/public/images/jobs.gif",
199
+ "webroot/public/images/sidebar-bottom.png",
200
+ "webroot/public/images/sidebar.png",
201
+ "webroot/public/images/treeview-default-line.gif",
202
+ "webroot/public/images/treeview-default.gif",
203
+ "webroot/public/images/ui-anim_basic_16x16.gif",
204
+ "webroot/public/images/ui-bg_flat_0_aaaaaa_40x100.png",
205
+ "webroot/public/images/ui-bg_flat_75_ffffff_40x100.png",
206
+ "webroot/public/images/ui-bg_glass_55_fbf9ee_1x400.png",
207
+ "webroot/public/images/ui-bg_glass_65_ffffff_1x400.png",
208
+ "webroot/public/images/ui-bg_glass_75_dadada_1x400.png",
209
+ "webroot/public/images/ui-bg_glass_75_e6e6e6_1x400.png",
210
+ "webroot/public/images/ui-bg_glass_95_fef1ec_1x400.png",
211
+ "webroot/public/images/ui-bg_highlight-hard_30_565356_1x100.png",
212
+ "webroot/public/images/ui-bg_highlight-hard_75_888588_1x100.png",
213
+ "webroot/public/images/ui-bg_highlight-soft_30_6e3b3a_1x100.png",
214
+ "webroot/public/images/ui-bg_highlight-soft_35_8e8b8e_1x100.png",
215
+ "webroot/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png",
216
+ "webroot/public/images/ui-icons_222222_256x240.png",
217
+ "webroot/public/images/ui-icons_2e83ff_256x240.png",
218
+ "webroot/public/images/ui-icons_454545_256x240.png",
219
+ "webroot/public/images/ui-icons_888888_256x240.png",
220
+ "webroot/public/images/ui-icons_cd0a0a_256x240.png",
221
+ "webroot/public/images/ui-icons_ffffff_256x240.png",
222
+ "webroot/public/js/ajaxupload.js",
223
+ "webroot/public/js/application.js",
224
+ "webroot/public/js/jquery-ui.combobox.js",
225
+ "webroot/public/js/jquery-ui.js",
226
+ "webroot/public/js/jquery-ui.min.js",
227
+ "webroot/public/js/jquery.dataTables.min.js",
228
+ "webroot/public/js/jquery.min.js",
229
+ "webroot/public/js/jquery.timeago.js",
230
+ "webroot/public/js/jquery.tooltip.min.js",
231
+ "webroot/public/js/jquery.treeview.min.js",
232
+ "webroot/public/js/resource.js",
233
+ "webroot/public/js/results.js",
234
+ "webroot/public/js/transformations.js",
235
+ "webroot/views/connections/index.erb",
236
+ "webroot/views/connections/list.erb",
237
+ "webroot/views/connections/new.erb",
238
+ "webroot/views/connections/show.erb",
239
+ "webroot/views/imports/edit.erb",
240
+ "webroot/views/imports/form.erb",
241
+ "webroot/views/imports/new.erb",
242
+ "webroot/views/index.erb",
243
+ "webroot/views/jobs/index.erb",
244
+ "webroot/views/jobs/list.erb",
245
+ "webroot/views/layout.erb",
246
+ "webroot/views/matchers/form.erb",
247
+ "webroot/views/matchers/list.erb",
248
+ "webroot/views/projects/form.erb",
249
+ "webroot/views/projects/index.erb",
250
+ "webroot/views/projects/show.erb",
251
+ "webroot/views/resources/edit.erb",
252
+ "webroot/views/resources/index.erb",
253
+ "webroot/views/resources/list.erb",
254
+ "webroot/views/resources/new.erb",
255
+ "webroot/views/resources/show.erb",
256
+ "webroot/views/resources/transform.erb",
257
+ "webroot/views/results/csv.erb",
258
+ "webroot/views/results/details.erb",
259
+ "webroot/views/results/index.erb",
260
+ "webroot/views/results/list.erb",
261
+ "webroot/views/results/record.erb",
262
+ "webroot/views/results/show.erb",
263
+ "webroot/views/scenarios/index.erb",
264
+ "webroot/views/scenarios/list.erb",
265
+ "webroot/views/scenarios/new.erb",
266
+ "webroot/views/scenarios/run.erb",
267
+ "webroot/views/scenarios/show.erb",
268
+ "webroot/views/sidebar.erb",
269
+ "webroot/views/transformations/create.erb",
270
+ "webroot/views/transformations/for.erb",
271
+ "webroot/views/transformations/index.erb",
272
+ "webroot/views/transformations/list.erb",
273
+ "webroot/views/transformations/new.erb",
274
+ "webroot/views/transformations/preview.erb",
275
+ "webroot/views/transformers/edit.erb",
276
+ "webroot/views/transformers/form.erb",
277
+ "webroot/views/transformers/index.erb",
278
+ "webroot/views/transformers/list.erb",
279
+ "webroot/views/transformers/new.erb",
280
+ "webroot/views/transformers/preview.erb",
281
+ "webroot/views/transformers/show.erb"
282
+ ]
283
+ s.homepage = %q{http://github.com/coupler/coupler}
284
+ s.licenses = ["MIT"]
285
+ s.require_paths = ["lib"]
286
+ s.rubygems_version = %q{1.5.1}
287
+ s.summary = %q{Coupler is a desktop application for linking datasets together}
288
+
289
+ if s.respond_to? :specification_version then
290
+ s.specification_version = 3
291
+
292
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
293
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
294
+ s.add_runtime_dependency(%q<sequel>, [">= 0"])
295
+ s.add_runtime_dependency(%q<rack-flash>, [">= 0"])
296
+ s.add_runtime_dependency(%q<json>, [">= 0"])
297
+ s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
298
+ s.add_runtime_dependency(%q<carrierwave>, [">= 0"])
299
+ s.add_runtime_dependency(%q<mongrel>, [">= 0"])
300
+ s.add_runtime_dependency(%q<jdbc-mysql>, [">= 0"])
301
+ s.add_development_dependency(%q<rake>, [">= 0"])
302
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
303
+ s.add_development_dependency(%q<forgery>, [">= 0"])
304
+ s.add_development_dependency(%q<test-unit>, ["= 2.2.0"])
305
+ s.add_development_dependency(%q<mocha>, [">= 0"])
306
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
307
+ s.add_development_dependency(%q<nokogiri>, [">= 0"])
308
+ s.add_development_dependency(%q<timecop>, [">= 0"])
309
+ s.add_development_dependency(%q<factory_girl>, [">= 0"])
310
+ s.add_development_dependency(%q<git>, [">= 0"])
311
+ s.add_development_dependency(%q<thor>, [">= 0"])
312
+ s.add_development_dependency(%q<rake>, [">= 0"])
313
+ s.add_development_dependency(%q<table_maker>, [">= 0"])
314
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
315
+ else
316
+ s.add_dependency(%q<sinatra>, [">= 0"])
317
+ s.add_dependency(%q<sequel>, [">= 0"])
318
+ s.add_dependency(%q<rack-flash>, [">= 0"])
319
+ s.add_dependency(%q<json>, [">= 0"])
320
+ s.add_dependency(%q<fastercsv>, [">= 0"])
321
+ s.add_dependency(%q<carrierwave>, [">= 0"])
322
+ s.add_dependency(%q<mongrel>, [">= 0"])
323
+ s.add_dependency(%q<jdbc-mysql>, [">= 0"])
324
+ s.add_dependency(%q<rake>, [">= 0"])
325
+ s.add_dependency(%q<jeweler>, [">= 0"])
326
+ s.add_dependency(%q<forgery>, [">= 0"])
327
+ s.add_dependency(%q<test-unit>, ["= 2.2.0"])
328
+ s.add_dependency(%q<mocha>, [">= 0"])
329
+ s.add_dependency(%q<rack-test>, [">= 0"])
330
+ s.add_dependency(%q<nokogiri>, [">= 0"])
331
+ s.add_dependency(%q<timecop>, [">= 0"])
332
+ s.add_dependency(%q<factory_girl>, [">= 0"])
333
+ s.add_dependency(%q<git>, [">= 0"])
334
+ s.add_dependency(%q<thor>, [">= 0"])
335
+ s.add_dependency(%q<rake>, [">= 0"])
336
+ s.add_dependency(%q<table_maker>, [">= 0"])
337
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
338
+ end
339
+ else
340
+ s.add_dependency(%q<sinatra>, [">= 0"])
341
+ s.add_dependency(%q<sequel>, [">= 0"])
342
+ s.add_dependency(%q<rack-flash>, [">= 0"])
343
+ s.add_dependency(%q<json>, [">= 0"])
344
+ s.add_dependency(%q<fastercsv>, [">= 0"])
345
+ s.add_dependency(%q<carrierwave>, [">= 0"])
346
+ s.add_dependency(%q<mongrel>, [">= 0"])
347
+ s.add_dependency(%q<jdbc-mysql>, [">= 0"])
348
+ s.add_dependency(%q<rake>, [">= 0"])
349
+ s.add_dependency(%q<jeweler>, [">= 0"])
350
+ s.add_dependency(%q<forgery>, [">= 0"])
351
+ s.add_dependency(%q<test-unit>, ["= 2.2.0"])
352
+ s.add_dependency(%q<mocha>, [">= 0"])
353
+ s.add_dependency(%q<rack-test>, [">= 0"])
354
+ s.add_dependency(%q<nokogiri>, [">= 0"])
355
+ s.add_dependency(%q<timecop>, [">= 0"])
356
+ s.add_dependency(%q<factory_girl>, [">= 0"])
357
+ s.add_dependency(%q<git>, [">= 0"])
358
+ s.add_dependency(%q<thor>, [">= 0"])
359
+ s.add_dependency(%q<rake>, [">= 0"])
360
+ s.add_dependency(%q<table_maker>, [">= 0"])
361
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
362
+ end
363
+ end
364
+
data/lib/coupler.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'java'
2
2
  require 'jruby/core_ext'
3
3
 
4
+ require 'rbconfig'
4
5
  require 'fileutils'
5
6
  require 'erb'
6
7
  require 'delegate'
@@ -18,9 +19,9 @@ require 'sequel/extensions/migration'
18
19
  require 'json'
19
20
  require 'fastercsv'
20
21
  require 'carrierwave'
21
- require 'mvn:com.h2database:h2'
22
22
  require 'mongrel'
23
- require 'jdbc/mysql' # FIXME: lazy load this
23
+ #require 'jdbc/mysql' # Sequel should load this when it needs to.
24
+ require File.dirname(__FILE__) + '/../vendor/h2-1.3.154.jar'
24
25
 
25
26
  require File.dirname(__FILE__) + "/coupler/logger"
26
27
  require File.dirname(__FILE__) + "/coupler/database"
data/lib/coupler/base.rb CHANGED
@@ -11,26 +11,44 @@ module Coupler
11
11
  set :dump_errors, true
12
12
  set :logging, Proc.new { !test? }
13
13
  set :methodoverride, true
14
- set :host, '127.0.0.1'
14
+ set :bind, '127.0.0.1'
15
15
  set :db_path, lambda { |dbname| File.join(data_path, 'db', environment.to_s, dbname) }
16
16
  set :connection_string, lambda { |dbname| "jdbc:h2:#{db_path(dbname)};IGNORECASE=TRUE" }
17
17
  set :upload_path, lambda { File.join(data_path, 'uploads', environment.to_s) }
18
18
  set :log_path, lambda { File.join(data_path, 'log') }
19
- enable :sessions
20
-
21
- data_path = inst_dir
22
- if ENV['APPDATA']
23
- # Windows
24
- data_path = File.join(ENV['APPDATA'], "coupler")
25
- elsif !File.writable?(data_path)
26
- if ENV['HOME']
27
- dir = File.join(ENV['HOME'], ".coupler")
28
- else
29
- raise "don't know where to put data!"
19
+ set(:data_path, lambda {
20
+ # NOTE: Unfortunately, this code is in two places. Coupler can
21
+ # be run with or without the launcher, and the launcher needs
22
+ # to know about Coupler's data path before it runs Coupler.
23
+ dir =
24
+ if ENV['COUPLER_HOME']
25
+ ENV['COUPLER_HOME']
26
+ else
27
+ case Config::CONFIG['host_os']
28
+ when /mswin|windows/i
29
+ # Windows
30
+ File.join(ENV['APPDATA'], "coupler")
31
+ else
32
+ if ENV['HOME']
33
+ File.join(ENV['HOME'], ".coupler")
34
+ else
35
+ raise "Can't figure out where Coupler lives! Try setting the COUPLER_HOME environment variable"
36
+ end
37
+ end
38
+ end
39
+ if !File.exist?(dir)
40
+ begin
41
+ Dir.mkdir(dir)
42
+ rescue SystemCallError
43
+ raise "Can't create Coupler directory (#{dir})! Is the parent directory accessible?"
44
+ end
30
45
  end
31
- end
32
- Dir.mkdir(data_path) if !File.exist?(data_path)
33
- set :data_path, data_path
46
+ if !File.writable?(dir)
47
+ raise "Coupler directory (#{dir}) is not writable!"
48
+ end
49
+ File.expand_path(dir)
50
+ })
51
+ enable :sessions
34
52
 
35
53
  use Rack::Flash
36
54
  register Extensions::Connections
@@ -1,6 +1,7 @@
1
1
  module Coupler
2
2
  class Runner
3
- def initialize(argv = ARGV)
3
+ def initialize(argv = ARGV, options = {}, &block)
4
+ @msg_proc = block
4
5
  irb = false
5
6
  OptionParser.new do |opts|
6
7
  opts.on("-p", "--port PORT", "Web server port") do |port|
@@ -22,13 +23,15 @@ module Coupler
22
23
  end
23
24
  end.parse!(argv)
24
25
 
25
- puts "Migrating database..."
26
+ say "Starting up Coupler..."
27
+
28
+ say "Migrating database..."
26
29
  Coupler::Database.instance.migrate!
27
30
 
28
- puts "Starting scheduler..."
31
+ say "Starting scheduler..."
29
32
  Coupler::Scheduler.instance.start
30
33
 
31
- puts "Starting web server..."
34
+ say "Starting web server..."
32
35
  handler = Rack::Handler.get('mongrel')
33
36
  settings = Coupler::Base.settings
34
37
 
@@ -43,34 +46,49 @@ module Coupler
43
46
  success = true
44
47
  rescue Errno::EADDRINUSE => e
45
48
  Scheduler.instance.shutdown
46
- puts "Can't start web server, port already in use. Aborting..."
49
+ say "Can't start web server, port already in use. Aborting..."
47
50
  end
48
51
 
49
52
  if success
50
53
  Coupler::Base.set(:running, true)
51
- trap("INT") do
52
- shutdown
54
+ say "Web server is up and running on http://#{settings.bind}:#{settings.port}"
55
+ if !options.has_key?(:trap) || options[:trap]
56
+ trap("INT") do
57
+ shutdown
58
+ end
53
59
  end
54
60
 
55
- puts <<'EOF'
56
- ___
57
- /\_ \
58
- ___ ___ __ __ _____\//\ \ __ _ __
59
- /'___\ / __`\/\ \/\ \/\ '__`\\ \ \ /'__`\/\`'__\
60
- /\ \__//\ \L\ \ \ \_\ \ \ \L\ \\_\ \_/\ __/\ \ \/
61
- \ \____\ \____/\ \____/\ \ ,__//\____\ \____\\ \_\
62
- \/____/\/___/ \/___/ \ \ \/ \/____/\/____/ \/_/
63
- \ \_\
64
- \/_/
65
- EOF
66
- @web_thread.join
61
+ # say <<'EOF'
62
+ # ___
63
+ # /\_ \
64
+ # ___ ___ __ __ _____\//\ \ __ _ __
65
+ # /'___\ / __`\/\ \/\ \/\ '__`\\ \ \ /'__`\/\`'__\
66
+ #/\ \__//\ \L\ \ \ \_\ \ \ \L\ \\_\ \_/\ __/\ \ \/
67
+ #\ \____\ \____/\ \____/\ \ ,__//\____\ \____\\ \_\
68
+ # \/____/\/___/ \/___/ \ \ \/ \/____/\/____/ \/_/
69
+ # \ \_\
70
+ # \/_/
71
+ #EOF
67
72
  end
68
73
  end
69
74
 
70
75
  def shutdown
71
- puts "Shutting down..."
76
+ say "Shutting down..."
72
77
  Scheduler.instance.shutdown
73
78
  @web_server.stop
74
79
  end
80
+
81
+ def join
82
+ @web_thread.join
83
+ end
84
+
85
+ private
86
+ def say(msg)
87
+ if @msg_proc
88
+ @msg_proc.call(msg)
89
+ else
90
+ puts msg
91
+ end
92
+ end
75
93
  end
76
94
  end
@@ -1,4 +1,5 @@
1
1
  task :environment do
2
+ ENV['COUPLER_HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
3
  require 'bundler'
3
4
  Bundler.setup(:default, :development)
4
5
  require File.join(File.dirname(__FILE__), '..', 'lib', 'coupler')
data/test/helper.rb CHANGED
@@ -27,8 +27,11 @@ dir = File.dirname(__FILE__)
27
27
  $LOAD_PATH.unshift(dir)
28
28
  require 'table_sets'
29
29
 
30
- $LOAD_PATH.unshift(File.join(dir, '..', 'lib'))
30
+ # set here and in the rake environment task
31
31
  ENV['COUPLER_ENV'] = 'test'
32
+ ENV['COUPLER_HOME'] = File.expand_path(File.join(dir, '..'))
33
+
34
+ $LOAD_PATH.unshift(File.join(dir, '..', 'lib'))
32
35
  require 'coupler'
33
36
 
34
37
  Coupler::Base.set(:sessions, false) # workaround
@@ -16,6 +16,7 @@ module Coupler
16
16
  Mongrel::HttpServer.stubs(:new).returns(@mongrel)
17
17
  @settings = stub('settings', :bind => '0.0.0.0', :port => 123)
18
18
  Base.stubs(:set => nil, :settings => @settings)
19
+ Runner.any_instance.stubs(:trap)
19
20
  end
20
21
 
21
22
  def capture_stdout
@@ -40,7 +41,6 @@ module Coupler
40
41
  @mongrel.expects(:register).with('/', @app)
41
42
  @mongrel.expects(:run).returns(@thread)
42
43
  Coupler::Base.expects(:set).with(:running, true)
43
- @thread.expects(:join)
44
44
  capture_stdout { Runner.new([]) }
45
45
  end
46
46
 
@@ -72,5 +72,34 @@ module Coupler
72
72
  Base.expects(:set).with(:environment, :development)
73
73
  capture_stdout { Runner.new(argv) }
74
74
  end
75
+
76
+ test "joining web server" do
77
+ r = nil
78
+ capture_stdout { r = Runner.new([]) }
79
+ @thread.expects(:join)
80
+ r.join
81
+ end
82
+
83
+ test "message proc" do
84
+ messages = []
85
+ Runner.new([]) do |msg|
86
+ messages << msg
87
+ end
88
+ assert !messages.empty?
89
+ end
90
+
91
+ test "traps INT" do
92
+ capture_stdout do
93
+ Runner.any_instance.expects(:trap).with("INT")
94
+ r = Runner.new([])
95
+ end
96
+ end
97
+
98
+ test "doesn't trap INT" do
99
+ capture_stdout do
100
+ Runner.any_instance.expects(:trap).with("INT").never
101
+ r = Runner.new([], :trap => false)
102
+ end
103
+ end
75
104
  end
76
105
  end
Binary file
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: coupler
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
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-10 00:00:00 -05:00
13
+ date: 2011-05-12 00:00:00 -05:00
14
14
  default_executable: coupler
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -279,6 +279,7 @@ files:
279
279
  - TODO
280
280
  - VERSION
281
281
  - bin/coupler
282
+ - coupler.gemspec
282
283
  - db/.gitignore
283
284
  - db/migrate/001_initial_schema.rb
284
285
  - db/migrate/002_stub.rb
@@ -363,8 +364,6 @@ files:
363
364
  - misc/jruby-json.license
364
365
  - misc/rack-flash.license
365
366
  - script/dbconsole.rb
366
- - src/edu/vanderbilt/coupler/Main.java
367
- - src/edu/vanderbilt/coupler/jruby.properties
368
367
  - tasks/annotations.rake
369
368
  - tasks/db.rake
370
369
  - tasks/environment.rake
@@ -420,7 +419,7 @@ files:
420
419
  - test/unit/test_runner.rb
421
420
  - test/unit/test_scheduler.rb
422
421
  - uploads/.gitignore
423
- - vendor/java/.gitignore
422
+ - vendor/h2-1.3.154.jar
424
423
  - webroot/public/css/960.css
425
424
  - webroot/public/css/dataTables.css
426
425
  - webroot/public/css/jquery-ui.css
@@ -1,116 +0,0 @@
1
- package edu.vanderbilt.coupler;
2
-
3
- import java.io.IOException;
4
- import java.io.InputStream;
5
- import java.util.Properties;
6
- import java.util.ArrayList;
7
- import java.util.List;
8
- import java.net.URISyntaxException;
9
- import java.net.URL;
10
- import java.util.regex.Matcher;
11
- import java.util.regex.Pattern;
12
- import org.jruby.embed.ScriptingContainer;
13
- import org.jruby.Ruby;
14
- import org.jruby.RubyArray;
15
- import org.jruby.RubyString;
16
-
17
- public class Main {
18
- private static final Properties couplerProperties = new Properties();
19
- public static final String COUPLER_PROPERTIES = "coupler.properties";
20
- public static final String JRUBY_PROPERTIES = "jruby.properties";
21
-
22
- static {
23
- InputStream stream = null;
24
- try {
25
- stream = Main.class.getResourceAsStream(COUPLER_PROPERTIES);
26
- if (stream == null) {
27
- throw new RuntimeException("Resource not found: " + COUPLER_PROPERTIES);
28
- }
29
- couplerProperties.load(stream);
30
- } catch (IOException ioe) {
31
- ioe.printStackTrace();
32
- } finally {
33
- if (stream != null) {
34
- try {
35
- stream.close();
36
- } catch (IOException e) {
37
- // silently ignore
38
- }
39
- }
40
- }
41
- }
42
-
43
- private Main(String[] args) {
44
- System.out.printf("Coupler version: %s\nBuild date: %s\n\n",
45
- couplerProperties.getProperty("coupler.version"),
46
- couplerProperties.getProperty("build.timestamp"));
47
-
48
- // Set JRuby runtime properties
49
- Properties systemProperties;
50
- InputStream stream = null;
51
- try {
52
- stream = Main.class.getResourceAsStream(JRUBY_PROPERTIES);
53
- if (stream == null) {
54
- throw new RuntimeException("Resource not found: " + JRUBY_PROPERTIES);
55
- }
56
- systemProperties = new Properties(System.getProperties());
57
- systemProperties.load(stream);
58
- System.setProperties(systemProperties);
59
- } catch (IOException ioe) {
60
- ioe.printStackTrace();
61
- } finally {
62
- if (stream != null) {
63
- try {
64
- stream.close();
65
- } catch (IOException e) {
66
- // silently ignore
67
- }
68
- }
69
- }
70
-
71
- String location = findCouplerPath();
72
- List<String> loadPaths = new ArrayList();
73
- loadPaths.add(location);
74
-
75
- ScriptingContainer container = new ScriptingContainer();
76
- container.setLoadPaths(loadPaths);
77
-
78
- // FIXME: I feel like there's a simpler way of doing this.
79
- Ruby ruby = container.getProvider().getRuntime();
80
- RubyArray rbArray = ruby.newArray();
81
- for (String string : args) {
82
- rbArray.append(ruby.newString(string));
83
- }
84
- container.put("argv", rbArray);
85
-
86
- // SystemExit gets thrown when someone runs the JAR with --help
87
- String script =
88
- "require 'coupler'\n" +
89
- "begin\n" +
90
- " Coupler::Runner.new(argv)\n" +
91
- "rescue SystemExit\n" +
92
- "end";
93
- container.runScriptlet(script);
94
- }
95
-
96
- private String findCouplerPath() {
97
- try {
98
- URL resource = getClass().getResource("/META-INF/coupler.home/lib/coupler.rb");
99
- String location = resource.toURI().getSchemeSpecificPart();
100
- Pattern p = Pattern.compile("coupler\\.rb$");
101
- Matcher m = p.matcher(location);
102
- while(m.find()) {
103
- location = location.substring(0, m.start() - 1);
104
- return location;
105
- }
106
- return null;
107
- }
108
- catch (URISyntaxException e) {
109
- return null;
110
- }
111
- }
112
-
113
- public static void main(String[] args) {
114
- new Main(args);
115
- }
116
- }
@@ -1 +0,0 @@
1
- jruby.thread.pooling=true
@@ -1,5 +0,0 @@
1
- mysql-connector-mxj*
2
- mysql-connector-java*
3
- one-jar*
4
- quartz*
5
- jruby-complete*