Class: Rant::SysObject

Inherits:
Object show all
Includes:
Sys
Defined in:
lib/rant/rantsys.rb

Overview

An instance of this class is returned from the sys method in Rantfiles (when called without arguments).

sys.rm_rf "tmp"

In this (Rantfile) example, the rm_rf message is sent to an instance of this class.

Instance Method Summary collapse

Methods included from Sys

#cd, #clean, #escape, #ln_f, #regular_filename, #ruby, #safe_ln, #sh, #sp, #split_all, #split_path, #unpack_tgz, #unpack_zip, #write_to_binfile, #write_to_file

Constructor Details

#initialize(rant) ⇒ SysObject

Returns a new instance of SysObject.



271
272
273
274
# File 'lib/rant/rantsys.rb', line 271

def initialize(rant)
    @rant = rant or
  raise ArgumentError, "rant application required"
end

Instance Method Details

#[](*patterns) ⇒ Object

corresponds to Rant::FileList[*patterns].



298
299
300
# File 'lib/rant/rantsys.rb', line 298

def [](*patterns)
    RacFileList.new(@rant).hide_dotfiles.include(*patterns)
end

#expand_path(path) ⇒ Object



315
316
317
# File 'lib/rant/rantsys.rb', line 315

def expand_path(path)
    File.expand_path(@rant.project_to_fs_path(path))
end

#filelist(arg = Rant.__rant_no_value__) ⇒ Object

sys.filelist(arg)

corresponds to Rant::FileList(arg)

sys.filelist

corresponds to Rant::FileList.new



285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/rant/rantsys.rb', line 285

def filelist(arg = Rant.__rant_no_value__)
    if Rant.__rant_no_value__.equal?(arg)
        RacFileList.new(@rant)
    elsif arg.respond_to?(:to_rant_filelist)
        arg.to_rant_filelist
    elsif arg.respond_to?(:to_ary)
        RacFileList.new(@rant, arg.to_ary)
    else
        raise TypeError,
            "cannot convert #{arg.class} into Rant::FileList"
    end
end

#glob(*patterns, &block) ⇒ Object

corresponds to Rant::FileList.glob(*patterns, &block).



303
304
305
306
307
# File 'lib/rant/rantsys.rb', line 303

def glob(*patterns, &block)
    fl = RacFileList.new(@rant).hide_dotfiles.include(*patterns)
           fl.ignore(".", "..")
           if block_given? then yield fl else fl end
end

#glob_all(*patterns, &block) ⇒ Object

corresponds to Rant::FileList.glob_all(*patterns, &block).



310
311
312
313
314
# File 'lib/rant/rantsys.rb', line 310

def glob_all(*patterns, &block)
      fl = RacFileList.new(@rant).include(*patterns)
    fl.ignore(".", "..") # use case: "*.*" as pattern
    if block_given? then yield fl else fl end
end

#ignore(*patterns) ⇒ Object

Preferred over directly modifying var. var might go in future.



277
278
279
280
# File 'lib/rant/rantsys.rb', line 277

def ignore(*patterns)
    @rant.var[:ignore].concat(patterns)
    nil
end