class RBT::FixPkgconfigFile

Constants

DEFAULT_PKGCONFIG_FILE
#

DEFAULT_PKGCONFIG_FILE

#
NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

initialize

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 38
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 101
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 = RBT::Cookbooks::Cookbook.new(program_name) { :bypass_menu_check }
      program_version = program_name.program_version?
    end
    opnn; e "Now modifying the file #{sfile(i)} with the new "\
            "program version"
    opnn; e '  '+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; e 'No file exists at '+sfile(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 83
def pkgconfig_file?
  @pkgconfig_file
end
Also aliased as: input?
reset() click to toggle source
#

reset (reset tag)

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

return_guessed_program_name

#
# File lib/rbt/utility_scripts/fix_pkgconfig_file.rb, line 90
def return_guessed_program_name(i)
  i = File.basename(i).sub(/\.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 169
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 132
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 69
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 144
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 76
def use_this_as_program_version?
  @use_this_as_program_version
end