class RBT::BuildDirectory

Public Class Methods

[](i = '') click to toggle source
#

RBT::BuildDirectory[]

#
# File lib/rbt/utility_scripts/build_directory.rb, line 192
def self.[](i = '')
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/build_directory.rb, line 37
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_use_this_path(i)
  run if run_already
end

Public Instance Methods

cd( i = @use_this_path, be_verbose = be_verbose? )
Alias for: do_change_directory
change_directory( i = @use_this_path, be_verbose = be_verbose? )
Alias for: do_change_directory
do_change_directory( i = @use_this_path, be_verbose = be_verbose? ) { || ... } click to toggle source
#

do_change_directory (cd tag)

Use this method if you need to change directory.

The change-directory action will be silent.

#
# File lib/rbt/utility_scripts/build_directory.rb, line 119
def do_change_directory(
    i          = @use_this_path,
    be_verbose = be_verbose?
  )
  case i
  when :be_verbose
    i = @use_this_path
    be_verbose = true
  end
  if block_given?
    yielded = yield
    case yielded
    when :ensure_that_the_directory_exists
      if i # But only for non-nil values.
        mkdir(i) unless File.directory? i
      end
    end
  end
  if i and File.directory?(i)
    if be_verbose
      e "Now entering the directory `#{sdir(i)}`."
    end
    chdir(i)
  else
    opne "Can not change directory to non-existing "\
         "path at `#{sfile(i.to_s)}`."
  end
end
Also aliased as: change_directory, cd
do_we_use_a_build_directory?()
full_path?()
Alias for: use_this_path?
name?() click to toggle source
#

name?

This method will just return the name of the path.

For example, if the path is “/abc/def/build_dir/” then this method will return the string:

"build_dir"
#
# File lib/rbt/utility_scripts/build_directory.rb, line 179
def name?
  File.basename(@use_this_path)
end
path?()
Alias for: use_this_path?
path_to_build_directory=( i = return_pwd )
Alias for: set_use_this_path
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/build_directory.rb, line 49
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @use_a_build_directory
  # ======================================================================= #
  @use_a_build_directory = true
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  set_be_quiet
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/build_directory.rb, line 186
def run
end
set_use_this_path( i = return_pwd ) click to toggle source
#

set_use_this_path (set tag)

Keep in mind that the build direcory can be nil too.

The path is the full path towards the build directory.

#
# File lib/rbt/utility_scripts/build_directory.rb, line 79
def set_use_this_path(
    i = return_pwd
  )
  if i
    # ===================================================================== #
    # === Handle the case when the input is an Array
    # ===================================================================== #
    if i.is_a? Array
      i = i.join(' ').strip
    # ===================================================================== #
    # === Handle the case when the input is a Hash
    # ===================================================================== #
    elsif i.is_a? Hash
      # =================================================================== #
      # === :path_to_build_directory
      # =================================================================== #
      if i.has_key? :path_to_build_directory
        i = i[:path_to_build_directory]
      end
    end
    unless i.include? '/'
      i = (return_pwd+i).squeeze('/')
    end
    unless i.end_with? '/'
      i = i.dup if i.frozen?
      i << '/' unless i.empty?
    end
  end # nil values are also valid here.
  @use_this_path = i
end
silently_make_sure_that_the_build_directory_exists() click to toggle source
#

silently_make_sure_that_the_build_directory_exists

#
# File lib/rbt/utility_scripts/build_directory.rb, line 162
def silently_make_sure_that_the_build_directory_exists
  unless File.directory? @use_this_path
    mkdir(@use_this_path, :be_silent)
  end
end
use_a_build_directory?() click to toggle source
#

use_a_build_directory?

This method is required because the RBT::Compile class may not always want to use a build directory.

#
# File lib/rbt/utility_scripts/build_directory.rb, line 68
def use_a_build_directory?
  @use_a_build_directory
end
Also aliased as: do_we_use_a_build_directory?
use_this_build_directory=( i = return_pwd )
Alias for: set_use_this_path
use_this_path=( i = return_pwd )
Alias for: set_use_this_path
use_this_path?() click to toggle source
#

use_this_path?

Determine the path to the build directory at hand.

#
# File lib/rbt/utility_scripts/build_directory.rb, line 154
def use_this_path?
  @use_this_path
end
Also aliased as: path?, full_path?