Class: EnvGen

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

Constant Summary collapse

@@options =

all possible commands

["init", "file", "dir", "gem", "help"]

Class Method Summary collapse

Class Method Details

.dirObject



13
14
15
16
# File 'lib/envGen.rb', line 13

def self.dir
  ARGV.delete_at(0) # gets rid of "dir" to isolate dir to add
  AddFile.dir(ARGV.first) # adds Ruby files in specified directory
end

.fileObject



8
9
10
11
# File 'lib/envGen.rb', line 8

def self.file
  ARGV.delete_at(0) # gets rid of "file" to isolate files to add
  AddFile.multiple(ARGV) # adds files individually
end

.newGemObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/envGen.rb', line 18

def self.newGem
  ARGV.delete_at(0) # gets rid of "gem" to isolate gems to add
  if ARGV[0] == "-s" # kicks off search
    new_gem = AddGem.new(ARGV[1])
    new_gem.gemSearch # searches for gem specified
  else
    ARGV.each do |arg|
      new_gem = AddGem.new(arg) # creates objects for each gem
      new_gem.gemEntry
    end
  end
end

.parse(input) ⇒ Object

handles user input from executable, ARGV



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/envGen.rb', line 31

def self.parse(input) # handles user input from executable, ARGV[0]
  if !@@options.include?(input)
    puts "invalid command"
  else
    case input
    when "init"
      Init.init # handles environment creation
    when "file"
      file
    when "dir"
      dir
    when "gem"
      newGem
    when "help"
      Init.help # displays help message
    end
  end
end