Class: Rake::FileTask
Direct Known Subclasses
Buildr::ArchiveTask, Buildr::Artifact, Buildr::BuildfileTask, Buildr::ConcatTask
Instance Method Summary collapse
-
#contain?(*patterns) ⇒ Boolean
:call-seq: contain?(pattern*) => boolean contain?(file*) => boolean.
-
#empty? ⇒ Boolean
:call-seq: empty?() => boolean.
-
#exist? ⇒ Boolean
:call-seq: exist?() => boolean.
Instance Method Details
#contain?(*patterns) ⇒ Boolean
:call-seq:
contain?(pattern*) => boolean
contain?(file*) => boolean
For a file, returns true if the file content matches against all the arguments. An argument may be a string or regular expression.
For a directory, return true if the directory contains the specified files. You can use relative file names and glob patterns (using *, **, etc).
238 239 240 241 242 243 244 245 246 |
# File 'lib/buildr/core/checks.rb', line 238 def contain?(*patterns) if File.directory?(name) patterns.map { |pattern| "#{name}/#{pattern}" }.all? { |pattern| !Dir[pattern].empty? } else contents = File.read(name) patterns.map { |pattern| Regexp === pattern ? pattern : Regexp.new(Regexp.escape(pattern.to_s)) }. all? { |pattern| contents =~ pattern } end end |
#empty? ⇒ Boolean
:call-seq:
empty?() => boolean
Returns true if file/directory is empty.
225 226 227 |
# File 'lib/buildr/core/checks.rb', line 225 def empty?() File.directory?(name) ? Dir.glob("#{name}/*").empty? : File.read(name).empty? end |
#exist? ⇒ Boolean
:call-seq:
exist?() => boolean
Returns true if this file exists.
217 218 219 |
# File 'lib/buildr/core/checks.rb', line 217 def exist?() File.exist?(name) end |