Class: CheckEverything

Inherits:
Object
  • Object
show all
Defined in:
lib/check_everything.rb

Constant Summary collapse

KNOWN_FLAGS =
{
  :help => {
    :position => 1,
    :flags => ['-h','--help'],
    :description => 'display the help message'
  },
  :links => {
    :position => 2,
    :flags => ['-l','--links'],
    :description => 'view/edit links and categories'
  },
  :ruby => {
    :position => 3,
    :flags => ['-r','--ruby'],
    :description => 'install/update Ruby Documentation functionality'
  },
  :categories => {
    :position => 4,
    :flags => ['-c', '--categories'],
    :description => 'view the currently defined categories'
  },
  :all => {
    :position => 5,
    :flags => ['-a', '--all'],
    :description => 'open all websites (will override documentation lookup)'
  }
}
LINKPATH =
"#{File.expand_path('~')}/.check_everything_links"
LINKFILE =
"#{LINKPATH}/links.txt"
RUBYFILE =
"#{LINKPATH}/ruby.txt"
SUB_CHARS =
{
  '?' => '-3F-',
  '!' => '-21-',
  '|' => '-7C-',
  ']' => '-5D-',
  '[' => '-5B-',
  '=' => '-3D-',
  '+' => '-2B-',
  '-' => '-2D-',
  '*' => '-2A-',
  '/' => '-2F-',
  '%' => '-25-',
  '~' => '-7E-',
  '<' => '-3C-',
  '>' => '-3E-',
  '&' => '-26-',
  '@' => '-40-'
}

Class Method Summary collapse

Class Method Details

.runObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/check_everything.rb', line 54

def self.run
  @argv = ARGV.map(&:downcase)
  ARGV.clear # prevent ARGV from interfering with "gets" input.

  # Run first-time options if check_everything hasn't been run yet.
  customize_installation if !File.exists?(LINKFILE)

  extract_links

  # First check for unknown arguments and print out a helpful message.
  unmatched_args = unknown_arguments
  if !unmatched_args.empty?
    puts_unmatched_error_message(unmatched_args)
  
  # Respond to flags.
  elsif argv_requests?(:help)
    help
  elsif argv_requests?(:links)
    system("open #{LINKFILE}")
  elsif argv_requests?(:ruby)
    assemble_ruby_docs_file
  
  # Block execution of final options if an invalid character exists
  # in the user's link file.
  elsif @invalid_char_in_links
      puts "Your link file includes a category with a " +
        "\"#{@invalid_char_in_links}\" character in it; please fix by " +
        "entering 'check_everything -l' into your command line."
  elsif argv_requests?(:categories)
    view_categories
  # If there are no flags, open the websites!
  else
    open_links
  end
end