rbbt-util 5.44.1 → 6.0.4

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 (175) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/bin/rbbt +67 -90
  4. data/bin/rbbt_exec.rb +2 -2
  5. data/etc/app.d/base.rb +2 -2
  6. data/etc/app.d/semaphores.rb +3 -3
  7. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  8. data/lib/rbbt/annotations/refactor.rb +27 -0
  9. data/lib/rbbt/annotations/util.rb +282 -282
  10. data/lib/rbbt/annotations.rb +343 -320
  11. data/lib/rbbt/association/database.rb +200 -225
  12. data/lib/rbbt/association/index.rb +294 -291
  13. data/lib/rbbt/association/item.rb +227 -227
  14. data/lib/rbbt/association/open.rb +35 -34
  15. data/lib/rbbt/association/util.rb +0 -169
  16. data/lib/rbbt/association.rb +2 -4
  17. data/lib/rbbt/entity/identifiers.rb +119 -118
  18. data/lib/rbbt/entity/refactor.rb +12 -0
  19. data/lib/rbbt/entity.rb +319 -315
  20. data/lib/rbbt/hpc/batch.rb +72 -53
  21. data/lib/rbbt/hpc/lsf.rb +2 -2
  22. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  24. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  25. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  26. data/lib/rbbt/hpc/slurm.rb +18 -18
  27. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  28. data/lib/rbbt/knowledge_base/query.rb +2 -2
  29. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  30. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  31. data/lib/rbbt/knowledge_base.rb +1 -1
  32. data/lib/rbbt/monitor.rb +36 -25
  33. data/lib/rbbt/persist/refactor.rb +166 -0
  34. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  35. data/lib/rbbt/persist/tsv.rb +187 -185
  36. data/lib/rbbt/persist.rb +556 -551
  37. data/lib/rbbt/refactor.rb +20 -0
  38. data/lib/rbbt/resource/path/refactor.rb +178 -0
  39. data/lib/rbbt/resource/path.rb +317 -497
  40. data/lib/rbbt/resource/util.rb +0 -48
  41. data/lib/rbbt/resource.rb +3 -390
  42. data/lib/rbbt/tsv/accessor.rb +2 -838
  43. data/lib/rbbt/tsv/attach.rb +303 -299
  44. data/lib/rbbt/tsv/change_id.rb +244 -245
  45. data/lib/rbbt/tsv/csv.rb +87 -85
  46. data/lib/rbbt/tsv/dumper.rb +2 -100
  47. data/lib/rbbt/tsv/excel.rb +26 -24
  48. data/lib/rbbt/tsv/field_index.rb +4 -1
  49. data/lib/rbbt/tsv/filter.rb +3 -2
  50. data/lib/rbbt/tsv/index.rb +2 -284
  51. data/lib/rbbt/tsv/manipulate.rb +750 -747
  52. data/lib/rbbt/tsv/marshal.rb +3 -3
  53. data/lib/rbbt/tsv/matrix.rb +2 -2
  54. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  55. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  56. data/lib/rbbt/tsv/parser.rb +678 -678
  57. data/lib/rbbt/tsv/refactor.rb +195 -0
  58. data/lib/rbbt/tsv/stream.rb +253 -251
  59. data/lib/rbbt/tsv/util.rb +420 -420
  60. data/lib/rbbt/tsv.rb +210 -208
  61. data/lib/rbbt/util/R/eval.rb +4 -4
  62. data/lib/rbbt/util/R/plot.rb +62 -166
  63. data/lib/rbbt/util/R.rb +21 -18
  64. data/lib/rbbt/util/cmd.rb +2 -318
  65. data/lib/rbbt/util/color.rb +269 -269
  66. data/lib/rbbt/util/colorize.rb +89 -89
  67. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  68. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  69. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  70. data/lib/rbbt/util/config.rb +169 -167
  71. data/lib/rbbt/util/filecache.rb +1 -1
  72. data/lib/rbbt/util/iruby.rb +20 -0
  73. data/lib/rbbt/util/log/progress/report.rb +241 -241
  74. data/lib/rbbt/util/log/progress/util.rb +99 -99
  75. data/lib/rbbt/util/log/progress.rb +102 -102
  76. data/lib/rbbt/util/log/refactor.rb +49 -0
  77. data/lib/rbbt/util/log.rb +486 -532
  78. data/lib/rbbt/util/migrate.rb +2 -2
  79. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  80. data/lib/rbbt/util/misc/development.rb +12 -11
  81. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  82. data/lib/rbbt/util/misc/format.rb +2 -230
  83. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  84. data/lib/rbbt/util/misc/inspect.rb +2 -476
  85. data/lib/rbbt/util/misc/lock.rb +109 -106
  86. data/lib/rbbt/util/misc/omics.rb +9 -1
  87. data/lib/rbbt/util/misc/pipes.rb +765 -793
  88. data/lib/rbbt/util/misc/refactor.rb +20 -0
  89. data/lib/rbbt/util/misc/ssw.rb +27 -17
  90. data/lib/rbbt/util/misc/system.rb +92 -105
  91. data/lib/rbbt/util/misc.rb +39 -20
  92. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  93. data/lib/rbbt/util/named_array.rb +3 -220
  94. data/lib/rbbt/util/open/refactor.rb +7 -0
  95. data/lib/rbbt/util/open.rb +3 -857
  96. data/lib/rbbt/util/procpath.rb +6 -6
  97. data/lib/rbbt/util/python/paths.rb +27 -0
  98. data/lib/rbbt/util/python/run.rb +115 -0
  99. data/lib/rbbt/util/python/script.rb +110 -0
  100. data/lib/rbbt/util/python/util.rb +3 -3
  101. data/lib/rbbt/util/python.rb +22 -81
  102. data/lib/rbbt/util/semaphore.rb +152 -148
  103. data/lib/rbbt/util/simpleopt.rb +9 -8
  104. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  105. data/lib/rbbt/util/ssh.rb +122 -118
  106. data/lib/rbbt/util/tar.rb +117 -115
  107. data/lib/rbbt/util/tmpfile.rb +69 -67
  108. data/lib/rbbt/util/version.rb +2 -0
  109. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  110. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  111. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  112. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  113. data/lib/rbbt/workflow/refactor/task_info.rb +66 -0
  114. data/lib/rbbt/workflow/refactor.rb +150 -0
  115. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +1 -2
  116. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  117. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  118. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  119. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  120. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  121. data/lib/rbbt/workflow/step/run.rb +766 -766
  122. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  123. data/lib/rbbt/workflow/step.rb +2 -362
  124. data/lib/rbbt/workflow/task.rb +118 -118
  125. data/lib/rbbt/workflow/usage.rb +289 -287
  126. data/lib/rbbt/workflow/util/archive.rb +6 -5
  127. data/lib/rbbt/workflow/util/data.rb +1 -1
  128. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  129. data/lib/rbbt/workflow/util/trace.rb +79 -44
  130. data/lib/rbbt/workflow.rb +4 -882
  131. data/lib/rbbt-util.rb +21 -13
  132. data/lib/rbbt.rb +16 -3
  133. data/python/rbbt/__init__.py +96 -4
  134. data/python/rbbt/workflow/remote.py +104 -0
  135. data/python/rbbt/workflow.py +64 -0
  136. data/python/test.py +10 -0
  137. data/share/Rlib/plot.R +37 -37
  138. data/share/Rlib/svg.R +22 -5
  139. data/share/install/software/lib/install_helpers +1 -1
  140. data/share/rbbt_commands/hpc/list +2 -3
  141. data/share/rbbt_commands/hpc/orchestrate +4 -4
  142. data/share/rbbt_commands/hpc/tail +2 -0
  143. data/share/rbbt_commands/hpc/task +10 -7
  144. data/share/rbbt_commands/lsf/list +2 -3
  145. data/share/rbbt_commands/lsf/orchestrate +4 -4
  146. data/share/rbbt_commands/lsf/tail +2 -0
  147. data/share/rbbt_commands/lsf/task +10 -7
  148. data/share/rbbt_commands/migrate +1 -1
  149. data/share/rbbt_commands/pbs/list +2 -3
  150. data/share/rbbt_commands/pbs/orchestrate +4 -4
  151. data/share/rbbt_commands/pbs/tail +2 -0
  152. data/share/rbbt_commands/pbs/task +10 -7
  153. data/share/rbbt_commands/resource/produce +8 -1
  154. data/share/rbbt_commands/slurm/list +2 -3
  155. data/share/rbbt_commands/slurm/orchestrate +4 -4
  156. data/share/rbbt_commands/slurm/tail +2 -0
  157. data/share/rbbt_commands/slurm/task +10 -7
  158. data/share/rbbt_commands/system/clean +5 -5
  159. data/share/rbbt_commands/system/status +5 -5
  160. data/share/rbbt_commands/tsv/get +2 -3
  161. data/share/rbbt_commands/tsv/info +10 -13
  162. data/share/rbbt_commands/tsv/keys +18 -14
  163. data/share/rbbt_commands/tsv/slice +2 -2
  164. data/share/rbbt_commands/tsv/transpose +6 -2
  165. data/share/rbbt_commands/workflow/info +20 -24
  166. data/share/rbbt_commands/workflow/list +1 -1
  167. data/share/rbbt_commands/workflow/prov +20 -13
  168. data/share/rbbt_commands/workflow/retry +43 -0
  169. data/share/rbbt_commands/workflow/server +12 -2
  170. data/share/rbbt_commands/workflow/task +80 -73
  171. data/share/rbbt_commands/workflow/write_info +26 -9
  172. data/share/software/opt/ssw/ssw.c +861 -0
  173. data/share/software/opt/ssw/ssw.h +130 -0
  174. data/share/workflow_config.ru +3 -3
  175. metadata +45 -6
