path_expander 1.1.3 → 2.0.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
2
  SHA256:
3
- metadata.gz: 2eeec1c048574cc4f0d12d4827fd428aad427165599cc9ebfc291a2584410fb5
4
- data.tar.gz: 427e3257b3683f4cceb531579a1451cba3ca64c9877dda8f1b311bebb131880f
3
+ metadata.gz: a8529b4f928a7169c1f791a8e30a721314ce449671340ec99368930915b1ea8f
4
+ data.tar.gz: 6ce9afc38678370b5ece8b7500749b24491be92911d378904bd608fa710e9ddb
5
5
  SHA512:
6
- metadata.gz: 18ee4bd508494c318766fd46dde203281cb6db721d34af35ac123163ee21bf7bef3cabbd3522be440c076280282fdf74f0fd89ca5c4aae684620b9ea12daa164
7
- data.tar.gz: abe9be4d62c6302f93d012d4ea2757c80b2828dd1faee86c9ab99dffe4aeaf7ab7d29ee2330633810cb11a638d33c69b66c12d03a07fd26c1f6c5e543fdb6a1f
6
+ metadata.gz: ea6fddb1ebe0e11bc152e2c73571d06b5609eacfe2b52ebf4e47d245c48aef096b6dfb8ddf16f2506daa89e98d3096eace1f586130714a2ebf5e74f5beefa038
7
+ data.tar.gz: 629edc765830f790ba10263dfcf77af4777926f986f8095c06b38ef624e5f9740e6c9e27ebe31704690fb56be1d90000bd37aa180cca8c36c9da29438f518ff8
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ === 2.0.0 / 2025-12-11
2
+
3
+ * 3 major enhancements:
4
+
5
+ * Added #pre_process and #post_process and call them from #process.
6
+ * Modified #process to return self if block given, otherwise Enumerator.
7
+ * Modified #process to take a block for processing files directly.
8
+
1
9
  === 1.1.3 / 2024-09-11
2
10
 
3
11
  * 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
@@ -13,7 +13,7 @@
13
13
  # PathExpander.
14
14
 
15
15
  class PathExpander
16
- VERSION = "1.1.3" # :nodoc:
16
+ VERSION = "2.0.0" # :nodoc:
17
17
 
18
18
  ##
19
19
  # The args array to process.
@@ -135,22 +135,43 @@ class PathExpander
135
135
  end
136
136
 
137
137
  ##
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
138
+ # Top-level method processes args. If no block is given, immediately
139
+ # returns with an Enumerator for further chaining.
141
140
  #
142
- # PathExpander.new(ARGV).process.each do |f|
141
+ # Otherwise, it calls +pre_process+, +process_args+ and
142
+ # +process_flags+, enumerates over the files, and then calls
143
+ # +post_process+, returning self for any further chaining.
144
+ #
145
+ # Most of the time, you're going to provide a block to process files
146
+ # and do nothing more with the result. Eg:
147
+ #
148
+ # PathExpander.new(ARGV).process do |f|
143
149
  # puts "./#{f}"
144
150
  # end
151
+ #
152
+ # or:
153
+ #
154
+ # PathExpander.new(ARGV).process # => Enumerator
155
+
156
+ def process(&b)
157
+ return enum_for(:process) unless block_given?
158
+
159
+ pre_process
145
160
 
146
- def process
147
161
  files, flags = process_args
148
162
 
149
163
  args.replace process_flags flags
150
164
 
151
- files.uniq
165
+ files.uniq.each(&b)
166
+
167
+ post_process
168
+
169
+ self
152
170
  end
153
171
 
172
+ def pre_process = nil
173
+ def post_process = nil
174
+
154
175
  ##
155
176
  # A file filter mechanism similar to, but not as extensive as,
156
177
  # .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.0
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
+ MIIDPjCCAiagAwIBAgIBCTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
13
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
14
+ GRYDY29tMB4XDTI1MDEwNjIzMjcwMVoXDTI2MDEwNjIzMjcwMVowRTETMBEGA1UE
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
+ AQAC0WQJcPOWPFwkojhzweilRVjTJ19UiLhiBTw3C1wJO3LVdBkWDmnnhAmKuX4D
25
+ r7vjQvESlABGIPdutI1Yl7mrHQzTkfLfXvNN6MT0nLChPyIYauT6SZZxubwJrUfA
26
+ 7R0c2CJTIboZ0XaGpLsXqHEF1c29H7TV1QvVuqKAN2mCjh4N82QVn+ZKtys28AwT
27
+ 6GfQX2fqLoi4KSc7xIzHKaNzqxeOICmJofk9w5VZ2rRN6yes8jvFYwz9HR41wdj8
28
+ bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
29
+ al9oSgPPHICMEX65qvLywitx
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
@@ -51,20 +50,34 @@ dependencies:
51
50
  - - "<"
52
51
  - !ruby/object:Gem::Version
53
52
  version: '7'
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.3'
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.3'
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