recls-ruby 2.9.1 → 2.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 633b42f5042eb49162aafc0a68e7d48cf47e1919
4
- data.tar.gz: 9ac21ed45d384c67863c7b4fad0d782dfec077b4
2
+ SHA256:
3
+ metadata.gz: 606018fcccb7395be01a33399eb15feb0e4b5a6cbda0845469c5f7088347ee1b
4
+ data.tar.gz: f33b673b8bf6d01ecee1a9ae626bd5e959a9da422541cc5b5deff1741c4f5cd7
5
5
  SHA512:
6
- metadata.gz: 5f204a82f58c74d870696c52f9f6f6b4d4a3c89a57bdb1cef6f4d6c74c017d21f78504ac67466d3b3fe068bf01c0efadbbb21d453a1bb596c4cdccc3389076c7
7
- data.tar.gz: 4c83a6e6ecbd1c791f035a8e5f98faddf662584a21ad69d3ecc64a5e18ea255093e79f171138cdf9d7d2634df089fadab5488457cda258a0d753eab38bbda27c
6
+ metadata.gz: 2601f4ce4f5b55a21b0d90b4c11d5a9eea22624d826821b82061f015b34ad05b2950d3a77534ee98ca9512c5d541936a759348010327bac57eeb7ca2a7d0f601
7
+ data.tar.gz: bc608e22ab8de3cc2aa7048e55a283402061262053603d229b9c5b3256ac6a09cffff08a06024ad1d1b794995811ca69730c3761f6ab855372abcfdbcfd65e61
@@ -4,7 +4,7 @@
4
4
  # Purpose: Defines Recls module search functions
5
5
  #
6
6
  # Created: 9th June 2016
7
- # Updated: 21st March 2019
7
+ # Updated: 14th April 2019
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
@@ -39,11 +39,14 @@
39
39
  require 'recls/file_search'
40
40
  require 'recls/flags'
41
41
 
42
+ =begin
43
+ =end
44
+
45
+ class Object; end # :nodoc:
46
+
42
47
  module Recls
43
48
 
44
- # [DEPRECATED] Use +Recls.file_search()+
45
- #
46
- # @deprecated
49
+ # [DEPRECATED] Use Recls::file_search()
47
50
  def self.FileSearch(search_root, patterns, options = {})
48
51
 
49
52
  Recls::FileSearch.new(search_root, patterns, options)
@@ -55,26 +58,16 @@ module Recls
55
58
  # === Signature
56
59
  #
57
60
  # * *Parameters:*
58
- # - +search_root+:: (String, Recls::Entry) The root directory of
59
- # the search. May be +nil+, in which case the current directory
60
- # is assumed
61
- # - +patterns+:: (String, Array) The pattern(s) for which to
62
- # search. May be +nil+, in which case +Recls::WILDCARDS_ALL+ is
63
- # assumed
64
- # - +options+:: (Hash, Integer) Combination of flags (with
65
- # behaviour as described below for the +flags+ option), or an
66
- # options hash
61
+ # - +search_root+ (String, Recls::Entry) The root directory of the search. May be +nil+, in which case the current directory is assumed
62
+ # - +patterns+ (String, Array) The pattern(s) for which to search. May be +nil+, in which case Recls::WILDCARDS_ALL is assumed
63
+ # - +options+ (Hash, Integer) Combination of flags (with behaviour as described below for the +flags+ option), or an options hash
67
64
  #
68
65
  # * *Options:*
69
- # - +flags+:: (Integer) Combination of flags - FILES,
70
- # DIRECTORIES, etc. If the value modulo TYPEMASK is 0,
71
- # then FILES is assumed. The value RECURSIVE is added by the
72
- # function, and so need not be added by the caller; it cannot be
73
- # removed
66
+ # - +flags+ (Integer) Combination of flags - FILES, DIRECTORIES, etc. If the value modulo TYPEMASK is 0, then FILES is assumed. The value RECURSIVE is added by the function, and so need not be added by the caller; it cannot be removed
74
67
  #