data/lib/rbbt/tsv/csv.rb CHANGED
@@ -1,85 +1,87 @@
1
- require 'csv'
2
-
3
- module TSV
4
- def self.csv(obj, options = {})
5
- options = Misc.add_defaults IndiferentHash.setup(options.dup), :headers => true, :type => :list
6
- headers = options[:headers]
7
-
8
- noheaders = ! headers
9
-
10
- type = options.delete :type
11
- cast = options.delete :cast
12
- merge = options.delete :merge
13
- key_field = options.delete :key_field
14
- fields = options.delete :fields
15
-
16
- if key_field || fields
17
- orig_type = type
18
- type = :double
19
- merge = true
20
- end
21
-
22
- options[:headers] = false
23
-
24
- csv = case obj
25
- when Path
26
- CSV.read obj.find.open, options
27
- when String
28
- if Open.remote?(obj)
29
- CSV.read Open.open(obj), options
30
- elsif Misc.is_filename?(obj)
31
- CSV.read obj, options
32
- else
33
- CSV.new obj, **options
34
- end
35
- else
36
- CSV.new obj, **options
37
- end
38
-
39
- tsv = if noheaders
40
- TSV.setup({}, :key_field => nil, :fields => nil, :type => type)
41
- else
42
- key, *csv_fields = csv.shift
43
- TSV.setup({}, :key_field => key, :fields => csv_fields, :type => type)
44
- end
45
-
46
- csv.each_with_index do |row,i|
47
- if noheaders
48
- key, values = ["row-#{i}", row]
49
- else
50
- key, *values = row
51
- end
52
-
53
- if cast
54
- values = values.collect{|v| v.send cast }
55
- end
56
-
57
- case type
58
- when :double, :flat
59
- tsv.zip_new(key, values)
60
- when :single
61
- tsv[key] = values.first
62
- when :list
63
- tsv[key] = values
64
- end
65
- end
66
-
67
- if key_field || fields
68
- tsv = tsv.reorder(key_field, fields, :zipped => true, :merge => true)
69
- if tsv.type != orig_type
70
- tsv = case orig_type
71
- when :list
72
- tsv.to_list
73
- when :single
74
- tsv.to_single
75
- when :list
76
- tsv.to_list
77
- when :flat
78
- tsv.to_flat
79
- end
80
- end
81
- end
82
-
83
- tsv
84
- end
85
- end
1
+ require_relative '../refactor'
2
+ Rbbt.require_instead 'scout/tsv'
3
+ #require 'csv'
4
+ #
5
+ #module TSV
6
+ # def self.csv(obj, options = {})
7
+ # options = Misc.add_defaults IndiferentHash.setup(options.dup), :headers => true, :type => :list
8
+ # headers = options[:headers]
9
+ #
10
+ # noheaders = ! headers
11
+ #
12
+ # type = options.delete :type
13
+ # cast = options.delete :cast
14
+ # merge = options.delete :merge
15
+ # key_field = options.delete :key_field
16
+ # fields = options.delete :fields
17
+ #
18
+ # if key_field || fields
19
+ # orig_type = type
20
+ # type = :double
21
+ # merge = true
22
+ # end
23
+ #
24
+ # options[:headers] = false
25
+ #
26
+ # csv = case obj
27
+ # when Path
28
+ # CSV.read obj.find.open, **options
29
+ # when String
30
+ # if Open.remote?(obj)
31
+ # CSV.read Open.open(obj), **options
32
+ # elsif Misc.is_filename?(obj)
33
+ # CSV.read obj, **options
34
+ # else
35
+ # CSV.new obj, **options
36
+ # end
37
+ # else
38
+ # CSV.new obj, **options
39
+ # end
40
+ #
41
+ # tsv = if noheaders
42
+ # TSV.setup({}, :key_field => nil, :fields => nil, :type => type)
43
+ # else
44
+ # key, *csv_fields = csv.shift
45
+ # TSV.setup({}, :key_field => key, :fields => csv_fields, :type => type)
46
+ # end
47
+ #
48
+ # csv.each_with_index do |row,i|
49
+ # if noheaders
50
+ # key, values = ["row-#{i}", row]
51
+ # else
52
+ # key, *values = row
53
+ # end
54
+ #
55
+ # if cast
56
+ # values = values.collect{|v| v.send cast }
57
+ # end
58
+ #
59
+ # case type
60
+ # when :double, :flat
61
+ # tsv.zip_new(key, values)
62
+ # when :single
63
+ # tsv[key] = values.first
64
+ # when :list
65
+ # tsv[key] = values
66
+ # end
67
+ # end
68
+ #
69
+ # if key_field || fields
70
+ # tsv = tsv.reorder(key_field, fields, :zipped => true, :merge => true)
71
+ # if tsv.type != orig_type
72
+ # tsv = case orig_type
73
+ # when :list
74
+ # tsv.to_list
75
+ # when :single
76
+ # tsv.to_single
77
+ # when :list
78
+ # tsv.to_list
79
+ # when :flat
80
+ # tsv.to_flat
81
+ # end
82
+ # end
83
+ # end
84
+ #
85
+ # tsv
86
+ # end
87
+ #end
@@ -1,100 +1,2 @@
1
- module TSV
2
- class Dumper
3
- attr_accessor :in_stream, :stream, :options, :filename, :sep
4
- def self.stream(options = {}, filename = nil, stream = nil, &block)
5
- dumper = TSV::Dumper.new options, filename
6
- if stream
7
- dumper.set_stream stream if stream
8
- yield dumper
9
- stream
10
- else
11
- thread = Thread.new(Thread.current) do |parent|
12
- yield dumper
13
- end
14
- ConcurrentStream.setup(dumper.stream, threads: thread)
15
- end
16
- end
17
-
18
- def set_stream(stream)
19
- @stream.close
20
- @in_stream.close
21
- @in_stream = @stream = stream
22
- end
23
-
24
- def initialize(options, filename = nil)
25
- if TSV === options
26
- @options = options.options.merge(:key_field => options.key_field, :fields => options.fields)
27
- @filename ||= options.filename
28
- else
29
- @options = options
30
- @filename = filename
31
- end
32
- @filename ||= Misc.fingerprint options
33
- @stream, @in_stream = Misc.pipe
34
- end
35
-
36
- def self.values_to_s(values, fields = nil, sep = "\t")
37
- sep = "\t" if sep.nil?
38
- case values
39
- when nil
40
- if fields.nil? or fields.empty?
41
- "\n"
42
- else
43
- sep + ([""] * fields.length) * sep << "\n"
44
- end
45
- when Array
46
- if fields.nil?
47
- sep + (values.collect{|v| Array === v ? v * "|" : v} * sep) << "\n"
48
- elsif fields.empty?
49
- "\n"
50
- else
51
- sep + (values.collect{|v| Array === v ? v * "|" : v} * sep) << "\n"
52
- end
53
- else
54
- if fields.nil?
55
- sep + values.to_s + "\n"
56
- elsif fields.empty?
57
- "\n"
58
- else
59
- sep + values.to_s << "\n"
60
- end
61
- end
62
- end
63
-
64
- def init(init_options = {})
65
- options = @options.dup
66
- key_field, fields = Misc.process_options options, :key_field, :fields
67
-
68
- str = TSV.header_lines(key_field, fields, options.merge(init_options || {}))
69
-
70
- Thread.pass while IO.select(nil, [@in_stream],nil,1).nil? if IO === @in_stream
71
-
72
- @in_stream << str
73
- end
74
-
75
- def add(k,v)
76
- @fields ||= @options[:fields]
77
- @sep ||= @options[:sep]
78
- begin
79
- Thread.pass while IO.select(nil, [@in_stream],nil,1).nil? if IO === @in_stream
80
- @in_stream << k << TSV::Dumper.values_to_s(v, @fields, @sep)
81
- rescue IOError
82
- rescue Exception
83
- raise $!
84
- end
85
- end
86
-
87
- def close_out
88
- @stream.close unless StringIO === @stream || @stream.closed?
89
- end
90
-
91
- def close_in
92
- @in_stream.join if @in_stream.respond_to?(:join) && ! @in_stream.joined?
93
- @in_stream.close if @in_stream.respond_to?(:close) && ! @in_stream.closed?
94
- end
95
-
96
- def close
97
- close_in unless @in_stream == @stream
98
- end
99
- end
100
- end
1
+ require_relative '../refactor'
2
+ Rbbt.require_instead 'scout/tsv'
@@ -1,10 +1,12 @@
1
+ Rbbt.require_instead 'scout/tsv'
2
+ require_relative '../refactor'
1
3
  require 'spreadsheet'
