class RBT::FixPkgconfigFile

Constants

DEFAULT_PKGCONFIG_FILE
#

DEFAULT_PKGCONFIG_FILE

#

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 36
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  if i.is_a? Hash
    if i.has_key? :use_this_as_the_new_version
      set_new_program_version(i.fetch(:use_this_as_the_new_version))
    end
    if i.has_key? :use_this_pkgconfig_file
      set_use_this_pkgconfig_file(i.fetch(:use_this_pkgconfig_file))
    end
  else
    set_pkgconfig_file(i)
  end
  run if run_already
end

Public Instance Methods

fix_incorrect_version_in_this_pkgconfig_file( i = pkgconfig_file?, use_this_as_program_version = use_this_as_program_version? ) click to toggle source
#

fix_incorrect_version_in_this_pkgconfig_file

This method will fix an incorrect version found in the given .pc file at hand.

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 104
def fix_incorrect_version_in_this_pkgconfig_file(
    i                           = pkgconfig_file?,
    use_this_as_program_version = use_this_as_program_version?
  )
  if File.exist? i
    if use_this_as_program_version
      program_version = use_this_as_program_version
    else
      # =================================================================== #
      # Tap into the Cookbooks project to get the correct program
      # version.
      # =================================================================== #
      program_name = return_guessed_program_name(i)
      program_name = action(:SanitizeCookbook, program_name) { :fast }
      program_version = program_name.program_version?
    end
    opne "#{rev}Now modifying the file #{sfile(i)} #{rev}with the "\
         "new program version"
    opne "  #{simp(program_version)}"
    regex_to_use = /Version: (\d+.\d+.\d+)/ # See: http://rubular.com/r/B06zYDqKtg
    dataset = File.read(i)
    dataset.gsub!(regex_to_use, "Version: #{program_version}")
    store_dataset(dataset, i)
  else
    opnn; no_file_exists_at(i)
  end
end
input?()
Alias for: pkgconfig_file?
menu(i = input?) click to toggle source
#

menu (menu tag)

#
pkgconfig_file?() click to toggle source
#

pkgconfig_file?

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 84
def pkgconfig_file?
  @pkgconfig_file
end
Also aliased as: input?
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 57
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @use_this_as_program_version
  # ======================================================================= #
  @use_this_as_program_version = nil
  set_pkgconfig_file(DEFAULT_PKGCONFIG_FILE)
end
return_guessed_program_name(i) click to toggle source
#

return_guessed_program_name

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 91
def return_guessed_program_name(i)
  i = File.basename(i).
           delete_suffix('.pc').
           gsub(/\d/,'') # Also remove numbers.
  return i
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 172
def run
  menu
end
set_new_program_version(i)
set_pkgconfig_file(i = DEFAULT_PKGCONFIG_FILE) click to toggle source
#

set_pkgconfig_file

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 135
def set_pkgconfig_file(i = DEFAULT_PKGCONFIG_FILE)
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  unless File.exist? i
    i = DEFAULT_PKGCONFIG_FILE
  end if i.empty?
  @pkgconfig_file = i
end
Also aliased as: set_use_this_pkgconfig_file
set_use_this_as_program_version(i) click to toggle source
#

set_use_this_as_program_version

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 70
def set_use_this_as_program_version(i)
  @use_this_as_program_version = i
end
Also aliased as: set_new_program_version
set_use_this_pkgconfig_file(i = DEFAULT_PKGCONFIG_FILE)
Alias for: set_pkgconfig_file
store_dataset(what, into_this_file) click to toggle source
#

store_dataset

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 147
def store_dataset(what, into_this_file)
  write_what_into(what, into_this_file)
end
use_this_as_program_version?() click to toggle source
#

use_this_as_program_version?

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 77
def use_this_as_program_version?
  @use_this_as_program_version
end