75
68
  # === Return
76
- # An instance of +::Recls::FileSearch+
77
- #
69
+ # An instance of a class implementing ::Enumerable whose value type is
70
+ # Recls::Entry
78
71
  def self.file_rsearch(search_root, patterns, options = {})
79
72
 
80
73
  case options
@@ -104,29 +97,21 @@ module Recls
104
97
  # === Signature
105
98
  #
106
99
  # * *Parameters:*
107
- # - +search_root+:: (String, Recls::Entry) The root directory of
108
- # the search. May be +nil+, in which case the current directory
109
- # is assumed
110
- # - +patterns+:: (String, Array) The pattern(s) for which to
111
- # search. May be +nil+, in which case +Recls::WILDCARDS_ALL+ is
112
- # assumed
113
- # - +options+:: (Hash, Integer) Combination of flags (with
114
- # behaviour as described below for the +flags+ option), or an
115
- # options hash
100
+ # - +search_root+ (String, Recls::Entry) The root directory of the search. May be +nil+, in which case the current directory is assumed
101
+ # - +patterns+ (String, Array) The pattern(s) for which to search. May be +nil+, in which case Recls::WILDCARDS_ALL is assumed
102
+ # - +options+ (Hash, Integer) Combination of flags (with behaviour as described below for the +flags+ option), or an options hash
116
103
  #
117
104
  # * *Options:*
118
- # - +flags+:: (Integer) Combination of flags - FILES,
119
- # DIRECTORIES, RECURSIVE, etc. If the value modulo TYPEMASK is 0,
120
- # then FILES is assumed
105
+ # - +flags+ (Integer) Combination of flags - FILES, DIRECTORIES, RECURSIVE, etc. If the value modulo TYPEMASK is 0, then FILES is assumed
121
106
  #
122
107
  # === Return
123
- # An instance of +::Recls::FileSearch+
124
- #
108
+ # An instance of a class implementing ::Enumerable whose value type is
109
+ # Recls::Entry
125
110
  def self.file_search(search_root, patterns, options = {})
126
111
 
127
112
  Recls::FileSearch.new(search_root, patterns, options)
128
113
  end
129
- end
114
+ end # module Recls
130
115
 
131
116
  # ############################## end of file ############################# #
132
117
 
@@ -4,7 +4,7 @@
4
4
  # Purpose: Definition of Recls::compare_paths() for Ruby 1.x
5
5
  #
6
6
  # Created: 17th February 2014
7
- # Updated: 21st March 2019
7
+ # Updated: 14th April 2019
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
@@ -38,6 +38,11 @@
38
38
 
39
39
  require 'recls/ximpl/util'
40
40
 
41
+ =begin
42
+ =end
43
+
44
+ class Object; end # :nodoc:
45
+
41
46
  module Recls
42
47
 
43
48
  # Combines paths
@@ -45,11 +50,10 @@ module Recls
45
50
  # === Signature
46
51
  #
47
52
  # * *Parameters:*
48
- # - +paths+:: ([ (::String, ::Recls::Entry( ]) Array of 1 or more path
49
- # elements to be combined
53
+ # - +paths+ ([ (::String, ::Recls::Entry) ]) Array of 1 or more path elements to be combined
50
54
  #
51
55
  # === Return
52
- # The combined path
56
+ # (String) The combined path
53
57
  def self.combine_paths(*paths)
54
58
 
55
59
  paths = paths.reject { |p| p.nil? }
@@ -4,7 +4,7 @@
4
4
  # Purpose: Definition of Recls::compare_paths() for Ruby 2+
5
5
  #
6
6
  # Created: 17th February 2014
7
- # Updated: 21st March 2019
7
+ # Updated: 14th April 2019
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
@@ -38,6 +38,11 @@
38
38
 
