class RBT::ApplySedOperations

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

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

[]

#
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 116
def self.[](i = '')
  self.new(i)
end
new( use_these_sed_operations = ARGV, run_already = true ) click to toggle source
#

initialize

The first argument to this method will be the sed-operations that this class will perform. It should be an Array, but if a String is given then it will be converted into an Array anyway.

#
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 33
def initialize(
    use_these_sed_operations = ARGV,
    run_already              = true
  )
  reset
  set_use_these_sed_operations(
    use_these_sed_operations
  )
  case run_already
  when :do_not_run_yet
    run_already = false
  end
  run if run_already
end

Public Instance Methods

obtain_sed_entries_for_this_program(i) click to toggle source
#

obtain_sed_entries_for_this_program

#
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 88
def obtain_sed_entries_for_this_program(i)
  if i.start_with? ':'
    i = i.dup if i.frozen?
    i[0,1] = ''
  end
  require 'rbt/cookbooks/class/class.rb'
  dataset = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check }
  dataset.sed?
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 51
def reset
  super()
  @namespace = NAMESPACE
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 101
def run
  _ = use_which_sed_operations?
  unless _.empty?
    opnn; e 'Trying to use the "'+teal('sed')+'" '\
            'binary next from `'+sdir_return_pwd+'`.'
    _.each {|run_this_sed_operation|
      e skyblue("  #{run_this_sed_operation}")
      system(run_this_sed_operation)
    }
  end 
end
sanitize_sed_operations() click to toggle source
#

sanitize_sed_operations

#
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 75
def sanitize_sed_operations
  @use_these_sed_operations.map! {|entry|
    if entry.is_a?(String) and entry.start_with?(':') # <- Assume a Symbol in this case.
      entry = obtain_sed_entries_for_this_program(entry)
    end
    entry
  }
  @use_these_sed_operations.flatten! # <- Must invoke this again due to the ^^^ above code.
end
set_use_these_sed_operations(i = get_pwd) click to toggle source
#

set_use_these_sed_operations

#
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 59
def set_use_these_sed_operations(i = get_pwd)
  i = [i].flatten.compact
  @use_these_sed_operations = i
  sanitize_sed_operations
end
use_these_sed_operations?() click to toggle source
#

use_these_sed_operations?

#
# File lib/rbt/utility_scripts/apply_sed_operations.rb, line 68
def use_these_sed_operations?
  @use_these_sed_operations
end
Also aliased as: use_which_sed_operations?
use_which_sed_operations?()