recls-ruby 2.11.0.3 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +24 -27
  3. data/README.md +1 -242
  4. data/examples/find_files_and_directories.md +30 -33
  5. data/examples/find_files_and_directories.recursive.md +254 -255
  6. data/examples/show_hidden_files.md +1 -4
  7. data/examples/show_hidden_files.rb +1 -1
  8. data/examples/show_readonly_files.md +1 -4
  9. data/examples/show_readonly_files.rb +1 -1
  10. data/lib/recls/api.rb +73 -76
  11. data/lib/recls/combine_paths_1.rb +23 -26
  12. data/lib/recls/combine_paths_2plus.rb +29 -32
  13. data/lib/recls/entry.rb +273 -277
  14. data/lib/recls/file_search.rb +193 -194
  15. data/lib/recls/flags.rb +45 -48
  16. data/lib/recls/foreach.rb +98 -105
  17. data/lib/recls/obsolete.rb +79 -80
  18. data/lib/recls/recls.rb +22 -16
  19. data/lib/recls/stat.rb +134 -137
  20. data/lib/recls/util.rb +92 -95
  21. data/lib/recls/version.rb +17 -22
  22. data/lib/recls/ximpl/os.rb +44 -46
  23. data/lib/recls/ximpl/unix.rb +35 -39
  24. data/lib/recls/ximpl/util.rb +596 -598
  25. data/lib/recls/ximpl/windows.rb +137 -141
  26. data/lib/recls.rb +9 -10
  27. data/test/scratch/test_display_parts.rb +33 -33
  28. data/test/scratch/test_entry.rb +6 -6
  29. data/test/scratch/test_files_and_directories.rb +8 -8
  30. data/test/scratch/test_foreach.rb +10 -10
  31. data/test/scratch/test_module_function.rb +33 -33
  32. data/test/scratch/test_pattern_arrays.rb +5 -5
  33. data/test/scratch/test_show_dev_and_ino.rb +1 -1
  34. data/test/scratch/test_show_hidden.rb +3 -3
  35. data/test/unit/tc_recls_entries.rb +31 -31
  36. data/test/unit/tc_recls_entry.rb +19 -19
  37. data/test/unit/tc_recls_file_search.rb +32 -32
  38. data/test/unit/tc_recls_module.rb +25 -25
  39. data/test/unit/tc_recls_util.rb +161 -161
  40. data/test/unit/tc_recls_ximpl_util.rb +676 -676
  41. data/test/unit/test_all_separately.sh +1 -1
  42. data/test/unit/ts_all.rb +4 -4
  43. metadata +7 -7
@@ -6,9 +6,9 @@ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
6
 
7
7
  require 'recls'
8
8
 
9
- root_dir = File.join(File.dirname(__FILE__), '../..')
10
- patterns_a = %w{ *.rb *.md }
11
- patterns_s = patterns_a.join('|')
9
+ root_dir = File.join(File.dirname(__FILE__), '../..')
10
+ patterns_a = %w{ *.rb *.md }
11
+ patterns_s = patterns_a.join('|')
12
12
 
13
13
 
14
14
  puts
@@ -16,7 +16,7 @@ puts "Searching for pattern string '#{patterns_s}':"
16
16
 
17
17
  Recls::FileSearch.new(root_dir, patterns_s, Recls::FILES | Recls::RECURSIVE).each do |fe|
18
18
 
19
- puts fe.search_relative_path
19
+ puts fe.search_relative_path
20
20
  end
21
21
 
22
22
 
@@ -26,7 +26,7 @@ puts "Searching for pattern array '#{patterns_a}':"
26
26
 
27
27
  Recls::FileSearch.new(root_dir, patterns_a, Recls::FILES | Recls::RECURSIVE).each do |fe|
28
28
 
29
- puts fe.search_relative_path
29
+ puts fe.search_relative_path
30
30
  end
31
31
 
32
32
 
@@ -8,6 +8,6 @@ require 'recls'
8
8
 
9
9
  Recls::FileSearch.new('.', Recls::WILDCARDS_ALL, Recls::FILES | Recls::RECURSIVE).each do |fe|
10
10
 
11
- puts "#{fe.search_relative_path}\t#{fe.dev}\t#{fe.ino}\t#{fe.nlink}"
11
+ puts "#{fe.search_relative_path}\t#{fe.dev}\t#{fe.ino}\t#{fe.nlink}"
12
12
  end
13
13
 
@@ -10,14 +10,14 @@ puts
10
10
  puts "Hidden directories:"
11
11
  Recls.file_rsearch(nil, nil, Recls::DIRECTORIES | Recls::SHOW_HIDDEN).each do |fe|
12
12
 
