scout-gear 10.2.0 → 10.3.0
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.
- checksums.yaml +4 -4
- data/.vimproject +1 -2
- data/VERSION +1 -1
- data/lib/scout/tsv/persist/tkrzw.rb +84 -0
- data/lib/scout/tsv/persist.rb +10 -1
- data/lib/scout/tsv.rb +11 -2
- data/lib/scout/workflow/definition.rb +2 -2
- data/lib/scout/workflow/task/dependencies.rb +2 -2
- data/lib/scout/workflow/task/inputs.rb +1 -1
- data/scout-gear.gemspec +6 -4
- data/test/scout/tsv/persist/test_tkrzw.rb +123 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a7adf9c59ab3ce69e89dd2e02089b5287605a1b74c6a435a5bfa4ece17c1f75
|
4
|
+
data.tar.gz: 65f9fa08d1b4a99e973d33eb5a7c0ddab85a98b5d6a675f8a2f5cfe381e664aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd78580f6d0fd2a417f15f425602131d4e3150fc8a0f35a1d2f63f5868e29cae8a9f59244a2fdc5d642441051b8528bcd2f8596aaf4bc11414437e6d4dc4cd14
|
7
|
+
data.tar.gz: ad61b8616e5029ff0ee748b48ef78928dc862bfbb0ba763610ad9f89f7e865975d816318ea388d30d774f1088894b9c2a3d42487b9a3c01c795c45cd5b37f2d7
|
data/.vimproject
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
10.
|
1
|
+
10.3.0
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'tkrzw'
|
2
|
+
require_relative 'adapter'
|
3
|
+
|
4
|
+
module ScoutTKRZW
|
5
|
+
attr_accessor :persistence_path, :persistence_class, :open_options
|
6
|
+
|
7
|
+
def self.open(path, write = true, persistence_class = 'tkh', options = {})
|
8
|
+
open_options = IndiferentHash.add_defaults options, truncate: true, num_buckets: 100, dbm: "HashDBM", sync_hard: true, encoding: "UTF-8"
|
9
|
+
|
10
|
+
path = path.find if Path === path
|
11
|
+
|
12
|
+
dir = File.dirname(File.expand_path(path))
|
13
|
+
Open.mkdir(dir) unless File.exist?(dir)
|
14
|
+
|
15
|
+
database = Persist::CONNECTIONS[[persistence_class, path]*":"] ||= Tkrzw::DBM.new
|
16
|
+
|
17
|
+
database.close if database.open?
|
18
|
+
|
19
|
+
database.open(path, write, open_options)
|
20
|
+
|
21
|
+
database.extend ScoutTKRZW
|
22
|
+
database.persistence_path ||= path
|
23
|
+
database.open_options = open_options
|
24
|
+
|
25
|
+
#Persist::CONNECTIONS[[persistence_class, path]*":"] = database
|
26
|
+
|
27
|
+
database
|
28
|
+
end
|
29
|
+
|
30
|
+
def close
|
31
|
+
@closed = true
|
32
|
+
@writable = false
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
def read(force = false)
|
37
|
+
return if open? && ! writable? && ! force
|
38
|
+
self.close if open?
|
39
|
+
if !self.open(@persistence_path, false, @open_options)
|
40
|
+
ecode = self.ecode
|
41
|
+
raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
|
42
|
+
end
|
43
|
+
|
44
|
+
@writable = false
|
45
|
+
@closed = false
|
46
|
+
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
def write(force = true)
|
51
|
+
return if open? && writable? && ! force
|
52
|
+
self.close if self.open?
|
53
|
+
|
54
|
+
if !self.open(@persistence_path, true, @open_options)
|
55
|
+
ecode = self.ecode
|
56
|
+
raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
|
57
|
+
end
|
58
|
+
|
59
|
+
@writable = true
|
60
|
+
@closed = false
|
61
|
+
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
def keys
|
66
|
+
search("contain", "")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
Persist.save_drivers[:tkh] = proc do |file, content|
|
71
|
+
data = ScoutTKRZW.open(file, true, "tkh")
|
72
|
+
content.annotate(data)
|
73
|
+
data.extend TSVAdapter
|
74
|
+
data.merge!(content)
|
75
|
+
data.close
|
76
|
+
data.read
|
77
|
+
data
|
78
|
+
end
|
79
|
+
|
80
|
+
Persist.load_drivers[:tkh] = proc do |file|
|
81
|
+
data = ScoutTKRZW.open(file, false, "tkh")
|
82
|
+
data.extend TSVAdapter unless TSVAdapter === data
|
83
|
+
data
|
84
|
+
end
|
data/lib/scout/tsv/persist.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
require 'scout/persist'
|
2
2
|
require_relative 'persist/adapter'
|
3
|
-
|
3
|
+
|
4
|
+
begin
|
5
|
+
require_relative 'persist/tokyocabinet'
|
6
|
+
rescue
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require_relative 'persist/tkrzw'
|
11
|
+
rescue
|
12
|
+
end
|
4
13
|
|
5
14
|
Persist.save_drivers[:tsv] = proc do |file,content|
|
6
15
|
stream = if IO === content
|
data/lib/scout/tsv.rb
CHANGED
@@ -37,11 +37,20 @@ module TSV
|
|
37
37
|
grep, invert_grep = IndiferentHash.process_options options, :grep, :invert_grep, :persist => false
|
38
38
|
|
39
39
|
persist_options = IndiferentHash.pull_keys options, :persist
|
40
|
-
persist_options = IndiferentHash.add_defaults persist_options, :prefix => "TSV", :type =>
|
40
|
+
persist_options = IndiferentHash.add_defaults persist_options, :prefix => "TSV", :type => :HDB
|
41
41
|
|
42
42
|
file = StringIO.new file if String === file && ! (Path === file) && file.index("\n")
|
43
43
|
Persist.persist(file, persist_options[:type], persist_options.merge(:other_options => options)) do |filename|
|
44
|
-
|
44
|
+
if filename
|
45
|
+
data = case persist_options[:type]
|
46
|
+
when :HDB, :BDB
|
47
|
+
ScoutCabinet.open(filename, true, persist_options[:type])
|
48
|
+
when :tkh, :tkt, :tks
|
49
|
+
ScoutTKRZW.open(filename, true, persist_options[:type])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
data = nil
|
53
|
+
end
|
45
54
|
options[:data] = data if data
|
46
55
|
options[:filename] = file
|
47
56
|
|
@@ -107,7 +107,7 @@ module Workflow
|
|
107
107
|
type = type.to_sym if String === type
|
108
108
|
name = name.to_sym if String === name
|
109
109
|
@tasks ||= IndiferentHash.setup({})
|
110
|
-
block = self.method(name) if block.nil?
|
110
|
+
block = lambda &self.method(name) if block.nil?
|
111
111
|
begin
|
112
112
|
@annotate_next_task ||= {}
|
113
113
|
@annotate_next_task[:extension] ||=
|
@@ -137,7 +137,7 @@ module Workflow
|
|
137
137
|
dep(workflow, oname, *rest, &block)
|
138
138
|
extension :dep_task unless @extension
|
139
139
|
task_proc = workflow.tasks[oname]
|
140
|
-
raise "Task #{
|
140
|
+
raise "Task #{oname} not found" if task_proc.nil?
|
141
141
|
returns task_proc.returns if @returns.nil?
|
142
142
|
type = task_proc.type
|
143
143
|
task name => type do
|
@@ -19,7 +19,7 @@ module Task
|
|
19
19
|
step_inputs.each do |k,v|
|
20
20
|
if Symbol === v
|
21
21
|
input_dep = dependencies.select{|d| d.task_name == v }.first
|
22
|
-
resolved_inputs[k] = input_dep || step_inputs[v] || k
|
22
|
+
resolved_inputs[k] = input_dep || provided_inputs[v] || step_inputs[v] || k
|
23
23
|
else
|
24
24
|
resolved_inputs[k] = v
|
25
25
|
end
|
@@ -79,7 +79,7 @@ module Task
|
|
79
79
|
when Step
|
80
80
|
dep = res
|
81
81
|
dependencies << dep
|
82
|
-
dep_non_default_inputs = find_dep_non_default_inputs.call(dep,
|
82
|
+
dep_non_default_inputs = find_dep_non_default_inputs.call(dep, definition_options)
|
83
83
|
non_default_inputs.concat(dep_non_default_inputs)
|
84
84
|
when Hash
|
85
85
|
step_options = block_options.merge(res)
|
@@ -3,7 +3,7 @@ module Task
|
|
3
3
|
def self.format_input(value, type, options = {})
|
4
4
|
return value if IO === value || StringIO === value || Step === value
|
5
5
|
|
6
|
-
if String === value && ! [:path, :file, :folder, :binary].include?(type) && ! (options && (options[:noload] || options[:stream] || options[:nofile]))
|
6
|
+
if String === value && ! [:path, :file, :folder, :binary, :tsv].include?(type) && ! (options && (options[:noload] || options[:stream] || options[:nofile]))
|
7
7
|
if Open.exists?(value) && ! Open.directory?(value)
|
8
8
|
Persist.load(value, type)
|
9
9
|
else
|
data/scout-gear.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: scout-gear 10.
|
5
|
+
# stub: scout-gear 10.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "scout-gear".freeze
|
9
|
-
s.version = "10.
|
9
|
+
s.version = "10.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Miguel Vazquez".freeze]
|
14
|
-
s.date = "2023-
|
14
|
+
s.date = "2023-08-01"
|
15
15
|
s.description = "Temporary files, logs, path, resources, persistence, workflows, TSV, etc.".freeze
|
16
16
|
s.email = "mikisvaz@gmail.com".freeze
|
17
17
|
s.executables = ["scout".freeze]
|
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
"lib/scout/tsv/persist/adapter.rb",
|
52
52
|
"lib/scout/tsv/persist/fix_width_table.rb",
|
53
53
|
"lib/scout/tsv/persist/serialize.rb",
|
54
|
+
"lib/scout/tsv/persist/tkrzw.rb",
|
54
55
|
"lib/scout/tsv/persist/tokyocabinet.rb",
|
55
56
|
"lib/scout/tsv/stream.rb",
|
56
57
|
"lib/scout/tsv/transformer.rb",
|
@@ -124,6 +125,7 @@ Gem::Specification.new do |s|
|
|
124
125
|
"test/scout/test_workflow.rb",
|
125
126
|
"test/scout/tsv/persist/test_adapter.rb",
|
126
127
|
"test/scout/tsv/persist/test_fix_width_table.rb",
|
128
|
+
"test/scout/tsv/persist/test_tkrzw.rb",
|
127
129
|
"test/scout/tsv/persist/test_tokyocabinet.rb",
|
128
130
|
"test/scout/tsv/test_attach.rb",
|
129
131
|
"test/scout/tsv/test_change_id.rb",
|
@@ -165,7 +167,7 @@ Gem::Specification.new do |s|
|
|
165
167
|
]
|
166
168
|
s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
|
167
169
|
s.licenses = ["MIT".freeze]
|
168
|
-
s.rubygems_version = "3.
|
170
|
+
s.rubygems_version = "3.4.13".freeze
|
169
171
|
s.summary = "basic gear for scouts".freeze
|
170
172
|
|
171
173
|
s.specification_version = 4
|
@@ -0,0 +1,123 @@
|
|
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
|
+
|
6
|
+
class TestScoutTKRZW < Test::Unit::TestCase
|
7
|
+
def _test_open
|
8
|
+
TmpFile.with_file nil do |tmp|
|
9
|
+
db = ScoutTKRZW.open(tmp, true)
|
10
|
+
1000.times do |i|
|
11
|
+
db["foo#{i}"] = "bar#{i}"
|
12
|
+
end
|
13
|
+
assert_include db, 'foo1'
|
14
|
+
assert_equal 1000, db.keys.length
|
15
|
+
|
16
|
+
db.close
|
17
|
+
TmpFile.with_file nil do |tmp_alt|
|
18
|
+
Open.cp tmp, tmp_alt
|
19
|
+
db2 = ScoutTKRZW.open(tmp_alt, false)
|
20
|
+
assert_include db2, 'foo1'
|
21
|
+
assert_equal 1000, db2.keys.length
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def _test_tkrzw
|
27
|
+
content =<<-'EOF'
|
28
|
+
#: :sep=/\s+/#:type=:double#:merge=:concat
|
29
|
+
#Id ValueA ValueB OtherID
|
30
|
+
row1 a|aa|aaa b Id1|Id2
|
31
|
+
row2 A B Id3
|
32
|
+
row2 a a id3
|
33
|
+
EOF
|
34
|
+
|
35
|
+
tsv = TmpFile.with_file(content) do |filename|
|
36
|
+
Persist.persist(__method__, 'tkh') do
|
37
|
+
TSV.open(filename)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
assert_equal %w(a aa aaa), tsv["row1"][0]
|
43
|
+
|
44
|
+
assert TSVAdapter === tsv
|
45
|
+
assert TSV === tsv
|
46
|
+
assert_include tsv.instance_variable_get(:@extension_attrs), :key_field
|
47
|
+
assert_include tsv.instance_variable_get(:@extension_attrs), :serializer
|
48
|
+
|
49
|
+
tsv.close
|
50
|
+
tsv_loaded = assert_nothing_raised do
|
51
|
+
TmpFile.with_file(content) do |filename|
|
52
|
+
Persist.persist(__method__, 'tkh') do
|
53
|
+
raise
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
assert_equal %w(a aa aaa), tsv_loaded["row1"][0]
|
59
|
+
end
|
60
|
+
|
61
|
+
def __test_benchmark1
|
62
|
+
TmpFile.with_file nil do |tmp|
|
63
|
+
|
64
|
+
Misc.benchmark(1000) do
|
65
|
+
db = ScoutTKRZW.open(tmp, true)
|
66
|
+
1000.times do |i|
|
67
|
+
db["foo#{i}"] = "bar#{i}"
|
68
|
+
end
|
69
|
+
10.times do
|
70
|
+
db.keys
|
71
|
+
end
|
72
|
+
10.times do |i|
|
73
|
+
db["foo#{i}"]
|
74
|
+
end
|
75
|
+
Open.rm tmp
|
76
|
+
end
|
77
|
+
|
78
|
+
Misc.benchmark(1000) do
|
79
|
+
db = ScoutCabinet.open(tmp, true)
|
80
|
+
1000.times do |i|
|
81
|
+
db["foo#{i}"] = "bar#{i}"
|
82
|
+
end
|
83
|
+
10.times do
|
84
|
+
db.keys
|
85
|
+
end
|
86
|
+
10.times do |i|
|
87
|
+
db["foo#{i}"]
|
88
|
+
end
|
89
|
+
db.close
|
90
|
+
Open.rm tmp
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_benchmark2
|
96
|
+
TmpFile.with_file nil do |tmp|
|
97
|
+
|
98
|
+
db = ScoutTKRZW.open(tmp, true)
|
99
|
+
10000.times do |i|
|
100
|
+
db["foo#{i}"] = "bar#{i}"
|
101
|
+
end
|
102
|
+
|
103
|
+
Misc.benchmark(1000) do
|
104
|
+
100.times do |i|
|
105
|
+
db["foo#{i}"]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
Open.rm tmp
|
110
|
+
db = ScoutCabinet.open(tmp, true)
|
111
|
+
10000.times do |i|
|
112
|
+
db["foo#{i}"] = "bar#{i}"
|
113
|
+
end
|
114
|
+
Misc.benchmark(1000) do
|
115
|
+
100.times do |i|
|
116
|
+
db["foo#{i}"]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout-gear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.
|
4
|
+
version: 10.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: scout-essentials
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/scout/tsv/persist/adapter.rb
|
164
164
|
- lib/scout/tsv/persist/fix_width_table.rb
|
165
165
|
- lib/scout/tsv/persist/serialize.rb
|
166
|
+
- lib/scout/tsv/persist/tkrzw.rb
|
166
167
|
- lib/scout/tsv/persist/tokyocabinet.rb
|
167
168
|
- lib/scout/tsv/stream.rb
|
168
169
|
- lib/scout/tsv/transformer.rb
|
@@ -236,6 +237,7 @@ files:
|
|
236
237
|
- test/scout/test_workflow.rb
|
237
238
|
- test/scout/tsv/persist/test_adapter.rb
|
238
239
|
- test/scout/tsv/persist/test_fix_width_table.rb
|
240
|
+
- test/scout/tsv/persist/test_tkrzw.rb
|
239
241
|
- test/scout/tsv/persist/test_tokyocabinet.rb
|
240
242
|
- test/scout/tsv/test_attach.rb
|
241
243
|
- test/scout/tsv/test_change_id.rb
|
@@ -293,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
295
|
- !ruby/object:Gem::Version
|
294
296
|
version: '0'
|
295
297
|
requirements: []
|
296
|
-
rubygems_version: 3.
|
298
|
+
rubygems_version: 3.4.13
|
297
299
|
signing_key:
|
298
300
|
specification_version: 4
|
299
301
|
summary: basic gear for scouts
|