path_expander 1.1.3 → 2.0.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: 2eeec1c048574cc4f0d12d4827fd428aad427165599cc9ebfc291a2584410fb5
4
- data.tar.gz: 427e3257b3683f4cceb531579a1451cba3ca64c9877dda8f1b311bebb131880f
3
+ metadata.gz: e36919ef787b530755a0706b85ac1e9718fbe8645ecd544d330b7aa391f7c5b9
4
+ data.tar.gz: adc4bcc85e12d66912486d2c6624f208a0e09d4d0351bf78c0840d960a32a150
5
5
  SHA512:
6
- metadata.gz: 18ee4bd508494c318766fd46dde203281cb6db721d34af35ac123163ee21bf7bef3cabbd3522be440c076280282fdf74f0fd89ca5c4aae684620b9ea12daa164
7
- data.tar.gz: abe9be4d62c6302f93d012d4ea2757c80b2828dd1faee86c9ab99dffe4aeaf7ab7d29ee2330633810cb11a638d33c69b66c12d03a07fd26c1f6c5e543fdb6a1f
6
+ metadata.gz: 44f28957ef37e141489b449064b2e945fc8ce9777b93bd1653cbb506eabdba7ee0fdc4b1c89f837ac0ad3fdd25ff44300b5a7b96411d2f56cfa073a6b8f62bca
7
+ data.tar.gz: 7b97304cc78414ae7d91625538943161d7721b6d3f21d479f88c65b437014432984c3f96bfa4d0e0eca62b195c42db259eedfd02f8a8be52ded96cbabe7fcc70
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,20 @@
1
+ === 2.0.1 / 2026-01-08
2
+
3
+ * 4 bug fixes:
4
+
5
+ * Fix path_expander processing of regexp args on windows.
6
+ * Normalize paths when expanding dirs.
7
+ * Added CI setup from minitest 6.
8
+ * Normalize GHA workflow with minitest and others.
9
+
10
+ === 2.0.0 / 2025-12-11
11
+
12
+ * 3 major enhancements:
13
+
14
+ * Added #pre_process and #post_process and call them from #process.
15
+ * Modified #process to return self if block given, otherwise Enumerator.
16
+ * Modified #process to take a block for processing files directly.
17
+
1
18
  === 1.1.3 / 2024-09-11
2
19
 
3
20
  * 1 bug fix:
data/README.rdoc CHANGED
@@ -36,7 +36,7 @@ PathExpander.
36
36
  end
37
37
  end
38
38
 
39
- MyPathExpander.new(ARGV, my_glob).process.each do |f|
39
+ MyPathExpander.new(ARGV, my_glob).process do |f|
40
40
  # do something with each file
41
41
  end
42
42
 
@@ -46,7 +46,7 @@ PathExpander.
46
46
 
47
47
  == INSTALL:
48
48
 
49
- * sudo gem install path_expander
49
+ * gem install path_expander
50
50
 
51
51
  == LICENSE:
52
52
 
data/Rakefile CHANGED
@@ -6,20 +6,7 @@ require "hoe"
6
6
  Hoe.plugin :isolate
7
7
  Hoe.plugin :seattlerb
8
8
  Hoe.plugin :rdoc
9
-
10
- # Hoe.plugin :compiler
11
- # Hoe.plugin :doofus
12
- # Hoe.plugin :email
13
- # Hoe.plugin :gem_prelude_sucks
14
- # Hoe.plugin :history
15
- # Hoe.plugin :inline
16
- # Hoe.plugin :isolate
17
- # Hoe.plugin :minitest
18
- # Hoe.plugin :perforce
19
- # Hoe.plugin :racc
20
- # Hoe.plugin :rcov
21
- # Hoe.plugin :rdoc
22
- # Hoe.plugin :seattlerb
9
+ Hoe.plugin :cov
23
10
 
24
11
  Hoe.spec "path_expander" do
25
12
  developer "Ryan Davis", "ryand-ruby@zenspider.com"
data/lib/path_expander.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require "pathname" unless defined? Pathname
2
+
1
3
  ##
2
4
  # PathExpander helps pre-process command-line arguments expanding
3
5
  # directories into their constituent files. It further helps by
@@ -13,7 +15,7 @@
13
15
  # PathExpander.
14
16
 
15
17
  class PathExpander
16
- VERSION = "1.1.3" # :nodoc:
18
+ VERSION = "2.0.1" # :nodoc:
17
19
 
