16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
89
90
91
92
93
|
# File 'lib/check_everything.rb', line 16
def self.run
@argv = ARGV.map(&:downcase)
until ARGV.empty?
ARGV.pop
end
@ruby_dev_assemble = false
if !File.exists?(LINKFILE)
if File.exists?(LINKPATH)
system("mv #{LINKPATH} #{LINKPATH}2")
system("mkdir #{LINKPATH}")
system("mv #{LINKPATH}2 #{LINKFILE}")
else
system("mkdir #{LINKPATH}")
system("cp #{File.dirname(__FILE__)}/check_everything/links.txt #{LINKFILE}")
end
@argv = ["-l"]
print "Are you a Ruby Dev who will want documentation-checking ",
"functionality? [Y/n] "
@ruby_dev_assemble = true unless gets.strip.downcase == 'n'
puts "\nPlease customize your installation.",
"This message will only be shown once.",
"To open again and customize, just enter 'check_everything -l' to open",
"the link file."
end
@category_space, @category_dash = false, false
known_tags = KNOWN_TAGS.values.flatten + @links.keys + @ruby_links
unmatched_args = @argv.select do |arg|
!known_tags.any?{|known_tag| known_tag.downcase == arg.downcase}
end
if !unmatched_args.empty?
puts "\nUnknown option#{@argv.size > 1 ? "s" : nil}: " +
"#{unmatched_args.join(" ")}"
print "usage: check_everything"
KNOWN_TAGS.values.flatten.each {|tag| print " [#{tag}]"}
puts "\n\nHint: Enter 'check_everything --help' to see the options!"
puts "\n"
elsif @argv.any? {|arg| KNOWN_TAGS[:help].include?(arg)}
help
elsif @argv.any? {|arg| KNOWN_TAGS[:links].include?(arg)}
assemble_ruby_docs_file if @ruby_dev_assemble
system("open #{LINKFILE}")
elsif @argv.any? {|arg| KNOWN_TAGS[:ruby].include?(arg)}
assemble_ruby_docs_file
elsif @category_space
puts "Your link file includes a category with a space in it; " +
"please fix by entering 'check_everything -l' into your command line."
elsif @category_dash
puts "Your link file includes a category with a dash, which is " +
"not allowed; please fix by entering 'check_everything -l' into your command line."
elsif @argv.any? {|arg| KNOWN_TAGS[:categories].include?(arg)}
view_categories
else
open_links
end
end
|