class RBT::Cookbooks::FeedbackLicenses

Constants

DEFAULT_FILTER_TO_USE
#

DEFAULT_FILTER_TO_USE

#
PADDING_TO_USE
#

PADDING_TO_USE

#
TOKEN_LEFT_THEN_PADDING
#

TOKEN_LEFT_THEN_PADDING

#

Public Class Methods

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

RBT::Cookbooks::FeedbackLicenses[]

#
# File lib/rbt/cookbooks/feedback_licenses.rb, line 165
def self.[](i = ARGV)
  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.

#
# File lib/rbt/cookbooks/feedback_licenses.rb, line 46
def initialize(
    filter_for_licenses = DEFAULT_FILTER_TO_USE,
    run_already         = true
  )
  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/rbt/cookbooks/feedback_licenses.rb, line 113
def feedback_licenses
  cliner {
    _ = 'known licenses' # Placeholder for now.
    _ = filter? unless filter? == DEFAULT_FILTER_TO_USE
    opne 'Feedback licenses matching search-criteria for'
    opne '`'+sfancy(_.to_s)+'` in alphabetical order next:'
  }
  output_header
  cliner {
    programs = available_programs?
    programs.each { |program|
      @cookbook = RBT::Cookbooks::SanitizeCookbook.new(program) { :do_not_run_yet }
      @cookbook.metafind(program)
      license = return_license
      if license.is_a? Array
        license = license.join(', ') # We want to see it on the same line here.
      end
      next if license == 'unknown'
      program = File.basename(program).sub(/\.yml$/,'')
      padding_left = '%-25s' % program
      padding_left = steelblue(padding_left).dup
      padding_left.prepend(TOKEN_LEFT_THEN_PADDING)
      padding_right = '%-10s' % license
      full_license_text = padding_left+'  | '+royalblue(padding_right)
      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/rbt/cookbooks/feedback_licenses.rb, line 106
def filter?
  @filter
end
filter_for(i = DEFAULT_FILTER_TO_USE)
output_header() click to toggle source
#

output_header

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

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/cookbooks/feedback_licenses.rb, line 60
def reset
  super()
  infer_the_namespace
  # ===================================================================== #
  # === @cookbook
  # ===================================================================== #
  @cookbook = RBT::Cookbooks::SanitizeCookbook.new { :do_not_run_yet }
  # ===================================================================== #
  # === @filter
  # ===================================================================== #
  @filter   = ''.dup # Set the filter to use.
end
return_license() click to toggle source
#

return_license

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

run (run tag)

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

set_filter_for_licenses

#
# File lib/rbt/cookbooks/feedback_licenses.rb, line 76
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/rbt/cookbooks/feedback_licenses.rb, line 88
def set_which_program(i) # Set which program we are seeking.
  @which_program = i
end