tb 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +60 -0
- data/bin/tb +1137 -0
- data/lib/tb.rb +35 -0
- data/lib/tb/basic.rb +1071 -0
- data/lib/tb/csv.rb +125 -0
- data/lib/tb/enumerable.rb +284 -0
- data/lib/tb/fieldset.rb +96 -0
- data/lib/tb/pathfinder.rb +569 -0
- data/lib/tb/qtsv.rb +93 -0
- data/lib/tb/reader.rb +213 -0
- data/lib/tb/record.rb +129 -0
- data/lib/tb/tsv.rb +93 -0
- data/sample/excel2csv +270 -0
- data/sample/poi-xls2csv.rb +397 -0
- data/sample/poi-xls2csv.sh +39 -0
- data/test-all.rb +7 -0
- data/test/test_basic.rb +290 -0
- data/test/test_csv.rb +78 -0
- data/test/test_enumerable.rb +122 -0
- data/test/test_record.rb +12 -0
- data/test/test_tsv.rb +41 -0
- metadata +73 -0
data/test/test_record.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'tb'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestTbRecord < Test::Unit::TestCase
|
5
|
+
def test_values_at
|
6
|
+
t = Tb.new %w[fruit color],
|
7
|
+
%w[apple red],
|
8
|
+
%w[banana yellow],
|
9
|
+
%w[orange orange]
|
10
|
+
assert_equal(["apple", "red"], t.get_record(0).values_at("fruit", "color"))
|
11
|
+
end
|
12
|
+
end
|
data/test/test_tsv.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'tb'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestTbTSV < Test::Unit::TestCase
|
5
|
+
def test_parse
|
6
|
+
tsv = "a\tb\n1\t2\n"
|
7
|
+
t = Tb.parse_tsv(tsv)
|
8
|
+
records = []
|
9
|
+
t.each_record {|record|
|
10
|
+
records << record.to_h_with_reserved
|
11
|
+
}
|
12
|
+
assert_equal(
|
13
|
+
[{"_recordid"=>0, "a"=>"1", "b"=>"2"}],
|
14
|
+
records)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_parse_conv
|
18
|
+
tsv = "foo\na\tb\n1\t2\n"
|
19
|
+
t = Tb.parse_tsv(tsv) {|aa|
|
20
|
+
assert_equal([%w[foo],
|
21
|
+
%w[a b],
|
22
|
+
%w[1 2]],
|
23
|
+
aa)
|
24
|
+
aa.shift
|
25
|
+
aa
|
26
|
+
}
|
27
|
+
records = []
|
28
|
+
t.each_record {|record|
|
29
|
+
records << record.to_h_with_reserved
|
30
|
+
}
|
31
|
+
assert_equal(
|
32
|
+
[{"_recordid"=>0, "a"=>"1", "b"=>"2"}],
|
33
|
+
records)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_generate_tsv
|
37
|
+
tbl = Tb.new %w[a b], %w[foo bar]
|
38
|
+
tbl.generate_tsv(out="")
|
39
|
+
assert_equal("a\tb\nfoo\tbar\n", out)
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tanaka Akira
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! 'manipulation tool for table: CSV, TSV, etc.
|
15
|
+
|
16
|
+
'
|
17
|
+
email: akr@fsij.org
|
18
|
+
executables:
|
19
|
+
- tb
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- README
|
24
|
+
- bin/tb
|
25
|
+
- lib/tb.rb
|
26
|
+
- lib/tb/basic.rb
|
27
|
+
- lib/tb/csv.rb
|
28
|
+
- lib/tb/enumerable.rb
|
29
|
+
- lib/tb/fieldset.rb
|
30
|
+
- lib/tb/pathfinder.rb
|
31
|
+
- lib/tb/qtsv.rb
|
32
|
+
- lib/tb/reader.rb
|
33
|
+
- lib/tb/record.rb
|
34
|
+
- lib/tb/tsv.rb
|
35
|
+
- sample/excel2csv
|
36
|
+
- sample/poi-xls2csv.rb
|
37
|
+
- sample/poi-xls2csv.sh
|
38
|
+
- test-all.rb
|
39
|
+
- test/test_basic.rb
|
40
|
+
- test/test_csv.rb
|
41
|
+
- test/test_enumerable.rb
|
42
|
+
- test/test_record.rb
|
43
|
+
- test/test_tsv.rb
|
44
|
+
homepage: https://github.com/akr/tb
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.11
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: ! 'manipulation tool for table: CSV, TSV, etc.'
|
68
|
+
test_files:
|
69
|
+
- test/test_basic.rb
|
70
|
+
- test/test_csv.rb
|
71
|
+
- test/test_enumerable.rb
|
72
|
+
- test/test_record.rb
|
73
|
+
- test/test_tsv.rb
|