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.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/LICENSE.txt +0 -0
  4. data/README.md +0 -0
  5. data/Rakefile +0 -0
  6. data/examples/d3js_layout_partition/data.js +0 -0
  7. data/examples/d3js_layout_partition/index.html +0 -0
  8. data/examples/d3js_layout_partition/run.sh +0 -0
  9. data/examples/d3js_layout_partition/style.css +0 -0
  10. data/examples/d3js_layout_treemap/data.js +0 -0
  11. data/examples/d3js_layout_treemap/index.html +0 -0
  12. data/examples/d3js_layout_treemap/run.sh +0 -0
  13. data/examples/d3js_layout_treemap/style.css +0 -0
  14. data/examples/protovis/directory_to_json_visitor.rb +0 -0
  15. data/examples/protovis/index.html +0 -0
  16. data/examples/protovis/protovis-r3.2.js +0 -0
  17. data/examples/protovis/treevisitor.js +0 -0
  18. data/examples/protovis/treevisitor.png +0 -0
  19. data/examples/ruby_examples/find_directory_without_subdirectory.rb +2 -2
  20. data/examples/ruby_examples/find_files.rb +0 -0
  21. data/examples/ruby_examples/find_orphan_xmp.rb +17 -0
  22. data/examples/ruby_examples/print_files.rb +1 -2
  23. data/ext/mkrf_conf.rb +3 -2
  24. data/lib/colors.rb +39 -0
  25. data/lib/tree_rb.rb +2 -2
  26. data/lib/tree_rb/cli/cli_json.rb +3 -3
  27. data/lib/tree_rb/cli/cli_tree.rb +0 -0
  28. data/lib/tree_rb/core/abs_node.rb +2 -2
  29. data/lib/tree_rb/core/basic_tree_node_visitor.rb +0 -0
  30. data/lib/tree_rb/core/leaf_node.rb +0 -0
  31. data/lib/tree_rb/core/tree_node.rb +0 -0
  32. data/lib/tree_rb/core/tree_node_visitor.rb +0 -0
  33. data/lib/tree_rb/exception.rb +0 -0
  34. data/lib/tree_rb/extension_digest.rb +0 -0
  35. data/lib/tree_rb/extension_numeric.rb +0 -0
  36. data/lib/tree_rb/input_plugins/file_system/dir_processor.rb +0 -0
  37. data/lib/tree_rb/input_plugins/file_system/directory_walker.rb +3 -3
  38. data/lib/tree_rb/input_plugins/html_page/dom_walker.rb +0 -0
  39. data/lib/tree_rb/output_plugins/dircat/dircat_output.rb +0 -0
  40. data/lib/tree_rb/output_plugins/dircat/dircat_visitor.rb +0 -0
  41. data/lib/tree_rb/output_plugins/dircat/entry.rb +0 -0
  42. data/lib/tree_rb/output_plugins/html/d3js_output.rb +0 -0
  43. data/lib/tree_rb/output_plugins/html/directory_to_hash2_visitor.rb +0 -0
  44. data/lib/tree_rb/output_plugins/html/erb_render.rb +0 -0
  45. data/lib/tree_rb/output_plugins/sqlite/sqlite_dir_tree_visitor.rb +0 -0
  46. data/lib/tree_rb/output_plugins/sqlite/sqlite_output.rb +0 -0
  47. data/lib/tree_rb/version.rb +1 -1
  48. data/lib/tree_rb/visitors/block_tree_node_visitor.rb +0 -0
  49. data/lib/tree_rb/visitors/callback_tree_node_visitor2.rb +2 -2
  50. data/lib/tree_rb/visitors/clone_tree_node_visitor.rb +0 -0
  51. data/lib/tree_rb/visitors/depth_tree_node_visitor.rb +0 -0
  52. data/lib/tree_rb/visitors/flat_print_tree_node_visitor.rb +0 -0
  53. data/lib/tree_rb/visitors/print_dir_tree_visitor.rb +0 -0
  54. data/lib/tree_rb/visitors/print_tree_node_visitor.rb +0 -0
  55. data/lib/tree_rb/visitors_file_system/build_dir_tree_visitor.rb +0 -0
  56. data/lib/tree_rb/visitors_file_system/directory_to_hash_visitor.rb +0 -0
  57. data/lib/tree_rb_cli.rb +0 -0
  58. data/lib/tree_visitor.rb +0 -0
  59. data/lib/treevisitor.rb +0 -0
  60. data/lib/treevisitor_cli.rb +0 -0
  61. data/spec/fixtures/html_pages/test_1.html +0 -0
  62. data/spec/fixtures/test_dir_1/.dir_with_dot/dummy.txt +0 -0
  63. data/spec/fixtures/test_dir_1/dir.1/dir.1.2/file.1.2.1 +0 -0
  64. data/spec/fixtures/test_dir_1/dir.1/file.1.1 +0 -0
  65. data/spec/fixtures/test_dir_1/dir.2/file.2.1 +0 -0
  66. data/spec/fixtures/test_dir_2/[Dsube]/sub/.gitkeep +0 -0
  67. data/spec/fixtures/test_json/1.json +0 -0
  68. data/spec/fixtures/test_orphaned_xmp/img_001.jpg +0 -0
  69. data/spec/fixtures/test_orphaned_xmp/img_001.xmp +0 -0
  70. data/spec/fixtures/test_orphaned_xmp/img_002.xmp +0 -0
  71. data/spec/spec_helper.rb +2 -0
  72. data/spec/tree_rb/cli/cli_json_spec.rb +3 -3
  73. data/spec/tree_rb/cli/cli_tree_d3js_spec.rb +3 -3
  74. data/spec/tree_rb/cli/cli_tree_digest_spec.rb +2 -2
  75. data/spec/tree_rb/cli/cli_tree_generic_spec.rb +15 -15
  76. data/spec/tree_rb/cli/cli_tree_sqlite_spec.rb +2 -2
  77. data/spec/tree_rb/core/tree_dsl_spec.rb +3 -3
  78. data/spec/tree_rb/core/tree_dsl_with_derived_class1_spec.rb +1 -1
  79. data/spec/tree_rb/core/tree_dsl_with_derived_class_spec.rb +2 -2
  80. data/spec/tree_rb/core/tree_node_paths_spec.rb +25 -25
  81. data/spec/tree_rb/core/tree_node_spec.rb +41 -41
  82. data/spec/tree_rb/core/tree_node_visitor_delegate_spec.rb +3 -3
  83. data/spec/tree_rb/core/tree_node_visitor_dsl_spec.rb +13 -13
  84. data/spec/tree_rb/extension_digest_spec.rb +6 -7
  85. data/spec/tree_rb/extension_numeric_spec.rb +3 -3
  86. data/spec/tree_rb/input_file_system/dir_processor_spec.rb +2 -2
  87. data/spec/tree_rb/input_file_system/directory_walker_conf_spec.rb +59 -59
  88. data/spec/tree_rb/input_file_system/directory_walker_run_spec.rb +73 -62
  89. data/spec/tree_rb/input_html_page/dom_walker_spec.rb +12 -3
  90. data/spec/tree_rb/visitors/block_tree_node_visitor_spec.rb +2 -2
  91. data/spec/tree_rb/visitors/callback_tree_node_visitor2_spec.rb +3 -3
  92. data/spec/tree_rb/visitors/depth_tree_node_visitor_spec.rb +2 -2
  93. data/spec/tree_rb/visitors/tree_node_visitors_spec.rb +2 -2
  94. data/tasks/rspec.rake +1 -1
  95. data/tasks/tree_rb.rake +0 -0
  96. data/tasks/yard.rake +0 -0
  97. data/tree.rb.gemspec +3 -2
  98. metadata +99 -87
  99. 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).should be_true
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.should == 3
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.should == out
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.should == out
54
- tree.find("l3").path_with_prefix.should == "pre/root/sub/l3"
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
@@ -44,6 +44,6 @@ a: droot
44
44
  `-- a: dsub
45
45
  `-- a: dl3