39
39
  require 'recls/ximpl/util'
40
40
 
41
+ =begin
42
+ =end
43
+
44
+ class Object; end # :nodoc:
45
+
41
46
  module Recls
42
47
 
43
48
  # Combines paths, optionally canonicalising them
@@ -45,22 +50,16 @@ module Recls
45
50
  # === Signature
46
51
  #
47
52
  # * *Parameters:*
48
- # - +paths+:: ([ (::String, ::Recls::Entry( ]) Array of 1 or more path
49
- # elements to be combined
50
- # - +options+:: (::Hash) Options that moderate the combination
53
+ # - +paths+ ([ (::String, ::Recls::Entry) ]) Array of 1 or more path elements to be combined
54
+ # - +options+ (::Hash) Options that moderate the combination
51
55
  #
52
56
  # * *Options:*
53
- # - +:canonicalise+:: (boolean) Causes the evaluated path to be
54
- # canonicalised - with +Recls.canonicalise_path+ - before it is
55
- # returned
56
- # - +:clean+:: (boolean) Causes the evaluated path to be cleaned
57
- # (i.e. sent to +cleanpath+) before it is returned. Ignored if
58
- # +:canonicalise+ is specified
59
- # - +:clean_path+:: (boolean) Equivalent to +:clean+, but deprecated
60
- # and may be removed in a future version
57
+ # - +:canonicalise+ (boolean) Causes the evaluated path to be canonicalised - with +Recls.canonicalise_path+ - before it is returned
58
+ # - +:clean+ (boolean) Causes the evaluated path to be cleaned (i.e. sent to +cleanpath+) before it is returned. Ignored if +:canonicalise+ is specified
59
+ # - +:clean_path+ (boolean) Equivalent to +:clean+, but deprecated and may be removed in a future version
61
60
  #
62
61
  # === Return
63
- # The combined path
62
+ # (String) The combined path
64
63
  def self.combine_paths(*paths, **options)
65
64
 
66
65
  paths = paths.reject { |p| p.nil? }
@@ -4,11 +4,11 @@
4
4
  # Purpose: Defines the Recls::Entry class for the recls.Ruby library.
5
5
  #
6
6
  # Created: 24th July 2012
7
- # Updated: 11th July 2016
7
+ # Updated: 14th April 2019
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
11
- # Copyright (c) 2012-2016, Matthew Wilson and Synesis Software
11
+ # Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
12
12
  # All rights reserved.
13
13
  #
14
14
  # Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,14 @@ require 'recls/ximpl/' + (Recls::Ximpl::OS::OS_IS_WINDOWS ? 'windows' : 'unix')
41
41
  require 'recls/ximpl/util'
42
42
  require 'recls/flags'
43
43
 
44
+ =begin
45
+ =end
46
+
47
+ class Object; end # :nodoc:
48
+
44
49
  module Recls
45
50
 
51
+ # A file-system entry
46
52
  class Entry
47
53
 
48
54
  private
@@ -90,6 +96,7 @@ module Recls
90
96
  @nlink = @file_stat.nlink if @file_stat
91
97
 
92
98
  if Recls::Ximpl::OS::OS_IS_WINDOWS && @file_stat
99
+
93
100
  @dev = @file_stat.by_handle_information.volume_id
94
101
  @ino = @file_stat.by_handle_information.file_index
95
102
  @nlink = @file_stat.by_handle_information.num_links
@@ -102,26 +109,43 @@ module Recls
102
109
  # ##########################
103
110
  # Name-related attributes
104
111
 
112
+ # (String) A normalised form of #path that can be used in comparisons
105
113
  attr_reader :compare_path
106
114
 
115
+ # (String) The full-path of the instance
107
116
  attr_reader :path
117
+ # (String) The (Windows) short-form of #path, or +nil+ if not on Windows
108
118
  attr_reader :short_path
119
+ # (String) The (Windows) drive. +nil+ if does not exist
109
120
  attr_reader :drive
