class RBT::CreateAndPopulatePkgconfigDirectory

Public Class Methods

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

RBT::CreateAndPopulatePkgconfigDirectory[]

#
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 133
def self.[](i = ARGV)
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 42
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_check_on_this_directory(
    i
  )
  run if run_already
end

Public Instance Methods

check_on_this_directory?() click to toggle source
#

check_on_this_directory?

#
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 77
def check_on_this_directory?
  @internal_hash[:check_on_this_directory]
end
Also aliased as: target?
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 56
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @mode
  # ======================================================================= #
  @mode = :copy # <- can be :symlink or :copy
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 84
def run
  _ = target? # This may be e. g. "/Programs/Sharedmimeinfo/Current/".
  if File.directory? _
    # ===================================================================== #
    # Ok, it is a directory. Now we have to check for two things:
    #   (1) does the subdirectory "share/pkgconfig/" exist.
    # ===================================================================== #
    new_target = _+'share/pkgconfig/'
    if File.directory?(new_target) and !(Dir.empty?(new_target))
      # =================================================================== #
      # If we enter here, we know that e. g.
      # "/Programs/Sharedmimeinfo/Current/share/pkgconfig/".
      # must exist. So now we have to check if lib/pkgconfig/ does
      # NOT exist - or if it does, whether it is empty.
      # =================================================================== #
      new_pkgconfig_directory = _+'lib/pkgconfig/'
      unless File.directory?(new_pkgconfig_directory) and
             !Dir.empty?(new_pkgconfig_directory)
        # ================================================================= #
        # In this case first create this directory:
        # ================================================================= #
        mkdir(new_pkgconfig_directory, :be_silent) unless File.directory?(new_pkgconfig_directory)
        if File.directory?(new_pkgconfig_directory) and
           Dir.empty?(new_pkgconfig_directory)
          case @mode
          when :copy
            Dir[new_target+'*'].each {|this_entry|
              opne 'Copying '+sfile(this_entry)+' towards '+
                    sdir(new_pkgconfig_directory)+'.'
              copy(this_entry, new_pkgconfig_directory)
            }
          when :symlink
            Dir[new_target+'*'].each {|this_entry|
              opne 'Symlinking '+sfile(this_entry)+' towards '+
                    sdir(new_pkgconfig_directory)+'.'
              symlink(this_entry, new_pkgconfig_directory)
            }
          end
        end
      end
    end
  else
    opne "#{teal(_)} is not a directory. This class requires a directory."
  end
end
set_check_on_this_directory(i = '') click to toggle source
#

set_check_on_this_directory

#
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 68
def set_check_on_this_directory(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @internal_hash[:check_on_this_directory] = i
end
target?()