46
46
  EOS
47
- tree.to_str.should == out
47
+ expect(tree.to_str).to be == out
48
48
  end
49
49
  end
@@ -34,7 +34,7 @@ dt: root
34
34
  `-- dt: sub
35
35
  `-- dl: l3
36
36
  EOS
37
- tree.to_str.should == out
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.should == out
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.should == "a"
19
- @sub_tree.path.should == "a/b"
20
- @tree.path_with_prefix.should == "a"
21
- @sub_tree.path_with_prefix.should == "a/b"
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.should == "<root>/"
28
- @tree.path.should == "a"
29
- @sub_tree.path.should == "a/b"
30
- @tree.path_with_prefix.should == "<root>/a"
31
- @sub_tree.path_with_prefix.should == "<root>/a/b"
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.should == "/"
38
- @tree.path.should == "a"
39
- @sub_tree.path.should == "a/b"
40
- @tree.path_with_prefix.should == "/a"
41
- @sub_tree.path_with_prefix.should == "/a/b"
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.should == "<root>/"
48
- @tree.path_with_prefix.should == "<root>/a"
49
- @sub_tree.path_with_prefix.should == "<root>/a/b"
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.should == "a/b"
55
- @sub_tree.path_with_prefix.should == "root/a/b"
56
- @sub_tree.depth.should == 2
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.should == "r/a/b"
61
- @sub_tree.path_with_prefix.should == "r/a/b"
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.should == "r/a/b"
65
- @sub_tree.path_with_prefix.should == "new_root/r/a/b"
66
- @sub_tree.depth.should == 3
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.should be_root
8
+ expect(ta).to be_root
9
9
 
