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

#absolute_path?, #cd, #clean, #escape, #ln_f, #regular_filename, #root_dir?, #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.



290
291
292
293
# File 'lib/rant/rantsys.rb', line 290

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

Instance Method Details

#[](*patterns) ⇒ Object

corresponds to Rant::FileList[*patterns].



317
318
319
# File 'lib/rant/rantsys.rb', line 317

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

#expand_path(path) ⇒ Object



334
335
336
# File 'lib/rant/rantsys.rb', line 334

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



304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/rant/rantsys.rb', line 304

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).



322
323
324
325
326
# File 'lib/rant/rantsys.rb', line 322

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).



329
330
331
332
333
# File 'lib/rant/rantsys.rb', line 329

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.



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

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