Module: RDist::TargetFileFinder
- Defined in:
- lib/rdist/targetfilefinder.rb
Constant Summary collapse
- PATTERN_HIDDEN =
%r/ \A \. [^\.] # pattern to accept parent directory: ``..'' /nxm
- EXTNAME_RUBY_CODE =
'.rb'.freeze
- EXTNAME_RUBY_EXEC_CODE =
'.rbw'.freeze
- PATTERN_TEST_CODE =
/(?:\A test_ | _spec \z)/nxm.freeze
Class Method Summary collapse
- .find(argv) ⇒ Object
- .hidden?(path) ⇒ Boolean
- .ruby_code?(path) ⇒ Boolean
- .test_code?(path) ⇒ Boolean
Class Method Details
.find(argv) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rdist/targetfilefinder.rb', line 6 def find(argv) Find.find(*argv) do |path| if FileTest.directory?(path) Find.prune if hidden?(path) next end next if hidden?(path) next unless ruby_code?(path) next if test_code?(path) yield path end end |
.hidden?(path) ⇒ Boolean
24 25 26 |
# File 'lib/rdist/targetfilefinder.rb', line 24 def hidden?(path) PATTERN_HIDDEN =~ File.basename(path) end |
.ruby_code?(path) ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/rdist/targetfilefinder.rb', line 30 def ruby_code?(path) case File.extname(path) when EXTNAME_RUBY_CODE, EXTNAME_RUBY_EXEC_CODE then true else false end end |
.test_code?(path) ⇒ Boolean
39 40 41 |
# File 'lib/rdist/targetfilefinder.rb', line 39 def test_code?(path) PATTERN_TEST_CODE =~ File.basename(path) end |