scout-gear 10.3.0 → 10.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vimproject +100 -657
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/scout +1 -3
- data/lib/scout/association/fields.rb +170 -0
- data/lib/scout/association/index.rb +229 -0
- data/lib/scout/association/item.rb +227 -0
- data/lib/scout/association/util.rb +7 -0
- data/lib/scout/association.rb +100 -0
- data/lib/scout/entity/format.rb +62 -0
- data/lib/scout/entity/identifiers.rb +111 -0
- data/lib/scout/entity/object.rb +20 -0
- data/lib/scout/entity/property.rb +165 -0
- data/lib/scout/entity.rb +40 -0
- data/lib/scout/offsite/step.rb +2 -2
- data/lib/scout/{tsv/persist → persist/engine}/fix_width_table.rb +25 -33
- data/lib/scout/persist/engine/packed_index.rb +100 -0
- data/lib/scout/persist/engine/sharder.rb +219 -0
- data/lib/scout/{tsv/persist → persist/engine}/tkrzw.rb +0 -17
- data/lib/scout/{tsv/persist → persist/engine}/tokyocabinet.rb +55 -31
- data/lib/scout/persist/engine.rb +4 -0
- data/lib/scout/{tsv/persist/adapter.rb → persist/tsv/adapter/base.rb} +80 -51
- data/lib/scout/persist/tsv/adapter/fix_width_table.rb +106 -0
- data/lib/scout/persist/tsv/adapter/packed_index.rb +95 -0
- data/lib/scout/persist/tsv/adapter/sharder.rb +54 -0
- data/lib/scout/persist/tsv/adapter/tkrzw.rb +18 -0
- data/lib/scout/persist/tsv/adapter/tokyocabinet.rb +65 -0
- data/lib/scout/persist/tsv/adapter.rb +6 -0
- data/lib/scout/{tsv/persist → persist/tsv}/serialize.rb +5 -0
- data/lib/scout/persist/tsv.rb +107 -0
- data/lib/scout/tsv/annotation/repo.rb +83 -0
- data/lib/scout/tsv/annotation.rb +169 -0
- data/lib/scout/tsv/attach.rb +104 -20
- data/lib/scout/tsv/change_id/translate.rb +148 -0
- data/lib/scout/tsv/change_id.rb +6 -3
- data/lib/scout/tsv/csv.rb +85 -0
- data/lib/scout/tsv/dumper.rb +113 -25
- data/lib/scout/tsv/entity.rb +5 -0
- data/lib/scout/tsv/index.rb +89 -37
- data/lib/scout/tsv/open.rb +21 -8
- data/lib/scout/tsv/parser.rb +156 -91
- data/lib/scout/tsv/path.rb +7 -2
- data/lib/scout/tsv/stream.rb +48 -6
- data/lib/scout/tsv/transformer.rb +25 -3
- data/lib/scout/tsv/traverse.rb +26 -18
- data/lib/scout/tsv/util/process.rb +8 -1
- data/lib/scout/tsv/util/reorder.rb +25 -15
- data/lib/scout/tsv/util/select.rb +9 -1
- data/lib/scout/tsv/util/sort.rb +90 -2
- data/lib/scout/tsv/util/unzip.rb +56 -0
- data/lib/scout/tsv/util.rb +52 -5
- data/lib/scout/tsv.rb +85 -19
- data/lib/scout/work_queue/socket.rb +8 -0
- data/lib/scout/work_queue/worker.rb +22 -5
- data/lib/scout/work_queue.rb +38 -24
- data/lib/scout/workflow/definition.rb +19 -11
- data/lib/scout/workflow/deployment/orchestrator.rb +20 -3
- data/lib/scout/workflow/deployment/trace.rb +205 -0
- data/lib/scout/workflow/deployment.rb +1 -0
- data/lib/scout/workflow/documentation.rb +1 -1
- data/lib/scout/workflow/step/archive.rb +42 -0
- data/lib/scout/workflow/step/children.rb +51 -0
- data/lib/scout/workflow/step/config.rb +1 -1
- data/lib/scout/workflow/step/dependencies.rb +24 -7
- data/lib/scout/workflow/step/file.rb +19 -0
- data/lib/scout/workflow/step/info.rb +37 -9
- data/lib/scout/workflow/step/progress.rb +11 -2
- data/lib/scout/workflow/step/status.rb +8 -1
- data/lib/scout/workflow/step.rb +80 -25
- data/lib/scout/workflow/task/dependencies.rb +4 -1
- data/lib/scout/workflow/task/inputs.rb +91 -41
- data/lib/scout/workflow/task.rb +54 -57
- data/lib/scout/workflow/usage.rb +1 -1
- data/lib/scout/workflow/util.rb +4 -0
- data/lib/scout/workflow.rb +110 -13
- data/lib/scout-gear.rb +2 -0
- data/lib/scout.rb +0 -1
- data/scout-gear.gemspec +80 -23
- data/scout_commands/rbbt +2 -0
- data/test/data/person/brothers +4 -0
- data/test/data/person/identifiers +10 -0
- data/test/data/person/marriages +3 -0
- data/test/data/person/parents +6 -0
- data/test/scout/association/test_fields.rb +105 -0
- data/test/scout/association/test_index.rb +70 -0
- data/test/scout/association/test_item.rb +21 -0
- data/test/scout/entity/test_format.rb +19 -0
- data/test/scout/entity/test_identifiers.rb +58 -0
- data/test/scout/entity/test_object.rb +0 -0
- data/test/scout/entity/test_property.rb +345 -0
- data/test/scout/{tsv/persist → persist/engine}/test_fix_width_table.rb +0 -1
- data/test/scout/persist/engine/test_packed_index.rb +99 -0
- data/test/scout/persist/engine/test_sharder.rb +31 -0
- data/test/scout/persist/engine/test_tkrzw.rb +0 -0
- data/test/scout/persist/engine/test_tokyocabinet.rb +17 -0
- data/test/scout/persist/test_tsv.rb +146 -0
- data/test/scout/{tsv/persist/test_adapter.rb → persist/tsv/adapter/test_base.rb} +3 -4
- data/test/scout/persist/tsv/adapter/test_fix_width_table.rb +46 -0
- data/test/scout/persist/tsv/adapter/test_packed_index.rb +37 -0
- data/test/scout/persist/tsv/adapter/test_serialize.rb +0 -0
- data/test/scout/persist/tsv/adapter/test_sharder.rb +290 -0
- data/test/scout/persist/tsv/adapter/test_tkrzw.rb +126 -0
- data/test/scout/persist/tsv/adapter/test_tokyocabinet.rb +282 -0
- data/test/scout/persist/tsv/test_serialize.rb +12 -0
- data/test/scout/test_association.rb +51 -0
- data/test/scout/test_entity.rb +40 -0
- data/test/scout/test_tsv.rb +63 -4
- data/test/scout/test_work_queue.rb +3 -2
- data/test/scout/test_workflow.rb +16 -15
- data/test/scout/tsv/annotation/test_repo.rb +150 -0
- data/test/scout/tsv/change_id/test_translate.rb +178 -0
- data/test/scout/tsv/test_annotation.rb +52 -0
- data/test/scout/tsv/test_attach.rb +226 -1
- data/test/scout/tsv/test_change_id.rb +25 -0
- data/test/scout/tsv/test_csv.rb +50 -0
- data/test/scout/tsv/test_dumper.rb +38 -0
- data/test/scout/tsv/test_entity.rb +0 -0
- data/test/scout/tsv/test_index.rb +82 -0
- data/test/scout/tsv/test_open.rb +44 -0
- data/test/scout/tsv/test_parser.rb +70 -0
- data/test/scout/tsv/test_stream.rb +22 -0
- data/test/scout/tsv/test_transformer.rb +39 -3
- data/test/scout/tsv/test_traverse.rb +78 -0
- data/test/scout/tsv/util/test_process.rb +36 -0
- data/test/scout/tsv/util/test_reorder.rb +67 -0
- data/test/scout/tsv/util/test_sort.rb +28 -1
- data/test/scout/tsv/util/test_unzip.rb +32 -0
- data/test/scout/work_queue/test_socket.rb +4 -1
- data/test/scout/workflow/deployment/test_orchestrator.rb +17 -26
- data/test/scout/workflow/deployment/test_trace.rb +25 -0
- data/test/scout/workflow/step/test_archive.rb +28 -0
- data/test/scout/workflow/step/test_children.rb +25 -0
- data/test/scout/workflow/step/test_info.rb +16 -0
- data/test/scout/workflow/task/test_dependencies.rb +16 -16
- data/test/scout/workflow/task/test_inputs.rb +45 -1
- data/test/scout/workflow/test_definition.rb +52 -0
- data/test/scout/workflow/test_step.rb +57 -0
- data/test/scout/workflow/test_task.rb +26 -1
- data/test/scout/workflow/test_usage.rb +4 -4
- data/test/test_helper.rb +23 -1
- metadata +71 -14
- data/lib/scout/tsv/persist.rb +0 -27
- data/test/scout/tsv/persist/test_tkrzw.rb +0 -123
- data/test/scout/tsv/persist/test_tokyocabinet.rb +0 -120
- data/test/scout/tsv/test_persist.rb +0 -45
@@ -0,0 +1,105 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
require 'scout/tsv'
|
5
|
+
class TestAssociationFields < Test::Unit::TestCase
|
6
|
+
def test_specs
|
7
|
+
spec = Association.parse_field_specification "=~Associated Gene Name=>Ensembl Gene ID"
|
8
|
+
assert_equal [nil, "Associated Gene Name", "Ensembl Gene ID"], spec
|
9
|
+
|
10
|
+
spec = Association.parse_field_specification "TG=~Associated Gene Name=>Ensembl Gene ID"
|
11
|
+
assert_equal ["TG", "Associated Gene Name", "Ensembl Gene ID"], spec
|
12
|
+
|
13
|
+
spec = Association.parse_field_specification "TG=~Associated Gene Name"
|
14
|
+
assert_equal ["TG", "Associated Gene Name", nil], spec
|
15
|
+
|
16
|
+
spec = Association.parse_field_specification "Associated Gene Name=>Ensembl Gene ID"
|
17
|
+
assert_equal ["Associated Gene Name", nil, "Ensembl Gene ID"], spec
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_normalize_specs
|
21
|
+
spec = Association.normalize_specs "TG=~Associated Gene Name=>Ensembl Gene ID", %w(SG TG Effect directed?)
|
22
|
+
assert_equal ["TG", "Associated Gene Name", "Ensembl Gene ID"], spec
|
23
|
+
|
24
|
+
spec = Association.normalize_specs "Ensembl Gene ID", %w(SG TG Effect directed?)
|
25
|
+
assert_equal ["Ensembl Gene ID", nil, nil], spec
|
26
|
+
|
27
|
+
spec = Association.normalize_specs "Ensembl Gene ID"
|
28
|
+
assert_equal ["Ensembl Gene ID", nil, nil], spec
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_process_specs
|
32
|
+
spec = Association.extract_specs %w(SG TG Effect directed?), :target => "TG=~Associated Gene Name=>Ensembl Gene ID"
|
33
|
+
assert_equal ["TG", "Associated Gene Name", "Ensembl Gene ID"], spec[:target]
|
34
|
+
assert_equal ["SG", nil, nil], spec[:source]
|
35
|
+
|
36
|
+
spec = Association.extract_specs %w(SG TG Effect directed?)
|
37
|
+
assert_equal ["SG", nil, nil], spec[:source]
|
38
|
+
assert_equal ["TG", nil,nil], spec[:target]
|
39
|
+
|
40
|
+
spec = Association.extract_specs %w(SG TG Effect directed?), :source => "TG"
|
41
|
+
assert_equal ["TG", nil, nil], spec[:source]
|
42
|
+
assert_equal ["SG", nil,nil], spec[:target]
|
43
|
+
|
44
|
+
spec = Association.extract_specs %w(SG TG Effect directed?), :source => "SG"
|
45
|
+
assert_equal ["SG", nil, nil], spec[:source]
|
46
|
+
assert_equal ["TG", nil,nil], spec[:target]
|
47
|
+
|
48
|
+
spec = Association.extract_specs %w(SG TG Effect directed?), :target => "SG"
|
49
|
+
assert_equal ["TG", nil, nil], spec[:source]
|
50
|
+
assert_equal ["SG", nil,nil], spec[:target]
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_headers
|
54
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect)
|
55
|
+
assert_equal 0, spec[0]
|
56
|
+
assert_equal 1, spec[1][0]
|
57
|
+
|
58
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :source => "SG"
|
59
|
+
assert_equal 0, spec[0]
|
60
|
+
assert_equal 1, spec[1][0]
|
61
|
+
|
62
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "TG"
|
63
|
+
assert_equal 0, spec[0]
|
64
|
+
assert_equal 1, spec[1][0]
|
65
|
+
|
66
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "TG", :source => "SG"
|
67
|
+
assert_equal 0, spec[0]
|
68
|
+
assert_equal 1, spec[1][0]
|
69
|
+
|
70
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :source => "TG"
|
71
|
+
assert_equal 1, spec[0]
|
72
|
+
assert_equal 0, spec[1][0]
|
73
|
+
|
74
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "SG"
|
75
|
+
assert_equal 1, spec[0]
|
76
|
+
assert_equal 0, spec[1][0]
|
77
|
+
|
78
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "SG", :source => "TG"
|
79
|
+
assert_equal 1, spec[0]
|
80
|
+
assert_equal 0, spec[1][0]
|
81
|
+
|
82
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "SG", :source => "TG=~Associated Gene Name=>Ensembl Gene ID"
|
83
|
+
assert_equal 1, spec[0]
|
84
|
+
assert_equal 0, spec[1][0]
|
85
|
+
|
86
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "SG=~Associated Gene Name=>Ensembl Gene ID", :source => "TG=~Associated Gene Name=>Ensembl Gene ID"
|
87
|
+
assert_equal 1, spec[0]
|
88
|
+
assert_equal 0, spec[1][0]
|
89
|
+
|
90
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "SG=~Associated Gene Name", :source => "TG=~Associated Gene Name=>Ensembl Gene ID"
|
91
|
+
assert_equal 1, spec[0]
|
92
|
+
assert_equal 0, spec[1][0]
|
93
|
+
|
94
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "TG=~Associated Gene Name", :source => "SG=~Associated Gene Name", :target_format => "Ensembl Gene ID"
|
95
|
+
assert_equal 0, spec[0]
|
96
|
+
assert_equal "Ensembl Gene ID", spec[5]
|
97
|
+
assert_equal nil, spec[4]
|
98
|
+
|
99
|
+
|
100
|
+
spec = Association.headers %w(SG TG Effect directed?), %w(Effect), :target => "TG=~Associated Gene Name", :source => "SG=~Associated Gene Name", :source_format => "Ensembl Gene ID"
|
101
|
+
assert_equal 0, spec[0]
|
102
|
+
assert_equal "Ensembl Gene ID", spec[4]
|
103
|
+
assert_equal nil, spec[5]
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
require 'scout/tsv'
|
5
|
+
require 'scout/association'
|
6
|
+
class TestAssociationIndex < Test::Unit::TestCase
|
7
|
+
def test_parents_simple
|
8
|
+
database = Association.database datadir_test.person.parents
|
9
|
+
index = Association.index datadir_test.person.parents
|
10
|
+
assert_include index, "Miki~Juan"
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_parents
|
14
|
+
index = Association.index datadir_test.person.parents, target: "Parent=>Name", source: "=>Name"
|
15
|
+
assert_include index, "Miguel~Juan Luis"
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_brothers
|
19
|
+
index = Association.index datadir_test.person.brothers, undirected: true, persist: false
|
20
|
+
assert_include index, "Clei~Guille"
|
21
|
+
assert_include index, "Guille~Clei"
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_brothers_match
|
25
|
+
index = Association.index datadir_test.person.brothers, undirected: true
|
26
|
+
assert_equal ["Clei~Guille"], index.match("Clei")
|
27
|
+
assert_equal ["Guille~Clei"], index.match("Guille")
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_parents_subset
|
31
|
+
index = Association.index datadir_test.person.parents
|
32
|
+
assert_include index.subset(["Miki", "Guille"], :all), "Miki~Juan"
|
33
|
+
assert_include index.subset(["Miki", "Guille"], :all), "Guille~Gloria"
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_parents_reverse
|
37
|
+
index = Association.index datadir_test.person.parents
|
38
|
+
assert_include index.reverse.source_field, "Parent"
|
39
|
+
assert_include index.reverse.subset(["Juan"], :all), "Juan~Miki"
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_parents_filter
|
43
|
+
index = Association.index datadir_test.person.parents
|
44
|
+
assert_include index.filter('Type of parent', 'mother'), "Miki~Mariluz"
|
45
|
+
assert_include index.filter('Type of parent', 'mother'), "Clei~Gloria"
|
46
|
+
refute index.filter('Type of parent', 'mother').include?("Miki~Juan")
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_parents_flat
|
50
|
+
tsv = datadir_test.person.parents.tsv type: :flat, fields: ["Parent"]
|
51
|
+
index = Association.index tsv
|
52
|
+
assert_include index, "Miki~Juan"
|
53
|
+
assert_include index, "Isa~Mariluz"
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_list_serializer
|
57
|
+
TmpFile.with_file <<-EOF do |f|
|
58
|
+
#: :sep=,#:type=:list
|
59
|
+
#lowcase,upcase,double,triple
|
60
|
+
a,A,aa,aaa
|
61
|
+
b,B,bb,bbb
|
62
|
+
EOF
|
63
|
+
tsv = TSV.open(f)
|
64
|
+
i = Association.index tsv
|
65
|
+
assert_equal ['aa', 'aaa'], i["a~A"]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
require 'scout/tsv'
|
5
|
+
require 'scout/association'
|
6
|
+
class TestAssociationItem < Test::Unit::TestCase
|
7
|
+
def test_incidence
|
8
|
+
pairs = [[:A, :a], [:B, :b]].collect{|p| "#{p.first.to_s}~#{p.last.to_s}"}
|
9
|
+
assert TSV === AssociationItem.incidence(pairs)
|
10
|
+
assert_equal 2, AssociationItem.incidence(pairs).length
|
11
|
+
assert_equal 2, AssociationItem.incidence(pairs).fields.length
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_brothers
|
15
|
+
incidence = TSV.incidence(datadir_test.person.brothers, undirected: true)
|
16
|
+
assert incidence["Clei"]["Guille"]
|
17
|
+
assert incidence["Guille"]["Clei"]
|
18
|
+
refute incidence["Clei"]["Isa"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
class TestEntityFormat < Test::Unit::TestCase
|
5
|
+
def test_format
|
6
|
+
index = Entity::FormatIndex.new
|
7
|
+
index["Ensembl Gene ID"] = "Gene"
|
8
|
+
assert_equal "Gene", index["Ensembl Gene ID"]
|
9
|
+
assert_equal "Gene", index["Transcription Factor (Ensembl Gene ID)"]
|
10
|
+
|
11
|
+
Entity::FORMATS["Ensembl Gene ID"] = "Gene"
|
12
|
+
assert_equal "Ensembl Gene ID", Entity::FORMATS.find("Ensembl Gene ID")
|
13
|
+
assert_equal "Ensembl Gene ID", Entity::FORMATS.find("Transcription Factor (Ensembl Gene ID)")
|
14
|
+
|
15
|
+
assert_equal "Gene", Entity::FORMATS["Ensembl Gene ID"]
|
16
|
+
assert_equal "Gene", Entity::FORMATS["Transcription Factor (Ensembl Gene ID)"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
require 'scout/tsv'
|
5
|
+
require 'scout/entity'
|
6
|
+
|
7
|
+
class TestEntityIdentifiers < Test::Unit::TestCase
|
8
|
+
module Person
|
9
|
+
extend Entity
|
10
|
+
end
|
11
|
+
|
12
|
+
module PersonWithNoIds
|
13
|
+
extend Entity
|
14
|
+
include Entity::Identified
|
15
|
+
end
|
16
|
+
|
17
|
+
Person.add_identifiers datafile_test(Entity::Identified::NAMESPACE_TAG + '/identifiers'), "Name", "Alias"
|
18
|
+
|
19
|
+
teardown do
|
20
|
+
Entity.formats.clear
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_alias
|
24
|
+
miguel = Person.setup("Miguel", namespace: :person)
|
25
|
+
assert_equal "Miki", miguel.to("Alias")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_alias_no_namespace
|
29
|
+
miguel = Person.setup("Miguel")
|
30
|
+
|
31
|
+
assert_raise do
|
32
|
+
miguel.to("Name")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_alias_no_ids
|
37
|
+
miguel = PersonWithNoIds.setup("Miguel", namespace: :person)
|
38
|
+
assert_raise do
|
39
|
+
miguel.to("Name")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def test_name_from_ID
|
45
|
+
assert_equal "Miki", Person.setup("001", :format => 'ID', namespace: :person).to("Alias")
|
46
|
+
assert_equal "Miguel", Person.setup("001", :format => 'ID', namespace: :person).to("Name")
|
47
|
+
assert_equal ["Miguel"], Person.setup(["001"], :format => 'ID', namespace: :person).to("Name")
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def test_identifier_files
|
52
|
+
assert Person.identifier_files.any?
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_Entity_identifier_files
|
56
|
+
assert Entity.identifier_files("Name").any?
|
57
|
+
end
|
58
|
+
end
|
File without changes
|
@@ -0,0 +1,345 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
require 'scout/entity'
|
5
|
+
require 'scout/tsv'
|
6
|
+
|
7
|
+
class TestEntityProperty < Test::Unit::TestCase
|
8
|
+
class TestA
|
9
|
+
attr_accessor :foo, :bar
|
10
|
+
def initialize(foo, bar)
|
11
|
+
@foo = foo
|
12
|
+
@bar = bar
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
$count = 0
|
17
|
+
|
18
|
+
module ReversableString
|
19
|
+
extend Entity
|
20
|
+
|
21
|
+
self.annotation :foo, :bar
|
22
|
+
|
23
|
+
property :times do |times|
|
24
|
+
[self] * times
|
25
|
+
end
|
26
|
+
|
27
|
+
property :reverse_both => :both do
|
28
|
+
if Array === self
|
29
|
+
self.collect{|s| s.reverse }
|
30
|
+
else
|
31
|
+
self.reverse
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
property :reverse_text_ary => :array do
|
36
|
+
$count += 1
|
37
|
+
self.collect{|s| s.reverse}
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
property :reverse_text_ary_hash => :array do
|
42
|
+
$count += 1
|
43
|
+
res = {}
|
44
|
+
self.each{|s| res[s] = s.reverse }
|
45
|
+
res
|
46
|
+
end
|
47
|
+
|
48
|
+
property :reverse_text_single => :single do
|
49
|
+
$count += 1
|
50
|
+
self.reverse
|
51
|
+
end
|
52
|
+
|
53
|
+
property :reverse_text_ary_p => :array2single do
|
54
|
+
$count += 1
|
55
|
+
self.collect{|s| s.reverse}
|
56
|
+
end
|
57
|
+
|
58
|
+
property :reverse_text_single_p => :single do
|
59
|
+
$count += 1
|
60
|
+
self.reverse
|
61
|
+
end
|
62
|
+
|
63
|
+
property :reverse_text_ary_p_array => :array do
|
64
|
+
$count += 1
|
65
|
+
self.collect{|s| s.reverse }
|
66
|
+
end
|
67
|
+
|
68
|
+
property :random => :single do
|
69
|
+
rand
|
70
|
+
end
|
71
|
+
|
72
|
+
property :annotation_list => :single do
|
73
|
+
self.chars.to_a.collect{|c|
|
74
|
+
ReversableString.setup(c)
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
property :annotation_list_empty => :single do
|
79
|
+
[]
|
80
|
+
end
|
81
|
+
|
82
|
+
$processed_multiple = []
|
83
|
+
property :multiple_annotation_list => :multiple do
|
84
|
+
$processed_multiple.concat self
|
85
|
+
res = {}
|
86
|
+
self.collect do |e|
|
87
|
+
e.chars.to_a.collect{|c|
|
88
|
+
ReversableString.setup(c)
|
89
|
+
}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
#persist :multiple_annotation_list, :annotation, :dir => Rbbt.tmp.test.annots
|
94
|
+
end
|
95
|
+
|
96
|
+
setup do
|
97
|
+
ReversableString.persist :reverse_text_ary_p, :marshal
|
98
|
+
|
99
|
+
ReversableString.persist :reverse_text_ary_p_array, :array, :dir => TmpFile.tmp_file
|
100
|
+
|
101
|
+
ReversableString.persist :annotation_list, :annotation, :annotation_repo => TmpFile.tmp_file
|
102
|
+
|
103
|
+
ReversableString.persist :annotation_list_empty, :annotation, :dir => TmpFile.tmp_file
|
104
|
+
|
105
|
+
ReversableString.persist :multiple_annotation_list, :annotation, :dir => TmpFile.tmp_file
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
def test_property_ary_make_list
|
110
|
+
$count = 0
|
111
|
+
a = "String1"
|
112
|
+
ReversableString.setup(a)
|
113
|
+
|
114
|
+
assert_equal "1gnirtS", a.reverse_text_ary
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_property_both
|
118
|
+
a = "String1"
|
119
|
+
ReversableString.setup(a)
|
120
|
+
|
121
|
+
$count = 0
|
122
|
+
|
123
|
+
assert_equal "1gnirtS", a.reverse_both
|
124
|
+
|
125
|
+
a = ["String1"]
|
126
|
+
ReversableString.setup(a)
|
127
|
+
|
128
|
+
assert_equal "1gnirtS", a.reverse_both.last
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_property_single_simple
|
132
|
+
a = "String1"
|
133
|
+
ReversableString.setup(a)
|
134
|
+
|
135
|
+
$count = 0
|
136
|
+
|
137
|
+
assert_equal "1gnirtS", a.reverse_text_single
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_property_ary
|
141
|
+
a = ["String1", "String2"]
|
142
|
+
ReversableString.setup(a)
|
143
|
+
|
144
|
+
$count = 0
|
145
|
+
|
146
|
+
assert_equal "2gnirtS", a.reverse_text_ary.last
|
147
|
+
assert_equal 1, $count
|
148
|
+
a._ary_property_cache.clear
|
149
|
+
assert ReversableString === a[1]
|
150
|
+
assert Entity::Object === a[1]
|
151
|
+
assert_equal "2gnirtS", a[1].reverse_text_ary
|
152
|
+
assert_equal 2, $count
|
153
|
+
a._ary_property_cache.clear
|
154
|
+
|
155
|
+
$count = 0
|
156
|
+
a.each do |string|
|
157
|
+
string.reverse_text_ary
|
158
|
+
assert_equal 1, $count
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_property_ary_hash
|
163
|
+
a = ["String1", "String2"]
|
164
|
+
ReversableString.setup(a)
|
165
|
+
|
166
|
+
$count = 0
|
167
|
+
|
168
|
+
assert_equal "2gnirtS", a.reverse_text_ary_hash["String2"]
|
169
|
+
assert_equal 1, $count
|
170
|
+
a._ary_property_cache.clear
|
171
|
+
assert_equal "2gnirtS", a[1].reverse_text_ary_hash
|
172
|
+
assert_equal 2, $count
|
173
|
+
a._ary_property_cache.clear
|
174
|
+
|
175
|
+
$count = 0
|
176
|
+
a.each do |string|
|
177
|
+
string.reverse_text_ary
|
178
|
+
assert_equal 1, $count
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_property_single
|
183
|
+
a = ["String1", "String2"]
|
184
|
+
ReversableString.setup a
|
185
|
+
|
186
|
+
$count = 0
|
187
|
+
|
188
|
+
assert_equal "2gnirtS", a.reverse_text_single.last
|
189
|
+
assert_equal 2, $count
|
190
|
+
assert_equal "2gnirtS", a[1].reverse_text_single
|
191
|
+
assert_equal 3, $count
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_property_ary_p
|
195
|
+
a = ["String1", "String2"]
|
196
|
+
ReversableString.setup a
|
197
|
+
|
198
|
+
a.reverse_text_ary_p
|
199
|
+
|
200
|
+
$count = 0
|
201
|
+
|
202
|
+
assert_equal "2gnirtS", a.reverse_text_ary_p.last
|
203
|
+
assert_equal "2gnirtS", a.collect{|e| e.reverse_text_ary_p }[1]
|
204
|
+
assert_equal 0, $count
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_property_single_p
|
208
|
+
a = ["String1", "String2"]
|
209
|
+
ReversableString.setup a
|
210
|
+
|
211
|
+
$count = 0
|
212
|
+
|
213
|
+
assert_equal "2gnirtS", a.reverse_text_single_p.last
|
214
|
+
|
215
|
+
assert_equal 2, $count
|
216
|
+
|
217
|
+
a = ["String1", "String2"]
|
218
|
+
ReversableString.setup a
|
219
|
+
|
220
|
+
$count = 0
|
221
|
+
|
222
|
+
assert_equal "2gnirtS", a.reverse_text_single_p.last
|
223
|
+
assert_equal 2, $count
|
224
|
+
assert_equal "2gnirtS", a[1].reverse_text_single_p
|
225
|
+
assert_equal 3, $count
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_property_ary_p_array
|
229
|
+
a = ["String1", "String2"]
|
230
|
+
ReversableString.setup a
|
231
|
+
|
232
|
+
assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
|
233
|
+
|
234
|
+
$count = 0
|
235
|
+
|
236
|
+
assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
|
237
|
+
assert_equal 0, $count
|
238
|
+
assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
|
239
|
+
assert_equal 0, $count
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_unpersist
|
243
|
+
a = ["String1", "String2"]
|
244
|
+
ReversableString.setup a
|
245
|
+
|
246
|
+
# Before persist
|
247
|
+
assert(! ReversableString.persisted?(:random))
|
248
|
+
|
249
|
+
r1 = a.random
|
250
|
+
r2 = a.random
|
251
|
+
assert_not_equal r1, r2
|
252
|
+
|
253
|
+
# After persist
|
254
|
+
ReversableString.persist :random
|
255
|
+
assert ReversableString.persisted?(:random)
|
256
|
+
|
257
|
+
r1 = a.random
|
258
|
+
r2 = a.random
|
259
|
+
assert_equal r1, r2
|
260
|
+
|
261
|
+
# After unpersist
|
262
|
+
ReversableString.unpersist :random
|
263
|
+
refute ReversableString.persisted?(:random)
|
264
|
+
|
265
|
+
r1 = a.random
|
266
|
+
r2 = a.random
|
267
|
+
assert_not_equal r1, r2
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_persist_annotations
|
272
|
+
string = 'aaabbbccc'
|
273
|
+
ReversableString.setup(string)
|
274
|
+
assert_equal string.length, string.annotation_list.length
|
275
|
+
assert_equal string.length, string.annotation_list.length
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_persist_annotations_empty
|
279
|
+
string = 'aaabbbccc'
|
280
|
+
ReversableString.setup(string)
|
281
|
+
assert_equal [], string.annotation_list_empty
|
282
|
+
assert_equal [], string.annotation_list_empty
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_persist_multiple_annotations
|
286
|
+
string1 = 'aaabbbccc'
|
287
|
+
string2 = 'AAABBBCCC'
|
288
|
+
string3 = 'AAABBBCCC_3'
|
289
|
+
string4 = 'AAABBBCCC_4'
|
290
|
+
|
291
|
+
|
292
|
+
$processed_multiple = []
|
293
|
+
|
294
|
+
array = ReversableString.setup([string1, string2])
|
295
|
+
assert_equal [string1, string2].collect{|s| s.chars}, array.multiple_annotation_list
|
296
|
+
assert_equal string1.length, array[0].multiple_annotation_list.length
|
297
|
+
assert_equal [string1, string2], $processed_multiple
|
298
|
+
|
299
|
+
array = ReversableString.setup([string2, string3])
|
300
|
+
assert_equal [string2, string3].collect{|s| s.chars}, array.multiple_annotation_list
|
301
|
+
assert_equal string3, array.multiple_annotation_list.last * ""
|
302
|
+
assert_equal [string1, string2, string3], $processed_multiple
|
303
|
+
|
304
|
+
$processed_multiple = []
|
305
|
+
array = ReversableString.setup([string2, string3])
|
306
|
+
assert_equal [string2, string3].collect{|s| s.chars}, array.multiple_annotation_list
|
307
|
+
assert_equal string2.length, array[0].multiple_annotation_list.length
|
308
|
+
assert_equal [], $processed_multiple
|
309
|
+
|
310
|
+
$processed_multiple = []
|
311
|
+
array = ReversableString.setup([string2, string3, string4])
|
312
|
+
assert_equal string2.length, array.multiple_annotation_list[0].length
|
313
|
+
assert_equal [string4], $processed_multiple
|
314
|
+
|
315
|
+
string1 = 'aaabbbccc'
|
316
|
+
string2 = 'AAABBBCCC'
|
317
|
+
string3 = 'AAABBBCCC_3'
|
318
|
+
string4 = 'AAABBBCCC_4'
|
319
|
+
|
320
|
+
$processed_multiple = []
|
321
|
+
array = ReversableString.setup([string2, string3, string4])
|
322
|
+
assert_equal string2.length, array[0].multiple_annotation_list.length
|
323
|
+
assert_equal $processed_multiple, []
|
324
|
+
|
325
|
+
end
|
326
|
+
|
327
|
+
def test_clean_annotations
|
328
|
+
|
329
|
+
string = "test_string"
|
330
|
+
ReversableString.setup string
|
331
|
+
assert string.respond_to?(:reverse_text_single)
|
332
|
+
assert ! string.purge.respond_to?(:reverse_text_single)
|
333
|
+
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_all_properties
|
337
|
+
assert ReversableString.setup("TEST").all_properties.include?(:reverse_text_ary)
|
338
|
+
assert_equal ReversableString.setup("TEST").all_properties, ReversableString.properties
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_times
|
342
|
+
assert_equal ["TEST", "TEST"], ReversableString.setup("TEST").times(2)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
2
|
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
3
|
|
4
|
-
require 'scout/tsv'
|
5
4
|
class TestFixWidthTable < Test::Unit::TestCase
|
6
5
|
def load_data(data)
|
7
6
|
tsv = TSV.open(data, type: :list, :sep=>":", :cast => proc{|e| e =~ /(\s*)(_*)/; ($1.length..($1.length + $2.length - 1))})
|