path_expander 1.0.4 → 1.1.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
  SHA256:
3
- metadata.gz: ed120692b50f83bb61e393ffc35e08a49bb71dfda9249fea4f6ec1bc61e5ee3a
4
- data.tar.gz: c9c2a465c122a03011eb2484b95fab74d9074c4f84b6018571ec856a35dc28bd
3
+ metadata.gz: 95157151cd3523ba3bcd9ca1668dbfa436e87b9dfabb3431ca218ea66571c436
4
+ data.tar.gz: b0714ed15b27ae4b4dc16f1f87ec20dd2732299ffbadff80b9e51ba004855ef6
5
5
  SHA512:
6
- metadata.gz: ea6b7c3be8e65bc0ee3b88f2f036fafddd91181cb5a2e166695b503ad40d4aea40bf1ed14b3bb668bd13696702d0643a5d3bcfad6a0abef0823e0c8125a9b758
7
- data.tar.gz: de812b35a9e648cb2f3ca4e64da9007f4c2ad1f4dcf2b89e27d2c9c5f27cd8115c19e1d1b8b94023801a76c0ab0e26642dced689884a34df8cecd8b6680b3ae9
6
+ metadata.gz: c53f545816dc9c6341c1bddfede9b4ef137e64100dd4883df1ee7bf81d4df2adf91f78fabfa2ce431d1f85c03d65941dadd6e1e8b50de6f27ab9a63724da1398
7
+ data.tar.gz: 017eb994f9a635e8b780d326a364cae4fc82fd3852cd792c8819ccb9550539b14f49fc01a68b076a7fb367a7e6020099b7dfb9d6f5134cc33cb464ea13fabf9d
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,21 @@
1
+ === 1.1.1 / 2022-07-03
2
+
3
+ * 1 bug fix:
4
+
5
+ * Process plain '-' as a file, not an option.
6
+
7
+ === 1.1.0 / 2019-09-22
8
+
9
+ * 1 minor enhancement:
10
+
11
+ * Added a default path (default: ".") to scan if no files are initially found.
12
+
13
+ === 1.0.5 / 2019-09-14
14
+
15
+ * 1 bug fix:
16
+
17
+ * Fixed a deprecation warning from File.exists?
18
+
1
19
  === 1.0.4 / 2019-05-26
2
20
 
3
21
  * 1 bug fix:
@@ -27,4 +45,3 @@
27
45
  * 1 major enhancement
28
46
 
29
47
  * Birthday!
30
-
data/lib/path_expander.rb CHANGED
@@ -13,7 +13,7 @@
13
13
  # PathExpander.
14
14
 
15
15
  class PathExpander
16
- VERSION = "1.0.4" # :nodoc:
16
+ VERSION = "1.1.1" # :nodoc:
17
17
 
18
18
  ##
19
19
  # The args array to process.
@@ -25,13 +25,20 @@ class PathExpander
25
25
 
26
26
  attr_accessor :glob
27
27
 
28
+ ##
29
+ # The path to scan if no paths are found in the initial scan.
30
+
31
+ attr_accessor :path
32
+
28
33
  ##
29
34
  # Create a new path expander that operates on args and expands via
30
- # glob as necessary.
35
+ # glob as necessary. Takes an optional +path+ arg to fall back on if
36
+ # no paths are found on the initial scan (see #process_args).
31
37
 
32
- def initialize args, glob
38
+ def initialize args, glob, path = "."
33
39
  self.args = args
34
40
  self.glob = glob
41
+ self.path = path
35
42
  end
36
43
 
37
44
  ##
@@ -67,22 +74,32 @@ class PathExpander
67
74
  # -not_a_path :: Add to flags to be processed.
68
75
  # dir_path :: Expand and add to files to be processed.
69
76
  # file_path :: Add to files to be processed.
77
+ # - :: Add "-" (stdin) to files to be processed.
70
78
  #
71
79
  # See expand_dirs_to_files for details on how expansion occurs.
72
80
  #
73
81
  # Subtraction happens last, regardless of argument ordering.
82
+ #
83
+ # If no files are found (which is not the same as having an empty
84
+ # file list after subtraction), then fall back to expanding on the
85
+ # default #path given to initialize.
74
86
 
75
87
  def process_args
76
88
  pos_files = []
77
89
  neg_files = []
78
90
  flags = []
91
+ clean = true
79
92
 
80
93
  args.each do |arg|
81
94
  case arg
82
95
  when /^@(.*)/ then # push back on, so they can have dirs/-/@ as well
96
+ clean = false
83
97
  args.concat process_file $1
98
+ when "-" then
99
+ pos_files << arg
84
100
  when /^-(.*)/ then
85
101
  if File.exist? $1 then
102
+ clean = false
86
103
  neg_files += expand_dirs_to_files($1)
87
104
  else
88
105
  flags << arg
@@ -90,6 +107,7 @@ class PathExpander
90
107
  else
91
108
  root_path = File.expand_path(arg) == "/" # eg: -n /./