18
20
  ##
19
21
  # The args array to process.
@@ -55,9 +57,11 @@ class PathExpander
55
57
  else
56
58
  p
57
59
  end
58
- }.flatten.sort.map { |s| s.to_s.delete_prefix "./" }
60
+ }.flatten.sort.map { |s| _normalize s }
59
61
  end
60
62
 
63
+ def _normalize(f) = Pathname.new(f).cleanpath.to_s # :nodoc:
64
+
61
65
  ##
62
66
  # Process a file into more arguments. Override this to add
63
67
  # additional capabilities.
@@ -92,6 +96,8 @@ class PathExpander
92
96
  flags = []
93
97
  clean = true
94
98
 
99
+ root_dir = File.expand_path "/" # needed for windows paths
100
+
95
101
  args.each do |arg|
96
102
  case arg
97
103
  when /^@(.*)/ then # push back on, so they can have dirs/-/@ as well
@@ -107,7 +113,7 @@ class PathExpander
107
113
  flags << arg
108
114
  end
109
115
  else
110
- root_path = File.expand_path(arg) == "/" # eg: -n /./
116
+ root_path = File.expand_path(arg) == root_dir # eg: -n /./
111
117
  if File.exist? arg and not root_path then
112
118
  clean = false
113
119
  pos_files += expand_dirs_to_files(arg)
@@ -135,22 +141,43 @@ class PathExpander
135
141
  end
136
142
 
137
143
  ##
138
- # Top-level method processes args. It replaces args' contents with a
139
- # new array of flags to process and returns a list of files to
140
- # process. Eg
144
+ # Top-level method processes args. If no block is given, immediately
145
+ # returns with an Enumerator for further chaining.
141
146
  #
142
- # PathExpander.new(ARGV).process.each do |f|
147
+ # Otherwise, it calls +pre_process+, +process_args+ and
148
+ # +process_flags+, enumerates over the files, and then calls
149
+ # +post_process+, returning self for any further chaining.
150
+ #
151
+ # Most of the time, you're going to provide a block to process files
152
+ # and do nothing more with the result. Eg:
153
+ #
154
+ # PathExpander.new(ARGV).process do |f|
143
155
  # puts "./#{f}"
144
156
  # end
157
+ #
158
+ # or:
159
+ #
160
+ # PathExpander.new(ARGV).process # => Enumerator
161
+
162
+ def process(&b)
163
+ return enum_for(:process) unless block_given?
164
+
165
+ pre_process
145
166
 
146
- def process
147
167
  files, flags = process_args
148
168
 
149
169
  args.replace process_flags flags
150
170
 
151
- files.uniq
171
+ files.uniq.each(&b)
172
+
173
+ post_process
174
+
175
+ self
152
176
  end
153
177
 
178
+ def pre_process = nil
179
+ def post_process = nil
180
+
154
181
  ##
155
182
  # A file filter mechanism similar to, but not as extensive as,
156
183
  # .gitignore files:
@@ -89,12 +89,33 @@ class TestPathExpander < Minitest::Test
89
89
  assert_filter_files_absolute_paths miss_absolute, "nope"
90
90
  end
91
91
 
92
+ def test_filter_files__ignore_file
93
+ files = expander.expand_dirs_to_files "test"
94
+
95
+ act = expander.filter_files files, "Manifest.txt"
96
+
97
+ assert_equal [], act
98
+ end
99
+
92
100
  def test_process
93
101
  self.args.concat %w[test --seed 42]
94
102
 
95
103
  act = expander.process
96
104
 
97
- assert_equal %w[test/test_bad.rb test/test_path_expander.rb], act
105
+ assert_kind_of Enumerator, act
106
+ assert_equal %w[test/test_bad.rb test/test_path_expander.rb], act.to_a
107
+ assert_equal %w[--seed 42], expander.args
108
+ assert_equal %w[--seed 42], args # affected our original array (eg, ARGV)
109
+ end
110
+
111
+ def test_process__block
112
+ self.args.concat %w[test --seed 42]
113
+
114
+ act = []
115
+ result = expander.process { |x| act << x }
116
+
117
+ assert_same expander, result
118
+ assert_equal %w[test/test_bad.rb test/test_path_expander.rb], act.to_a
98
119
  assert_equal %w[--seed 42], expander.args
99
120
  assert_equal %w[--seed 42], args # affected our original array (eg, ARGV)
