caruby-core 1.4.9 → 1.5.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.
- data/History.md +48 -0
- data/lib/caruby/cli/command.rb +2 -1
- data/lib/caruby/csv/csv_mapper.rb +8 -8
- data/lib/caruby/database/persistable.rb +44 -65
- data/lib/caruby/database/persistence_service.rb +12 -9
- data/lib/caruby/database/persistifier.rb +14 -14
- data/lib/caruby/database/reader.rb +53 -51
- data/lib/caruby/database/search_template_builder.rb +9 -10
- data/lib/caruby/database/store_template_builder.rb +58 -58
- data/lib/caruby/database/writer.rb +96 -96
- data/lib/caruby/database.rb +19 -19
- data/lib/caruby/domain/attribute.rb +581 -0
- data/lib/caruby/domain/attributes.rb +615 -0
- data/lib/caruby/domain/dependency.rb +240 -0
- data/lib/caruby/domain/importer.rb +183 -0
- data/lib/caruby/domain/introspection.rb +176 -0
- data/lib/caruby/domain/inverse.rb +173 -0
- data/lib/caruby/domain/inversible.rb +1 -2
- data/lib/caruby/domain/java_attribute.rb +173 -0
- data/lib/caruby/domain/merge.rb +13 -10
- data/lib/caruby/domain/metadata.rb +141 -0
- data/lib/caruby/domain/mixin.rb +35 -0
- data/lib/caruby/domain/reference_visitor.rb +5 -3
- data/lib/caruby/domain.rb +340 -0
- data/lib/caruby/import/java.rb +29 -25
- data/lib/caruby/migration/migratable.rb +5 -5
- data/lib/caruby/migration/migrator.rb +19 -15
- data/lib/caruby/migration/resource_module.rb +1 -1
- data/lib/caruby/resource.rb +39 -30
- data/lib/caruby/util/collection.rb +94 -33
- data/lib/caruby/util/coordinate.rb +28 -2
- data/lib/caruby/util/log.rb +4 -4
- data/lib/caruby/util/module.rb +12 -28
- data/lib/caruby/util/partial_order.rb +9 -10
- data/lib/caruby/util/pretty_print.rb +46 -26
- data/lib/caruby/util/topological_sync_enumerator.rb +10 -4
- data/lib/caruby/util/transitive_closure.rb +2 -2
- data/lib/caruby/util/visitor.rb +1 -1
- data/lib/caruby/version.rb +1 -1
- data/test/lib/caruby/database/persistable_test.rb +1 -1
- data/test/lib/caruby/domain/domain_test.rb +14 -28
- data/test/lib/caruby/domain/inversible_test.rb +1 -1
- data/test/lib/caruby/import/java_test.rb +5 -0
- data/test/lib/caruby/migration/test_case.rb +0 -1
- data/test/lib/caruby/test_case.rb +9 -10
- data/test/lib/caruby/util/collection_test.rb +23 -5
- data/test/lib/caruby/util/module_test.rb +10 -14
- data/test/lib/caruby/util/partial_order_test.rb +16 -15
- data/test/lib/caruby/util/visitor_test.rb +1 -1
- data/test/lib/examples/galena/clinical_trials/migration/test_case.rb +1 -1
- metadata +16 -15
- data/History.txt +0 -44
- data/lib/caruby/domain/attribute_metadata.rb +0 -551
- data/lib/caruby/domain/java_attribute_metadata.rb +0 -183
- data/lib/caruby/domain/resource_attributes.rb +0 -565
- data/lib/caruby/domain/resource_dependency.rb +0 -217
- data/lib/caruby/domain/resource_introspection.rb +0 -160
- data/lib/caruby/domain/resource_inverse.rb +0 -151
- data/lib/caruby/domain/resource_metadata.rb +0 -155
- data/lib/caruby/domain/resource_module.rb +0 -370
- data/lib/caruby/yard/resource_metadata_handler.rb +0 -8
@@ -7,14 +7,15 @@ require 'caruby/util/collection'
|
|
7
7
|
require 'caruby/util/inflector'
|
8
8
|
|
9
9
|
class PrettyPrint
|
10
|
-
#
|
10
|
+
# The standard +prettyprint+ gem SingleLine is adjusted to add an output accessor and an optional output argument to {#initialize}.
|
11
11
|
class SingleLine
|
12
|
+
# @return [String] the print target
|
12
13
|
attr_reader :output
|
13
14
|
|
14
15
|
alias :base__initialize :initialize
|
15
16
|
private :base__initialize
|
16
17
|
|
17
|
-
#
|
18
|
+
# Overrides the standard SingleLine initializer to supply an output parameter default.
|
18
19
|
def initialize(output='', maxwidth=nil, newline=nil)
|
19
20
|
base__initialize(output, maxwidth, newline)
|
20
21
|
end
|
@@ -29,13 +30,14 @@ class PrintWrapper < Proc
|
|
29
30
|
@args = args
|
30
31
|
end
|
31
32
|
|
32
|
-
#
|
33
|
+
# @param args this wrapper's print block parameters
|
34
|
+
# @return [PrintWrapper] self
|
33
35
|
def wrap(*args)
|
34
36
|
@args = args
|
35
37
|
self
|
36
38
|
end
|
37
39
|
|
38
|
-
# Calls this PrintWrapper's print procedure on
|
40
|
+
# Calls this PrintWrapper's print procedure on the arguments set in the initializer.
|
39
41
|
def to_s
|
40
42
|
@args.empty? ? 'nil' : call(*@args)
|
41
43
|
end
|
@@ -44,7 +46,7 @@ class PrintWrapper < Proc
|
|
44
46
|
end
|
45
47
|
|
46
48
|
class Object
|
47
|
-
#
|
49
|
+
# @return [String] this object's class demodulized name and object id
|
48
50
|
def print_class_and_id
|
49
51
|
"#{self.class.qp}@#{object_id}"
|
50
52
|
end
|
@@ -52,11 +54,14 @@ class Object
|
|
52
54
|
# qp, an abbreviation for quick-print, calls {#print_class_and_id} in this base implementation.
|
53
55
|
alias :qp :print_class_and_id
|
54
56
|
|
55
|
-
# Formats this object
|
56
|
-
#
|
57
|
-
|
57
|
+
# Formats this object with the standard {PrettyPrint}.
|
58
|
+
#
|
59
|
+
# @param [Hash, Symbol, nil] opts the print options
|
60
|
+
# @option opts [Boolean] :single_line print the output on a single line
|
61
|
+
# @return [String] the formatted print result
|
62
|
+
def pp_s(opts=nil)
|
58
63
|
s = StringIO.new
|
59
|
-
if Options.get(:single_line,
|
64
|
+
if Options.get(:single_line, opts) then
|
60
65
|
PP.singleline_pp(self, s)
|
61
66
|
else
|
62
67
|
PP.pp(self, s)
|
@@ -67,58 +72,70 @@ class Object
|
|
67
72
|
end
|
68
73
|
|
69
74
|
class Numeric
|
70
|
-
# qp
|
75
|
+
# Alias #{Object#qp} to {#to_s} in this primitive class.
|
71
76
|
alias :qp :to_s
|
72
77
|
end
|
73
78
|
|
74
79
|
class String
|
75
|
-
# qp
|
80
|
+
# Alias #{Object#qp} to {#to_s} in this primitive class.
|
76
81
|
alias :qp :to_s
|
77
82
|
end
|
78
83
|
|
79
84
|
class TrueClass
|
80
|
-
# qp
|
85
|
+
# Alias #{Object#qp} to {#to_s} in this primitive class.
|
81
86
|
alias :qp :to_s
|
82
87
|
end
|
83
88
|
|
84
89
|
class FalseClass
|
85
|
-
# qp
|
90
|
+
# Alias #{Object#qp} to {#to_s} in this primitive class.
|
86
91
|
alias :qp :to_s
|
87
92
|
end
|
88
93
|
|
89
94
|
class NilClass
|
90
|
-
# qp
|
95
|
+
# Alias #{Object#qp} to {#to_s} in this primitive class.
|
91
96
|
alias :qp :inspect
|
92
97
|
end
|
93
98
|
|
94
99
|
class Symbol
|
95
|
-
# qp
|
100
|
+
# Alias #{Object#qp} to {#to_s} in this primitive class.
|
96
101
|
alias :qp :inspect
|
97
102
|
end
|
98
103
|
|
99
104
|
class Module
|
100
|
-
#
|
105
|
+
# @return [String ] the demodulized name
|
101
106
|
def qp
|
102
107
|
name[/\w+$/]
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
106
111
|
module Enumerable
|
107
|
-
#
|
108
|
-
# Non-collection
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
#
|
112
|
+
# Prints this Enumerable with a filter that calls qp on each item.
|
113
|
+
# Non-collection Enumerable classes override this method to delegate to {Object#qp}.
|
114
|
+
#
|
115
|
+
# Unlike {Object#qp}, this implementation accepts the {Object#pp_s} options.
|
116
|
+
# The options are used to format this Enumerable, but are not propagated to the
|
117
|
+
# enumerated items.
|
118
|
+
#
|
119
|
+
# @param (see Object#pp_s)
|
120
|
+
# @return [String] the formatted result
|
121
|
+
def qp(opts=nil)
|
122
|
+
wrap { |item| item.qp }.pp_s(opts)
|
123
|
+
end
|
124
|
+
|
125
|
+
# If a transformer block is given to this method, then the block is applied to each
|
114
126
|
# enumerated item before pretty-printing the result.
|
115
|
-
|
127
|
+
#
|
128
|
+
# @param (see Object#pp_s)
|
129
|
+
# @yield [item] transforms the item to print
|
130
|
+
# @yieldparam item the item to print
|
131
|
+
# @return (see Oblect#pp_s)
|
132
|
+
def pp_s(opts=nil)
|
116
133
|
# delegate to Object if no block
|
117
|
-
return super
|
134
|
+
return super unless block_given?
|
118
135
|
# make a print wrapper
|
119
136
|
wrapper = PrintWrapper.new { |item| yield item }
|
120
137
|
# print using the wrapper on each item
|
121
|
-
wrap { |item| wrapper.wrap(item) }.pp_s(
|
138
|
+
wrap { |item| wrapper.wrap(item) }.pp_s(opts)
|
122
139
|
end
|
123
140
|
|
124
141
|
# Pretty-prints the content within brackets, as is done by the Array pretty printer.
|
@@ -138,6 +155,8 @@ end
|
|
138
155
|
|
139
156
|
module Hashable
|
140
157
|
# qp, short for quick-print, prints this Hashable with a filter that calls qp on each key and value.
|
158
|
+
#
|
159
|
+
# @return [String] the quick-print result
|
141
160
|
def qp
|
142
161
|
qph = {}
|
143
162
|
each { |k, v| qph[k.qp] = v.qp }
|
@@ -161,6 +180,7 @@ class String
|
|
161
180
|
end
|
162
181
|
|
163
182
|
class DateTime
|
183
|
+
# @return [String] the formatted +strftime+
|
164
184
|
def pretty_print(q)
|
165
185
|
q.text(strftime)
|
166
186
|
end
|
@@ -3,16 +3,22 @@ require 'caruby/util/collection'
|
|
3
3
|
class TopologicalSyncEnumerator
|
4
4
|
include Enumerable
|
5
5
|
|
6
|
-
|
6
|
+
# @param targets the objects to synch to
|
7
|
+
# @param sources the objects to synch from
|
8
|
+
# @param [Symbol] method the topological order reference method
|
9
|
+
# @yield (see #each)
|
10
|
+
def initialize(targets, sources, method, &matcher)
|
7
11
|
@tgts = targets
|
8
12
|
@srcs = sources
|
9
|
-
@mthd =
|
13
|
+
@mthd = method
|
10
14
|
@matcher = matcher || lambda { |tgt, srcs| srcs.first }
|
11
15
|
end
|
12
16
|
|
13
17
|
# Calls the given block on each matching target and source.
|
14
|
-
#
|
15
|
-
|
18
|
+
#
|
19
|
+
# @yield [target, source] the objects to synchronize
|
20
|
+
# @return [Hash] the matching target => source hash
|
21
|
+
def each
|
16
22
|
# the parent hashes for targets and sources
|
17
23
|
pt = @tgts.to_compact_hash { |tgt| tgt.send(@mthd) }
|
18
24
|
ps = @srcs.to_compact_hash { |src| src.send(@mthd) }
|
@@ -34,9 +34,9 @@ module Enumerable
|
|
34
34
|
# Returns the transitive closure over all items in this Enumerable.
|
35
35
|
#
|
36
36
|
# @see Object#transitive_closure
|
37
|
-
def transitive_closure(method=nil
|
37
|
+
def transitive_closure(method=nil)
|
38
38
|
# delegate to Object if there is a method argument
|
39
|
-
return super(method
|
39
|
+
return super(method) if method
|
40
40
|
# this Enumerable's children are this Enumerable's contents
|
41
41
|
closure = super() { |node| node.equal?(self) ? self : yield(node) }
|
42
42
|
# remove this collection from the closure
|
data/lib/caruby/util/visitor.rb
CHANGED
@@ -139,7 +139,7 @@ module CaRuby
|
|
139
139
|
|
140
140
|
# @return [Enumerable] iterator over each visited node
|
141
141
|
def to_enum(node)
|
142
|
-
# JRuby
|
142
|
+
# JRuby could use Generator instead, but that results in dire behavior on any error
|
143
143
|
# by crashing with an elided Java lineage trace.
|
144
144
|
VisitorEnumerator.new(self, node)
|
145
145
|
end
|
data/lib/caruby/version.rb
CHANGED
@@ -85,7 +85,7 @@ class PersistableTest < Test::Unit::TestCase
|
|
85
85
|
|
86
86
|
def duplicate_with_id(obj)
|
87
87
|
return obj.map { |item| duplicate_with_id(item) } if Enumerable === obj
|
88
|
-
copy = obj.copy
|
88
|
+
copy = obj.copy
|
89
89
|
copy.identifier ||= @@counter += 1
|
90
90
|
copy
|
91
91
|
end
|
@@ -15,38 +15,24 @@ class DomainTest < Test::Unit::TestCase
|
|
15
15
|
super
|
16
16
|
@crd = ClinicalTrials::User.new(:login => 'study.coordinator@test.org')
|
17
17
|
address = ClinicalTrials::Address.new(:street => '555 Elm St', :city => 'Burlington', :state => 'VT', :zip_code => '55555')
|
18
|
-
@
|
19
|
-
@study = ClinicalTrials::Study.new(:name => 'Test Study', :coordinator => @crd, :enrollment => [@
|
18
|
+
@sbj = ClinicalTrials::Subject.new(:name => 'Test Subject', :address => address)
|
19
|
+
@study = ClinicalTrials::Study.new(:name => 'Test Study', :coordinator => @crd, :enrollment => [@sbj])
|
20
20
|
@evt = ClinicalTrials::StudyEvent.new(:study => @study, :calendar_event_point => 1.0)
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_alias
|
24
24
|
assert(ClinicalTrials::Study.method_defined?(:events), "Study alias not recognized: events")
|
25
|
-
assert_equal(@
|
26
|
-
assert_equal(:zip_code, @
|
25
|
+
assert_equal(@sbj.address.zip_code, @sbj.address.postal_code, 'zip_code not aliased to postal_code')
|
26
|
+
assert_equal(:zip_code, @sbj.address.class.standard_attribute(:postal_code), 'postal_code does not map to a standard attribute symbol')
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_redefine
|
30
|
-
@
|
31
|
-
assert_equal('55555', @
|
30
|
+
@sbj.address.zip_code = 55555
|
31
|
+
assert_equal('55555', @sbj.address.zip_code, "Address zip_code not redefined to support a numeric value")
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_merge_attributes
|
35
|
-
assert_same(@study.enrollment.first, @
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_merge_unambiguous_dependent_collection_attribute
|
39
|
-
@study.enrollment.clear
|
40
|
-
assert_same(@study.enrollment, @study.merge_attribute(:enrollment, [@pnt]), "Merge collection attribute result incorrect")
|
41
|
-
assert_not_nil(@study.enrollment.first, "Merge collection attribute didn't add source item")
|
42
|
-
assert_same(@study.enrollment.first, @pnt, "Merge collection attribute incorrect")
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_merge_ambiguous_dependent_collection_attribute
|
46
|
-
@study.enrollment.clear
|
47
|
-
assert_same(@study.enrollment, @study.merge_attribute(:enrollment, [@pnt]), "Merge collection attribute result incorrect")
|
48
|
-
assert_not_nil(@study.enrollment.first, "Merge collection attribute didn't add source item")
|
49
|
-
assert_same(@study.enrollment.first, @pnt, "Merge collection attribute incorrect")
|
35
|
+
assert_same(@study.enrollment.first, @sbj, "Merge incorrect")
|
50
36
|
end
|
51
37
|
|
52
38
|
def test_owner_inverse_setter
|
@@ -72,9 +58,9 @@ class DomainTest < Test::Unit::TestCase
|
|
72
58
|
|
73
59
|
# Tests whether add_defaults method propagates to dependents.
|
74
60
|
def test_participant_defaults
|
75
|
-
assert_nil(@
|
76
|
-
@
|
77
|
-
assert_equal('US', @
|
61
|
+
assert_nil(@sbj.address.country, 'Subject address country is already set')
|
62
|
+
@sbj.add_defaults
|
63
|
+
assert_equal('US', @sbj.address.country, 'Subject address country is not set to default')
|
78
64
|
end
|
79
65
|
|
80
66
|
def test_dependents
|
@@ -91,9 +77,9 @@ class DomainTest < Test::Unit::TestCase
|
|
91
77
|
assert_equal([@study, 1.0], @evt.key, "Event key incorrect")
|
92
78
|
end
|
93
79
|
|
94
|
-
|
95
|
-
|
96
|
-
|
80
|
+
def test_address_key
|
81
|
+
assert_nil(@sbj.address.key, "Address key incorrect")
|
82
|
+
end
|
97
83
|
|
98
84
|
def test_set_collection_attribute
|
99
85
|
consent = ClinicalTrials::Consent.new(:statement => 'Test Statement 1')
|
@@ -115,7 +101,7 @@ class DomainTest < Test::Unit::TestCase
|
|
115
101
|
def test_visit_path
|
116
102
|
visited = []
|
117
103
|
@study.visit_path([:enrollment, :address]) { |ref| visited << ref }
|
118
|
-
assert_equal([@study, @
|
104
|
+
assert_equal([@study, @sbj, @sbj.address], visited, "Path visitor incorrect")
|
119
105
|
end
|
120
106
|
|
121
107
|
def test_visit_dependents
|
@@ -44,7 +44,6 @@ module CaRuby
|
|
44
44
|
# @return [CaTissue::Migrator]
|
45
45
|
# @yield [opts] the optional Migrator factory
|
46
46
|
def create_migrator(fixture, opts={}, &factory)
|
47
|
-
opts[:quiet] = true
|
48
47
|
opts[:input] ||= File.join(@fixtures, fixture.to_s + '.csv')
|
49
48
|
block_given? ? yield(opts) : CaRuby::Migrator.new(opts)
|
50
49
|
end
|
@@ -113,8 +113,7 @@ module CaRuby
|
|
113
113
|
|
114
114
|
def verify_dependency(dependent)
|
115
115
|
return if dependent.class.owner_attribute.nil?
|
116
|
-
|
117
|
-
ownr = Annotation === dependent ? (dependent.hook or dependent.owner) : dependent.owner
|
116
|
+
ownr = dependent.owner
|
118
117
|
assert_not_nil(ownr, "Owner missing for dependent: #{dependent}")
|
119
118
|
attribute = ownr.class.dependent_attribute(dependent.class)
|
120
119
|
assert_not_nil(attribute, "Dependent attribute missing for #{dependent} owner #{ownr}")
|
@@ -129,7 +128,7 @@ module CaRuby
|
|
129
128
|
# Verifies that the given dependent has an identifier and that the given owner dependent attribute value
|
130
129
|
# contains the dependent.
|
131
130
|
#
|
132
|
-
# JRuby
|
131
|
+
# JRuby Set include? incorrectly returns false in the OHSU PSR samples_test test_save_grade
|
133
132
|
# call to this method. Work around by using Set detect rather than include?.
|
134
133
|
def verify_saved_dependent_collection_member(dependent, owner, attribute)
|
135
134
|
deps = owner.send(attribute)
|
@@ -168,12 +167,12 @@ module CaRuby
|
|
168
167
|
# Verifies that the given expected domain object has the same content as actual,
|
169
168
|
# and that the dependents match.
|
170
169
|
#
|
171
|
-
# caTissue
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
170
|
+
# @quirk caTissue caTissue mutilates an unspecified specimen type available quantity, e.g.
|
171
|
+
# changing a Specimen with specimen type 'Not Specified' from available quantity 1, initial
|
172
|
+
# quantity 1 to available quantity 0, initial quantity 3 results in available quantity 2
|
173
|
+
# in database. The update is necessary when creating the Specimen with available quantity 0,
|
174
|
+
# initial quantity 3 to work around a different caTissue bug. Thus, the bug work-around
|
175
|
+
# is broken by a different caTissue bug.
|
177
176
|
#
|
178
177
|
# @param [Resource] expected the saved value
|
179
178
|
# @param [Resource] actual the fetched value
|
@@ -201,7 +200,7 @@ module CaRuby
|
|
201
200
|
verify_dependents_match(expected, actual)
|
202
201
|
end
|
203
202
|
|
204
|
-
# @param [
|
203
|
+
# @param [Attribute] attr_md the saved attribute to check
|
205
204
|
# @return whether the attribute is fetched, creatable and not volatile
|
206
205
|
def verify_saved_attribute?(attr_md)
|
207
206
|
attr_md.fetched? and attr_md.creatable? and not attr_md.volatile?
|
@@ -127,6 +127,12 @@ class CollectionTest < Test::Unit::TestCase
|
|
127
127
|
b << 5
|
128
128
|
assert_equal([1, 2, 3, 3, 4, 5], ab.to_a, "Addition does not reflect change to second enumerable")
|
129
129
|
end
|
130
|
+
|
131
|
+
def test_partial_sort
|
132
|
+
sorted = [Array, Object, Numeric, Enumerable, Set].partial_sort
|
133
|
+
assert(sorted.index(Array) < sorted.index(Enumerable), "Partial sort order incorrect")
|
134
|
+
assert(sorted.index(Set) < sorted.index(Enumerable), "Partial sort order incorrect")
|
135
|
+
end
|
130
136
|
|
131
137
|
def test_hash_union
|
132
138
|
a = {:a => 1, :b => 2}
|
@@ -173,11 +179,11 @@ class CollectionTest < Test::Unit::TestCase
|
|
173
179
|
end
|
174
180
|
|
175
181
|
def test_hash_enum_keys
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
assert_equal([
|
182
|
+
hash = { 1 => :a, 2 => :b }
|
183
|
+
ek = hash.enum_keys
|
184
|
+
assert_equal([1, 2], ek.sort, "Hash key enumerator incorrect")
|
185
|
+
hash[3] = :c
|
186
|
+
assert_equal([1, 2, 3], ek.sort, "Hash key enumerator does not reflect hash change")
|
181
187
|
end
|
182
188
|
|
183
189
|
def test_hash_enum_keys_with_value
|
@@ -188,6 +194,18 @@ class CollectionTest < Test::Unit::TestCase
|
|
188
194
|
assert_equal([:b, :c], {:a => 1, :b => 2, :c => 3}.enum_keys_with_value { |value| value > 1 }.to_a, "Hash filtered value block keys incorrect")
|
189
195
|
end
|
190
196
|
|
197
|
+
def test_hash_enum_values
|
198
|
+
hash = { :a => 1, :b => 2 }
|
199
|
+
ev = hash.enum_values
|
200
|
+
assert_equal([1, 2], ev.sort, "Hash value enumerator incorrect")
|
201
|
+
hash[:c] = 3
|
202
|
+
assert_equal([1, 2, 3], ev.sort, "Hash value enumerator does not reflect hash change")
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_hash_partition
|
206
|
+
assert_equal([{:a => 1}, { :b => 2}], { :a => 1, :b => 2 }.partition { |key, value| value < 2 }, "Hash partition incorrect")
|
207
|
+
end
|
208
|
+
|
191
209
|
def test_hash_flatten
|
192
210
|
assert_equal([:a, :b, :c, :d, :e, :f, :g], {:a => {:b => :c}, :d => :e, :f => [:g]}.flatten, "Hash flatten incorrect")
|
193
211
|
end
|
@@ -5,25 +5,21 @@ require 'caruby/util/module'
|
|
5
5
|
|
6
6
|
module Outer
|
7
7
|
module Middle
|
8
|
-
|
9
|
-
class InnerClass; end
|
8
|
+
class C; end
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
12
|
class ModuleTest < Test::Unit::TestCase
|
14
|
-
def
|
15
|
-
assert_equal(Array, Module.module_with_name(nil, 'Array'), "Top level module incorrect")
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_module_with_unqualified_name
|
13
|
+
def test_module_with_name
|
19
14
|
assert_equal(Outer::Middle, Outer.module_with_name('Middle'), "Unqualified module incorrect")
|
15
|
+
assert_nil(Outer.module_with_name('Zed'), "Missing module incorrectly resolves to non-nil value")
|
16
|
+
assert_equal(Outer::Middle::C, Outer.module_with_name('Middle::C'), "Qualified module incorrect")
|
17
|
+
assert_equal(Outer, Kernel.module_with_name('Outer'), "Top-level module incorrect")
|
20
18
|
end
|
21
|
-
|
22
|
-
def
|
23
|
-
assert_equal(Outer
|
24
|
-
|
25
|
-
|
26
|
-
def test_class_with_name
|
27
|
-
assert_equal(Outer::Middle::InnerClass, Outer.module_with_name('Middle::InnerClass'), "Inner class incorrect")
|
19
|
+
|
20
|
+
def test_parent_module
|
21
|
+
assert_equal(Outer, Outer::Middle.parent_module, "Middle parent module incorrect")
|
22
|
+
assert_equal(Outer::Middle, Outer::Middle::C.parent_module, "Inner parent module incorrect")
|
23
|
+
assert_equal(Kernel, Outer.parent_module, "Outer parent module incorrect")
|
28
24
|
end
|
29
25
|
end
|
@@ -6,36 +6,37 @@ require 'caruby/util/partial_order'
|
|
6
6
|
class Queued
|
7
7
|
include PartialOrder
|
8
8
|
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :queue
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@value = value
|
11
|
+
def initialize(on)
|
13
12
|
@queue = on.push(self)
|
14
13
|
end
|
15
14
|
|
16
15
|
def <=>(other)
|
17
|
-
|
16
|
+
queue.index(self) <=> other.queue.index(other) if queue.equal?(other.queue)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
class PartialOrderTest < Test::Unit::TestCase
|
22
21
|
def test_same_queue
|
23
|
-
|
24
|
-
|
22
|
+
q = []
|
23
|
+
a = Queued.new(q)
|
24
|
+
assert_equal(a, a, "Same value, queue not equal")
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_different_eql_queue
|
28
|
-
|
29
|
-
@b = Queued.new(
|
30
|
-
assert_nil(
|
31
|
-
assert_not_equal(
|
28
|
+
a = Queued.new([])
|
29
|
+
@b = Queued.new([])
|
30
|
+
assert_nil(a <=> @b, "Same value, different queue <=> not nil")
|
31
|
+
assert_not_equal(a, @b, "Same value, different queue is equal")
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_less_than
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
q = []
|
36
|
+
a = Queued.new(q)
|
37
|
+
b = Queued.new(q)
|
38
|
+
c = Queued.new([])
|
39
|
+
assert(a < b, "Comparison incorrect")
|
40
|
+
assert_nil(a < c, "Comparison incorrect")
|
40
41
|
end
|
41
42
|
end
|
@@ -13,7 +13,7 @@ module Galena
|
|
13
13
|
FIXTURES = 'examples/galena/data'
|
14
14
|
|
15
15
|
# The migration input data directory.
|
16
|
-
SHIMS = 'examples/galena/lib/galena/migration'
|
16
|
+
SHIMS = 'examples/galena/lib/galena/clinical_trials/migration'
|
17
17
|
|
18
18
|
# The migration configuration directory.
|
19
19
|
CONFIGS = 'examples/galena/conf/migration'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caruby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 5
|
9
|
+
- 1
|
10
|
+
version: 1.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- OHSU
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05
|
18
|
+
date: 2011-07-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -104,20 +104,22 @@ files:
|
|
104
104
|
- lib/caruby/database/store_template_builder.rb
|
105
105
|
- lib/caruby/database/writer.rb
|
106
106
|
- lib/caruby/database.rb
|
107
|
-
- lib/caruby/domain/
|
107
|
+
- lib/caruby/domain/attribute.rb
|
108
|
+
- lib/caruby/domain/attributes.rb
|
109
|
+
- lib/caruby/domain/dependency.rb
|
108
110
|
- lib/caruby/domain/id_alias.rb
|
111
|
+
- lib/caruby/domain/importer.rb
|
112
|
+
- lib/caruby/domain/introspection.rb
|
113
|
+
- lib/caruby/domain/inverse.rb
|
109
114
|
- lib/caruby/domain/inversible.rb
|
110
|
-
- lib/caruby/domain/
|
115
|
+
- lib/caruby/domain/java_attribute.rb
|
111
116
|
- lib/caruby/domain/merge.rb
|
117
|
+
- lib/caruby/domain/metadata.rb
|
118
|
+
- lib/caruby/domain/mixin.rb
|
112
119
|
- lib/caruby/domain/properties.rb
|
113
120
|
- lib/caruby/domain/reference_visitor.rb
|
114
|
-
- lib/caruby/domain/resource_attributes.rb
|
115
|
-
- lib/caruby/domain/resource_dependency.rb
|
116
|
-
- lib/caruby/domain/resource_introspection.rb
|
117
|
-
- lib/caruby/domain/resource_inverse.rb
|
118
|
-
- lib/caruby/domain/resource_metadata.rb
|
119
|
-
- lib/caruby/domain/resource_module.rb
|
120
121
|
- lib/caruby/domain/uniquify.rb
|
122
|
+
- lib/caruby/domain.rb
|
121
123
|
- lib/caruby/import/java.rb
|
122
124
|
- lib/caruby/migration/migratable.rb
|
123
125
|
- lib/caruby/migration/migrator.rb
|
@@ -154,7 +156,6 @@ files:
|
|
154
156
|
- lib/caruby/util/visitor.rb
|
155
157
|
- lib/caruby/util/weak_hash.rb
|
156
158
|
- lib/caruby/version.rb
|
157
|
-
- lib/caruby/yard/resource_metadata_handler.rb
|
158
159
|
- lib/caruby.rb
|
159
160
|
- test/lib/caruby/csv/csv_mapper_test.rb
|
160
161
|
- test/lib/caruby/csv/csvio_test.rb
|
@@ -192,7 +193,7 @@ files:
|
|
192
193
|
- test/lib/caruby/util/weak_hash_test.rb
|
193
194
|
- test/lib/examples/galena/clinical_trials/migration/participant_test.rb
|
194
195
|
- test/lib/examples/galena/clinical_trials/migration/test_case.rb
|
195
|
-
- History.
|
196
|
+
- History.md
|
196
197
|
- LEGAL
|
197
198
|
- LICENSE
|
198
199
|
- README.md
|