class RBT::CompileStrategies

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

RBT::CompileStrategies[]

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

initialize

#
# File lib/rbt/statistics/compile_strategies.rb, line 33
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(
    i
  )
  run if run_already
end

Public Instance Methods

colour_on_the_left_hand_side(i) click to toggle source
#

colour_on_the_left_hand_side

#
# File lib/rbt/statistics/compile_strategies.rb, line 231
def colour_on_the_left_hand_side(i)
  sfancy(i)
end
determine_how_many_programs_are_registered() click to toggle source
#

determine_how_many_programs_are_registered

#
# File lib/rbt/statistics/compile_strategies.rb, line 117
def determine_how_many_programs_are_registered
  @n_programs_are_registered = @hash.keys.size
end
input?() click to toggle source
#

input?

#
# File lib/rbt/statistics/compile_strategies.rb, line 70
def input?
  @input
end
load_dataset_from_the_expanded_data() click to toggle source
#

load_dataset_from_the_expanded_data

#
# File lib/rbt/statistics/compile_strategies.rb, line 100
def load_dataset_from_the_expanded_data
  reset_the_main_hash
  _ = RBT.directory_expanded_cookbooks?
  all_files = Dir["#{_}*.yml"]
  all_files.each {|this_file|
    dataset_from_the_yaml_file = YAML.load_file(this_file)
    name_of_the_program = File.basename(this_file).sub(/\.yml$/,'')
    hash = {}
    hash[name_of_the_program] = dataset_from_the_yaml_file
    @hash.update(hash)
  }
  determine_how_many_programs_are_registered
end
n_programs_are_registered?() click to toggle source
#

n_programs_are_registered?

#
# File lib/rbt/statistics/compile_strategies.rb, line 124
def n_programs_are_registered?
  @n_programs_are_registered
end
Also aliased as: n_total_programs?
n_programs_depend_on( a = 'cmake', b = cmake_deps ) click to toggle source
#

n_programs_depend_

#
# File lib/rbt/statistics/compile_strategies.rb, line 213
def n_programs_depend_on(
    a = 'cmake',
    b = cmake_deps
  )
  @n_programs_are_assumed_to_be_run_via_makefiles -= b.keys.size
  n_percent = (
    b.keys.size * 100.0 / @n_programs_are_registered
  ).round(1).to_s.rjust(4)+'%'
  # Next append the number:
  n_percent << ' ('+b.keys.size.to_s.rjust(4)+' / '+n_total_programs?.to_s+')'
  colourized_n_percent = mediumseagreen(n_percent)
  e "#{colour_on_the_left_hand_side(b.keys.size.to_s.rjust(3))} programs "\
    "depend on #{royalblue((a+'.').ljust(7))} #{colourized_n_percent}"
end
n_total_programs?()
report() click to toggle source
#

report

#
# File lib/rbt/statistics/compile_strategies.rb, line 131
def report
  _ = @hash
  # ======================================================================= #
  # Seed the variable @n_programs_are_assumed_to_be_run_via_makefiles
  # with an initial value, which will lateron be decremented accordingly.
  # ======================================================================= #
  @n_programs_are_assumed_to_be_run_via_makefiles = @n_programs_are_registered
  cmake_deps = _.select {|key, inner_value|
    array_required_deps_on = inner_value['required_deps_on']
    array_required_deps_on.include?('cmake')
  }
  python_deps = _.select {|key, inner_value|
    array_required_deps_on = inner_value['required_deps_on']
    array_required_deps_on.include?('python')
  }
  meson_deps = _.select {|key, inner_value|
    array_required_deps_on = inner_value['required_deps_on']
    array_required_deps_on.include?('meson')
  }
  ruby_deps = _.select {|key, inner_value|
    array_required_deps_on = inner_value['required_deps_on']
    array_required_deps_on.include?('ruby')
  }
  perl_deps = _.select {|key, inner_value|
    array_required_deps_on = inner_value['required_deps_on']
    array_required_deps_on.include?('perl')
  }
  scons_deps = _.select {|key, inner_value|
    array_required_deps_on = inner_value['required_deps_on']
    array_required_deps_on.include?('scons')
  }
  waf_deps = _.select {|key, inner_value|
    array_required_deps_on = inner_value['required_deps_on']
    array_required_deps_on.include?('waf')
  }
  e
  report_how_many_programs_are_registered_in_total
  e
  # ======================================================================= #
  # === cmake
  # ======================================================================= #
  n_programs_depend_on('cmake', cmake_deps)
  # ======================================================================= #
  # === ruby
  # ======================================================================= #
  n_programs_depend_on('ruby', ruby_deps)
  # ======================================================================= #
  # === python
  # ======================================================================= #
  n_programs_depend_on('python', python_deps)
  # ======================================================================= #
  # === meson
  # ======================================================================= #
  n_programs_depend_on('meson', meson_deps)
  # ======================================================================= #
  # === perl
  # ======================================================================= #
  n_programs_depend_on('perl', perl_deps)
  # ======================================================================= #
  # === scons
  # ======================================================================= #
  n_programs_depend_on('scons', scons_deps)
  # ======================================================================= #
  # === waf
  # ======================================================================= #
  n_programs_depend_on('waf', waf_deps)
  e slateblue('---')
  e colour_on_the_left_hand_side(
    @n_programs_are_registered - @n_programs_are_assumed_to_be_run_via_makefiles
  )+' programs make use of any of the above ^^^ compile-time strategies.'
  e
  e "#{sfancy(@n_programs_are_assumed_to_be_run_via_makefiles.to_s)} programs"\
    " are assumed to be compiled through #{orange('make')} (and possibly"
  e '     '+lightsalmon('GNU autoconfigure')+'). Note that meson depends on python,'
  e '     so strictly speaking, the meson-dependencies should have'
  e '     to be added to the python-subsection.'
  e
end
report_how_many_programs_are_registered_in_total() click to toggle source
#

report_how_many_programs_are_registered_in_total

#
# File lib/rbt/statistics/compile_strategies.rb, line 85
def report_how_many_programs_are_registered_in_total
  e "There are a total of #{springgreen(@n_programs_are_registered)} "\
    "programs registered."
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/statistics/compile_strategies.rb, line 47
def reset
  super()
  @namespace = NAMESPACE
  @hash = {}
  @n_programs_are_assumed_to_be_run_via_makefiles = 0
  # ======================================================================= #
  # Remember if you need to know the amount of programs, within this
  # class the variable @n_programs_are_registered keeps track of this.
  # ======================================================================= #
end
reset_the_main_hash() click to toggle source
#

reset_the_main_hash

#
# File lib/rbt/statistics/compile_strategies.rb, line 93
def reset_the_main_hash
  @hash.clear
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/statistics/compile_strategies.rb, line 238
def run
  show_introduction
  load_dataset_from_the_expanded_data
  report
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/rbt/statistics/compile_strategies.rb, line 61
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @input = i
end
show_introduction() click to toggle source
#

show_introduction

#
# File lib/rbt/statistics/compile_strategies.rb, line 77
def show_introduction
  opnn; e 'Next gathering some compile-statistics about the'
  opnn; e 'registered programs.'
end