2
4
  require 'rubyXL'
3
5
 
4
6
  module TSV
5
7
 
6
8
  def self._remove_link(value)
7
- if value =~ /<([\w]+)[^>]*>(.*?)<\/\1>/
9
+ if String === value && value =~ /<([\w]+)[^>]*>(.*?)<\/\1>/
8
10
  $2
9
11
  else
10
12
  value
@@ -28,14 +30,14 @@ module TSV
28
30
 
29
31
 
30
32
  def self._excel_data(tsv, options ={})
31
- options = Misc.add_defaults options, :sep2 => ', '
33
+ options = IndiferentHash.add_defaults options, :sep2 => ', '
32
34
 
33
- name = Misc.process_options options, :name
34
- sep2 = Misc.process_options options, :sep2
35
- unmerge = Misc.process_options options, :unmerge
36
- sort_by = Misc.process_options options, :sort_by
37
- sort_by_cast = Misc.process_options options, :sort_by_cast
38
- remove_links = Misc.process_options options, :remove_links
35
+ name = IndiferentHash.process_options options, :name
36
+ sep2 = IndiferentHash.process_options options, :sep2
37
+ unmerge = IndiferentHash.process_options options, :unmerge
38
+ sort_by = IndiferentHash.process_options options, :sort_by
39
+ sort_by_cast = IndiferentHash.process_options options, :sort_by_cast
40
+ remove_links = IndiferentHash.process_options options, :remove_links
39
41
 