13
- puts "\t#{fe.search_relative_path}" if fe.hidden?
13
+ puts "\t#{fe.search_relative_path}" if fe.hidden?
14
14
  end
15
15
 
16
16
  puts
17
17
  puts "Hidden files:"
18
18
  Recls.file_search(nil, nil, Recls::RECURSIVE | Recls::FILES | Recls::SHOW_HIDDEN).each do |fe|
19
19
 
20
- puts "\t#{fe.search_relative_path}" if fe.hidden?
20
+ puts "\t#{fe.search_relative_path}" if fe.hidden?
21
21
  end
22
22
 
23
23
 
@@ -25,6 +25,6 @@ puts
25
25
  puts "Hidden directories & files:"
26
26
  Recls.file_search(nil, nil, Recls::RECURSIVE | Recls::DIRECTORIES | Recls::FILES | Recls::MARK_DIRECTORIES | Recls::SHOW_HIDDEN).each do |fe|
27
27
 
28
- puts "\t#{fe.search_relative_path}" if fe.hidden?
28
+ puts "\t#{fe.search_relative_path}" if fe.hidden?
29
29
  end
30
30
 
@@ -1,55 +1,55 @@
1
- #! /usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # test Recls entries
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
6
 
7
+
7
8
  require 'recls'
8
9
 
9
10
  require 'test/unit'
10
11
 
11
-
12
12
  class Test_Recls_entries < Test::Unit::TestCase
13
13
 
14
- unless defined? assert_false
15
- def assert_false arg0, *args
16
- assert !arg0, *args
17
- end
18
- end
14
+ unless defined? assert_false
15
+ def assert_false arg0, *args
16
+ assert !arg0, *args
17
+ end
18
+ end
19
19
 
20
- def test_entries_in_directory_have_unique_names
20
+ def test_entries_in_directory_have_unique_names
21
21
 
22
- entries = Recls::FileSearch.new('~', Recls::WILDCARDS_ALL, Recls::FILES).to_a
22
+ entries = Recls::FileSearch.new('~', Recls::WILDCARDS_ALL, Recls::FILES).to_a
23
23
 
24
- hashed_entries = Hash[entries.each_with_index.map { |fe, index| [ fe, index] }]
24
+ hashed_entries = Hash[entries.each_with_index.map { |fe, index| [ fe, index] }]
25
25
 
26
- # ensure that no duplicates in hash (and hence Entry.hash and Entry.<=> work)
27
- assert_equal entries.size, hashed_entries.size
26
+ # ensure that no duplicates in hash (and hence Entry.hash and Entry.<=> work)
27
+ assert_equal entries.size, hashed_entries.size
28
28
 
29
- entries.each_with_index do |entry, index|
29
+ entries.each_with_index do |entry, index|
30
30
 
31
- entry_a = entries[index]
32
- entry_b = Recls.stat(entries[index].path)
31
+ entry_a = entries[index]
32
+ entry_b = Recls.stat(entries[index].path)
33
33
 
34
- # ensure that different entry instances representing the same path evaluate
35
- # equal (and hence Entry.eq? and Entry.== work)
34
+ # ensure that different entry instances representing the same path evaluate
35
+ # equal (and hence Entry.eq? and Entry.== work)
36
36
 
37
- assert entry_a.eql? entry_a
38
- assert entry_a.eql? entry_b
39
- assert_false entry_a.eql? entry_a.path
40
- assert_false entry_a.eql? entry_b.path
37
+ assert entry_a.eql? entry_a
38
+ assert entry_a.eql? entry_b
39
+ assert_false entry_a.eql? entry_a.path
40
+ assert_false entry_a.eql? entry_b.path
41
41
 
42
- assert_equal entry_a, entry_a
43
- assert_equal entry_a, entry_b
44
- assert_equal entry_a, entry_a.path
45
- assert_equal entry_a, entry_b.path
42
+ assert_equal entry_a, entry_a
43
+ assert_equal entry_a, entry_b
44
+ assert_equal entry_a, entry_a.path
45
+ assert_equal entry_a, entry_b.path
46
46
 
47
- assert_same entry_a, entries[index]
48
- assert_not_same entry_a, entry_b
47
+ assert_same entry_a, entries[index]
48
+ assert_not_same entry_a, entry_b
49
49
 
50
- assert_equal index, hashed_entries[entry_a]
51
- assert_equal index, hashed_entries[entry_b]
52
- end
53
- end
50
+ assert_equal index, hashed_entries[entry_a]
51
+ assert_equal index, hashed_entries[entry_b]
52
+ end
53
+ end
54
54
  end
55
55
 
@@ -1,40 +1,40 @@
1
- #! /usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # test Recls entries
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
6
 
7
+
7
8
  require 'recls'
8
9
 
9
10
  require 'test/unit'
10
11
 
