tree.rb 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/examples/d3js_layout_partition/data.js +0 -0
- data/examples/d3js_layout_partition/index.html +0 -0
- data/examples/d3js_layout_partition/run.sh +0 -0
- data/examples/d3js_layout_partition/style.css +0 -0
- data/examples/d3js_layout_treemap/data.js +0 -0
- data/examples/d3js_layout_treemap/index.html +0 -0
- data/examples/d3js_layout_treemap/run.sh +0 -0
- data/examples/d3js_layout_treemap/style.css +0 -0
- data/examples/protovis/directory_to_json_visitor.rb +0 -0
- data/examples/protovis/index.html +0 -0
- data/examples/protovis/protovis-r3.2.js +0 -0
- data/examples/protovis/treevisitor.js +0 -0
- data/examples/protovis/treevisitor.png +0 -0
- data/examples/ruby_examples/find_directory_without_subdirectory.rb +2 -2
- data/examples/ruby_examples/find_files.rb +0 -0
- data/examples/ruby_examples/find_orphan_xmp.rb +17 -0
- data/examples/ruby_examples/print_files.rb +1 -2
- data/ext/mkrf_conf.rb +3 -2
- data/lib/colors.rb +39 -0
- data/lib/tree_rb.rb +2 -2
- data/lib/tree_rb/cli/cli_json.rb +3 -3
- data/lib/tree_rb/cli/cli_tree.rb +0 -0
- data/lib/tree_rb/core/abs_node.rb +2 -2
- data/lib/tree_rb/core/basic_tree_node_visitor.rb +0 -0
- data/lib/tree_rb/core/leaf_node.rb +0 -0
- data/lib/tree_rb/core/tree_node.rb +0 -0
- data/lib/tree_rb/core/tree_node_visitor.rb +0 -0
- data/lib/tree_rb/exception.rb +0 -0
- data/lib/tree_rb/extension_digest.rb +0 -0
- data/lib/tree_rb/extension_numeric.rb +0 -0
- data/lib/tree_rb/input_plugins/file_system/dir_processor.rb +0 -0
- data/lib/tree_rb/input_plugins/file_system/directory_walker.rb +3 -3
- data/lib/tree_rb/input_plugins/html_page/dom_walker.rb +0 -0
- data/lib/tree_rb/output_plugins/dircat/dircat_output.rb +0 -0
- data/lib/tree_rb/output_plugins/dircat/dircat_visitor.rb +0 -0
- data/lib/tree_rb/output_plugins/dircat/entry.rb +0 -0
- data/lib/tree_rb/output_plugins/html/d3js_output.rb +0 -0
- data/lib/tree_rb/output_plugins/html/directory_to_hash2_visitor.rb +0 -0
- data/lib/tree_rb/output_plugins/html/erb_render.rb +0 -0
- data/lib/tree_rb/output_plugins/sqlite/sqlite_dir_tree_visitor.rb +0 -0
- data/lib/tree_rb/output_plugins/sqlite/sqlite_output.rb +0 -0
- data/lib/tree_rb/version.rb +1 -1
- data/lib/tree_rb/visitors/block_tree_node_visitor.rb +0 -0
- data/lib/tree_rb/visitors/callback_tree_node_visitor2.rb +2 -2
- data/lib/tree_rb/visitors/clone_tree_node_visitor.rb +0 -0
- data/lib/tree_rb/visitors/depth_tree_node_visitor.rb +0 -0
- data/lib/tree_rb/visitors/flat_print_tree_node_visitor.rb +0 -0
- data/lib/tree_rb/visitors/print_dir_tree_visitor.rb +0 -0
- data/lib/tree_rb/visitors/print_tree_node_visitor.rb +0 -0
- data/lib/tree_rb/visitors_file_system/build_dir_tree_visitor.rb +0 -0
- data/lib/tree_rb/visitors_file_system/directory_to_hash_visitor.rb +0 -0
- data/lib/tree_rb_cli.rb +0 -0
- data/lib/tree_visitor.rb +0 -0
- data/lib/treevisitor.rb +0 -0
- data/lib/treevisitor_cli.rb +0 -0
- data/spec/fixtures/html_pages/test_1.html +0 -0
- data/spec/fixtures/test_dir_1/.dir_with_dot/dummy.txt +0 -0
- data/spec/fixtures/test_dir_1/dir.1/dir.1.2/file.1.2.1 +0 -0
- data/spec/fixtures/test_dir_1/dir.1/file.1.1 +0 -0
- data/spec/fixtures/test_dir_1/dir.2/file.2.1 +0 -0
- data/spec/fixtures/test_dir_2/[Dsube]/sub/.gitkeep +0 -0
- data/spec/fixtures/test_json/1.json +0 -0
- data/spec/fixtures/test_orphaned_xmp/img_001.jpg +0 -0
- data/spec/fixtures/test_orphaned_xmp/img_001.xmp +0 -0
- data/spec/fixtures/test_orphaned_xmp/img_002.xmp +0 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/tree_rb/cli/cli_json_spec.rb +3 -3
- data/spec/tree_rb/cli/cli_tree_d3js_spec.rb +3 -3
- data/spec/tree_rb/cli/cli_tree_digest_spec.rb +2 -2
- data/spec/tree_rb/cli/cli_tree_generic_spec.rb +15 -15
- data/spec/tree_rb/cli/cli_tree_sqlite_spec.rb +2 -2
- data/spec/tree_rb/core/tree_dsl_spec.rb +3 -3
- data/spec/tree_rb/core/tree_dsl_with_derived_class1_spec.rb +1 -1
- data/spec/tree_rb/core/tree_dsl_with_derived_class_spec.rb +2 -2
- data/spec/tree_rb/core/tree_node_paths_spec.rb +25 -25
- data/spec/tree_rb/core/tree_node_spec.rb +41 -41
- data/spec/tree_rb/core/tree_node_visitor_delegate_spec.rb +3 -3
- data/spec/tree_rb/core/tree_node_visitor_dsl_spec.rb +13 -13
- data/spec/tree_rb/extension_digest_spec.rb +6 -7
- data/spec/tree_rb/extension_numeric_spec.rb +3 -3
- data/spec/tree_rb/input_file_system/dir_processor_spec.rb +2 -2
- data/spec/tree_rb/input_file_system/directory_walker_conf_spec.rb +59 -59
- data/spec/tree_rb/input_file_system/directory_walker_run_spec.rb +73 -62
- data/spec/tree_rb/input_html_page/dom_walker_spec.rb +12 -3
- data/spec/tree_rb/visitors/block_tree_node_visitor_spec.rb +2 -2
- data/spec/tree_rb/visitors/callback_tree_node_visitor2_spec.rb +3 -3
- data/spec/tree_rb/visitors/depth_tree_node_visitor_spec.rb +2 -2
- data/spec/tree_rb/visitors/tree_node_visitors_spec.rb +2 -2
- data/tasks/rspec.rake +1 -1
- data/tasks/tree_rb.rake +0 -0
- data/tasks/yard.rake +0 -0
- data/tree.rb.gemspec +3 -2
- metadata +99 -87
- data/spec/fixtures/tmp/test.db +0 -0
@@ -26,12 +26,12 @@ describe CliTree do
|
|
26
26
|
args << File.join(FIXTURES, 'test_dir_1')
|
27
27
|
CliTree.new.parse_args(args)
|
28
28
|
end
|
29
|
-
File.exist?(@db_filename).
|
29
|
+
expect(File.exist?(@db_filename)).to be true
|
30
30
|
|
31
31
|
db = SQLite3::Database.new(@db_filename)
|
32
32
|
ar = db.execute('select count(*) from files')
|
33
33
|
nr_files = ar[0][0]
|
34
|
-
nr_files.
|
34
|
+
expect(nr_files).to be == 3
|
35
35
|
db.close
|
36
36
|
end
|
37
37
|
|
@@ -24,7 +24,7 @@ root
|
|
24
24
|
| `-- l3
|
25
25
|
`-- wo leaves
|
26
26
|
EOS
|
27
|
-
tree.to_str.
|
27
|
+
expect(tree.to_str).to be == out
|
28
28
|
end
|
29
29
|
|
30
30
|
it "test_dsl_block_with_arg" do
|
@@ -50,8 +50,8 @@ root
|
|
50
50
|
| `-- l3
|
51
51
|
`-- woleaves
|
52
52
|
EOS
|
53
|
-
tree.to_str.
|
54
|
-
tree.find("l3").path_with_prefix.
|
53
|
+
expect(tree.to_str).to be == out
|
54
|
+
expect(tree.find("l3").path_with_prefix).to be == "pre/root/sub/l3"
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
@@ -34,7 +34,7 @@ dt: root
|
|
34
34
|
`-- dt: sub
|
35
35
|
`-- dl: l3
|
36
36
|
EOS
|
37
|
-
tree.to_str.
|
37
|
+
expect(tree.to_str).to be == out
|
38
38
|
|
39
39
|
tree = DTreeNode.create(DLeafNode) do
|
40
40
|
node "root" do
|
@@ -45,7 +45,7 @@ EOS
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
tree.to_str.
|
48
|
+
expect(tree.to_str).to be == out
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
@@ -15,55 +15,55 @@ describe TreeNode do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "correct path" do
|
18
|
-
@tree.path.
|
19
|
-
@sub_tree.path.
|
20
|
-
@tree.path_with_prefix.
|
21
|
-
@sub_tree.path_with_prefix.
|
18
|
+
expect(@tree.path).to be == "a"
|
19
|
+
expect(@sub_tree.path).to be == "a/b"
|
20
|
+
expect(@tree.path_with_prefix).to be == "a"
|
21
|
+
expect(@sub_tree.path_with_prefix).to be == "a/b"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "assign prefix path with a /" do
|
25
25
|
@tree.prefix_path= "<root>/"
|
26
26
|
|
27
|
-
@tree.prefix_path.
|
28
|
-
@tree.path.
|
29
|
-
@sub_tree.path.
|
30
|
-
@tree.path_with_prefix.
|
31
|
-
@sub_tree.path_with_prefix.
|
27
|
+
expect(@tree.prefix_path).to be == "<root>/"
|
28
|
+
expect(@tree.path).to be == "a"
|
29
|
+
expect(@sub_tree.path).to be == "a/b"
|
30
|
+
expect(@tree.path_with_prefix).to be == "<root>/a"
|
31
|
+
expect(@sub_tree.path_with_prefix).to be == "<root>/a/b"
|
32
32
|
end
|
33
33
|
|
34
34
|
it "assign empty prefix path" do
|
35
35
|
@tree.prefix_path= ""
|
36
36
|
|
37
|
-
@tree.prefix_path.
|
38
|
-
@tree.path.
|
39
|
-
@sub_tree.path.
|
40
|
-
@tree.path_with_prefix.
|
41
|
-
@sub_tree.path_with_prefix.
|
37
|
+
expect(@tree.prefix_path).to be == "/"
|
38
|
+
expect(@tree.path).to be == "a"
|
39
|
+
expect(@sub_tree.path).to be == "a/b"
|
40
|
+
expect(@tree.path_with_prefix).to be == "/a"
|
41
|
+
expect(@sub_tree.path_with_prefix).to be == "/a/b"
|
42
42
|
end
|
43
43
|
|
44
44
|
it "assign prefix path wo a /" do
|
45
45
|
@tree.prefix_path= "<root>"
|
46
46
|
|
47
|
-
@tree.prefix_path.
|
48
|
-
@tree.path_with_prefix.
|
49
|
-
@sub_tree.path_with_prefix.
|
47
|
+
expect(@tree.prefix_path).to be == "<root>/"
|
48
|
+
expect(@tree.path_with_prefix).to be == "<root>/a"
|
49
|
+
expect(@sub_tree.path_with_prefix).to be == "<root>/a/b"
|
50
50
|
end
|
51
51
|
|
52
52
|
it "invalidate" do
|
53
53
|
@tree.prefix_path="root/"
|
54
|
-
@sub_tree.path.
|
55
|
-
@sub_tree.path_with_prefix.
|
56
|
-
@sub_tree.depth.
|
54
|
+
expect(@sub_tree.path).to be == "a/b"
|
55
|
+
expect(@sub_tree.path_with_prefix).to be == "root/a/b"
|
56
|
+
expect(@sub_tree.depth).to be == 2
|
57
57
|
|
58
58
|
r = TreeNode.new("r")
|
59
59
|
r.add_child(@tree)
|
60
|
-
@sub_tree.path.
|
61
|
-
@sub_tree.path_with_prefix.
|
60
|
+
expect(@sub_tree.path).to be == "r/a/b"
|
61
|
+
expect(@sub_tree.path_with_prefix).to be == "r/a/b"
|
62
62
|
|
63
63
|
r.prefix_path="new_root/"
|
64
|
-
@sub_tree.path.
|
65
|
-
@sub_tree.path_with_prefix.
|
66
|
-
@sub_tree.depth.
|
64
|
+
expect(@sub_tree.path).to be == "r/a/b"
|
65
|
+
expect(@sub_tree.path_with_prefix).to be == "new_root/r/a/b"
|
66
|
+
expect(@sub_tree.depth).to be == 3
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -5,35 +5,35 @@ describe TreeNode do
|
|
5
5
|
|
6
6
|
it "should initialize correctly" do
|
7
7
|
ta = TreeNode.new("a")
|
8
|
-
ta.
|
8
|
+
expect(ta).to be_root
|
9
9
|
|
10
10
|
ln1 = LeafNode.new("1", ta)
|
11
|
-
ln1.parent.
|
12
|
-
ln1.
|
11
|
+
expect(ln1.parent).to be == ta
|
12
|
+
expect(ln1).to_not be_root
|
13
13
|
|
14
14
|
ln2 = LeafNode.new("2", ta)
|
15
15
|
tb = TreeNode.new("b", ta)
|
16
16
|
ln3 = LeafNode.new("3", tb)
|
17
|
-
ln3.parent.
|
17
|
+
expect(ln3.parent).to be == tb
|
18
18
|
|
19
19
|
# test depth
|
20
|
-
tb.depth.
|
21
|
-
ln3.depth.
|
20
|
+
expect(tb.depth).to be == 2
|
21
|
+
expect(ln3.depth).to be == 3
|
22
22
|
|
23
23
|
# test nr_nodes
|
24
|
-
tb.nr_nodes.
|
25
|
-
ta.nr_nodes.
|
24
|
+
expect(tb.nr_nodes).to be == 1
|
25
|
+
expect(ta.nr_nodes).to be == 4
|
26
26
|
|
27
27
|
# puts ta.to_str
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should add child and leaf" do
|
31
31
|
ta = TreeNode.new("a")
|
32
|
-
ta.
|
32
|
+
expect(ta).to be_root
|
33
33
|
|
34
34
|
ln1 = LeafNode.new("1")
|
35
35
|
ta.add_leaf(ln1)
|
36
|
-
ln1.parent.
|
36
|
+
expect(ln1.parent).to be == ta
|
37
37
|
|
38
38
|
ln2 = LeafNode.new("2", ta)
|
39
39
|
ta.add_leaf(ln2)
|
@@ -41,7 +41,7 @@ describe TreeNode do
|
|
41
41
|
tb = TreeNode.new("b", ta)
|
42
42
|
ln3 = LeafNode.new("3", tb)
|
43
43
|
tb.add_leaf(ln3)
|
44
|
-
ln3.parent.
|
44
|
+
expect(ln3.parent).to be == tb
|
45
45
|
|
46
46
|
ta.add_child(tb)
|
47
47
|
# puts ta.to_str
|
@@ -49,27 +49,27 @@ describe TreeNode do
|
|
49
49
|
|
50
50
|
it "next and prev" do
|
51
51
|
ta = TreeNode.new("a")
|
52
|
-
ta.prev.
|
53
|
-
ta.next.
|
52
|
+
expect(ta.prev).to be_nil
|
53
|
+
expect(ta.next).to be_nil
|
54
54
|
|
55
55
|
ln1 = LeafNode.new("1", ta)
|
56
|
-
ln1.prev.
|
57
|
-
ln1.next.
|
56
|
+
expect(ln1.prev).to be_nil
|
57
|
+
expect(ln1.next).to be_nil
|
58
58
|
|
59
59
|
ln2 = LeafNode.new("2", ta)
|
60
|
-
ln2.prev.
|
61
|
-
ln2.next.
|
60
|
+
expect(ln2.prev).to be == ln1
|
61
|
+
expect(ln2.next).to be_nil
|
62
62
|
|
63
63
|
ln3 = LeafNode.new("3", ta)
|
64
|
-
ln2.next.
|
64
|
+
expect(ln2.next).to be == ln3
|
65
65
|
|
66
66
|
tb = TreeNode.new("b", ta)
|
67
|
-
tb.next.
|
68
|
-
tb.prev.
|
67
|
+
expect(tb.next).to be_nil
|
68
|
+
expect(tb.prev).to be_nil
|
69
69
|
|
70
70
|
tc = TreeNode.new("c", ta)
|
71
|
-
tc.prev.
|
72
|
-
tc.next.
|
71
|
+
expect(tc.prev).to be == tb
|
72
|
+
expect(tc.next).to be_nil
|
73
73
|
end
|
74
74
|
|
75
75
|
context "navigate tree" do
|
@@ -84,37 +84,37 @@ describe TreeNode do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
it "nr_nodes and nr_leaves and nr_children" do
|
87
|
-
@tree.nr_nodes.
|
88
|
-
@tree.nr_leaves.
|
89
|
-
@tree.nr_children.
|
87
|
+
expect(@tree.nr_nodes).to be == 5
|
88
|
+
expect(@tree.nr_leaves).to be == 4
|
89
|
+
expect(@tree.nr_children).to be == 1
|
90
90
|
|
91
|
-
@sub_tree.nr_nodes.
|
92
|
-
@sub_tree.nr_leaves.
|
93
|
-
@sub_tree.nr_children.
|
91
|
+
expect(@sub_tree.nr_nodes).to be == 2
|
92
|
+
expect(@sub_tree.nr_leaves).to be == 2
|
93
|
+
expect(@sub_tree.nr_children).to be == 0
|
94
94
|
end
|
95
95
|
|
96
96
|
|
97
97
|
context "find" do
|
98
98
|
|
99
99
|
it "find by string" do
|
100
|
-
@tree.find("a").
|
101
|
-
@tree.find("b").
|
102
|
-
@tree.find("3").
|
103
|
-
@tree.find("not existent").
|
100
|
+
expect(@tree.find("a")).to be === @tree
|
101
|
+
expect(@tree.find("b")).to be === @sub_tree
|
102
|
+
expect(@tree.find("3")).to be === @ln3
|
103
|
+
expect(@tree.find("not existent")).to be_nil
|
104
104
|
end
|
105
105
|
|
106
106
|
it "find by regex" do
|
107
|
-
@tree.find(/[a,b]/).
|
108
|
-
@tree.find(/[b,c]/).
|
109
|
-
@tree.find(/\d\d/).
|
110
|
-
@tree.find(/not existent/).
|
107
|
+
expect(@tree.find(/[a,b]/)).to be === @tree
|
108
|
+
expect(@tree.find(/[b,c]/)).to be === @sub_tree
|
109
|
+
expect(@tree.find(/\d\d/)).to be === @ln4
|
110
|
+
expect(@tree.find(/not existent/)).to be_nil
|
111
111
|
end
|
112
112
|
|
113
113
|
it "find with block" do
|
114
|
-
@tree.find { |e| e.content == "a" }.
|
115
|
-
@tree.find { |e| e.content == "b" }.
|
116
|
-
@tree.find { |e| e.content == "3" }.
|
117
|
-
@tree.find { |e| e.content == "not existent" }.
|
114
|
+
expect(@tree.find { |e| e.content == "a" }).to be === @tree
|
115
|
+
expect(@tree.find { |e| e.content == "b" }).to be === @sub_tree
|
116
|
+
expect(@tree.find { |e| e.content == "3" }).to be === @ln3
|
117
|
+
expect(@tree.find { |e| e.content == "not existent" }).to be_nil
|
118
118
|
end
|
119
119
|
|
120
120
|
it "to_str" do
|
@@ -126,7 +126,7 @@ a
|
|
126
126
|
|-- 3
|
127
127
|
`-- 12
|
128
128
|
EOS
|
129
|
-
@tree.to_str.
|
129
|
+
expect(@tree.to_str).to be == out
|
130
130
|
end
|
131
131
|
|
132
132
|
end
|
@@ -23,13 +23,13 @@ describe TreeNodeVisitor do
|
|
23
23
|
visitor = TreeNodeVisitor.new(delegate)
|
24
24
|
|
25
25
|
visitor.enter_node(nil)
|
26
|
-
delegate.instance_eval{ @entered_node }.
|
26
|
+
expect(delegate.instance_eval{ @entered_node }).to be true
|
27
27
|
|
28
28
|
visitor.exit_node(nil)
|
29
|
-
delegate.instance_eval{ @exit_node }.
|
29
|
+
expect(delegate.instance_eval{ @exit_node }).to be true
|
30
30
|
|
31
31
|
visitor.visit_leaf(nil)
|
32
|
-
delegate.instance_eval{ @visited_leaf }.
|
32
|
+
expect(delegate.instance_eval{ @visited_leaf }).to be true
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -20,16 +20,16 @@ describe TreeNodeVisitor do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
visitor.enter_node(nil)
|
23
|
-
visitor.instance_eval{ @entered_node }.
|
23
|
+
expect(visitor.instance_eval{ @entered_node }).to be true
|
24
24
|
|
25
25
|
visitor.exit_node(nil)
|
26
|
-
visitor.instance_eval{ @exit_node }.
|
26
|
+
expect(visitor.instance_eval{ @exit_node }).to be true
|
27
27
|
|
28
28
|
visitor.visit_leaf(nil)
|
29
|
-
visitor.instance_eval{ @visit_leaf }.
|
29
|
+
expect(visitor.instance_eval{ @visit_leaf }).to be true
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'should initialize correctly' do
|
33
33
|
visitor = TreeNodeVisitor.new do
|
34
34
|
|
35
35
|
on_enter_node do |node, parent|
|
@@ -50,17 +50,17 @@ describe TreeNodeVisitor do
|
|
50
50
|
|
51
51
|
visitor.instance_eval{ @stack = ["p"] }
|
52
52
|
visitor.enter_node("n")
|
53
|
-
visitor.instance_eval{ @node }.
|
54
|
-
visitor.instance_eval{ @parent }.
|
55
|
-
visitor.instance_eval{ @stack }.
|
53
|
+
expect(visitor.instance_eval{ @node }).to be == "n"
|
54
|
+
expect(visitor.instance_eval{ @parent }).to be == "p"
|
55
|
+
expect(visitor.instance_eval{ @stack }).to have(2).node
|
56
56
|
|
57
57
|
visitor.exit_node("n")
|
58
|
-
visitor.instance_eval{ @node }.
|
59
|
-
visitor.instance_eval{ @stack }.
|
58
|
+
expect(visitor.instance_eval{ @node }).to be == "n"
|
59
|
+
expect(visitor.instance_eval{ @stack }).to have(1).node
|
60
60
|
|
61
|
-
visitor.instance_eval{ @stack = [
|
62
|
-
visitor.visit_leaf(
|
63
|
-
visitor.instance_eval{ @leaf }.
|
64
|
-
visitor.instance_eval{ @parent }.
|
61
|
+
visitor.instance_eval{ @stack = ['p'] }
|
62
|
+
visitor.visit_leaf('l')
|
63
|
+
expect(visitor.instance_eval{ @leaf }).to be == 'l'
|
64
|
+
expect(visitor.instance_eval{ @parent }).to be == 'p'
|
65
65
|
end
|
66
66
|
end
|
@@ -1,19 +1,18 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require File.expand_path( File.join(File.dirname(__FILE__),
|
2
|
+
require File.expand_path( File.join(File.dirname(__FILE__), '..', 'spec_helper') )
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe 'MD5' do
|
5
5
|
|
6
6
|
before do
|
7
7
|
@file_name = File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "lib", "tree_rb", "extension_digest.rb" ) )
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
MD5.file( @file_name ).to_s.should == "b33c6b70109037fc02686f8babfc2db4"
|
10
|
+
it 'should calculate md5' do
|
11
|
+
expect(MD5.file( @file_name ).to_s).to be == 'b33c6b70109037fc02686f8babfc2db4'
|
13
12
|
end
|
14
13
|
|
15
|
-
it
|
16
|
-
SHA1.file( @file_name ).to_s.
|
14
|
+
it 'should calculate sha1' do
|
15
|
+
expect(SHA1.file( @file_name ).to_s).to be == 'f99700dbdd200d7255f586ceb0cac05e05871cc5'
|
17
16
|
end
|
18
17
|
|
19
18
|
end
|
@@ -5,9 +5,9 @@ require File.expand_path( File.join(File.dirname(__FILE__), "..", "spec_helper")
|
|
5
5
|
describe "TCNumeric" do
|
6
6
|
|
7
7
|
it "test_simple" do
|
8
|
-
10.with_separator.
|
9
|
-
10.0.with_separator.
|
10
|
-
1000000.with_separator.
|
8
|
+
expect(10.with_separator).to be == "10"
|
9
|
+
expect(10.0.with_separator).to be == "10.0"
|
10
|
+
expect(1000000.with_separator).to be == "1,000,000"
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -1,59 +1,59 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
|
3
|
-
|
4
|
-
describe DirTreeWalker do
|
5
|
-
|
6
|
-
it 'should accept option :ignore with regex' do
|
7
|
-
walker = DirTreeWalker.new :ignore => /^\./
|
8
|
-
walker.ignore_file?('.thumbnails').
|
9
|
-
walker.ignore_dir?('.thumbnails').
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should accept option :ignore with string' do
|
13
|
-
walker = DirTreeWalker.new :ignore => '.git'
|
14
|
-
walker.ignore_file?('.git').
|
15
|
-
walker.ignore_dir?('.git').
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should accept option :ignore_dir' do
|
19
|
-
dtw = DirTreeWalker.new :ignore_dir => [/^\./, "private_dir" ]
|
20
|
-
dtw.
|
21
|
-
dtw.
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should accept option :ignore_file' do
|
25
|
-
dtw = DirTreeWalker.new :ignore_file => [/.xml/, /(ignore)|(orig)/ ]
|
26
|
-
dtw.
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should accept option :match with string' do
|
30
|
-
dtw = DirTreeWalker.new :match => '.jpg'
|
31
|
-
dtw.
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should accept option :match with regex' do
|
35
|
-
dtw = DirTreeWalker.new :match => /.jpg/
|
36
|
-
dtw.
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should ignore files and directory' do
|
40
|
-
walker = DirTreeWalker.new('.')
|
41
|
-
|
42
|
-
walker.ignore(/^\./)
|
43
|
-
walker.ignore_file?('.thumbnails').
|
44
|
-
walker.ignore_dir?('.thumbnails').
|
45
|
-
|
46
|
-
walker.ignore_dir('thumbnails')
|
47
|
-
walker.ignore_dir?('.thumbnails').
|
48
|
-
walker.ignore_dir?('thumbnails').
|
49
|
-
walker.ignore_dir?('pippo').
|
50
|
-
|
51
|
-
walker.ignore_file('xvpics')
|
52
|
-
walker.ignore_file?('xvpics').
|
53
|
-
|
54
|
-
walker.ignore('sub')
|
55
|
-
walker.ignore_file?('[Dsube]').
|
56
|
-
walker.ignore_dir?('[Dsube]').
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
|
3
|
+
|
4
|
+
describe DirTreeWalker do
|
5
|
+
|
6
|
+
it 'should accept option :ignore with regex' do
|
7
|
+
walker = DirTreeWalker.new :ignore => /^\./
|
8
|
+
expect(walker.ignore_file?('.thumbnails')).to be true
|
9
|
+
expect(walker.ignore_dir?('.thumbnails')).to be true
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should accept option :ignore with string' do
|
13
|
+
walker = DirTreeWalker.new :ignore => '.git'
|
14
|
+
expect(walker.ignore_file?('.git')).to be true
|
15
|
+
expect(walker.ignore_dir?('.git')).to be true
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should accept option :ignore_dir' do
|
19
|
+
dtw = DirTreeWalker.new :ignore_dir => [/^\./, "private_dir" ]
|
20
|
+
expect(dtw.ignore_dir?('.git')).to be true
|
21
|
+
expect(dtw.ignore_dir?('private_dir')).to be true
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should accept option :ignore_file' do
|
25
|
+
dtw = DirTreeWalker.new :ignore_file => [/.xml/, /(ignore)|(orig)/ ]
|
26
|
+
expect(dtw).to be_ignore_file('pippo.xml')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should accept option :match with string' do
|
30
|
+
dtw = DirTreeWalker.new :match => '.jpg'
|
31
|
+
expect(dtw).to be_match('foo.jpg')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should accept option :match with regex' do
|
35
|
+
dtw = DirTreeWalker.new :match => /.jpg/
|
36
|
+
expect(dtw).to be_match('foo.jpg')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should ignore files and directory' do
|
40
|
+
walker = DirTreeWalker.new('.')
|
41
|
+
|
42
|
+
walker.ignore(/^\./)
|
43
|
+
expect(walker.ignore_file?('.thumbnails')).to be true
|
44
|
+
expect(walker.ignore_dir?('.thumbnails')).to be true
|
45
|
+
|
46
|
+
walker.ignore_dir('thumbnails')
|
47
|
+
expect(walker.ignore_dir?('.thumbnails')).to be true
|
48
|
+
expect(walker.ignore_dir?('thumbnails')).to be true
|
49
|
+
expect(walker.ignore_dir?('pippo')).to be false
|
50
|
+
|
51
|
+
walker.ignore_file('xvpics')
|
52
|
+
expect(walker.ignore_file?('xvpics')).to be true
|
53
|
+
|
54
|
+
walker.ignore('sub')
|
55
|
+
expect(walker.ignore_file?('[Dsube]')).to be false
|
56
|
+
expect(walker.ignore_dir?('[Dsube]')).to be false
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|