40
42
  i = 1
41
43
  if sort_by
@@ -83,7 +85,7 @@ module TSV
83
85
  new_rows = []
84
86
  rows.each do |row|
85
87
  header = row.shift
86
- Misc.zip_fields(row).each do |values|
88
+ NamedArray.zip_fields(row).each do |values|
87
89
  new_rows << [header] + values
88
90
  end
89
91
  end
@@ -94,11 +96,11 @@ module TSV
94
96
 
95
97
  module XLS
96
98
  def self.read(file, options = {})
97
- options = Misc.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
98
- sheet = Misc.process_options options, :sheet
99
- header = Misc.process_options options, :header
100
- text = Misc.process_options options, :text
101
- skip_rows = Misc.process_options options, :skip_rows
99
+ options = IndiferentHash.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
100
+ sheet = IndiferentHash.process_options options, :sheet
101
+ header = IndiferentHash.process_options options, :header
102
+ text = IndiferentHash.process_options options, :text
103
+ skip_rows = IndiferentHash.process_options options, :skip_rows
102
104
  skip_rows = skip_rows.to_i
103
105
 
104
106
  header = true unless header == false
@@ -112,7 +114,7 @@ module TSV
112
114
  sheet_name = sheet
113
115
  Log.debug "Opening LSX #{file} sheet #{ sheet_name }"