100
121
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: path_expander
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
12
11
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
12
+ MIIDPjCCAiagAwIBAgIBCjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
13
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
14
+ GRYDY29tMB4XDTI2MDEwNzAxMDkxNFoXDTI3MDEwNzAxMDkxNFowRTETMBEGA1UE
16
15
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
16
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
17
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +21,14 @@ cert_chain:
22
21
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
22
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
23
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCygvpmncmkiSs9r/Kceo4bBPDszhTv6iBi4LwMReqnFrpNLMOWJw7xi8x+3eL2
26
- XS09ZPNOt2zm70KmFouBMgOysnDY4k2dE8uF6B8JbZOO8QfalW+CoNBliefOTcn2
27
- bg5IOP7UoGM5lC174/cbDJrJnRG9bzig5FAP0mvsgA8zgTRXQzIUAZEo92D5K7p4
28
- B4/O998ho6BSOgYBI9Yk1ttdCtti6Y+8N9+fZESsjtWMykA+WXWeGUScHqiU+gH8
29
- S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
30
- deKfBjgVAq7EYHu1AczzlUly
24
+ AQA/X8/PKTTc/IkYQEUL6XWtfK8fAfbuLJzmLcz6f2ZWrtBvPsYvqRuwI1bWUtil
25
+ 2ibJEfIuSIHX6BsUTX18+hlaIussf6EWq/YkE7e2BKmgQE42vSOZMce0kCEAPbx0
26
+ rQtqonfWTHQ8UbQ7GqCL3gDQ0QDD2B+HUlb4uaCZ2icxqa/eOtxMvHC2tj+h0xKY
27
+ xL84ipM5kr0bHGf9/MRZJWcw51urueNycBXu1Xh+pEN8qBmYsFRR4SIODLClybAO
28
+ 6cbm2PyPQgKNiqE4H+IQrDVHd9bJs1XgLElk3qoaJBWXc/5fy0J1imYb25UqmiHG
29
+ snGe1hrppvBRdcyEzvhfIPjI
31
30
  -----END CERTIFICATE-----
32
- date: 2024-09-11 00:00:00.000000000 Z
31
+ date: 1980-01-02 00:00:00.000000000 Z
33
32
  dependencies:
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: rdoc
@@ -37,34 +36,48 @@ dependencies:
37
36
  requirements:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '4.0'
39
+ version: '6.0'
41
40
  - - "<"
42
41
  - !ruby/object:Gem::Version
43
- version: '7'
42
+ version: '8'
44
43
  type: :development
45
44
  prerelease: false
46
45
  version_requirements: !ruby/object:Gem::Requirement
47
46
  requirements:
48
47
  - - ">="
49
48
  - !ruby/object:Gem::Version
50
- version: '4.0'
49
+ version: '6.0'
51
50
  - - "<"
52
51
  - !ruby/object:Gem::Version
53
- version: '7'
52
+ version: '8'
53
+ - !ruby/object:Gem::Dependency
54
+ name: simplecov
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.21'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.21'
54
67
  - !ruby/object:Gem::Dependency
55
68
  name: hoe
56
69
  requirement: !ruby/object:Gem::Requirement
57
70
  requirements:
58
71
  - - "~>"
59
72
  - !ruby/object:Gem::Version
60
- version: '4.2'
73
+ version: '4.5'
61
74
  type: :development
62
75
  prerelease: false
63
76
  version_requirements: !ruby/object:Gem::Requirement
64
77
  requirements:
65
78
  - - "~>"
66
79
  - !ruby/object:Gem::Version
67
- version: '4.2'
80
+ version: '4.5'
68
81
  description: |-
69
82
  PathExpander helps pre-process command-line arguments expanding
70
83
  directories into their constituent files. It further helps by
@@ -101,7 +114,6 @@ licenses:
101
114
  - MIT
102
115
  metadata:
103
116
  homepage_uri: https://github.com/seattlerb/path_expander
104
- post_install_message:
105
117
  rdoc_options:
106
118
  - "--main"
107
119
  - README.rdoc
@@ -118,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
130
  - !ruby/object:Gem::Version
119
131
  version: '0'
120
132
  requirements: []
121
- rubygems_version: 3.5.18
122
- signing_key:
133
+ rubygems_version: 3.7.2
123
134
  specification_version: 4
124
135
  summary: PathExpander helps pre-process command-line arguments expanding directories
125
136
  into their constituent files
metadata.gz.sig CHANGED
Binary file