10
10
  ln1 = LeafNode.new("1", ta)
11
- ln1.parent.should == ta
12
- ln1.should_not be_root
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.should == tb
17
+ expect(ln3.parent).to be == tb
18
18
 
19
19
  # test depth
20
- tb.depth.should == 2
21
- ln3.depth.should == 3
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.should == 1
25
- ta.nr_nodes.should == 4
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.should be_root
32
+ expect(ta).to be_root
33
33
 
34
34
  ln1 = LeafNode.new("1")
35
35
  ta.add_leaf(ln1)
36
- ln1.parent.should == ta
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.should == tb
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.should be_nil
53
- ta.next.should be_nil
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.should be_nil
57
- ln1.next.should be_nil
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.should == ln1
61
- ln2.next.should be_nil
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.should == ln3
64
+ expect(ln2.next).to be == ln3
65
65
 
66
66
  tb = TreeNode.new("b", ta)
67
- tb.next.should be_nil
68
- tb.prev.should be_nil
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.should == tb
72
- tc.next.should be_nil
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.should == 5
88
- @tree.nr_leaves.should == 4
89
- @tree.nr_children.should == 1
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.should == 2
92
- @sub_tree.nr_leaves.should == 2
93
- @sub_tree.nr_children.should == 0
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").should === @tree
101
- @tree.find("b").should === @sub_tree
102
- @tree.find("3").should === @ln3
103
- @tree.find("not existent").should be_nil
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]/).should === @tree
108
- @tree.find(/[b,c]/).should === @sub_tree
109
- @tree.find(/\d\d/).should === @ln4
110
- @tree.find(/not existent/).should be_nil
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" }.should === @tree
115
- @tree.find { |e| e.content == "b" }.should === @sub_tree
116
- @tree.find { |e| e.content == "3" }.should === @ln3
117
- @tree.find { |e| e.content == "not existent" }.should be_nil
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.should == out
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 }.should be_true
26
+ expect(delegate.instance_eval{ @entered_node }).to be true
27
27
 
28
28
  visitor.exit_node(nil)
29
- delegate.instance_eval{ @exit_node }.should be_true
29
+ expect(delegate.instance_eval{ @exit_node }).to be true
30
30
 
31
31
  visitor.visit_leaf(nil)