114
116
 
115
- TmpFile.with_file :extension => Misc.sanitize_filename(sheet_name.to_s) do |filename|
117
+ TmpFile.with_file :extension => Path.sanitize_filename(sheet_name.to_s) do |filename|
116
118
 
117
119
  sheet = workbook.worksheet sheet
118
120
 
@@ -146,8 +148,8 @@ module TSV
146
148
  end
147
149
 
148
150
  def self.write(tsv, file, options = {})
149
- options = Misc.add_defaults options, :sheet => "Sheet1"
150
- sheet = Misc.process_options options, :sheet
151
+ options = IndiferentHash.add_defaults options, :sheet => "Sheet1"
152
+ sheet = IndiferentHash.process_options options, :sheet
151
153
  fields, rows = TSV._excel_data(tsv, options)
152
154
 
153
155
  book = Spreadsheet::Workbook.new
@@ -170,11 +172,11 @@ module TSV
170
172
 
171
173
  module XLSX
172
174
  def self.read(file, options = {})
173
- options = Misc.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
174
- sheet = Misc.process_options options, :sheet
175
- header = Misc.process_options options, :header
176
- text = Misc.process_options options, :text
177
- skip_rows = Misc.process_options options, :skip_rows
175
+ options = IndiferentHash.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
176
+ sheet = IndiferentHash.process_options options, :sheet
177
+ header = IndiferentHash.process_options options, :header
178
+ text = IndiferentHash.process_options options, :text
179
+ skip_rows = IndiferentHash.process_options options, :skip_rows
178
180
  skip_rows = skip_rows.to_i
