class GitIndexCLI
Attributes
directory[R]
path[R]
Public Class Methods
new()
click to toggle source
# File lib/gitindexcli.rb, line 3 def initialize @filename = "" end
Public Instance Methods
call()
click to toggle source
# File lib/gitindexcli.rb, line 7 def call if !mac_OS? puts "Sorry, this gem is only compatible with Mac OS" else greeting input = gets.chomp if input.downcase != "exit" directory_from_input(input) determine_path create_file `open #{@filename}` end end end
Private Instance Methods
create_file()
click to toggle source
# File lib/gitindexcli.rb, line 37 def create_file #file = "#{path}/index.html" if !Dir.exists?('/tmp/gitindex') FileUtils::mkdir_p '/tmp/gitindex' end @filename = '/tmp/gitindex/index.html' puts "Mapping #{path}..." output_message $stdout.reopen(@filename, "w") GithubIndex.new(path).generate_index end
determine_path()
click to toggle source
# File lib/gitindexcli.rb, line 32 def determine_path @path = Pathname.new(directory) @path = path.expand_path if path.relative? end
directory_from_input(input)
click to toggle source
# File lib/gitindexcli.rb, line 28 def directory_from_input(input) input.strip.empty? ? @directory = (Dir.pwd) : @directory = input end
greeting()
click to toggle source
# File lib/gitindexcli.rb, line 23 def greeting puts "What directory would you like to map?" puts "(leave blank for present working directory)" end
mac_OS?()
click to toggle source
# File lib/gitindexcli.rb, line 53 def mac_OS? return ((/darwin/ =~ RbConfig::CONFIG["arch"]) != nil) end
output_message()
click to toggle source
# File lib/gitindexcli.rb, line 49 def output_message puts "If results do not automatically open, type 'open #{@filename}'" end