tree.rb 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 037bf51f0b4d7686237af3731ee0a1f61daef2fb
|
|
4
|
+
data.tar.gz: 2a527f8e2cb669fe76a4aed27a997c43578b21cc
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d028765225493c73d8ab7c62953d95aa933bdab6368312431f20ec142c2be19eb5fc2de61a8a3f15fa8b9878448feb7f17f282dbfd01c650ad85a1bb8850c01d
|
|
7
|
+
data.tar.gz: 21aec5481901641e646d0cbe09b5d93b16ab436a699a81f348c6341314ca45fbc4d1dcf3e33761c83ea8b7354afe11c0bc078c46978114aaf7dc96f5e0430905
|
data/.gemtest
CHANGED
|
File without changes
|
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -25,13 +25,13 @@ class DirWithoutSubDir < TreeRb::BasicTreeNodeVisitor
|
|
|
25
25
|
def exit_node( pathname )
|
|
26
26
|
info = @stack.pop
|
|
27
27
|
if info.nr == @nr
|
|
28
|
-
puts "leaf: #{pathname}"
|
|
28
|
+
puts "leaf: #{pathname} with no subdir"
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
dtw = TreeRb::DirTreeWalker.new( File.join('..', '..'))
|
|
34
|
+
dtw = TreeRb::DirTreeWalker.new( File.join('..', '..') )
|
|
35
35
|
dtw.ignore /^\./
|
|
36
36
|
dtw.visit_file=false
|
|
37
37
|
dtw.run( DirWithoutSubDir.new )
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
cwd = File.expand_path( File.join( File.dirname(__FILE__), '..', '..', 'lib') )
|
|
3
|
+
$:.unshift(cwd) unless $:.include?(cwd)
|
|
4
|
+
require 'tree_rb'
|
|
5
|
+
include TreeRb
|
|
6
|
+
|
|
7
|
+
root_dir = File.expand_path( File.join( cwd, '..', 'spec', 'fixtures', 'test_orphaned_xmp' ) )
|
|
8
|
+
|
|
9
|
+
puts "*** print all xmp files starting from '#{root_dir}'"
|
|
10
|
+
dtw = DirTreeWalker.new( :match => /.xmp/ )
|
|
11
|
+
dtw.run root_dir do
|
|
12
|
+
on_leaf do |pathname|
|
|
13
|
+
puts "- #{pathname}"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
on_enter_node
|
|
17
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
cwd = File.expand_path( File.join( File.dirname(__FILE__),
|
|
2
|
+
cwd = File.expand_path( File.join( File.dirname(__FILE__), '..', '..', 'lib') )
|
|
3
3
|
$:.unshift(cwd) unless $:.include?(cwd)
|
|
4
4
|
require 'tree_rb'
|
|
5
5
|
include TreeRb
|
|
@@ -15,7 +15,6 @@ dtw.run root_dir do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
puts '*** print files with extension *.sh" and "*.js"'
|
|
18
|
-
#dtw = DirTreeWalker.new( :match => %w(/.sh/ /.jd/) )
|
|
19
18
|
dtw = DirTreeWalker.new( :match => /.sh/ )
|
|
20
19
|
dtw.run root_dir do
|
|
21
20
|
on_leaf do |pathname|
|
data/ext/mkrf_conf.rb
CHANGED
|
@@ -11,13 +11,14 @@ end
|
|
|
11
11
|
inst = Gem::DependencyInstaller.new
|
|
12
12
|
begin
|
|
13
13
|
if RUBY_PLATFORM =~ /win32/
|
|
14
|
-
inst.install
|
|
14
|
+
inst.install 'win32console'
|
|
15
15
|
end
|
|
16
16
|
rescue
|
|
17
17
|
exit(1)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
# create dummy rakefile to indicate success
|
|
21
|
+
f = File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w')
|
|
21
22
|
f.write("task :default\n")
|
|
22
23
|
f.close
|
|
23
24
|
|
data/lib/colors.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Below are the color init strings for the basic file types. A color init
|
|
2
|
+
# string consists of one or more of the following numeric codes:
|
|
3
|
+
# Attribute codes:
|
|
4
|
+
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
|
5
|
+
# Text color codes:
|
|
6
|
+
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
|
7
|
+
# Background color codes:
|
|
8
|
+
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
m = { }
|
|
12
|
+
ENV['LS_COLORS'].split(":").each do |e|
|
|
13
|
+
k, v = e.split('=')
|
|
14
|
+
m[k] = v
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
puts m
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## ANSIname => ANSIcode LUT
|
|
21
|
+
#ANSINAME2CODE= { "reset" => "\e[0m", "bold" => "\e[1m",
|
|
22
|
+
# "underline" => "\e[4m", "blink" => "\e[5m",
|
|
23
|
+
# "reverse" => "\e[7m", "invisible" => "\e[8m",
|
|
24
|
+
# "black" => "\e[0;30m", "darkgrey" => "\e[1;30m",
|
|
25
|
+
# "red" => "\e[0;31m", "lightred" => "\e[1;31m",
|
|
26
|
+
# "green" => "\e[0;32m", "lightgreen" => "\e[1;32m",
|
|
27
|
+
# "brown" => "\e[0;33m", "yellow" => "\e[1;33m",
|
|
28
|
+
# "blue" => "\e[0;34m", "lightblue" => "\e[1;34m",
|
|
29
|
+
# "purple" => "\e[0;35m", "magenta" => "\e[1;35m",
|
|
30
|
+
# "cyan" => "\e[1;36m", "lightcyan" => "\e[1;36m",
|
|
31
|
+
# "grey" => "\e[0;37m", "white" => "\e[1;37m",
|
|
32
|
+
# "bgblack" => "\e[40m", "bgred" => "\e[41m",
|
|
33
|
+
# "bggreen" => "\e[42m", "bgyellow" => "\e[43m",
|
|
34
|
+
# "bgblue" => "\e[44m", "bgmagenta" => "\e[45m",
|
|
35
|
+
# "bgcyan" => "\e[46m", "bgwhite" => "\e[47m"
|
|
36
|
+
i,e= m['*.tga'].split(';')
|
|
37
|
+
|
|
38
|
+
puts "\e[#{i}m\e[1;#{e}m prova.tga \e[0m"
|
|
39
|
+
|
data/lib/tree_rb.rb
CHANGED
|
@@ -17,7 +17,7 @@ require 'ansi/code'
|
|
|
17
17
|
begin
|
|
18
18
|
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
|
|
19
19
|
rescue LoadError
|
|
20
|
-
puts
|
|
20
|
+
puts "to use color on Windows you can install win32console 'gem install win32console'"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
#
|
|
@@ -44,7 +44,7 @@ require 'tree_rb/input_plugins/html_page/dom_walker'
|
|
|
44
44
|
# visitors
|
|
45
45
|
#
|
|
46
46
|
|
|
47
|
-
visitors_dir = File.join(File.dirname(__FILE__),
|
|
47
|
+
visitors_dir = File.join(File.dirname(__FILE__), 'tree_rb', 'visitors')
|
|
48
48
|
unless Dir.exist? visitors_dir
|
|
49
49
|
raise "cannot found directory '#{visitors_dir}'"
|
|
50
50
|
end
|
data/lib/tree_rb/cli/cli_json.rb
CHANGED
|
@@ -15,11 +15,11 @@ module TreeRb
|
|
|
15
15
|
|
|
16
16
|
def options_parser(options)
|
|
17
17
|
parser = OptionParser.new
|
|
18
|
-
parser.banner =
|
|
18
|
+
parser.banner = 'Usage: rjson.rb [options] [directory]'
|
|
19
19
|
parser.separator 'pretty format json file'
|
|
20
20
|
parser.separator 'Code https://github.com/tokiro/treevisitor. Feedback to tokiro.oyama@gmail.com'
|
|
21
21
|
|
|
22
|
-
parser.on('-o [FILE]',
|
|
22
|
+
parser.on('-o [FILE]', '--output [FILE]', String) do |v|
|
|
23
23
|
if options[:output]
|
|
24
24
|
puts 'only one file of output can be used'
|
|
25
25
|
options[:exit] = true
|
|
@@ -28,7 +28,7 @@ module TreeRb
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
options[:force_overwrite_output] = false
|
|
31
|
-
parser.on(
|
|
31
|
+
parser.on('--force', 'overwrite output') do
|
|
32
32
|
options[:force_overwrite_output] = true
|
|
33
33
|
end
|
|
34
34
|
parser.on_tail('--help', 'Show this message') do
|
data/lib/tree_rb/cli/cli_tree.rb
CHANGED
|
File without changes
|
|
@@ -64,12 +64,12 @@ module TreeRb
|
|
|
64
64
|
# Root node could have assigned a path
|
|
65
65
|
#
|
|
66
66
|
def prefix_path
|
|
67
|
-
raise
|
|
67
|
+
raise 'Not root!!' unless @parent.nil?
|
|
68
68
|
@prefix_path
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def prefix_path=(prefix)
|
|
72
|
-
raise
|
|
72
|
+
raise 'Not root!!' unless @parent.nil?
|
|
73
73
|
if prefix != @prefix_path
|
|
74
74
|
@prefix_path = prefix
|
|
75
75
|
if prefix and prefix !~ /\/$/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/tree_rb/exception.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -162,7 +162,7 @@ module TreeRb
|
|
|
162
162
|
# @return [boolean] if dirname match almost one pattern
|
|
163
163
|
#
|
|
164
164
|
def ignore_dir?(dirname)
|
|
165
|
-
_include?(@ignore_dir_patterns, File.basename(dirname))
|
|
165
|
+
_include?(@ignore_dir_patterns, File.basename(dirname)) != nil
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
#
|
|
@@ -172,7 +172,7 @@ module TreeRb
|
|
|
172
172
|
# @return [boolean] if filename match almost one pattern
|
|
173
173
|
#
|
|
174
174
|
def ignore_file?(filename)
|
|
175
|
-
_include?(@ignore_file_patterns, File.basename(filename))
|
|
175
|
+
_include?(@ignore_file_patterns, File.basename(filename)) != nil
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
#
|
|
@@ -183,7 +183,7 @@ module TreeRb
|
|
|
183
183
|
#
|
|
184
184
|
def match?(filename)
|
|
185
185
|
return true if @match_file_patterns.empty?
|
|
186
|
-
_include?(@match_file_patterns, File.basename(filename))
|
|
186
|
+
_include?(@match_file_patterns, File.basename(filename)) != nil
|
|
187
187
|
end
|
|
188
188
|
|
|
189
189
|
#
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/tree_rb/version.rb
CHANGED
|
File without changes
|
|
@@ -16,12 +16,12 @@ module TreeRb
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def on_enter_node(&block)
|
|
19
|
-
raise
|
|
19
|
+
raise 'already defined a delegate' if @delegate
|
|
20
20
|
@action_enter_tree_node = block
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def on_visit_leaf(&block)
|
|
24
|
-
raise
|
|
24
|
+
raise 'already defined a delegate' if @delegate
|
|
25
25
|
@action_visit_leaf_node = block
|
|
26
26
|
end
|
|
27
27
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/tree_rb_cli.rb
CHANGED
|
File without changes
|
data/lib/tree_visitor.rb
CHANGED
|
File without changes
|
data/lib/treevisitor.rb
CHANGED
|
File without changes
|
data/lib/treevisitor_cli.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
|
@@ -9,7 +9,7 @@ describe CliJson do
|
|
|
9
9
|
# args << File.join(FIXTURES, "test_dir_1")
|
|
10
10
|
CliJson.new.parse_args(args)
|
|
11
11
|
end
|
|
12
|
-
captured.out.
|
|
12
|
+
expect(captured.out).to match /Usage:/
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'should accept --version switch' do
|
|
@@ -18,7 +18,7 @@ describe CliJson do
|
|
|
18
18
|
CliJson.new.parse_args(args)
|
|
19
19
|
end
|
|
20
20
|
version = TreeRb::VERSION
|
|
21
|
-
captured.out.
|
|
21
|
+
expect(captured.out).to match version
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it 'should format simple json file' do
|
|
@@ -34,7 +34,7 @@ describe CliJson do
|
|
|
34
34
|
"b": 2
|
|
35
35
|
}
|
|
36
36
|
EOS
|
|
37
|
-
captured.out.
|
|
37
|
+
expect(captured.out).to be == certified_out
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
end
|
|
@@ -9,7 +9,7 @@ describe CliTree do
|
|
|
9
9
|
args << File.join(FIXTURES, "test_dir_1")
|
|
10
10
|
CliTree.new.parse_args(args)
|
|
11
11
|
end
|
|
12
|
-
captured.out.
|
|
12
|
+
expect(captured.out).to match /d3.layout.partition/
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'should accepts --format html_tree' do
|
|
@@ -18,7 +18,7 @@ describe CliTree do
|
|
|
18
18
|
args << File.join(FIXTURES, "test_dir_1")
|
|
19
19
|
CliTree.new.parse_args(args)
|
|
20
20
|
end
|
|
21
|
-
captured.out.
|
|
21
|
+
expect(captured.out).to match /d3.layout.tree/
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it 'should accepts --format html_treemap' do
|
|
@@ -27,6 +27,6 @@ describe CliTree do
|
|
|
27
27
|
args << File.join(FIXTURES, "test_dir_1")
|
|
28
28
|
CliTree.new.parse_args(args)
|
|
29
29
|
end
|
|
30
|
-
captured.out.
|
|
30
|
+
expect(captured.out).to match /d3.layout.treemap/
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -15,7 +15,7 @@ a4788ba25d42f21003db11ec53112f1e file.1.1
|
|
|
15
15
|
afb96f2652f4ba3cd84f7be0ae6fffe3 file.1.2.1
|
|
16
16
|
c4c0c530b842efe4038ac4a659bfbe77 file.2.1
|
|
17
17
|
EOS
|
|
18
|
-
captured.out.
|
|
18
|
+
expect(captured.out).to be == certified_out
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should accepts --sha1sum switch" do
|
|
@@ -30,7 +30,7 @@ EOS
|
|
|
30
30
|
4b7f45a8c0be069e7eac5f7d64b997c92c740656 file.1.2.1
|
|
31
31
|
3c58aeb1552b0318a86279b52c918f2fb953b4b9 file.2.1
|
|
32
32
|
EOS
|
|
33
|
-
captured.out.
|
|
33
|
+
expect(captured.out).to be == certified_out
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
end
|
|
@@ -8,7 +8,7 @@ describe CliTree do
|
|
|
8
8
|
args = %w{--help}
|
|
9
9
|
CliTree.new.parse_args(args)
|
|
10
10
|
end
|
|
11
|
-
captured.out.
|
|
11
|
+
expect(captured.out).to match(/Usage:/)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "should accept --version switch" do
|
|
@@ -17,7 +17,7 @@ describe CliTree do
|
|
|
17
17
|
CliTree.new.parse_args(args)
|
|
18
18
|
end
|
|
19
19
|
version = TreeRb::VERSION
|
|
20
|
-
captured.out.
|
|
20
|
+
expect(captured.out).to match(version)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "should accepts -d switch (directories only)" do
|
|
@@ -27,8 +27,8 @@ describe CliTree do
|
|
|
27
27
|
CliTree.new.parse_args(args)
|
|
28
28
|
end
|
|
29
29
|
expected = "test_dir_1\n|-- dir.1\n| `-- dir.1.2\n`-- dir.2\n\n4 directories, 0 files\n"
|
|
30
|
-
captured.out.
|
|
31
|
-
captured.out.split("\n").length.
|
|
30
|
+
expect(captured.out).to be == expected
|
|
31
|
+
expect(captured.out.split("\n").length).to be == 6
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "should accepts -da switch (directories only)" do
|
|
@@ -38,8 +38,8 @@ describe CliTree do
|
|
|
38
38
|
CliTree.new.parse_args(args)
|
|
39
39
|
end
|
|
40
40
|
expected = "test_dir_1\n|-- .dir_with_dot\n|-- dir.1\n| `-- dir.1.2\n`-- dir.2\n\n5 directories, 0 files\n"
|
|
41
|
-
captured.out.
|
|
42
|
-
captured.out.split("\n").length.
|
|
41
|
+
expect(captured.out).to be == expected
|
|
42
|
+
expect(captured.out.split("\n").length).to be == 7
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "should accepts -a switch (all files)" do
|
|
@@ -50,8 +50,8 @@ describe CliTree do
|
|
|
50
50
|
end
|
|
51
51
|
# pp captured
|
|
52
52
|
expected ="test_dir_1\n|-- .dir_with_dot\n| `-- dummy.txt\n|-- dir.1\n| |-- file.1.1\n| `-- dir.1.2\n| `-- file.1.2.1\n`-- dir.2\n `-- file.2.1\n\n5 directories, 4 files\n"
|
|
53
|
-
captured.out.
|
|
54
|
-
captured.out.split("\n").length.
|
|
53
|
+
expect(captured.out).to be == expected
|
|
54
|
+
expect(captured.out.split("\n").length).to be == 11
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "should accepts -a switch (all files)" do
|
|
@@ -62,8 +62,8 @@ describe CliTree do
|
|
|
62
62
|
end
|
|
63
63
|
# puts captured
|
|
64
64
|
expected ="test_dir_1\n|-- dir.1\n| |-- file.1.1\n| `-- dir.1.2\n| `-- file.1.2.1\n`-- dir.2\n `-- file.2.1\n\n4 directories, 3 files\n"
|
|
65
|
-
captured.out.
|
|
66
|
-
captured.out.split("\n").length.
|
|
65
|
+
expect(captured.out).to be == expected
|
|
66
|
+
expect(captured.out.split("\n").length).to be == 9
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "should accepts -A switch (ascii line graphics)" do
|
|
@@ -84,7 +84,7 @@ test_dir_1
|
|
|
84
84
|
|
|
85
85
|
4 directories, 3 files
|
|
86
86
|
EOS
|
|
87
|
-
captured.out.encode('utf-8').
|
|
87
|
+
expect(captured.out.encode('utf-8')).to be == expected.encode('utf-8')
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it "should show tree with inaccessible directories" do
|
|
@@ -115,10 +115,10 @@ test_dir_3_with_error
|
|
|
115
115
|
EOS
|
|
116
116
|
expected_err=/Permission denied/
|
|
117
117
|
|
|
118
|
-
captured.out.
|
|
119
|
-
captured.err.
|
|
120
|
-
captured.err.
|
|
121
|
-
captured.out.split("\n").length.
|
|
118
|
+
expect(captured.out).to be == expected_out
|
|
119
|
+
expect(captured.err).to match(expected_err)
|
|
120
|
+
expect(captured.err).not_to be_empty
|
|
121
|
+
expect(captured.out.split("\n").length).to be == 4
|
|
122
122
|
|
|
123
123
|
# File.chmod(0644,d)
|
|
124
124
|
# Dir.unlink(d)
|