121
+ # (String) The full path of the entry's directory (taking into account the
122
+ # #drive if on Windows)
110
123
  attr_reader :directory_path
111
124
  alias_method :dirname, :directory_path
125
+ # (String) The entry's directory (excluding the #drive if on Windows)
112
126
  attr_reader :directory
127
+ # ([String]) An array of directory parts, where each part ends in Recls::PATH_NAME_SEPARATOR
113
128
  attr_reader :directory_parts
129
+ # (String) The entry's file name (combination of #stem + #extension)
114
130
  attr_reader :file_full_name
131
+ # (String) The (Windows) short-form of #basename, or +nil+ if not on Windows
115
132
  attr_reader :file_short_name
116
133
  alias_method :basename, :file_full_name
134
+ # (String) The entry's file stem
117
135
  attr_reader :file_name_only
118
136
  alias_method :stem, :file_name_only
137
+ # (String) The entry's file extension
119
138
  attr_reader :file_extension
120
139
  alias_method :extension, :file_extension
140
+ # (String) The search directory if specified; +nil+ otherwise
121
141
  attr_reader :search_directory
142
+ # (String) The #path relative to #search_directory; +nil+ if no search directory specified
122
143
  attr_reader :search_relative_path
144
+ # (String) The #directory relative to #search_directory; +nil+ if no search directory specified
123
145
  attr_reader :search_relative_directory
146
+ # (String) The #directory_path relative to #search_directory; +nil+ if no search directory specified
124
147
  attr_reader :search_relative_directory_path
148
+ # ([String]) The #directory_parts relative to #search_directory; +nil+ if no search directory specified
125
149
  attr_reader :search_relative_directory_parts
126
150
 
127
151
  # ##########################
@@ -157,6 +181,7 @@ module Recls
157
181
 
158
182
  if Recls::Ximpl::OS::OS_IS_WINDOWS
159
183
 
184
+ # [WINDOWS-ONLY] Indicates whether the entry has the *system* bit
160
185
  def system?
161
186
 
162
187
  return false if @file_stat.nil?
@@ -164,6 +189,7 @@ module Recls
164
189
  @file_stat.system?
165
190
  end
166
191
 
192
+ # [WINDOWS-ONLY] Indicates whether the entry has the *archive* bit
167
193
  def archive?
168
194
 
169
195
  return false if @file_stat.nil?
@@ -171,6 +197,7 @@ module Recls
171
197
  @file_stat.archive?
172
198
  end
173
199
 
200
+ # [WINDOWS-ONLY] Indicates whether the entry is a device
174
201
  def device?
175
202
 
176
203
  return false if @file_stat.nil?
@@ -178,6 +205,7 @@ module Recls
178
205
  @file_stat.device?
179
206
  end
180
207
 
208
+ # [WINDOWS-ONLY] Indicates whether the entry is *normal*
181
209
  def normal?
182
210
 
183
211
  return false if @file_stat.nil?
@@ -185,6 +213,7 @@ module Recls
185
213
  @file_stat.normal?
186
214
  end
187
215
 
216
+ # [WINDOWS-ONLY] Indicates whether the entry has the *temporary* bit
188
217
  def temporary?
189
218
 
190
219
  return false if @file_stat.nil?
@@ -192,6 +221,7 @@ module Recls
192
221
  @file_stat.temporary?
193
222
  end
194
223
 
224
+ # [WINDOWS-ONLY] Indicates whether the entry has the *compressed* bit
195
225
  def compressed?
196
226
 
197
227
  return false if @file_stat.nil?
@@ -199,6 +229,7 @@ module Recls
199
229
  @file_stat.compressed?
200
230
  end
201
231
 
232
+ # [WINDOWS-ONLY] Indicates whether the entry has the *encrypted* bit
202
233
  def encrypted?
203
234
 
204
235
  return false if @file_stat.nil?
