flat_kit 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -2
- data/HISTORY.md +15 -0
- data/Manifest.txt +21 -26
- data/{bin → exe}/fk +2 -1
- data/flat_kit.gemspec +33 -0
- data/lib/flat_kit/cli.rb +48 -23
- data/lib/flat_kit/command/cat.rb +34 -32
- data/lib/flat_kit/command/merge.rb +37 -36
- data/lib/flat_kit/command/sort.rb +37 -37
- data/lib/flat_kit/command/stats.rb +96 -0
- data/lib/flat_kit/command.rb +10 -10
- data/lib/flat_kit/descendant_tracker.rb +17 -5
- data/lib/flat_kit/error.rb +4 -0
- data/lib/flat_kit/event_emitter.rb +7 -4
- data/lib/flat_kit/field_stats.rb +246 -0
- data/lib/flat_kit/field_type/boolean_type.rb +52 -0
- data/lib/flat_kit/field_type/date_type.rb +181 -0
- data/lib/flat_kit/field_type/float_type.rb +43 -0
- data/lib/flat_kit/field_type/guess_type.rb +23 -0
- data/lib/flat_kit/field_type/integer_type.rb +36 -0
- data/lib/flat_kit/field_type/null_type.rb +39 -0
- data/lib/flat_kit/field_type/string_type.rb +24 -0
- data/lib/flat_kit/field_type/timestamp_type.rb +48 -0
- data/lib/flat_kit/field_type/unknown_type.rb +30 -0
- data/lib/flat_kit/field_type.rb +83 -0
- data/lib/flat_kit/format.rb +11 -5
- data/lib/flat_kit/input/file.rb +11 -9
- data/lib/flat_kit/input/io.rb +18 -21
- data/lib/flat_kit/input.rb +8 -7
- data/lib/flat_kit/internal_node.rb +22 -19
- data/lib/flat_kit/jsonl/format.rb +6 -2
- data/lib/flat_kit/jsonl/reader.rb +7 -4
- data/lib/flat_kit/jsonl/record.rb +16 -19
- data/lib/flat_kit/jsonl/writer.rb +25 -18
- data/lib/flat_kit/jsonl.rb +8 -4
- data/lib/flat_kit/leaf_node.rb +6 -5
- data/lib/flat_kit/log_formatter.rb +20 -0
- data/lib/flat_kit/logger.rb +12 -19
- data/lib/flat_kit/merge.rb +21 -16
- data/lib/flat_kit/merge_tree.rb +5 -6
- data/lib/flat_kit/output/file.rb +13 -9
- data/lib/flat_kit/output/io.rb +40 -35
- data/lib/flat_kit/output.rb +12 -7
- data/lib/flat_kit/position.rb +18 -0
- data/lib/flat_kit/reader.rb +8 -8
- data/lib/flat_kit/record.rb +12 -12
- data/lib/flat_kit/sentinel_internal_node.rb +6 -5
- data/lib/flat_kit/sentinel_leaf_node.rb +4 -1
- data/lib/flat_kit/sort.rb +8 -9
- data/lib/flat_kit/stat_type/nominal_stats.rb +64 -0
- data/lib/flat_kit/stat_type/numerical_stats.rb +120 -0
- data/lib/flat_kit/stat_type/ordinal_stats.rb +37 -0
- data/lib/flat_kit/stat_type.rb +70 -0
- data/lib/flat_kit/stats.rb +64 -0
- data/lib/flat_kit/writer.rb +17 -3
- data/lib/flat_kit/xsv/format.rb +6 -2
- data/lib/flat_kit/xsv/reader.rb +8 -6
- data/lib/flat_kit/xsv/record.rb +21 -15
- data/lib/flat_kit/xsv/writer.rb +36 -18
- data/lib/flat_kit/xsv.rb +7 -4
- data/lib/flat_kit.rb +33 -21
- metadata +38 -113
- data/Rakefile +0 -20
- data/tasks/default.rake +0 -242
- data/tasks/extension.rake +0 -38
- data/tasks/man.rake +0 -7
- data/tasks/this.rb +0 -208
- data/test/device_dataset.rb +0 -117
- data/test/input/test_file.rb +0 -73
- data/test/input/test_io.rb +0 -93
- data/test/jsonl/test_format.rb +0 -22
- data/test/jsonl/test_reader.rb +0 -49
- data/test/jsonl/test_record.rb +0 -61
- data/test/jsonl/test_writer.rb +0 -68
- data/test/output/test_file.rb +0 -60
- data/test/output/test_io.rb +0 -104
- data/test/test_conversions.rb +0 -45
- data/test/test_event_emitter.rb +0 -72
- data/test/test_format.rb +0 -24
- data/test/test_helper.rb +0 -26
- data/test/test_merge.rb +0 -40
- data/test/test_merge_tree.rb +0 -64
- data/test/test_version.rb +0 -11
- data/test/xsv/test_format.rb +0 -22
- data/test/xsv/test_reader.rb +0 -61
- data/test/xsv/test_record.rb +0 -69
- data/test/xsv/test_writer.rb +0 -68
data/test/xsv/test_writer.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
module TestXsv
|
4
|
-
class TestWriter < ::Minitest::Test
|
5
|
-
def setup
|
6
|
-
@count = 20
|
7
|
-
@dataset = DeviceDataset.new(count: @count)
|
8
|
-
@compare_fields = @dataset.compare_fields
|
9
|
-
@write_path = "tmp/test_writes_to_io.csv"
|
10
|
-
@read_path = "tmp/test_read.csv"
|
11
|
-
|
12
|
-
File.open(@read_path, "wb") do |f|
|
13
|
-
f.write(@dataset.records_as_csv)
|
14
|
-
end
|
15
|
-
|
16
|
-
@reader = ::FlatKit::Xsv::Reader.new(source: @read_path, compare_fields: @compare_fields)
|
17
|
-
@records = @reader.to_a
|
18
|
-
end
|
19
|
-
|
20
|
-
def teardown
|
21
|
-
File.unlink(@write_path) if File.exist?(@write_path)
|
22
|
-
File.unlink(@read_path) if File.exist?(@read_path)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_raises_error_on_invalid_destination
|
26
|
-
assert_raises(::FlatKit::Error) {
|
27
|
-
::FlatKit::Xsv::Writer.new(destination: Object.new, fields: @reader.fields)
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_writes_to_pathname
|
32
|
-
writer = ::FlatKit::Xsv::Writer.new(destination: @write_path, fields: @reader.fields)
|
33
|
-
@records.each do |r|
|
34
|
-
writer.write(r)
|
35
|
-
end
|
36
|
-
writer.close
|
37
|
-
assert_equal(@count, writer.count)
|
38
|
-
|
39
|
-
expected = @dataset.records_as_csv
|
40
|
-
actual = IO.read(@write_path)
|
41
|
-
assert_equal(expected, actual)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_writes_to_io
|
45
|
-
File.open(@write_path, "w+") do |f|
|
46
|
-
writer = ::FlatKit::Xsv::Writer.new(destination: f,fields: @reader.fields)
|
47
|
-
|
48
|
-
@records.each do |r|
|
49
|
-
writer.write(r)
|
50
|
-
end
|
51
|
-
writer.close
|
52
|
-
|
53
|
-
assert_equal(@count, writer.count)
|
54
|
-
|
55
|
-
expected = @dataset.records_as_csv
|
56
|
-
actual = IO.read(@write_path)
|
57
|
-
assert_equal(expected, actual)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_raises_error_on_io_error
|
62
|
-
s = StringIO.new
|
63
|
-
writer = ::FlatKit::Xsv::Writer.new(destination: s, fields: @reader.fields)
|
64
|
-
s.close_write
|
65
|
-
assert_raises(::FlatKit::Error) { writer.write(@records.first) }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|