caruby-tissue 1.2.1

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 (133) hide show
  1. data/History.txt +4 -0
  2. data/LEGAL +5 -0
  3. data/LICENSE +22 -0
  4. data/README.md +44 -0
  5. data/bin/crtdump +31 -0
  6. data/bin/crtexample +18 -0
  7. data/bin/crtextract +47 -0
  8. data/bin/crtmigrate +17 -0
  9. data/bin/crtsmoke +27 -0
  10. data/examples/galena/README.md +53 -0
  11. data/examples/galena/bin/migrate.rb +42 -0
  12. data/examples/galena/bin/seed.rb +43 -0
  13. data/examples/galena/conf/extract/simple_fields.yaml +4 -0
  14. data/examples/galena/conf/migration/filter_fields.yaml +7 -0
  15. data/examples/galena/conf/migration/filter_migration.yaml +9 -0
  16. data/examples/galena/conf/migration/frozen_fields.yaml +11 -0
  17. data/examples/galena/conf/migration/frozen_migration.yaml +9 -0
  18. data/examples/galena/conf/migration/general_fields.yaml +42 -0
  19. data/examples/galena/conf/migration/general_migration.yaml +9 -0
  20. data/examples/galena/conf/migration/simple_fields.yaml +30 -0
  21. data/examples/galena/conf/migration/simple_migration.yaml +7 -0
  22. data/examples/galena/conf/migration/small_fields.yaml +24 -0
  23. data/examples/galena/conf/migration/small_migration.yaml +9 -0
  24. data/examples/galena/data/filter.csv +1 -0
  25. data/examples/galena/data/frozen.csv +1 -0
  26. data/examples/galena/data/general.csv +1 -0
  27. data/examples/galena/data/minimal.csv +1 -0
  28. data/examples/galena/data/simple.csv +1 -0
  29. data/examples/galena/data/small.csv +1 -0
  30. data/examples/galena/doc/CaTissue.html +93 -0
  31. data/examples/galena/doc/CaTissue/CollectionProtocolRegistration.html +181 -0
  32. data/examples/galena/doc/CaTissue/Participant.html +241 -0
  33. data/examples/galena/doc/CaTissue/SpecimenCollectionGroup.html +190 -0
  34. data/examples/galena/doc/CaTissue/StorageContainer.html +179 -0
  35. data/examples/galena/doc/CaTissue/TissueSpecimen.html +320 -0
  36. data/examples/galena/doc/Galena.html +290 -0
  37. data/examples/galena/doc/Galena/Seed.html +203 -0
  38. data/examples/galena/doc/Galena/Seed/Defaults.html +646 -0
  39. data/examples/galena/doc/_index.html +188 -0
  40. data/examples/galena/doc/class_list.html +36 -0
  41. data/examples/galena/doc/css/common.css +1 -0
  42. data/examples/galena/doc/css/full_list.css +53 -0
  43. data/examples/galena/doc/css/style.css +307 -0
  44. data/examples/galena/doc/file.README.html +108 -0
  45. data/examples/galena/doc/file_list.html +38 -0
  46. data/examples/galena/doc/frames.html +13 -0
  47. data/examples/galena/doc/index.html +108 -0
  48. data/examples/galena/doc/js/app.js +202 -0
  49. data/examples/galena/doc/js/full_list.js +149 -0
  50. data/examples/galena/doc/js/jquery.js +154 -0
  51. data/examples/galena/doc/method_list.html +179 -0
  52. data/examples/galena/doc/top-level-namespace.html +112 -0
  53. data/examples/galena/lib/README.html +33 -0
  54. data/examples/galena/lib/galena.rb +8 -0
  55. data/examples/galena/lib/galena/cli/seed.rb +43 -0
  56. data/examples/galena/lib/galena/migration/filter_shims.rb +43 -0
  57. data/examples/galena/lib/galena/migration/frozen_shims.rb +54 -0
  58. data/examples/galena/lib/galena/seed/defaults.rb +97 -0
  59. data/lib/catissue.rb +26 -0
  60. data/lib/catissue/cli/command.rb +51 -0
  61. data/lib/catissue/cli/example.rb +31 -0
  62. data/lib/catissue/cli/migrate.rb +60 -0
  63. data/lib/catissue/cli/smoke.rb +45 -0
  64. data/lib/catissue/database.rb +451 -0
  65. data/lib/catissue/database/annotation/annotatable_service.rb +25 -0
  66. data/lib/catissue/database/annotation/annotation_service.rb +79 -0
  67. data/lib/catissue/database/annotation/annotator.rb +84 -0
  68. data/lib/catissue/database/annotation/entity_manager.rb +10 -0
  69. data/lib/catissue/database/annotation/integration_service.rb +87 -0
  70. data/lib/catissue/database/controlled_value_finder.rb +43 -0
  71. data/lib/catissue/database/controlled_values.rb +162 -0
  72. data/lib/catissue/domain/abstract_domain_object.rb +8 -0
  73. data/lib/catissue/domain/abstract_position.rb +22 -0
  74. data/lib/catissue/domain/abstract_specimen.rb +288 -0
  75. data/lib/catissue/domain/abstract_specimen_collection_group.rb +25 -0
  76. data/lib/catissue/domain/address.rb +13 -0
  77. data/lib/catissue/domain/cancer_research_group.rb +11 -0
  78. data/lib/catissue/domain/capacity.rb +34 -0
  79. data/lib/catissue/domain/check_in_check_out_event_parameter.rb +19 -0
  80. data/lib/catissue/domain/collection_event_parameters.rb +13 -0
  81. data/lib/catissue/domain/collection_protocol.rb +177 -0
  82. data/lib/catissue/domain/collection_protocol_event.rb +108 -0
  83. data/lib/catissue/domain/collection_protocol_registration.rb +108 -0
  84. data/lib/catissue/domain/consent_tier_response.rb +13 -0
  85. data/lib/catissue/domain/consent_tier_status.rb +29 -0
  86. data/lib/catissue/domain/container.rb +234 -0
  87. data/lib/catissue/domain/container_position.rb +21 -0
  88. data/lib/catissue/domain/container_type.rb +131 -0
  89. data/lib/catissue/domain/department.rb +13 -0
  90. data/lib/catissue/domain/disposal_event_parameters.rb +13 -0
  91. data/lib/catissue/domain/embedded_event_parameters.rb +10 -0
  92. data/lib/catissue/domain/external_identifier.rb +22 -0
  93. data/lib/catissue/domain/frozen_event_parameters.rb +10 -0
  94. data/lib/catissue/domain/institution.rb +13 -0
  95. data/lib/catissue/domain/new_specimen_array_order_item.rb +35 -0
  96. data/lib/catissue/domain/order_details.rb +25 -0
  97. data/lib/catissue/domain/participant.rb +138 -0
  98. data/lib/catissue/domain/participant_medical_identifier.rb +38 -0
  99. data/lib/catissue/domain/password.rb +11 -0
  100. data/lib/catissue/domain/race.rb +11 -0
  101. data/lib/catissue/domain/received_event_parameters.rb +25 -0
  102. data/lib/catissue/domain/scg_event_parameters.rb +11 -0
  103. data/lib/catissue/domain/site.rb +30 -0
  104. data/lib/catissue/domain/specimen.rb +456 -0
  105. data/lib/catissue/domain/specimen_array.rb +47 -0
  106. data/lib/catissue/domain/specimen_array_content.rb +19 -0
  107. data/lib/catissue/domain/specimen_array_type.rb +20 -0
  108. data/lib/catissue/domain/specimen_characteristics.rb +20 -0
  109. data/lib/catissue/domain/specimen_collection_group.rb +412 -0
  110. data/lib/catissue/domain/specimen_event_parameters.rb +111 -0
  111. data/lib/catissue/domain/specimen_position.rb +38 -0
  112. data/lib/catissue/domain/specimen_protocol.rb +34 -0
  113. data/lib/catissue/domain/specimen_requirement.rb +143 -0
  114. data/lib/catissue/domain/storage_container.rb +204 -0
  115. data/lib/catissue/domain/storage_type.rb +82 -0
  116. data/lib/catissue/domain/transfer_event_parameters.rb +53 -0
  117. data/lib/catissue/domain/user.rb +100 -0
  118. data/lib/catissue/extract/command.rb +31 -0
  119. data/lib/catissue/extract/delta.rb +62 -0
  120. data/lib/catissue/extract/extractor.rb +99 -0
  121. data/lib/catissue/migration/migrator.rb +101 -0
  122. data/lib/catissue/migration/shims.rb +108 -0
  123. data/lib/catissue/migration/uniquify.rb +111 -0
  124. data/lib/catissue/resource.rb +84 -0
  125. data/lib/catissue/util/controlled_value.rb +29 -0
  126. data/lib/catissue/util/location.rb +116 -0
  127. data/lib/catissue/util/log.rb +30 -0
  128. data/lib/catissue/util/person.rb +31 -0
  129. data/lib/catissue/util/position.rb +54 -0
  130. data/lib/catissue/util/storable.rb +34 -0
  131. data/lib/catissue/util/storage_type_holder.rb +30 -0
  132. data/lib/catissue/version.rb +7 -0
  133. metadata +212 -0
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>Top Level Namespace</title>
7
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="_index.html">Index</a> &raquo;
27
+
28
+
29
+ <span class="title">Top Level Namespace</span>
30
+
31
+
32
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
+ </div>
34
+
35
+ <div id="search">
36
+ <a id="class_list_link" href="#">Class List</a>
37
+ <a id="method_list_link" href="#">Method List</a>
38
+ <a id ="file_list_link" href="#">File List</a>
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+ </div>
43
+
44
+ <iframe id="search_frame"></iframe>
45
+
46
+ <div id="content"><h1>Top Level Namespace
47
+
48
+
49
+
50
+ </h1>
51
+
52
+ <dl class="box">
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ </dl>
62
+ <div class="clear"></div>
63
+
64
+ <h2>Defined Under Namespace</h2>
65
+ <p class="children">
66
+
67
+
68
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="CaTissue.html" title="CaTissue (module)">CaTissue</a></span>, <span class='object_link'><a href="Galena.html" title="Galena (module)">Galena</a></span>
69
+
70
+
71
+
72
+
73
+ </p>
74
+
75
+ <h2>Constant Summary</h2>
76
+
77
+ <dl class="constants">
78
+
79
+ <dt id="DEF_LOG_FILE-constant" class="">DEF_LOG_FILE =
80
+ <div class="docstring">
81
+ <div class="discussion">
82
+ <p>
83
+ the default log file
84
+ </p>
85
+
86
+
87
+ </div>
88
+ </div>
89
+ <div class="tags">
90
+
91
+ </div>
92
+ </dt>
93
+ <dd><pre class="code"><span class='string val'>'log/migration.log'</span>
94
+ </pre></dd>
95
+
96
+ </dl>
97
+
98
+
99
+
100
+
101
+
102
+
103
+ </div>
104
+
105
+ <div id="footer">
106
+ Generated on Tue Nov 23 11:38:43 2010 by
107
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
+ 0.6.1 (ruby-1.8.6).
109
+ </div>
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,33 @@
1
+ <h1>Galena Cancer Center Tissue Bank Migrator example</h1>
2
+ <p>
3
+ This migration example demonstrates how to load the content of a hypothetical
4
+ custom tissue bank into caTissue. The use case illustrates several common
5
+ migration impediments:
6
+ <ul>
7
+ <li>Different terminology than caTissue
8
+ <li>Different associations than caTissue
9
+ <li>Incomplete input for caTissue
10
+ <li>Denormalized input
11
+ <li>Inconsistent input
12
+ <li>Input data scrubbing
13
+ <li>Aliquot inference
14
+ <li>Pre-defined caTissue protocol
15
+ </ul>
16
+ These migration features are described in the migration process below.
17
+ </p>
18
+ <h2>Migration Process</h2>
19
+ <h2>Input data</h2>
20
+ <p>
21
+ The hypothetical Galena Tissue Bank data resides in the <tt>data/galena.csv</tt>
22
+ CSV file included in the example. The CSV file holds one row for each specimen.
23
+ The fields are as follows:
24
+ <dl>
25
+ <dt>MRN</dt><dd>Patient Medical Record Number</dd>
26
+ <dt>Initials</dt><dd>Patient name initials</dd>
27
+ <dt>Frozen?</dt><dd>Flag indicating whether the specimen is frozen</dd>
28
+ <dt>SPN</dt><dd>Surgical Pathology Number</dd>
29
+ <dt>Collection Date</dt><dd>Specimen date of collection</dd>
30
+ <dt>Quantity</dt><dd>Amount collected</dd>
31
+ </dl>
32
+ </p>
33
+
@@ -0,0 +1,8 @@
1
+ # The caRuby Tissue Galena example module.
2
+ module Galena
3
+ # @param [String] the path (without wildcards) of the desired file relative to the gem root directory
4
+ # @return [String, nil] the file in this gem which matches the given path
5
+ def self.resource(path)
6
+ File.expand_path(File.join(File.dirname(__FILE__), '..', path))
7
+ end
8
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # == Synopsis
4
+ #
5
+ # catissue-seed-galena.rb: seeds the Galena example administrative objects in the database
6
+ #
7
+ # == Usage
8
+ #
9
+ # catissue-seed-galena.rb [options] file
10
+ #
11
+ # --help, -h:
12
+ # print this help message and exit
13
+ #
14
+ # --log file, -l file:
15
+ # log file (default ./log/migration.log)
16
+ #
17
+ # --debug, -d:
18
+ # print debug messages to log (optional)
19
+ #
20
+ # == License
21
+ #
22
+ # This program is licensed under the terms of the +LEGAL+ file in
23
+ # the source distribution.
24
+
25
+ # load the required gems
26
+ require 'rubygems'
27
+ begin
28
+ gem 'caruby-tissue'
29
+ rescue LoadError
30
+ # if the gem is not available, then try a local source
31
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
32
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'examples', 'galena', 'lib')
33
+ end
34
+
35
+ # the default log file
36
+ DEF_LOG_FILE = 'log/migration.log'
37
+
38
+ require 'catissue'
39
+ require 'catissue/cli/command'
40
+
41
+ require 'galena/seed/defaults'
42
+
43
+ CaTissue::Command.new.execute { Galena::Seed.defaults.ensure_exists }
@@ -0,0 +1,43 @@
1
+ require 'uom'
2
+
3
+ module CaTissue
4
+
5
+ # Declares the classes modified for migration.
6
+ shims Participant, TissueSpecimen, SpecimenCollectionGroup
7
+
8
+ class Participant
9
+ # Extracts the Participant first name from the +Initials+ input field.
10
+ def migrate_first_name(value, row)
11
+ self.first_name = value[0, 1]
12
+ end
13
+
14
+ # Extracts the Participant last name from the +Initials+ input field.
15
+ def migrate_last_name(value, row)
16
+ self.last_name = value[-1, 1]
17
+ end
18
+ end
19
+
20
+ class TissueSpecimen
21
+ # Transforms the +Frozen?+ flag input field to the caTissue specimen type +Frozen Tissue+ value.
22
+ def migrate_specimen_type(value, row)
23
+ 'Frozen Tissue' if value =~ /TRUE/i
24
+ end
25
+
26
+ # Parses the source field as a UOM::Measurement if it is a string.
27
+ # Otherwises, returns the source value.
28
+ def migrate_initial_quantity(value, row)
29
+ # if value is not a string, then use it as is
30
+ return value unless value.is_a?(String)
31
+ # the value has a unit qualifier; parse the measurement.
32
+ # the unit is normalized to the Specimen standard unit.
33
+ value.to_measurement_quantity(standard_unit)
34
+ end
35
+ end
36
+
37
+ class SpecimenCollectionGroup
38
+ # Returns whether this SCG has a SPN.
39
+ def migration_valid?
40
+ surgical_pathology_number
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,54 @@
1
+ require 'galena/seed/defaults'
2
+
3
+ module CaTissue
4
+
5
+ # Declares the classes modified for migration.
6
+ shims TissueSpecimen, CollectionProtocolRegistration, StorageContainer
7
+
8
+ class TissueSpecimen
9
+ # Sets the specimen type to +Frozen Tissue+.
10
+ #
11
+ # @param (see CaRuby::Migratable#migrate)
12
+ def migrate(row, migrated)
13
+ super
14
+ self.specimen_type = 'Frozen Tissue'
15
+ end
16
+ end
17
+
18
+ class CollectionProtocolRegistration
19
+ # Sets this CPR's protocol to the pre-defined {Galena::Migration::Defaults#protocol}.
20
+ #
21
+ # @param (see CaRuby::Migratable#migrate)
22
+ def migrate(row, migrated)
23
+ super
24
+ self.protocol = Galena::Seed.defaults.protocol
25
+ end
26
+ end
27
+
28
+ class StorageContainer
29
+ # Creates the migrated box in the database, if necessary.
30
+ #
31
+ # @param (see CaRuby::Migratable#migrate)
32
+ def migrate(row, migrated)
33
+ super
34
+ find or create_box
35
+ end
36
+
37
+ private
38
+
39
+ # Creates a new box of type {Galena::Migration::Defaults#box_type} in a
40
+ # freezer of type {Galena::Migration::Defaults#freezer_type}.
41
+ #
42
+ # @return [StorageContainer] the new box
43
+ def create_box
44
+ defs = Galena::Seed.defaults
45
+ self.storage_type = defs.box_type
46
+ self.site = defs.tissue_bank
47
+ # A freezer with a spot for the box
48
+ frz = defs.freezer_type.find_available(site, :create)
49
+ if frz.nil? then raise CaRuby::MigrationError.new("Freezer not available to place #{self}") end
50
+ # Add this box to the first open slot in the first unfilled rack in the freezer.
51
+ frz << self
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,97 @@
1
+ require 'singleton'
2
+ require 'catissue'
3
+
4
+ module Galena
5
+ # Creates the {Galena::Seed::Defaults} administrative objects as necessary.
6
+ def self.seed
7
+ Seed.defaults.ensure_exists
8
+ end
9
+
10
+ # Galena example utility module to populate the database with pre-defined administrative objects.
11
+ module Seed
12
+ # @return [Defaults] the defaults instance
13
+ def self.defaults
14
+ Defaults.instance
15
+ end
16
+
17
+ # Pre-defined Galena example administrative objects. If the Galena example is already set up
18
+ # in the caTissue database, then the default object secondary key attributes can be used as a
19
+ # {CaRuby::Persistable#find} template to retrieve the existing objects. Otherwise, the Defaults
20
+ # attributes can be created by calling {CaRuby::Persistable#create}.
21
+ #
22
+ # In a real-world use case, the administrative objects are typically built in the UI before-hand.
23
+ # In that case, it is only necessary to define the object secondary key rather than content, e.g.:
24
+ # pcl = CaTissue::CollectionProtocol.new(:short_title => 'Galena CP')
25
+ # The complete definitions are included in this method for convenience in order to seed the
26
+ # example in a test database.
27
+ class Defaults
28
+ include Singleton
29
+
30
+ attr_reader :protocol, :hospital, :tissue_bank, :freezer_type, :box_type
31
+
32
+ # Creates the Galena example Defaults singleton and populates the attributes.
33
+ def initialize
34
+ super
35
+ populate
36
+ end
37
+
38
+ # Creates the Galena example administrative objects as necessary.
39
+ def ensure_exists
40
+ @protocol.find(:create)
41
+ @hospital.find(:create)
42
+ @freezer_type.find(:create)
43
+ end
44
+
45
+ private
46
+
47
+ # Sets the Galena example Defaults attributes to new objects.
48
+ def populate
49
+ galena = CaTissue::Institution.new(:name => 'Galena University')
50
+
51
+ addr = CaTissue::Address.new(
52
+ :city => 'Galena', :state => 'Illinois', :country => 'United States', :zipCode => '37544',
53
+ :street => '411 Basin St', :phoneNumber => '311-555-5555')
54
+
55
+ dept = CaTissue::Department.new(:name => 'Pathology')
56
+
57
+ crg = CaTissue::CancerResearchGroup.new(:name => 'Don Thomas Cancer Center')
58
+
59
+ coord = CaTissue::User.new(
60
+ :email_address => 'corey.nator@galena.edu',
61
+ :last_name => 'Nator', :first_name => 'Corey', :address => addr.copy,
62
+ :institution => galena, :department => dept, :cancer_research_group => crg)
63
+
64
+ @hospital = CaTissue::Site.new(
65
+ :site_type => CaTissue::Site::SiteType::COLLECTION, :name => 'Galena Hospital',
66
+ :address => addr, :coordinator => coord)
67
+
68
+ @tissue_bank = CaTissue::Site.new(
69
+ :site_type => CaTissue::Site::SiteType::REPOSITORY, :name => 'Galena Tissue Bank',
70
+ :address => addr, :coordinator => coord)
71
+
72
+ pi = CaTissue::User.new(
73
+ :email_address => 'vesta.gator@galena.edu',
74
+ :last_name => 'Gator', :first_name => 'Vesta', :address => addr.copy,
75
+ :institution => galena, :department => dept, :cancer_research_group => crg)
76
+
77
+ @protocol = CaTissue::CollectionProtocol.new(:short_title => 'Galena CP',
78
+ :principal_investigator => pi, :sites => [@tissue_bank])
79
+
80
+ # CPE has default 1.0 event point and label
81
+ cpe = CaTissue::CollectionProtocolEvent.new(:collection_protocol => @protocol)
82
+
83
+ # the sole specimen requirement. Setting the requirement collection_event attribute to a CPE automatically
84
+ # sets the CPE requirement inverse attribute in caRuby.
85
+ CaTissue::TissueSpecimenRequirement.new(:collection_event => cpe, :specimen_type => 'Fixed Tissue')
86
+
87
+ # a storage container
88
+ @freezer_type = CaTissue::StorageType.new(:name => 'GTB Freezer', :columns => 10, :rows => 1, :column_label => 'Rack')
89
+ rack_type = CaTissue::StorageType.new(:name => 'GTB Rack', :columns => 10, :rows => 10)
90
+ @box_type = CaTissue::StorageType.new(:name => 'GTB Box', :columns => 10, :rows => 10)
91
+ @freezer_type << rack_type
92
+ rack_type << box_type
93
+ @box_type << 'Tissue'
94
+ end
95
+ end
96
+ end
97
+ end
data/lib/catissue.rb ADDED
@@ -0,0 +1,26 @@
1
+ # This file is the entry point included by applications which reference a CaTissue object or service.
2
+
3
+ # the caRuby core gem
4
+ require 'rubygems'
5
+ begin
6
+ gem 'caruby-core'
7
+ rescue LoadError
8
+ # if the gem is not available, then try a local development source
9
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'caruby', 'lib')
10
+ end
11
+
12
+ require 'caruby/util/log'
13
+ require 'catissue/util/log'
14
+ require 'catissue/resource'
15
+ require 'catissue/database'
16
+
17
+ # CaTissue wraps the caTissue Java API.
18
+ # See the caRuby[http://http://caruby.rubyforge.org/] home page for more information.
19
+ module CaTissue
20
+ # @param [<String>] nodes the path components relative to the caRuby Tissue source directory
21
+ # @return [String] the file path to the specified path components
22
+ def self.path(*nodes)
23
+ root = File.join(File.dirname(__FILE__), '..')
24
+ File.expand_path(File.join(*nodes), root)
25
+ end
26
+ end
@@ -0,0 +1,51 @@
1
+ # the standard log file
2
+ DEF_LOG_FILE = 'log/catissue.log' unless defined?(DEF_LOG_FILE)
3
+
4
+ begin
5
+ require 'catissue'
6
+ rescue Exception => e
7
+ logger.error("caTissue client load was unsuccessful - #{e}:\n#{e.backtrace.qp}")
8
+ puts "caTissue client load was unsuccessful - #{e}."
9
+ puts "See the log at #{CaRuby::Log.instance.file} for more information."
10
+ exit 1
11
+ end
12
+
13
+ require 'caruby/cli/command'
14
+ require 'catissue/version'
15
+
16
+ module CaTissue
17
+ module CLI
18
+ # Augments {CaRuby::CLI::Command} with caTissue-specific command line option handlers.
19
+ class Command < CaRuby::CLI::Command
20
+ # @see {CaRuby::CLI::Command#initialize}
21
+ def initialize(specs=[], &executor)
22
+ specs << VERSION_OPT
23
+ super { |opts| handle_catissue_options(opts, &executor) }
24
+ end
25
+
26
+ private
27
+
28
+ # If the version option is set, then prints the version and exits.
29
+ # Otherwise, extracts the connection command line options, adds them
30
+ # to {CaTissue.access_properties}, and yields to the executor block.
31
+ #
32
+ # @param [{Symbol => Object}] opts the command line argument and option symbol => value hash
33
+ def handle_catissue_options(opts)
34
+ if opts[:version] then
35
+ puts "#{CaTissue::VERSION} for caTissue v#{CaTissue::CATISSUE_VERSIONS}"
36
+ else
37
+ CaRuby::ACCESS_OPTS.each do |opt, *spec|
38
+ value = opts.delete(opt)
39
+ CaTissue.access_properties[opt] = value if value
40
+ end
41
+ yield(opts)
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ VERSION_OPT = [:version, "--version", "Prints the version of caRuby Tissue and the supported caTissue releases and exits"]
48
+
49
+ end
50
+ end
51
+ end