recls-ruby 2.6.4 → 2.7.1

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
2
  SHA1:
3
- metadata.gz: 518087f6042cc31fe5d05f724d0f16e00d7192fa
4
- data.tar.gz: e480c2ce6cf0aab32dc5ab01a1797c6c5fa275c4
3
+ metadata.gz: ea5f4b792cc0f8882a7a4e9779fd32fb2ce231cd
4
+ data.tar.gz: 98f5d6b1cae89e306aa303c5e383a2951d7ff09f
5
5
  SHA512:
6
- metadata.gz: 20fd43b0fff86081eb62e1ea43d889c45bfe0c9add816b70e9d62a568ba2203af551cdaeecbb221bb2d15939a1e31d072f3c4d8f0a4c9a0c86c8cac5bba1ad76
7
- data.tar.gz: baa78f624be64f88e3ca5bbc2ec689ac23c7d907bd4ac1dba793816c3d978f70d30891089bf99661c689284093dfde6842640aac5211a1578646573d7baf597e
6
+ metadata.gz: b403a936e24d295db49df5eae668953325af07df610655858eeb98e61cdf9dca4927354b3b35012e1a7088a8057a1a4f2431a16291bfb88e2acfb3a537b4ce42
7
+ data.tar.gz: 2f79d4ba659fe1484f74ba0a23653f41fb7aa6e298596e026fe3eebc1b831058d9408b0fd78561192a52dfd1ca114e42ff2f776aa751ef3fc2f974b5898183b6
data/README.md CHANGED
@@ -1,2 +1,28 @@
1
1
  # recls.Ruby
