dir_r 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.txt +14 -0
- data/Manifest.txt +6 -0
- data/README.md +56 -0
- data/Rakefile +29 -0
- data/lib/dir_r.rb +52 -0
- data/version +2 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d33dbcd163e86efcee3e334d6ee0d3ba31e4360d93b4318a807c941bab72a56
|
4
|
+
data.tar.gz: f8e68a793609862438eddec5f850167de8faa4c32603a594926617c8cb207b32
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea6e168330a387413e89aba6873940952d37d59110190586fb68c74f09e7ecc57477e73e0112aecb2eb3fdf833d23a89c5cbac9a302c8a941f0bb973a0eb0c0c
|
7
|
+
data.tar.gz: fa3b30de105b8c769f964c46caa77a90b17a81810d80223aed2eb42849b115292eb4bc1f86c6fa90e897c453e5963e40e2772e91a1d69904903f3da888ffc869
|
data/History.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
robertburrowes Tue Nov 3 13:15:06 2020 +1300
|
2
|
+
completing for release
|
3
|
+
robertburrowes Tue Nov 3 13:14:38 2020 +1300
|
4
|
+
test dependency an wikk_json
|
5
|
+
robertburrowes Tue Nov 3 13:08:22 2020 +1300
|
6
|
+
Copied from earlier non-gem code base
|
7
|
+
robertburrowes Tue Nov 3 13:07:36 2020 +1300
|
8
|
+
Set current version
|
9
|
+
robertburrowes Tue Nov 3 13:07:17 2020 +1300
|
10
|
+
Unit tests
|
11
|
+
robertburrowes Tue Nov 3 13:06:25 2020 +1300
|
12
|
+
test directory tree for testing with test_dir_r.rb
|
13
|
+
robertburrowes Sun Nov 1 17:05:48 2020 +1300
|
14
|
+
Empty Gem Project
|
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# dir_r
|
2
|
+
|
3
|
+
* Docs :: https://rbur004.github.io/dir_r/
|
4
|
+
* Source :: https://github.com/wikarekare/dir_r
|
5
|
+
* Gem :: https://rubygems.org/gems/dir_r
|
6
|
+
|
7
|
+
## DESCRIPTION:
|
8
|
+
|
9
|
+
Simple recursive walk through a directory, yielding the directory, filename and if the entry is a symbolic link.
|
10
|
+
|
11
|
+
## FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
* Symbolic links, that point nowhere, are skipped.
|
14
|
+
* Symbolic links, that point to directories, are skipped to avoid loops, double processing, and/or escaping the dir tree.
|
15
|
+
|
16
|
+
## SYNOPSIS:
|
17
|
+
|
18
|
+
```
|
19
|
+
require 'dir_r'
|
20
|
+
DirR.walk_dir(directory: "#{__dir__}/test_dir", walk_sub_directories: true, ignore_symlinks: true) do |dir,fn,link|
|
21
|
+
puts "Directory Path: #{dir} Filename: #{fn} Is a link: #{link}"
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
## REQUIREMENTS:
|
26
|
+
|
27
|
+
* require 'dir_r'
|
28
|
+
|
29
|
+
## INSTALL:
|
30
|
+
|
31
|
+
* sudo gem install dir_r
|
32
|
+
|
33
|
+
## LICENSE:
|
34
|
+
|
35
|
+
(The MIT License)
|
36
|
+
|
37
|
+
Copyright (c) 2020 FIX
|
38
|
+
|
39
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
40
|
+
a copy of this software and associated documentation files (the
|
41
|
+
'Software'), to deal in the Software without restriction, including
|
42
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
43
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
44
|
+
permit persons to whom the Software is furnished to do so, subject to
|
45
|
+
the following conditions:
|
46
|
+
|
47
|
+
The above copyright notice and this permission notice shall be
|
48
|
+
included in all copies or substantial portions of the Software.
|
49
|
+
|
50
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
51
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
52
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
53
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
54
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
55
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
56
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'hoe'
|
4
|
+
Hoe.plugin :yard
|
5
|
+
load "#{__dir__}/version"
|
6
|
+
|
7
|
+
Hoe.spec PROJECT do
|
8
|
+
self.readme_file = "README.md"
|
9
|
+
self.developer( "Rob Burrowes","r.burrowes@auckland.ac.nz")
|
10
|
+
remote_rdoc_dir = '' # Release to root
|
11
|
+
|
12
|
+
self.yard_title = PROJECT
|
13
|
+
self.yard_options = ['--markup', 'markdown', '--protected']
|
14
|
+
|
15
|
+
self.dependency 'wikk_json', ['~> 0.1', '>= 0.1.0'], type=:dev
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
#Validate manfest.txt
|
20
|
+
#rake check_manifest
|
21
|
+
|
22
|
+
#Local checking. Creates pkg/
|
23
|
+
#rake gem
|
24
|
+
|
25
|
+
#create doc/
|
26
|
+
#rake docs
|
27
|
+
|
28
|
+
#Copy up to rubygem.org
|
29
|
+
#rake release VERSION=1.0.1
|
data/lib/dir_r.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Recursive walk through a directory tree
|
2
|
+
# There is also Find.find and Dir.glob as alternatives
|
3
|
+
# Symbolic links, pointing nowhere, are ignored
|
4
|
+
# Symbolic links to directories are ignored
|
5
|
+
# We will process the linked to directory, if it is in this tree;
|
6
|
+
# But we don't want to break out of this tree, and go wondering through the file system.
|
7
|
+
# We also ignore special files (i.e. sockets, dev nodes, ...)
|
8
|
+
#
|
9
|
+
class DirR
|
10
|
+
VERSION = '1.0.0'
|
11
|
+
# Directory listing. Ignoring symbolic links
|
12
|
+
#
|
13
|
+
# @param directory [String] directory to list
|
14
|
+
# @param walk_sub_directories [Boolean] Recurse through the subdirectories
|
15
|
+
# @param ignore_symlinks [Boolean] Skip over symbolic links to files
|
16
|
+
# @yield [String, String, Boolean] Directory path, Filename, Symbolic Link true/false
|
17
|
+
def self.walk_dir(directory:, walk_sub_directories: true, ignore_symlinks: true, debug: false, &block)
|
18
|
+
puts "In #{directory}" if debug
|
19
|
+
Dir.open(directory).each do |filename|
|
20
|
+
puts " Got: #{filename}" if debug
|
21
|
+
if filename != '.' && filename != '..' #ignore parent, and current directories.
|
22
|
+
qualified_filename = "#{directory}/#{filename}"
|
23
|
+
begin
|
24
|
+
stat_record = File.stat(qualified_filename) #File end
|
25
|
+
lstat_record = File.lstat(qualified_filename)#Link end
|
26
|
+
rescue Errno::ENOENT
|
27
|
+
puts " Skipping #{qualified_filename}" if debug
|
28
|
+
next # Link points nowhere, so we ignore it, rather than stop.
|
29
|
+
end
|
30
|
+
link = lstat_record.symlink?
|
31
|
+
if stat_record.directory?
|
32
|
+
if !link && walk_sub_directories
|
33
|
+
#recurse through sub-directories.
|
34
|
+
#don't follow links to directories though, as they could take us anywhere, including looping.
|
35
|
+
walk_dir( directory: qualified_filename,
|
36
|
+
walk_sub_directories: walk_sub_directories,
|
37
|
+
ignore_symlinks: ignore_symlinks,
|
38
|
+
debug: debug,
|
39
|
+
&block
|
40
|
+
)
|
41
|
+
puts "Back In #{directory}" if debug
|
42
|
+
end
|
43
|
+
elsif stat_record.file?
|
44
|
+
# Ordinary file and not a link, or we are accepting links
|
45
|
+
if !link || (link && !ignore_symlinks)
|
46
|
+
yield directory, filename, link
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/version
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dir_r
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Burrowes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hoe-yard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.3
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: wikk_json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.1.0
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.1'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.1.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: hoe
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.22'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.22'
|
61
|
+
description: Simple recursive walk through a directory, yielding the directory, filename
|
62
|
+
and if the entry is a symbolic link.
|
63
|
+
email:
|
64
|
+
- r.burrowes@auckland.ac.nz
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files:
|
68
|
+
- History.txt
|
69
|
+
- Manifest.txt
|
70
|
+
- README.md
|
71
|
+
files:
|
72
|
+
- History.txt
|
73
|
+
- Manifest.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- lib/dir_r.rb
|
77
|
+
- version
|
78
|
+
homepage: https://rbur004.github.io/dir_r/
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options:
|
84
|
+
- "--markup"
|
85
|
+
- markdown
|
86
|
+
- "--protected"
|
87
|
+
- "--title"
|
88
|
+
- dir_r
|
89
|
+
- "--quiet"
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.1.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Simple recursive walk through a directory, yielding the directory, filename
|
107
|
+
and if the entry is a symbolic link.
|
108
|
+
test_files: []
|