class RBT::ImproveTheCookbookRecipes

Public Class Methods

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

RBT::ImproveTheCookbookRecipes[]

#
# File lib/rbt/cookbooks/improve_the_cookbook_recipes/improve_the_cookbook_recipes.rb, line 97
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/cookbooks/improve_the_cookbook_recipes/improve_the_cookbook_recipes.rb, line 35
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/cookbooks/improve_the_cookbook_recipes/improve_the_cookbook_recipes.rb, line 49
def reset
  super()
  infer_the_namespace
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/cookbooks/improve_the_cookbook_recipes/improve_the_cookbook_recipes.rb, line 57
def run
  all_yaml_files = Dir[
    '/home/x/programming/ruby/src/rbt/lib/rbt/yaml/cookbooks/*.yml'
  ]
  found_n_problems = 0
  all_yaml_files.each {|entry|
    dataset = File.read(entry)
    if dataset =~ /keep_extracted: f$/
      found_n_problems += 1
      e 'The file `'+steelblue(entry.to_s)+'` has a less-than-optimal '\
        'keep_extracted value (of "f").'
      if is_on_roebe?
        e 'This has been corrected.'
        # copy_file(entry, '/Depot/j/'+File.basename(entry))
        data = File.read(entry)
        data.sub!(/keep_extracted: f/,'keep_extracted: no')
        write_what_into(data, entry)
      end
    end
    if dataset =~ /keep_extracted: t$/
      found_n_problems += 1
      e 'The file `'+steelblue(entry.to_s)+'` has a less-than-optimal '\
        'keep_extracted value (of "t").'
      if is_on_roebe?
        e 'This has been corrected.'
        data = File.read(entry)
        data.sub!(/keep_extracted: t/,'keep_extracted: yes')
        write_what_into(data, entry)
      end
    end
  }
  if found_n_problems == 0
    opne 'No problem was found. This is great! '+
         gold(cheering_person)
  end
end