11
-
12
12
  class Test_Recls_entry < Test::Unit::TestCase
13
13
 
14
- unless defined? assert_false
15
- def assert_false arg0, *args
16
- assert !arg0, *args
17
- end
18
- end
14
+ unless defined? assert_false
15
+ def assert_false arg0, *args
16
+ assert !arg0, *args
17
+ end
18
+ end
19
19
 
20
- def setup
20
+ def setup
21
21
 
22
- @cwd = Dir.pwd
23
- end
22
+ @cwd = Dir.pwd
23
+ end
24
24
 
25
- def test_entry_does_not_mark_directory
25
+ def test_entry_does_not_mark_directory
26
26
 
27
- cwd = Recls.stat @cwd
27
+ cwd = Recls.stat @cwd
28
28
 
29
- assert_equal @cwd, cwd.path
30
- end
29
+ assert_equal @cwd, cwd.path
30
+ end
31
31
 
32
- def test_entry_does_mark_directory
32
+ def test_entry_does_mark_directory
33
33
 
34
- cwd = Recls.stat @cwd, Recls::MARK_DIRECTORIES
34
+ cwd = Recls.stat @cwd, Recls::MARK_DIRECTORIES
35
35
 
36
- # assert_equal "#{@cwd}#{Recls::PATH_NAME_SEPARATOR}", cwd.path
37
- assert_equal "#{@cwd}/", cwd.path
38
- end
36
+ # assert_equal "#{@cwd}#{Recls::PATH_NAME_SEPARATOR}", cwd.path
37
+ assert_equal "#{@cwd}/", cwd.path
38
+ end
39
39
  end
40
40
 
@@ -4,65 +4,65 @@
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
6
 
7
+
7
8
  require 'recls'
8
9
 
9
10
  require 'test/unit'
10
11
 
11
-
12
12
  class Test_Recls_FileSearch_class < Test::Unit::TestCase
13
13
 
14
- def test_construction
14
+ def test_construction
15
15
 
16
- fs = Recls::FileSearch.new(nil, nil, 0)
16
+ fs = Recls::FileSearch.new(nil, nil, 0)
17
17
 
18
- assert_not_nil(fs)
18
+ assert_not_nil(fs)
19
19
 
20
- end # def test_construction
20
+ end # def test_construction
21
21
 
22
- def test_construction_1
22
+ def test_construction_1
23
23
 
24
- fs = Recls::FileSearch.new('abc', '*c', Recls::FILES)
24
+ fs = Recls::FileSearch.new('abc', '*c', Recls::FILES)
25
25
 
26
- assert_not_nil(fs)
27
- assert_equal('abc', fs.search_root)
28
- assert_equal(['*c'], fs.patterns)
26
+ assert_not_nil(fs)
27
+ assert_equal('abc', fs.search_root)
28
+ assert_equal(['*c'], fs.patterns)
29
29
  if not defined? RECLS_NO_OBSOLETE
30
- assert_equal('abc', fs.searchRoot)
31
- assert_equal(['*c'], fs.pattern)
30
+ assert_equal('abc', fs.searchRoot)
31
+ assert_equal(['*c'], fs.pattern)
32
32
  end
33
- assert_equal(Recls::FILES, fs.flags)
33
+ assert_equal(Recls::FILES, fs.flags)
34
34
 
35
- end # def test_construction_1
35
+ end # def test_construction_1
36
36
 
37
- def test_construction_2
37
+ def test_construction_2
38
38
 
39
- fs = Recls::FileSearch.new('def', '*c', 0)
39
+ fs = Recls::FileSearch.new('def', '*c', 0)
40
40
 
41
- assert_not_nil(fs)
42
- assert_equal('def', fs.search_root)
43
- assert_equal(['*c'], fs.patterns)
41
+ assert_not_nil(fs)
42
+ assert_equal('def', fs.search_root)
43
+ assert_equal(['*c'], fs.patterns)
44
44
  if not defined? RECLS_NO_OBSOLETE
45
- assert_equal('def', fs.searchRoot)
46
- assert_equal(['*c'], fs.pattern)
45
+ assert_equal('def', fs.searchRoot)
46
+ assert_equal(['*c'], fs.pattern)
47
47
  end
48
- assert_equal(Recls::FILES, fs.flags)
48
+ assert_equal(Recls::FILES, fs.flags)
49
49
 
50
- end # def test_construction_2
50
+ end # def test_construction_2
51
51
 
52
- def test_construction_3
52
+ def test_construction_3
53
53
 
54
- fs = Recls::FileSearch.new('ghi', '*c', Recls::DIRECTORIES)
54
+ fs = Recls::FileSearch.new('ghi', '*c', Recls::DIRECTORIES)
55
55
 