179
181
 
180
182
  header = true unless header == false
@@ -187,7 +189,7 @@ module TSV
187
189
  sheet_name = sheet
188
190
  Log.debug "Opening XLSX #{file} sheet #{ sheet_name }"
189
191
 
190
- TmpFile.with_file :extension => Misc.sanitize_filename(sheet_name.to_s) do |filename|
192
+ TmpFile.with_file :extension => Path.sanitize_filename(sheet_name.to_s) do |filename|
191
193
 
192
194
  sheet = sheet_name ? workbook[sheet_name] : workbook.worksheets.first
193
195
 
@@ -223,7 +225,7 @@ module TSV
223
225
  end
224
226
 
225
227
  def self.write(tsv, file, options = {})
226
- sheet, add_sheet = Misc.process_options options, :sheet, :add_sheet
228
+ sheet, add_sheet = IndiferentHash.process_options options, :sheet, :add_sheet
227
229
 
228
230
  fields, rows = TSV._excel_data(tsv, options)
229
231
 
@@ -13,6 +13,8 @@ module TSV
13
13
  def field_index(field)
14
14
  @field_indices ||= {}
15
15
  @field_indices[field] ||= Persist.persist_tsv(self, filename, {:field => field}, :prefix => "FieldIndex", :dir => TSV.field_index_dir, :persist => true, :serializer => :list, :engine => "BDB" ) do |data|
16
+ data.serializer = :flat
17
+
16
18
  tsv = {}
17
19
  case type
18
20
  when :single, :list
@@ -30,6 +32,7 @@ module TSV
30
32
  end
31
33
  end
32
34
 
35
+ TSV.setup(data, :key_field => field, :fields => ["Keys"], :type => :flat)
33
36
  tsv.each do |v,keys|
34
37
  data[v] = keys.sort
35
38
  end
@@ -44,7 +47,7 @@ module TSV
44
47
  i = field_index(field)
45
48
 
46
49
  if Array === values
47
- keys = values.inject([]){|acc,value| m = i[value]; acc = m.nil? ? acc : Misc.merge_sorted_arrays( acc, m) }
50
+ keys = values.inject([]){|acc,value| m = i[value]; acc = m.nil? ? acc : Misc.merge_sorted_arrays(acc, m) }
48
51
  else
49
52
  keys = i[values] || []
50
53
  end
@@ -32,7 +32,8 @@ module Filtered
32
32
  when Hash === persistence
33
33
  @persistence = persistence
34
34
  when String === persistence
35
- @persistence = TSV.setup Persist.open_tokyocabinet(persistence, false, :list)
35
+ @persistence = Persist.open_tokyocabinet(persistence, false, :list)
36
+ @persistence = TSV.setup(@persistence)
36
37
  @persistence.read
37
38
  end
38
39
 
@@ -192,7 +193,7 @@ module Filtered
192
193
  if filters.empty?
193
194
  unfiltered_filename
194
195
  else
195
- unfiltered_filename + ":Filtered[#{filters.collect{|f| [f.match, Array === f.value ? Misc.hash2md5(:values => f.value) : f.value] * "="} * ", "}]"
196
+ unfiltered_filename + ":Filtered[#{filters.collect{|f| [f.match, Array === f.value ? Misc.digest(:values => f.value) : f.value] * "="} * ", "}]"
196
197
  end
197
198
  end
198
199