@@ -355,8 +386,8 @@ module Recls
355
386
 
356
387
  path
357
388
  end
358
- end
359
- end
389
+ end # class Entry
390
+ end # module Recls
360
391
 
361
392
  # ############################## end of file ############################# #
362
393
 
@@ -4,7 +4,7 @@
4
4
  # Purpose: Defines the Recls::FileSearch class for the recls.Ruby library.
5
5
  #
6
6
  # Created: 24th July 2012
7
- # Updated: 21st March 2019
7
+ # Updated: 14th April 2019
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
@@ -40,9 +40,14 @@ require 'recls/entry'
40
40
  require 'recls/flags'
41
41
  require 'recls/ximpl/os'
42
42
 
43
+ =begin
44
+ =end
45
+
46
+ class Object; end # :nodoc:
47
+
43
48
  module Recls
44
49
 
45
- class FileSearch
50
+ class FileSearch # :nodoc: all
46
51
 
47
52
  include Enumerable
48
53
 
@@ -52,20 +57,12 @@ module Recls
52
57
  # === Signature
53
58
  #
54
59
  # * *Parameters:*
55
- # - +search_root+:: (String, Recls::Entry) The root directory of
56
- # the search. May be +nil+, in which case the current directory
57
- # is assumed
58
- # - +patterns+:: (String, Array) The pattern(s) for which to
59
- # search. May be +nil+, in which case +Recls::WILDCARDS_ALL+ is
60
- # assumed
61
- # - +options+:: (Hash, Integer) Combination of flags (with
62
- # behaviour as described below for the +flags+ option), or an
63
- # options hash
60
+ # - +search_root+ (String, Recls::Entry) The root directory of the search. May be +nil+, in which case the current directory is assumed
61
+ # - +patterns+ (String, Array) The pattern(s) for which to search. May be +nil+, in which case +Recls::WILDCARDS_ALL+ is assumed
62
+ # - +options+ (Hash, Integer) Combination of flags (with behaviour as described below for the +flags+ option), or an options hash
64
63
  #
65
64
  # * *Options:*
66
- # - +flags+:: (Integer) Combination of flags - FILES,
67
- # DIRECTORIES, RECURSIVE, etc. If the value modulo TYPEMASK is 0,
68
- # then FILES is assumed
65
+ # - +flags+ (Integer) Combination of flags - FILES, DIRECTORIES, RECURSIVE, etc. If the value modulo TYPEMASK is 0, then FILES is assumed
69
66
  #
70
67
  # === Return
71
68
  # An instance of the class
@@ -133,11 +130,14 @@ module Recls
133
130
  @flags = flags
134
131
  end
135
132
 
133
+ # (String) The search root
136
134
  attr_reader :search_root
135
+ # (String) The search patterns
137
136
  attr_reader :patterns
137
+ # (Integer) The search flags
138
138
  attr_reader :flags
139
139
 
140
- def each(&blk)
140
+ def each(&blk) # :nodoc:
141
141
 
142
142
  search_root = @search_root
143
143
  search_root = Recls::Ximpl::absolute_path search_root
@@ -179,7 +179,7 @@ module Recls
179
179
  end
180
180
 
181
181
  private
182
- def FileSearch::is_dots(name)
182
+ def FileSearch.is_dots(name) # :nodoc:
183
183
 
184
184
  case name
185
185
  when '.', '..'
@@ -189,12 +189,12 @@ module Recls
189
189
  end
190
190
  end
191
191
 
192
- def FileSearch::stat_or_nil_(path, flags)
192
+ def FileSearch.stat_or_nil_(path, flags) # :nodoc:
193
193
 
194
194
  begin
195
195
 
196
196
  Recls::Ximpl::FileStat.stat path
197
- rescue Errno::ENOENT => x
197
+ rescue Errno::ENOENT, Errno::ENXIO
198
198
 
199
199
  nil
200
200
  rescue SystemCallError => x