56
- assert_not_nil(fs)
57
- assert_equal('ghi', fs.search_root)
58
- assert_equal(['*c'], fs.patterns)
56
+ assert_not_nil(fs)
57
+ assert_equal('ghi', fs.search_root)
58
+ assert_equal(['*c'], fs.patterns)
59
59
  if not defined? RECLS_NO_OBSOLETE
60
- assert_equal('ghi', fs.searchRoot)
61
- assert_equal(['*c'], fs.pattern)
60
+ assert_equal('ghi', fs.searchRoot)
61
+ assert_equal(['*c'], fs.pattern)
62
62
  end
63
- assert_equal(Recls::DIRECTORIES, fs.flags)
63
+ assert_equal(Recls::DIRECTORIES, fs.flags)
64
64
 
65
- end # def test_construction_3
65
+ end # def test_construction_3
66
66
 
67
67
  end
68
68
 
@@ -4,72 +4,72 @@
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
6
 
7
+
7
8
  require 'recls'
8
9
 
9
10
  require 'test/unit'
10
11
 
11
-
12
12
  class Test_Recls_constants < Test::Unit::TestCase
13
13
 
14
- private
15
- @@OS_IS_WINDOWS = Recls::Ximpl::OS::OS_IS_WINDOWS
14
+ private
15
+ @@OS_IS_WINDOWS = Recls::Ximpl::OS::OS_IS_WINDOWS
16
16
 
17
- public
17
+ public
18
18
 
19
19
 
20
- def test_PATH_NAME_SEPARATOR
20
+ def test_PATH_NAME_SEPARATOR
21
21
 
22
- expected = @@OS_IS_WINDOWS ? '\\' : '/'
22
+ expected = @@OS_IS_WINDOWS ? '\\' : '/'
23
23
 
24
- assert_equal(expected, Recls::PATH_NAME_SEPARATOR)
24
+ assert_equal(expected, Recls::PATH_NAME_SEPARATOR)
25
25
 
26
- end # def test_PATH_NAME_SEPARATOR
26
+ end # def test_PATH_NAME_SEPARATOR
27
27
 
28
28
  if not defined? RECLS_NO_OBSOLETE
29
29
 
30
- def test_pathNameSeparator
30
+ def test_pathNameSeparator
31
31
 
32
- assert_equal(Recls::PATH_NAME_SEPARATOR, Recls::pathNameSeparator)
32
+ assert_equal(Recls::PATH_NAME_SEPARATOR, Recls::pathNameSeparator)
33
33
 
34
- end # def test_pathNameSeparator
34
+ end # def test_pathNameSeparator
35
35
 
36
36
  end
37
37
 
38
- def test_PATH_SEPARATOR
38
+ def test_PATH_SEPARATOR
39
39
 
40
- expected = @@OS_IS_WINDOWS ? ';' : ':'
40
+ expected = @@OS_IS_WINDOWS ? ';' : ':'
41
41
 
42
- assert_equal(expected, Recls::PATH_SEPARATOR)
42
+ assert_equal(expected, Recls::PATH_SEPARATOR)
43
43
 
44
- end # def test_PATH_SEPARATOR
44
+ end # def test_PATH_SEPARATOR
45
45
 
46
46
  if not defined? RECLS_NO_OBSOLETE
47
47
 
48
- def test_pathSeparator
48
+ def test_pathSeparator
49
49
 
50
- assert_equal(Recls::PATH_SEPARATOR, Recls::pathSeparator)
50
+ assert_equal(Recls::PATH_SEPARATOR, Recls::pathSeparator)
51
51
 
52
- end # def test_pathSeparator
52
+ end # def test_pathSeparator
53
53
 
54
54
  end
55
55
 
56
56
 
57
57
 
58
- def test_WILDCARDS_ALL
58
+ def test_WILDCARDS_ALL
59
59
 
60
- #expected = @@OS_IS_WINDOWS ? '*.*' : '*'
60
+ #expected = @@OS_IS_WINDOWS ? '*.*' : '*'
61
61
 
62
- assert_equal('*', Recls::WILDCARDS_ALL)
62
+ assert_equal('*', Recls::WILDCARDS_ALL)
63
63
 
64
- end # def test_WILDCARDS_ALL
64
+ end # def test_WILDCARDS_ALL
65
65
 
66
66
  if not defined? RECLS_NO_OBSOLETE
67
67
 
68
- def test_wildcardsAll
68
+ def test_wildcardsAll
69
69
 
70
- assert_equal(Recls::WILDCARDS_ALL, Recls::wildcardsAll)
70
+ assert_equal(Recls::WILDCARDS_ALL, Recls::wildcardsAll)
71
71
 
72
- end # def test_wildcardsAll
72
+ end # def test_wildcardsAll
73
73
 
74
74
  end
75
75