32
- delegate.instance_eval{ @visited_leaf }.should be_true
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 }.should be_true
23
+ expect(visitor.instance_eval{ @entered_node }).to be true
24
24
 
25
25
  visitor.exit_node(nil)
26
- visitor.instance_eval{ @exit_node }.should be_true
26
+ expect(visitor.instance_eval{ @exit_node }).to be true
27
27
 
28
28
  visitor.visit_leaf(nil)
29
- visitor.instance_eval{ @visit_leaf }.should be_true
29
+ expect(visitor.instance_eval{ @visit_leaf }).to be true
30
30
  end
31
31
 
32
- it "should initialize correctly" do
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 }.should == "n"
54
- visitor.instance_eval{ @parent }.should == "p"
55
- visitor.instance_eval{ @stack }.should have(2).node
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 }.should == "n"
59
- visitor.instance_eval{ @stack }.should have(1).node
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 = ["p"] }
62
- visitor.visit_leaf("l")
63
- visitor.instance_eval{ @leaf }.should == "l"
64
- visitor.instance_eval{ @parent }.should == "p"
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__), "..", "spec_helper") )
2
+ require File.expand_path( File.join(File.dirname(__FILE__), '..', 'spec_helper') )
3
3
 
4
- describe "MD5" do
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
- it "should calculate md5" do
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 "should calculate sha1" do
16
- SHA1.file( @file_name ).to_s.should == "f99700dbdd200d7255f586ceb0cac05e05871cc5"
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.should == "10"
9
- 10.0.with_separator.should == "10.0"
10
- 1000000.with_separator.should == "1,000,000"
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
@@ -8,8 +8,8 @@ describe DirProcessor do
8
8
  dp = DirProcessor.new { |f| files << f }
9
9
  dp.process(FIXTURES)
10
10
 
11
- puts files
12
- files.length.should == 5
11
+ # puts files
12
+ expect(files.length).to be == 8
13
13
  end
14
14
 
15
15
  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').should be_true
9
- walker.ignore_dir?('.thumbnails').should be_true
10
- end
11
-
12
- it 'should accept option :ignore with string' do
13
- walker = DirTreeWalker.new :ignore => '.git'
14
- walker.ignore_file?('.git').should be_true
15
- walker.ignore_dir?('.git').should be_true
16
- end
17
-
18
- it 'should accept option :ignore_dir' do
19
- dtw = DirTreeWalker.new :ignore_dir => [/^\./, "private_dir" ]
20
- dtw.should be_ignore_dir '.git'
21
- dtw.should be_ignore_dir 'private_dir'
22
- end
23
-
24
- it 'should accept option :ignore_file' do
25
- dtw = DirTreeWalker.new :ignore_file => [/.xml/, /(ignore)|(orig)/ ]
26
- dtw.should be_ignore_file 'pippo.xml'
27
- end
28
-
29
- it 'should accept option :match with string' do
30
- dtw = DirTreeWalker.new :match => '.jpg'
31
- dtw.should be_match 'foo.jpg'
32
- end
33
-
34
- it 'should accept option :match with regex' do
35
- dtw = DirTreeWalker.new :match => /.jpg/
36
- dtw.should be_match 'foo.jpg'
37
- end
38
-
39
- it 'should ignore files and directory' do
40
- walker = DirTreeWalker.new('.')
41
-
42
- walker.ignore(/^\./)
43
- walker.ignore_file?('.thumbnails').should be_true
44
- walker.ignore_dir?('.thumbnails').should be_true
45
-
46
- walker.ignore_dir('thumbnails')
47
- walker.ignore_dir?('.thumbnails').should be_true
48
- walker.ignore_dir?('thumbnails').should be_true
49
- walker.ignore_dir?('pippo').should be_false
50
-
51
- walker.ignore_file('xvpics')
52
- walker.ignore_file?('xvpics').should be_true
53
-
54
- walker.ignore('sub')
55
- walker.ignore_file?('[Dsube]').should be_false
56
- walker.ignore_dir?('[Dsube]').should be_false
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