@@ -217,7 +217,7 @@ module Recls
217
217
  # order to allow calculation of search_relative_path in the
218
218
  # entry.
219
219
 
220
- def FileSearch::search_directory_(search_root, dir, patterns, flags, &blk)
220
+ def FileSearch.search_directory_(search_root, dir, patterns, flags, &blk) # :nodoc:
221
221
 
222
222
  # array of FileStat instances
223
223
  entries = []
@@ -310,8 +310,8 @@ module Recls
310
310
  FileSearch::search_directory_(search_root, fs.path, patterns, flags, &blk)
311
311
  end
312
312
  end
313
- end
314
- end
313
+ end # class FileSearch
314
+ end # module Recls
315
315
 
316
316
  # ############################## end of file ############################# #
317
317
 
@@ -4,11 +4,11 @@
4
4
  # Purpose: Defines the Recls::Flags module for the recls.Ruby library.
5
5
  #
6
6
  # Created: 24th July 2012
7
- # Updated: 27th August 2015
7
+ # Updated: 14th April 2019
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
11
- # Copyright (c) 2012-2015, Matthew Wilson and Synesis Software
11
+ # Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
12
12
  # All rights reserved.
13
13
  #
14
14
  # Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,11 @@
36
36
  # ######################################################################### #
37
37
 
38
38
 
39
+ =begin
40
+ =end
41
+
42
+ class Object; end # :nodoc:
43
+
39
44
  module Recls
40
45
 
41
46
  # Specifies that files are to be listed
@@ -46,32 +51,43 @@ module Recls
46
51
  LINKS = 0x00000004
47
52
  # Specifies that devices are to be listed
48
53
  DEVICES = 0x00000008
54
+ # Type mask (combination of Recls::FILES, Recls::DIRECTORIES, Recls::LINKS, Recls::DEVICES)
49
55
  TYPEMASK = 0x000000ff
50
56
 
51
57
  # Specifies that hidden items are to be shown and hidden directories are
52
58
  # to be searched
53
59
  SHOW_HIDDEN = 0x00000100
54
60
 
61
+ # [IGNORED] This for compatibility with *recls* libraries written in other languages
55
62
  DIR_PROGRESS = 0x00001000
56
63
  # Causes search to terminate if a directory cannot be entered or an
57
64
  # entry's information cannot be stat()'d
58
65
  STOP_ON_ACCESS_FAILURE = 0x00002000
66
+ # [IGNORED] This for compatibility with *recls* libraries written in other languages
59
67
  LINK_COUNT = 0000004000
68
+ # [IGNORED] This for compatibility with *recls* libraries written in other languages
60
69
  NODE_INDEX = 0x00008000
61
70
 
71
+ # Causes search to operate recursively
62
72
  RECURSIVE = 0x00010000
63
73
  private
64
- NO_SEARCH_LINKS = 0x00020000
74
+ NO_SEARCH_LINKS = 0x00020000 # :nodoc:
65
75
  public
76
+ # [IGNORED] In previous versions the Recls::Entry#directory_parts property was not obtained (for performance reasons) unless this flag was specified. In current version the parts are always obtained
66
77
  DIRECTORY_PARTS = 0x00040000
78
+ # Causes operations (such as Recls::stat()) to obtain a result even when
79
+ # no corresponding file-system entity does not exist
67
80
  DETAILS_LATER = 0x00080000
68
81
 
82
+ # Causes the Recls::Entry#path and Recls::Entry#search_relative_path
83
+ # attributes to contain a trailing path-name-separator for directory
84
+ # entries
69
85
  MARK_DIRECTORIES = 0x00200000
70
86
 
71
87
  # Causes sub-directories that are links to be searched; default is not
72
88
  # to search through links
73
89
  SEARCH_THROUGH_LINKS = 0x00100000
74
- end
90
+ end # module Recls
75
91
 
76
92
  # ############################## end of file ############################# #
77
93