class Cookbooks::FeedbackLicenses

Constants

DEFAULT_FILTER_TO_USE
#

DEFAULT_FILTER_TO_USE

#
NAMESPACE
#

NAMESPACE

#
PADDING_LEFT
#

PADDING_LEFT

#
PADDING_TO_USE
#

PADDING_TO_USE

#

Public Class Methods

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

Cookbooks::FeedbackLicenses[]

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 161
def self.[](i = '')
  Cookbooks::FeedbackLicenses.new(i)
end
new( filter_for_licenses = DEFAULT_FILTER_TO_USE, run_already = true ) click to toggle source
#

initialize

Usage example:

FeedbackLicenses.new(filter_for_licenses = DEFAULT_FILTER_TO_USE, run_already = true)

If the filter is * then we will filter for ALL licenses.

#
Calls superclass method
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 48
def initialize(
    filter_for_licenses = DEFAULT_FILTER_TO_USE,
    run_already         = true
  )
  super()
  reset
  set_filter_for_licenses(filter_for_licenses)
  run if run_already
end

Public Instance Methods

feedback_licenses() click to toggle source
#

#feedback_licenses

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 107
def feedback_licenses
  cliner {
    _ = 'known licenses' # Placeholder for now.
    _ = filter? unless filter? == DEFAULT_FILTER_TO_USE
    opnn; e 'Feedback licenses matching search-criteria for'
    opnn; e '`'+sfancy(_.to_s)+'` in alphabetical order next:'
  }
  output_header
  cliner {
    programs = Cookbooks.available_programs?
    programs.each { |program|
      @cookbook = Cookbooks::Cookbook.new(program) { :bypass_menu }
      license = return_license
      if license.is_a? Array
        license = license.join(', ')
      end
      next if license == 'unknown'
      full_license_text = PADDING_LEFT+'%-25s' % program+'  | '+'%-10s' % license

      if @filter == DEFAULT_FILTER_TO_USE
        e full_license_text
      else # else we assume user wants filtering done
        unless license.to_s.downcase.scan(/#{filter?}/).empty?
          e full_license_text 
        end
      end
    }
  }
end
filter?() click to toggle source
#

filter?

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 100
def filter?
  @filter
end
filter_for(i = DEFAULT_FILTER_TO_USE)
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 147
def opnn
  super(NAMESPACE)
end
output_header() click to toggle source
#

#output_header

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 89
def output_header
  # ===================================================================== #
  # This is the header content.
  # ===================================================================== #
  e PADDING_LEFT+('%-25s' % 'Name  ')+
    '  | License                                         |'
end
reset() click to toggle source
#

reset

#
Calls superclass method Cookbooks::Base#reset
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 61
def reset
  super()
  @cookbook = Cookbooks::Cookbook.new { :bypass_menu }
  @filter   = ''.dup # Set the filter to use.
end
return_license() click to toggle source
#

#return_license

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 140
def return_license
  @cookbook.license?.to_s # .downcase
end
run() click to toggle source
#

run (run tag)

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 154
def run
  feedback_licenses
end
set_filter_for_licenses(i = DEFAULT_FILTER_TO_USE) click to toggle source
#

#set_filter_for_licenses

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 70
def set_filter_for_licenses(i = DEFAULT_FILTER_TO_USE)
  i = i.first if i.is_a? Array
  i = DEFAULT_FILTER_TO_USE if i.nil?
  i = DEFAULT_FILTER_TO_USE if i.empty?
  i = i.to_s.dup
  i = i.downcase
  @filter = i
end
Also aliased as: filter_for
set_which_program(i) click to toggle source
#

#set_which_program

#
# File lib/cookbooks/utility_scripts/feedback_licenses.rb, line 82
def set_which_program(i) # Set which program we are seeking.
  @which_program = i
end