class RBT::CreateAndPopulatePkgconfigDirectory

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

[]

#
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 130
def self.[](i = '')
  self.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 74
def check_on_this_directory?
  @check_on_this_directory
end
Also aliased as: target?
reset() click to toggle source
#

reset (reset tag)

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

run (run tag)

#
# File lib/rbt/misc/create_and_populate_pkgconfig_directory.rb, line 81
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|
              opnn; e 'Copying '+sfile(this_entry)+' towards '+
                       sdir(new_pkgconfig_directory)+'.'
              copy(this_entry, new_pkgconfig_directory)
            }
          when :symlink
            Dir[new_target+'*'].each {|this_entry|
              opnn; e 'Symlinking '+sfile(this_entry)+' towards '+
                       sdir(new_pkgconfig_directory)+'.'
              symlink(this_entry, new_pkgconfig_directory)
            }
          end
        end
      end
    end
  else
    opnn; e "#{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 65
def set_check_on_this_directory(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @check_on_this_directory = i
end
target?()