tb 0.8 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +14 -7
- data/bin/tb +3 -3
- data/lib/tb.rb +3 -3
- data/lib/tb/basic.rb +34 -34
- data/lib/tb/catreader.rb +3 -3
- data/lib/tb/cmd_cat.rb +5 -5
- data/lib/tb/cmd_consecutive.rb +4 -4
- data/lib/tb/cmd_crop.rb +4 -4
- data/lib/tb/cmd_cross.rb +3 -3
- data/lib/tb/cmd_cut.rb +3 -3
- data/lib/tb/cmd_git.rb +3 -3
- data/lib/tb/cmd_grep.rb +3 -3
- data/lib/tb/cmd_group.rb +3 -3
- data/lib/tb/cmd_gsub.rb +3 -3
- data/lib/tb/cmd_help.rb +3 -3
- data/lib/tb/cmd_join.rb +3 -3
- data/lib/tb/cmd_ls.rb +3 -3
- data/lib/tb/cmd_melt.rb +3 -3
- data/lib/tb/cmd_mheader.rb +3 -3
- data/lib/tb/cmd_nest.rb +3 -3
- data/lib/tb/cmd_newfield.rb +17 -7
- data/lib/tb/cmd_rename.rb +3 -3
- data/lib/tb/cmd_shape.rb +3 -3
- data/lib/tb/cmd_sort.rb +3 -3
- data/lib/tb/cmd_svn.rb +3 -3
- data/lib/tb/cmd_tar.rb +3 -3
- data/lib/tb/cmd_to_csv.rb +4 -4
- data/lib/tb/cmd_to_json.rb +3 -3
- data/lib/tb/cmd_to_ltsv.rb +4 -4
- data/lib/tb/cmd_to_pnm.rb +3 -3
- data/lib/tb/cmd_to_pp.rb +3 -3
- data/lib/tb/cmd_to_tsv.rb +4 -4
- data/lib/tb/cmd_to_yaml.rb +3 -3
- data/lib/tb/cmd_unmelt.rb +3 -3
- data/lib/tb/cmd_unnest.rb +5 -4
- data/lib/tb/cmdmain.rb +3 -3
- data/lib/tb/cmdtop.rb +3 -3
- data/lib/tb/cmdutil.rb +3 -3
- data/lib/tb/csv.rb +10 -4
- data/lib/tb/customcmp.rb +3 -3
- data/lib/tb/customeq.rb +3 -3
- data/lib/tb/enumerable.rb +3 -3
- data/lib/tb/enumerator.rb +3 -3
- data/lib/tb/ex_enumerable.rb +2 -2
- data/lib/tb/ex_enumerator.rb +4 -4
- data/lib/tb/fieldset.rb +3 -3
- data/lib/tb/fileenumerator.rb +6 -6
- data/lib/tb/func.rb +3 -3
- data/lib/tb/json.rb +3 -3
- data/lib/tb/ltsv.rb +32 -7
- data/lib/tb/pnm.rb +3 -3
- data/lib/tb/reader.rb +3 -3
- data/lib/tb/record.rb +3 -3
- data/lib/tb/revcmp.rb +3 -3
- data/lib/tb/ropen.rb +23 -23
- data/lib/tb/search.rb +7 -7
- data/lib/tb/tsv.rb +3 -3
- data/lib/tb/zipper.rb +3 -3
- data/sample/excel2csv +36 -36
- data/sample/poi-xls2csv.rb +78 -78
- data/sample/poi-xls2csv.sh +3 -3
- data/sample/tbplot +214 -112
- data/test/test_basic.rb +4 -4
- data/test/test_cmd_newfield.rb +17 -3
- data/test/test_ex_enumerable.rb +18 -18
- data/test/test_ltsv.rb +8 -0
- metadata +5 -5
data/lib/tb/cmd_to_pnm.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/cmd_to_pp.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/cmd_to_tsv.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -31,7 +31,7 @@ Tb::Cmd.subcommands << 'to-tsv'
|
|
31
31
|
def (Tb::Cmd).op_to_tsv
|
32
32
|
op = OptionParser.new
|
33
33
|
op.banner = "Usage: tb to-tsv [OPTS] [TABLE]\n" +
|
34
|
-
"Convert a table to TSV (Tab Separated
|
34
|
+
"Convert a table to TSV (Tab Separated Values)."
|
35
35
|
define_common_option(op, "hNo", "--no-pager")
|
36
36
|
op
|
37
37
|
end
|
data/lib/tb/cmd_to_yaml.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/cmd_unmelt.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/cmd_unnest.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -91,7 +91,8 @@ def (Tb::Cmd).main_unnest(argv)
|
|
91
91
|
}
|
92
92
|
y.set_header header2
|
93
93
|
}.each {|pairs|
|
94
|
-
pairs2 =
|
94
|
+
pairs2 = {}
|
95
|
+
pairs.each {|f, v| pairs2[f] = v if f != target_field }
|
95
96
|
ntbl = pairs[target_field]
|
96
97
|
if ntbl.nil? || ntbl.empty?
|
97
98
|
if Tb::Cmd.opt_unnest_outer
|
data/lib/tb/cmdmain.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/cmdtop.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2013 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/cmdutil.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2011-2013 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/csv.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# lib/tb/csv.rb - CSV related fetures for table library
|
2
2
|
#
|
3
|
-
# Copyright (C) 2010-
|
4
|
-
#
|
3
|
+
# Copyright (C) 2010-2013 Tanaka Akira <akr@fsij.org>
|
4
|
+
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
6
6
|
# modification, are permitted provided that the following conditions
|
7
7
|
# are met:
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# 1. Redistributions of source code must retain the above copyright
|
10
10
|
# notice, this list of conditions and the following disclaimer.
|
11
11
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# 3. The name of the author may not be used to endorse or promote
|
16
16
|
# products derived from this software without specific prior
|
17
17
|
# written permission.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
20
20
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
21
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -62,6 +62,12 @@ class Tb
|
|
62
62
|
nil
|
63
63
|
end
|
64
64
|
|
65
|
+
def Tb.csv_read_aa(csv)
|
66
|
+
aa = []
|
67
|
+
Tb.csv_stream_input(csv) {|ary| aa << ary }
|
68
|
+
aa
|
69
|
+
end
|
70
|
+
|
65
71
|
class CSVReader
|
66
72
|
def initialize(input)
|
67
73
|
@csv = CSV.new(input)
|
data/lib/tb/customcmp.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/customeq.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/enumerable.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2012-2013 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/enumerator.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/ex_enumerable.rb
CHANGED
@@ -315,7 +315,7 @@ module Enumerable
|
|
315
315
|
mapfunc = opts[:map]
|
316
316
|
opts = opts.dup
|
317
317
|
opts[:map] = mapfunc ?
|
318
|
-
lambda {|v| Marshal.dump(mapfunc.call(v)) } :
|
318
|
+
lambda {|v| Marshal.dump(mapfunc.call(v)) } :
|
319
319
|
lambda {|v| Marshal.dump(v) }
|
320
320
|
uniqfunc = opts[:unique]
|
321
321
|
if uniqfunc
|
@@ -566,7 +566,7 @@ module Enumerable
|
|
566
566
|
# Note that +detect_group_by+ can be cascaeded but
|
567
567
|
# It doesn't work as nested manner.
|
568
568
|
#
|
569
|
-
# (0..9).detect_group_by(
|
569
|
+
# (0..9).detect_group_by(
|
570
570
|
# lambda {|v| print "[" },
|
571
571
|
# lambda {|v| print "]" }) {|v|
|
572
572
|
# v.even?
|
data/lib/tb/ex_enumerator.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -38,7 +38,7 @@ module Tb::ExEnumerator
|
|
38
38
|
#
|
39
39
|
# Tb::Enumerator.merge_sorted iterates keys in all of the enumerators.
|
40
40
|
# It yields an array which contains a key and enumerators which has the key.
|
41
|
-
# The array contains nil if corresponding enumerator don't have the key.
|
41
|
+
# The array contains nil if corresponding enumerator don't have the key.
|
42
42
|
#
|
43
43
|
# The block may or may not use +next+ method to advance enumerators.
|
44
44
|
# Anyway Tb::Enumerator.merge_sorted advance enumerators until peeked key is
|
data/lib/tb/fieldset.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# lib/tb/fieldset.rb - Tb::FieldSet class
|
2
2
|
#
|
3
3
|
# Copyright (C) 2011-2012 Tanaka Akira <akr@fsij.org>
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
6
6
|
# modification, are permitted provided that the following conditions
|
7
7
|
# are met:
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# 1. Redistributions of source code must retain the above copyright
|
10
10
|
# notice, this list of conditions and the following disclaimer.
|
11
11
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# 3. The name of the author may not be used to endorse or promote
|
16
16
|
# products derived from this software without specific prior
|
17
17
|
# written permission.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
20
20
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
21
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/lib/tb/fileenumerator.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Copyright (C) 2012 Tanaka Akira <akr@fsij.org>
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Redistribution and use in source and binary forms, with or without
|
4
4
|
# modification, are permitted provided that the following conditions
|
5
5
|
# are met:
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
9
9
|
# 2. Redistributions in binary form must reproduce the above
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# 3. The name of the author may not be used to endorse or promote
|
14
14
|
# products derived from this software without specific prior
|
15
15
|
# written permission.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
18
18
|
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
19
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -128,7 +128,7 @@ class Tb::FileEnumerator
|
|
128
128
|
end
|
129
129
|
rescue EOFError
|
130
130
|
ensure
|
131
|
-
io.close
|
131
|
+
io.close
|
132
132
|
end
|
133
133
|
}
|
134
134
|
else
|
@@ -155,7 +155,7 @@ class Tb::FileEnumerator
|
|
155
155
|
def closed?
|
156
156
|
@io.nil?
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
def finalize
|
160
160
|
@io.close
|
161
161
|
@io = nil
|
@@ -349,7 +349,7 @@ class Tb::FileHeaderEnumerator < Tb::FileEnumerator
|
|
349
349
|
end
|
350
350
|
rescue EOFError
|
351
351
|
ensure
|
352
|
-
io.close
|
352
|
+
io.close
|
353
353
|
end
|
354
354
|
}
|
355
355
|
end
|