2
2
  recls for Ruby
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/recls-ruby.svg)](https://badge.fury.io/rb/recls-ruby)
5
+
6
+ ## Installation & usage
7
+
8
+ Install using `gem install recls-ruby` or add it to your `Gemfile`.
9
+
10
+ ## Description
11
+
12
+ TODO
13
+
14
+ ## Where to get help
15
+
16
+ [GitHub Page](https://github.com/synesissoftware/recls.Ruby "GitHub Page")
17
+
18
+ ## Contribution guidelines
19
+
20
+ Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/recls.Ruby.
21
+
22
+ ## Related projects
23
+
24
+ **recls.Ruby** is used in the **[libCLImate.Ruby](https://github.com/synesissoftware/libCLImate.Ruby)** library.
25
+
26
+ ## License
27
+
28
+ **recls.Ruby** is released under the 3-clause BSD license. See LICENSE for details.
@@ -0,0 +1,51 @@
1
+ # ######################################################################### #
2
+ # File: recls/api.rb
3
+ #
4
+ # Purpose: Defines Recls module search functions
5
+ #
6
+ # Created: 9th June 2016
7
+ # Updated: 9th June 2016
8
+ #
9
+ # Author: Matthew Wilson
10
+ #
11
+ # Copyright (c) 2016, Matthew Wilson and Synesis Software
12
+ # All rights reserved.
13
+ #
14
+ # Redistribution and use in source and binary forms, with or without
15
+ # modification, are permitted provided that the following conditions are met:
16
+ #
17
+ # * Redistributions of source code must retain the above copyright notice,
18
+ # this list of conditions and the following disclaimer.
19
+ #
20
+ # * Redistributions in binary form must reproduce the above copyright notice,
21
+ # this list of conditions and the following disclaimer in the documentation
22
+ # and/or other materials provided with the distribution.
23
+ #
24
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
+ # POSSIBILITY OF SUCH DAMAGE.
35
+ #
36
+ # ######################################################################### #
37
+
38
+
39
+ require 'recls/file_search'
40
+
41
+ module Recls
42
+
43
+ def self.FileSearch(search_root, patterns, options = {})
44
+
45
+ Recls::FileSearch.new(search_root, patterns, options)
46
+ end
47
+ end
48
+
49
+ # ############################## end of file ############################# #
50
+
51
+
@@ -1,10 +1,10 @@
1
1
  # ######################################################################### #
2
- # File: recls/filesearch.rb
2
+ # File: recls/file_search.rb
3
3
  #
4
4
  # Purpose: Defines the Recls::FileSearch class for the recls.Ruby library.
5
5
  #
6
6
  # Created: 24th July 2012
7
- # Updated: 29th December 2015
7
+ # Updated: 13th June 2016
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
@@ -46,11 +46,35 @@ module Recls
46
46
 
47
47
  include Enumerable
48
48
 
49
- def initialize(search_root, patterns, flags)
49
+ def initialize(search_root, patterns, options={})
50
+
51
+ # for backwards compatibility, we allow for options to
52
+ # be a number
53
+
54
+ flags = 0
55
+
56
+ case options
57
+ when ::NilClass
58
+
59
+ options = { flags: 0 }
60
+ when ::Integer
61
+
62
+ flags = options
63
+ options = { flags: flags }
64
+ when ::Hash
65
+
66
+ flags = options[:flags] || 0
67
+ else
68
+
69
+ raise ArgumentError, "options parameter must a #{::Hash}, nil, or an integer specifying flags - an instance of #{options.class} given"
70
+ end
71
+
50
72
 
51
73
  if not search_root
74
+
52
75
  search_root = '.'
53
76
  else
77
+
54
78
  search_root = search_root.to_s
55
79
  end
56
80
  search_root = '.' if search_root.empty?
@@ -58,17 +82,21 @@ module Recls
58
82
 
59
83
  case patterns
60
84
  when NilClass
85
+
61
86
  patterns = []
62
87
  when String
88
+
63
89
  patterns = patterns.split(/[|#{Recls::Ximpl::OS::PATH_SEPARATOR}]/)
64
90
  when Array
65
91
  else
92
+
66
93
  patterns = patterns.to_a
67
94
  end
68
95
 
69
96
  patterns = [ Recls::WILDCARDS_ALL ] if patterns.empty?
70
97
 
71
98
  if(0 == (Recls::TYPEMASK & flags))
99
+
72
100
  flags |= Recls::FILES
73
101
  end
74
102
 
@@ -98,12 +126,15 @@ module Recls
98
126
  flags = @flags
99
127
 
100
128
  if(Recls::Ximpl::OS::OS_IS_WINDOWS)
129
+
101
130
  mask = (Recls::FILES | Recls::DIRECTORIES)
102
131
  else
132
+
103
133
  mask = (Recls::FILES | Recls::DIRECTORIES | Recls::LINKS | Recls::DEVICES)
104
134
  end
105
135
 
106
136
  if(mask == (mask & flags))
137
+
107
138
  flags = flags & ~Recls::TYPEMASK
108
139
  end
109
140
 
@@ -137,13 +168,17 @@ module Recls
137
168
  def FileSearch::stat_or_nil_(path, flags)
138
169
 
139
170
  begin
171
+
140
172
  Recls::Ximpl::FileStat.stat path
141
173
  rescue Errno::ENOENT => x
174
+
142
175
  nil
143
176
  rescue SystemCallError => x
177
+
144
178
  # TODO this should be filtered up and/or logged
145
179
 
146
180
  if(0 != (STOP_ON_ACCESS_FAILURE & flags))
181
+
147
182
  raise
148
183
  end
149
184
 
@@ -170,6 +205,7 @@ module Recls
170
205
  next if is_dots(name)
171
206
 
172
207
  if not name =~ /^#{pattern}$/
208
+
173
209
  next
174
210
  end
175
211
 
@@ -207,7 +243,9 @@ module Recls
207
243
  next if not fs
208
244
 
209
245
  if(0 == (Recls::SHOW_HIDDEN & flags))
246
+
210
247
  if fs.hidden?
248
+
211
249
  next
212
250
  end
213
251
  end
@@ -230,13 +268,17 @@ module Recls
230
268
  subdirectories.each do |fs|
231
269
 
232
270
  if(0 == (Recls::SHOW_HIDDEN & flags))
271
+
233
272
  if fs.hidden?
273
+
234
274
  next
235
275
  end
236
276
  end
237
277
 
238
278
  if(0 == (Recls::SEARCH_THROUGH_LINKS & flags))
279
+
239
280
  if File.symlink? fs.path
281
+
240
282
  next
241
283
  end
242
284
  end
@@ -4,11 +4,11 @@
4
4
  # Purpose: Definition of Recls::foreach() utility function
5
5
  #
6
6
  # Created: 22nd October 2014
7
- # Updated: 27th August 2015
7
+ # Updated: 9th June 2016
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
11
- # Copyright (c) 2012-2015, Matthew Wilson and Synesis Software
11
+ # Copyright (c) 2012-2016, 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,7 +36,7 @@
36
36
  # ######################################################################### #
37
37
 
38
38
 
39
- require 'recls/filesearch'
39
+ require 'recls/file_search'
40
40
 
41
41
  module Recls
42
42
 
@@ -4,7 +4,7 @@
4
4
  # Purpose: Main source file for recls library
5
5
  #
6
6
  # Created: 19th July 2012
7
- # Updated: 29th December 2015
7
+ # Updated: 9th June 2016
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
@@ -38,7 +38,8 @@
38
38
 
39
39
  require 'recls/version'
40
40
 
41
- require 'recls/filesearch'
41
+ require 'recls/api'
42
+ require 'recls/file_search'
42
43
  require 'recls/foreach'
43
44
  require 'recls/stat'
44
45
  require 'recls/util'
@@ -4,7 +4,7 @@
4
4
  # Purpose: Version for recls library
5
5
  #
6
6
  # Created: 14th February 2014
7
- # Updated: 31st May 2016
7
+ # Updated: 9th June 2016
8
8
  #
9
9
  # Author: Matthew Wilson
10
10
  #
@@ -39,7 +39,7 @@
39
39
  module Recls
40
40
 
41
41
  # Current version of the recls.Ruby library
42
- VERSION = '2.6.4'
42
+ VERSION = '2.7.1'
43
43
 
44
44
  private
45
45
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -6,23 +6,29 @@ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
6
 
7
7
  require 'recls'
8
8
 
9
- Recls::FileSearch.new(nil, nil, Recls::FILES | Recls::RECURSIVE).each do |fe|
9
+ root_dir = '.'
10
+ patterns = Recls::WILDCARDS_ALL
11
+
12
+ Recls::FileSearch.new(root_dir, patterns, Recls::FILES | Recls::RECURSIVE).each do |fe|
13
+
14
+ drive = fe.drive || ''
10
15
 
11
16
  puts
17
+ puts "entry:"
12
18
  puts fe.path
13
19
  puts fe.short_path
14
20
  puts fe.directory_path
15
- puts fe.drive
16
- puts "".ljust(fe.drive.size) + fe.directory
21
+ puts drive
22
+ puts "".ljust(drive ? drive.size : 0) + fe.directory
17
23
  puts "".ljust(fe.directory_path.size) + fe.file
18
- puts "".ljust(fe.directory_path.size) + fe.file_short_name
24
+ puts "".ljust(fe.directory_path.size) + "#{fe.file_short_name}"
19
25
  puts "".ljust(fe.directory_path.size) + fe.stem
20
26
  puts "".ljust(fe.directory_path.size + fe.stem.size) + fe.extension
21
- n = fe.drive.size
27
+ n = drive.size
22
28
  fe.directory_parts.each do |part|
23
29
 
24
- puts "".ljust(n) + part
25
- n += part.size
30
+ puts "".ljust(n) + part
31
+ n += part.size
26
32
  end
27
33
 
28
34
  puts fe.search_directory
@@ -33,8 +39,8 @@ Recls::FileSearch.new(nil, nil, Recls::FILES | Recls::RECURSIVE).each do |fe|
33
39
  n = fe.search_directory.size
34
40
  fe.search_relative_directory_parts.each do |part|
35
41
 
36
- puts "".ljust(n) + part
37
- n += part.size
42
+ puts "".ljust(n) + part
43
+ n += part.size
38
44
  end
39
45
  end
40
46
 
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby
2
+
3
+ #############################################################################
4
+ # File: ./test/scratch/test_files_and_directories.rb
5
+ #
6
+ # Purpose: COMPLETE_ME
7
+ #
8
+ # Created: 09 06 2016
9
+ # Updated: 09 06 2016
10
+ #
11
+ # Author: Matthew Wilson
12
+ #
13
+ # Copyright: <<TBD>>
14
+ #
15
+ #############################################################################
16
+
17
+ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
18
+
19
+ require 'recls'
20
+
21
+ Recls::FileSearch.new(nil, nil, Recls::FILES | Recls::DIRECTORIES | Recls::RECURSIVE).each do |fe|
22
+
23
+ path = fe.search_relative_path
24
+
25
+ if fe.directory?
26
+
27
+ puts path + '/'
28
+ else
29
+
30
+ puts path
31
+ end
32
+ end
33
+
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # test Recls entry methods
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
+
7
+ require 'recls'
8
+
9
+ root_dir = '.'
10
+ patterns = Recls::WILDCARDS_ALL
11
+
12
+ Recls.FileSearch(root_dir, patterns, flags: Recls::FILES).each do |fe|
13
+
14
+ drive = fe.drive || ''
15
+
16
+ puts
17
+ puts "entry:"
18
+ puts fe.path
19
+ puts fe.short_path
20
+ puts fe.directory_path
21
+ puts drive
22
+ puts "".ljust(drive ? drive.size : 0) + fe.directory
23
+ puts "".ljust(fe.directory_path.size) + fe.file
24
+ puts "".ljust(fe.directory_path.size) + "#{fe.file_short_name}"
25
+ puts "".ljust(fe.directory_path.size) + fe.stem
26
+ puts "".ljust(fe.directory_path.size + fe.stem.size) + fe.extension
27
+ n = drive.size
28
+ fe.directory_parts.each do |part|
29
+
30
+ puts "".ljust(n) + part
31
+ n += part.size
32
+ end
33
+
34
+ puts fe.search_directory
35
+ puts "".ljust(fe.search_directory.size) + fe.search_relative_path
36
+ puts "".ljust(fe.search_directory.size) + fe.search_relative_directory_path
37
+ puts "".ljust(fe.search_directory.size) + fe.search_relative_directory
38
+
39
+ n = fe.search_directory.size
40
+ fe.search_relative_directory_parts.each do |part|
41
+
42
+ puts "".ljust(n) + part
43
+ n += part.size
44
+ end
45
+ end
46
+
@@ -0,0 +1,5 @@
1
+ @echo off
2
+
3
+ echo Executing all ruby tests, each in a separate process:
4
+ for %i in (*.rb) do @ruby "%i"
5
+
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ echo "Executing all ruby tests, each in a separate process:"
4
+ find . -name '*.rb' -depth 1 -exec ruby {} \;
5
+
6
+
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recls-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.4
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-11 00:00:00.000000000 Z
11
+ date: 2016-06-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |2+
14
-
13
+ description: |
14
+ RECursive LS for Ruby
15
15
  email: matthew@recls.org
16
16
  executables: []
17
17
  extensions: []
@@ -22,8 +22,9 @@ files:
22
22
  - examples/show_hidden_files.rb
23
23
  - examples/show_readonly_files.rb
24
24
  - lib/recls.rb
25
+ - lib/recls/api.rb
25
26
  - lib/recls/entry.rb
26
- - lib/recls/filesearch.rb
27
+ - lib/recls/file_search.rb
27
28
  - lib/recls/flags.rb
28
29
  - lib/recls/foreach.rb
29
30
  - lib/recls/recls.rb
@@ -36,7 +37,9 @@ files:
36
37
  - lib/recls/ximpl/windows.rb
37
38
  - test/scratch/test_display_parts.rb
38
39
  - test/scratch/test_entry.rb
40
+ - test/scratch/test_files_and_directories.rb
39
41
  - test/scratch/test_foreach.rb
42
+ - test/scratch/test_module_function.rb
40
43
  - test/scratch/test_show_dev_and_ino.rb
41
44
  - test/scratch/test_show_hidden.rb
42
45
  - test/unit/tc_recls_entries.rb
@@ -45,6 +48,8 @@ files:
45
48
  - test/unit/tc_recls_module.rb
46
49
  - test/unit/tc_recls_util.rb
47
50
  - test/unit/tc_recls_ximpl_util.rb
51
+ - test/unit/test_all_separately.cmd
52
+ - test/unit/test_all_separately.sh
48
53
  - test/unit/ts_all.rb
49
54
  homepage: http://recls.org/
50
55
  licenses: