Module: Hapyrus::Helpers

Included in:
Cli, Credentials
Defined in:
lib/hapyrus/helpers.rb

Class Method Summary collapse

Class Method Details

.home_directoryObject



16
17
18
# File 'lib/hapyrus/helpers.rb', line 16

def home_directory
  ENV['HOME'] || Dir.pwd
end

.parse_command(cmd) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/hapyrus/helpers.rb', line 4

def parse_command(cmd)
  klass = Hapyrus::Command::Base
  method = cmd
  if cmd.include?(':')
    class_name, method = cmd.split(':')
    klass = to_command_class(class_name)
  end
  [klass, method]
end

.to_command_class(class_name) ⇒ Object



13
14
15
# File 'lib/hapyrus/helpers.rb', line 13

def to_command_class(class_name)
  eval("Hapyrus::Command::#{class_name.camelcase}")
end