92
109
  if File.exist? arg and not root_path then
110
+ clean = false
93
111
  pos_files += expand_dirs_to_files(arg)
94
112
  else
95
113
  flags << arg
@@ -97,7 +115,10 @@ class PathExpander
97
115
  end
98
116
  end
99
117
 
100
- [pos_files - neg_files, flags]
118
+ files = pos_files - neg_files
119
+ files += expand_dirs_to_files(self.path) if files.empty? && clean
120
+
121
+ [files, flags]
101
122
  end
102
123
 
103
124
  ##
@@ -144,7 +165,7 @@ class PathExpander
144
165
  def filter_files files, ignore
145
166
  ignore_paths = if ignore.respond_to? :read then
146
167
  ignore.read
147
- elsif File.exists? ignore then
168
+ elsif File.exist? ignore then
148
169
  File.read ignore
149
170
  end
150
171
 
@@ -24,7 +24,7 @@ class TestPathExpander < Minitest::Test
24
24
  def assert_process_args exp_files, exp_args, *args
25
25
  expander.args.concat args
26
26
 
27
- assert_equal [exp_files, exp_args], expander.process_args
27
+ assert_equal [exp_files.sort, exp_args], expander.process_args
28
28
  end
29
29
 
30
30
  def test_expand_dirs_to_files
@@ -157,6 +157,20 @@ class TestPathExpander < Minitest::Test
157
157
  "/./")
158
158
  end
159
159
 
160
+ def test_process_args_no_files
161
+ self.expander = PathExpander.new args, "*.rb", "test" # extra test default
162
+
163
+ assert_process_args(%w[test/test_bad.rb test/test_path_expander.rb],
164
+ %w[-v],
165
+ "-v")
166
+ end
167
+
168
+ def test_process_args_dash
169
+ assert_process_args(%w[-],
170
+ %w[-v],
171
+ "-", "-v")
172
+ end
173
+
160
174
  def test_process_flags
161
175
  exp = %w[a b c]
162
176
  act = expander.process_flags %w[a b c]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: path_expander
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE4MTIwNDIxMzAxNFoXDTE5MTIwNDIxMzAxNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCbJwLmpJR2PomLU+Zzw3KRzH/hbyUWc/ftru71AopZ1fy4iY9J/BW5QYKVYwbP
26
- V0FSBWtvfI/RdwfKGtuGhPKECZgmLieGuZ3XCc09qPu1bdg7i/tu1p0t0c6163ku
27
- nDMDIC/t/DAFK0TY9I3HswuyZGbLW7rgF0DmiuZdN/RPhHq2pOLMLXJmFclCb/im
28
- 9yToml/06TJdUJ5p64mkBs0TzaK66DIB1Smd3PdtfZqoRV+EwaXMdx0Hb3zdR1JR
29
- Em82dBUFsipwMLCYj39kcyHWAxyl6Ae1Cn9r/ItVBCxoeFdrHjfavnrIEoXUt4bU
30
- UfBugfLD19bu3nvL+zTAGx/U
25
+ AQCKB5jfsuSnKb+t/Wrh3UpdkmX7TrEsjVmERC0pPqzQ5GQJgmEXDD7oMgaKXaAq
26
+ x2m+KSZDrqk7c8uho5OX6YMqg4KdxehfSLqqTZGoeV78qwf/jpPQZKTf+W9gUSJh
27
+ zsWpo4K50MP+QtdSbKXZwjAafpQ8hK0MnnZ/aeCsW9ov5vdXpYbf3dpg6ADXRGE7
28
+ lQY2y1tJ5/chqu6h7dQmnm2ABUqx9O+JcN9hbCYoA5i/EeubUEtFIh2w3SpO6YfB
29
+ JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
30
+ YsuyUzsMz6GQA4khyaMgKNSD
31
31
  -----END CERTIFICATE-----
32
- date: 2019-05-26 00:00:00.000000000 Z
32
+ date: 2022-07-04 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '3.17'
60
+ version: '3.24'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.17'
67
+ version: '3.24'
68
68
  description: |-
69
69
  PathExpander helps pre-process command-line arguments expanding
70
70
  directories into their constituent files. It further helps by
@@ -99,8 +99,9 @@ files:
99
99
  homepage: https://github.com/seattlerb/path_expander
100
100
  licenses:
101
101
  - MIT
102
- metadata: {}
103
- post_install_message:
102
+ metadata:
103
+ homepage_uri: https://github.com/seattlerb/path_expander
104
+ post_install_message:
104
105
  rdoc_options:
105
106
  - "--main"
106
107
  - README.rdoc
@@ -117,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  - !ruby/object:Gem::Version
118
119
  version: '0'
119
120
  requirements: []
120
- rubygems_version: 3.0.2
121
- signing_key:
121
+ rubygems_version: 3.3.12
122
+ signing_key:
122
123
  specification_version: 4
123
124
  summary: PathExpander helps pre-process command-line arguments expanding directories
124
125
  into their constituent files
metadata.gz.sig CHANGED
Binary file